Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
48688:053a5bf508da | 48689:fbf7e383e961 |
---|---|
63 # (i.e. 'tip') | 63 # (i.e. 'tip') |
64 # | 64 # |
65 # replaced changesets: same as divergent except we know there | 65 # replaced changesets: same as divergent except we know there |
66 # is no conflict | 66 # is no conflict |
67 # | 67 # |
68 # pruned changeset: no update is done; though, we could | 68 # pruned changeset: update to the closest non-obsolete ancestor, |
69 # consider updating to the first non-obsolete parent, | 69 # similar to what 'hg prune' currently does |
70 # similar to what is current done for 'hg prune' | |
71 | 70 |
72 if successors: | 71 if successors: |
73 # flatten the list here handles both divergent (len > 1) | 72 # flatten the list here handles both divergent (len > 1) |
74 # and the usual case (len = 1) | 73 # and the usual case (len = 1) |
75 successors = [n for sub in successors for n in sub] | 74 successors = [n for sub in successors for n in sub] |
76 | 75 |
77 # get the max revision for the given successors set, | 76 # get the max revision for the given successors set, |
78 # i.e. the 'tip' of a set | 77 # i.e. the 'tip' of a set |
79 node = repo.revs(b'max(%ln)', successors).first() | 78 node = repo.revs(b'max(%ln)', successors).first() |
80 if bookmarks.isactivewdirparent(repo): | |
81 movemark = repo[b'.'].node() | |
82 else: | 79 else: |
83 # TODO: copy hg prune logic | 80 p1 = p1.p1() |
84 node = repo[b'.'].node() | 81 while p1.obsolete(): |
82 p1 = p1.p1() | |
83 node = p1.node() | |
84 | |
85 if node is not None and bookmarks.isactivewdirparent(repo): | |
86 movemark = repo[b'.'].node() | |
87 | |
85 return node, movemark, None | 88 return node, movemark, None |
86 | 89 |
87 | 90 |
88 def _destupdatebook(repo, clean): | 91 def _destupdatebook(repo, clean): |
89 """decide on an update destination from active bookmark""" | 92 """decide on an update destination from active bookmark""" |