Page MenuHomePhabricator
Paste P1051

no_op.diff
ActivePublic

Authored by epriestley on Jan 27 2014, 9:33 PM.
Tags
None
Referenced Files
F105332: no_op.diff
Jan 27 2014, 9:33 PM
Subscribers
None
diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php
index 3ece7d9..44f3489 100644
--- a/src/repository/api/ArcanistMercurialAPI.php
+++ b/src/repository/api/ArcanistMercurialAPI.php
@@ -750,9 +750,23 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
$tmp_file = new TempFile();
Filesystem::writeFile($tmp_file, $message);
- $this->execxLocal(
- 'commit --amend -l %s',
- $tmp_file);
+
+ try {
+ $this->execxLocal(
+ 'commit --amend -l %s',
+ $tmp_file);
+ } catch (Exception $ex) {
+ if (preg_match('/nothing changed/', $ex->getStdErr())) {
+ // NOTE: Mercurial considers it an error to make a no-op amend. Although
+ // we generally defer to the underlying VCS to dictate behavior, this
+ // one seems a little goofy, and we use amend as part of various
+ // workflows under the assumption that no-op amends are fine. If this
+ // amend failed because it's a no-op, just continue.
+ } else {
+ throw $ex;
+ }
+ }
+
$this->reloadWorkingCopy();
}

Event Timeline

epriestley changed the title of this paste from untitled to no_op.diff.
epriestley updated the paste's language from autodetect to autodetect.