diff mercurial/merge.py @ 21264:4e932dc5c113

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 18 Apr 2014 19:08:32 -0700
parents 6ca05c46aa95
children 19d6fec60b81
line wrap: on
line diff
--- 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: