Page MenuHomePhabricator
Paste P1052

Fork of P1051 no_op.diff
ActivePublic

Authored by richardvanvelzen on Jan 28 2014, 8:30 AM.
Tags
None
Referenced Files
F105470: Fork_of_P1051_no_op.diff
Jan 28 2014, 8:30 AM
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->getStdOut())) {
+ // 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

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