diff mercurial/destutil.py @ 48689:fbf7e383e961

destutil: if wdp is obsolete, update to the closest non-obsolete ancestor As the original comments suggest, using prune as a model here was an existing idea, and now this patch implements it. I think it would be even better to do what solveobswdp() from evolve does (in short, it allows to update to a successor of the closest ancestor even if that ancestor is obsolete), but that is outside of this series' scope. Differential Revision: https://phab.mercurial-scm.org/D12099
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 15 Jan 2022 09:08:41 +0300
parents f8f2ecdde4b5
children 6000f5b25c9b
line wrap: on
line diff
--- a/mercurial/destutil.py	Tue Jan 04 23:38:39 2022 +0300
+++ b/mercurial/destutil.py	Sat Jan 15 09:08:41 2022 +0300
@@ -65,9 +65,8 @@
         # replaced changesets: same as divergent except we know there
         # is no conflict
         #
-        # pruned changeset: no update is done; though, we could
-        #     consider updating to the first non-obsolete parent,
-        #     similar to what is current done for 'hg prune'
+        # pruned changeset: update to the closest non-obsolete ancestor,
+        # similar to what 'hg prune' currently does
 
         if successors:
             # flatten the list here handles both divergent (len > 1)
@@ -77,11 +76,15 @@
             # get the max revision for the given successors set,
             # i.e. the 'tip' of a set
             node = repo.revs(b'max(%ln)', successors).first()
-            if bookmarks.isactivewdirparent(repo):
-                movemark = repo[b'.'].node()
         else:
-            # TODO: copy hg prune logic
-            node = repo[b'.'].node()
+            p1 = p1.p1()
+            while p1.obsolete():
+                p1 = p1.p1()
+            node = p1.node()
+
+        if node is not None and bookmarks.isactivewdirparent(repo):
+            movemark = repo[b'.'].node()
+
     return node, movemark, None