[Request] [++- ] D8966: merge: show list of bids for each file in bid-merge in ui.note()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Aug 27 09:39:36 UTC 2020


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Earlier, we were showing the list of bids only when we were ambiguously picking.
  However, the cases where we unambiguously picked a side may not always be
  correct and need to be fixed.
  
  Having list of bids for all files will be helpful in debugging.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge-criss-cross.t

CHANGE DETAILS

diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -150,8 +150,16 @@
    f2: remote unchanged -> k
   
   auction for merging merge bids
-   f1: picking 'get' action
-   f2: picking 'keep' action
+   f1:
+     list of bids:
+       remote is newer -> g
+       versions differ -> m
+     picking 'get' action
+   f2:
+     list of bids:
+       remote unchanged -> k
+       versions differ -> m
+     picking 'keep' action
   end of auction
   
    f1: remote is newer -> g
@@ -193,8 +201,16 @@
    f2: remote is newer -> g
   
   auction for merging merge bids
-   f1: picking 'keep' action
-   f2: picking 'get' action
+   f1:
+     list of bids:
+       remote unchanged -> k
+       versions differ -> m
+     picking 'keep' action
+   f2:
+     list of bids:
+       remote is newer -> g
+       versions differ -> m
+     picking 'get' action
   end of auction
   
    f2: remote is newer -> g
@@ -231,8 +247,16 @@
   resolving manifests
   
   auction for merging merge bids
-   f1: picking 'get' action
-   f2: picking 'keep' action
+   f1:
+     list of bids:
+       remote is newer -> g
+       versions differ -> m
+     picking 'get' action
+   f2:
+     list of bids:
+       remote unchanged -> k
+       versions differ -> m
+     picking 'keep' action
   end of auction
   
   getting f1
@@ -258,8 +282,16 @@
    f2: remote unchanged -> k
   
   auction for merging merge bids
-   f1: picking 'get' action
-   f2: picking 'keep' action
+   f1:
+     list of bids:
+       remote is newer -> g
+       versions differ -> m
+     picking 'get' action
+   f2:
+     list of bids:
+       remote unchanged -> k
+       versions differ -> m
+     picking 'keep' action
   end of auction
   
    f1: remote is newer -> g
@@ -344,10 +376,11 @@
   resolving manifests
   
   auction for merging merge bids
-   x: multiple bids for merge action:
-    versions differ -> m
-    versions differ -> m
-   x: ambiguous merge - picked m action
+   x:
+     list of bids:
+       versions differ -> m
+       versions differ -> m
+     ambiguous merge - picked m action
   end of auction
   
   merging x
@@ -433,9 +466,21 @@
    d2/b: remote created -> g
   
   auction for merging merge bids
-   d1/a: picking 'keep' action
-   d1/b: picking 'keep' action
-   d2/b: consensus for g
+   d1/a:
+     list of bids:
+       ancestor missing, remote missing -> k
+       other deleted -> r
+     picking 'keep' action
+   d1/b:
+     list of bids:
+       ancestor missing, remote missing -> k
+       other deleted -> r
+     picking 'keep' action
+   d2/b:
+     list of bids:
+       remote created -> g
+       remote created -> g
+     consensus for g
   end of auction
   
    d2/b: remote created -> g
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1175,37 +1175,35 @@
         # Pick the best bid for each file
         repo.ui.note(_(b'\nauction for merging merge bids\n'))
         for f, bids in sorted(fbids.items()):
+            repo.ui.note(_(b" %s:\n   list of bids:\n") % f)
+            for m, l in sorted(bids.items()):
+                for _f, args, msg in l:
+                    repo.ui.note(b'     %s -> %s\n' % (msg, m))
             # bids is a mapping from action method to list af actions
             # Consensus?
             if len(bids) == 1:  # all bids are the same kind of method
                 m, l = list(bids.items())[0]
                 if all(a == l[0] for a in l[1:]):  # len(bids) is > 1
-                    repo.ui.note(_(b" %s: consensus for %s\n") % (f, m))
+                    repo.ui.note(_(b"   consensus for %s\n") % (m))
                     mresult.addfile(f, *l[0])
                     continue
             # If keep is an option, just do it.
             if mergestatemod.ACTION_KEEP in bids:
-                repo.ui.note(_(b" %s: picking 'keep' action\n") % f)
+                repo.ui.note(_(b"   picking 'keep' action\n"))
                 mresult.addfile(f, *bids[mergestatemod.ACTION_KEEP][0])
                 continue
             # If there are gets and they all agree [how could they not?], do it.
             if mergestatemod.ACTION_GET in bids:
                 ga0 = bids[mergestatemod.ACTION_GET][0]
                 if all(a == ga0 for a in bids[mergestatemod.ACTION_GET][1:]):
-                    repo.ui.note(_(b" %s: picking 'get' action\n") % f)
+                    repo.ui.note(_(b"   picking 'get' action\n"))
                     mresult.addfile(f, *ga0)
                     continue
             # TODO: Consider other simple actions such as mode changes
             # Handle inefficient democrazy.
-            repo.ui.note(_(b' %s: multiple bids for merge action:\n') % f)
-            for m, l in sorted(bids.items()):
-                for _f, args, msg in l:
-                    repo.ui.note(b'  %s -> %s\n' % (msg, m))
             # Pick random action. TODO: Instead, prompt user when resolving
             m, l = list(bids.items())[0]
-            repo.ui.warn(
-                _(b' %s: ambiguous merge - picked %s action\n') % (f, m)
-            )
+            repo.ui.warn(_(b'   ambiguous merge - picked %s action\n') % (m))
             mresult.addfile(f, *l[0])
             continue
         repo.ui.note(_(b'end of auction\n\n'))



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200827/491c7737/attachment-0001.html>


More information about the Mercurial-patches mailing list