[Updated] D8533: flags: actually merge flags in simplemerge

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu May 28 16:39:42 UTC 2020


Closed by commit rHG84614212ae39: flags: actually merge flags in simplemerge (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8533?vs=21397&id=21501

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

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

AFFECTED FILES
  mercurial/simplemerge.py
  tests/test-merge-exec.t

CHANGE DETAILS

diff --git a/tests/test-merge-exec.t b/tests/test-merge-exec.t
--- a/tests/test-merge-exec.t
+++ b/tests/test-merge-exec.t
@@ -195,7 +195,6 @@
   M z
     a
   $ [ -x z ] || echo "executable bit lost"
-  executable bit lost
 
 merge them (from the chmod side)
 
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -22,7 +22,9 @@
 from . import (
     error,
     mdiff,
+    node as nodemod,
     pycompat,
+    util,
 )
 from .utils import stringutil
 
@@ -449,6 +451,17 @@
     return result
 
 
+def _bytes_to_set(b):
+    """turns a multiple bytes (usually flags) into a set of individual byte"""
+    return set(b[x : x + 1] for x in range(len(b)))
+
+
+def is_null(ctx):
+    if not util.safehasattr(ctx, "node"):
+        return False
+    return ctx.node() != nodemod.nullid
+
+
 def simplemerge(ui, localctx, basectx, otherctx, **opts):
     """Performs the simplemerge algorithm.
 
@@ -503,8 +516,20 @@
         else:
             mergedtext += line
 
+    # merge flags if necessary
+    flags = localctx.flags()
+    localflags = _bytes_to_set(flags)
+    otherflags = _bytes_to_set(otherctx.flags())
+    if is_null(basectx) and localflags != otherflags:
+        baseflags = _bytes_to_set(basectx.flags())
+        flags = localflags & otherflags
+        for f in localflags.symmetric_difference(otherflags):
+            if f not in baseflags:
+                flags.add(f)
+        flags = b''.join(sorted(flags))
+
     if not opts.get(b'print'):
-        localctx.write(mergedtext, localctx.flags())
+        localctx.write(mergedtext, flags)
 
     if m3.conflicts and not mode == b'union':
         return 1



To: marmoute, #hg-reviewers, durin42
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200528/407dea32/attachment-0002.html>


More information about the Mercurial-patches mailing list