[Updated] D8816: merge: introduce hasconflicts() on mergeresult object

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sun Aug 2 17:44:06 UTC 2020


Closed by commit rHG0c849f0166c2: merge: introduce hasconflicts() on mergeresult object (authored by pulkit).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D8816?vs=22100&id=22199#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8816?vs=22100&id=22199

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8816/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8816

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -581,6 +581,21 @@
     def setactions(self, actions):
         self._actions = actions
 
+    def hasconflicts(self):
+        """ tells whether this merge resulted in some actions which can
+        result in conflicts or not """
+        for _f, (m, _unused, _unused) in pycompat.iteritems(self._actions):
+            if m not in (
+                mergestatemod.ACTION_GET,
+                mergestatemod.ACTION_KEEP,
+                mergestatemod.ACTION_EXEC,
+                mergestatemod.ACTION_REMOVE,
+                mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
+            ):
+                return True
+
+        return False
+
 
 def manifestmerge(
     repo,
@@ -1809,17 +1824,10 @@
         actionbyfile = mresult.actions
 
         if updatecheck == UPDATECHECK_NO_CONFLICT:
-            for f, (m, args, msg) in pycompat.iteritems(actionbyfile):
-                if m not in (
-                    mergestatemod.ACTION_GET,
-                    mergestatemod.ACTION_KEEP,
-                    mergestatemod.ACTION_EXEC,
-                    mergestatemod.ACTION_REMOVE,
-                    mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
-                ):
-                    msg = _(b"conflicting changes")
-                    hint = _(b"commit or update --clean to discard changes")
-                    raise error.Abort(msg, hint=hint)
+            if mresult.hasconflicts():
+                msg = _(b"conflicting changes")
+                hint = _(b"commit or update --clean to discard changes")
+                raise error.Abort(msg, hint=hint)
 
         # Prompt and create actions. Most of this is in the resolve phase
         # already, but we can't handle .hgsubstate in filemerge or



To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200802/4218b760/attachment-0002.html>


More information about the Mercurial-patches mailing list