[Request] [+- ] D12099: destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
av6 (Anton Shestakov)
phabricator at mercurial-scm.org
Fri Jan 28 17:39:42 UTC 2022
av6 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12099
AFFECTED FILES
mercurial/destutil.py
tests/test-update-branches.t
CHANGE DETAILS
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -696,9 +696,8 @@
(commit or update --clean to discard changes)
[255]
-Test that we don't crash when updating from a pruned changeset (i.e. has no
-successors). Behavior should probably be that we update to the first
-non-obsolete parent but that will be decided later.
+Test that we update to the closest non-obsolete ancestor when updating from a
+pruned changeset (i.e. that has no successors)
$ hg id --debug -r 2
bd10386d478cd5a9faf2e604114c8e6da62d3889
$ hg up --quiet 0
@@ -706,21 +705,18 @@
$ hg debugobsolete bd10386d478cd5a9faf2e604114c8e6da62d3889
1 new obsolescence markers
obsoleted 1 changesets
+ $ hg log -r '_destupdate()'
+ 1:0786582aa4b1 1 (no-eol)
$ hg up
- 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-Test experimental revset support
-
- $ hg log -r '_destupdate()'
- 2:bd10386d478c 2 (no-eol)
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Test that boolean flags allow --no-flag specification to override [defaults]
$ cat >> $HGRCPATH <<EOF
> [defaults]
> update = --check
> EOF
- $ hg co 2
+ $ hg co 1
abort: uncommitted changes
[20]
- $ hg co --no-check 2
+ $ hg co --no-check 1
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -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
To: av6, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220128/080b1bf7/attachment.html>
More information about the Mercurial-patches
mailing list