# HG changeset patch # User Gregory Szorc # Date 1397873312 25200 # Node ID 4e932dc5c113f003eefda05a2dae8cf7da9f2c2b # Parent f3e37409ecd39454d6415389d0232e320731cbd0 resolve: abort when not applicable (BC) The resolve command is only relevant when mergestate is present. This patch will make resolve abort when no mergestate is present. This change will let people know when they are using resolve when they shouldn't be. This change will let people know when their use of resolve doesn't do anything. Previously, |hg resolve -m| would allow mergestate to be created. This patch now forbids that. Strictly speaking, this is backwards incompatible. The author of this patch believes creating mergestate via resolve doesn't make much sense and this side-effect was unintended. diff -r f3e37409ecd3 -r 4e932dc5c113 mercurial/commands.py --- a/mercurial/commands.py Fri Apr 18 18:26:42 2014 -0700 +++ b/mercurial/commands.py Fri Apr 18 19:08:32 2014 -0700 @@ -4927,6 +4927,10 @@ 'use --all to remerge all files')) ms = mergemod.mergestate(repo) + + if not ms.active(): + raise util.Abort(_('resolve command not applicable when not merging')) + m = scmutil.match(repo[None], pats, opts) ret = 0 diff -r f3e37409ecd3 -r 4e932dc5c113 mercurial/merge.py --- a/mercurial/merge.py Fri Apr 18 18:26:42 2014 -0700 +++ b/mercurial/merge.py Fri Apr 18 19:08:32 2014 -0700 @@ -175,6 +175,18 @@ raise return records + def active(self): + """Whether mergestate is active. + + Returns True if there appears to be mergestate. This is a rough proxy + for "is a merge in progress." + """ + # Check local variables before looking at filesystem for performance + # reasons. + return bool(self._local) or bool(self._state) or \ + self._repo.opener.exists(self.statepathv1) or \ + self._repo.opener.exists(self.statepathv2) + def commit(self): """Write current state on disk (if necessary)""" if self._dirty: diff -r f3e37409ecd3 -r 4e932dc5c113 tests/test-histedit-non-commute-abort.t --- a/tests/test-histedit-non-commute-abort.t Fri Apr 18 18:26:42 2014 -0700 +++ b/tests/test-histedit-non-commute-abort.t Fri Apr 18 19:08:32 2014 -0700 @@ -85,6 +85,8 @@ log after abort $ hg resolve -l + abort: resolve command not applicable when not merging + [255] $ hg log --graph @ changeset: 6:bfa474341cc9 | tag: tip diff -r f3e37409ecd3 -r 4e932dc5c113 tests/test-resolve.t --- a/tests/test-resolve.t Fri Apr 18 18:26:42 2014 -0700 +++ b/tests/test-resolve.t Fri Apr 18 19:08:32 2014 -0700 @@ -37,9 +37,11 @@ $ hg resolve -m file $ hg commit -m 'resolved' -resolve -l, should be empty +resolve -l should error since no merge in progress $ hg resolve -l + abort: resolve command not applicable when not merging + [255] test crashed merge with empty mergestate diff -r f3e37409ecd3 -r 4e932dc5c113 tests/test-shelve.t --- a/tests/test-shelve.t Fri Apr 18 18:26:42 2014 -0700 +++ b/tests/test-shelve.t Fri Apr 18 19:08:32 2014 -0700 @@ -262,6 +262,8 @@ summary: second $ hg resolve -l + abort: resolve command not applicable when not merging + [255] $ hg status A foo/foo ? a/a.orig