comparison mercurial/destutil.py @ 37787:92213f6745ed

rebase: introduce support for automatically rebasing orphan changes _destautorebase(SRC) is based on the _destrestack(SRC) revset from fbamend. The supporting _possibledestination function is extracted from evolve, with minor cleanups. We've considered some alternatives here: * This change, but with --auto as the flag name. We're hedging our bets on this a little in this change so that if this ends up being the wrong direction we haven't burned the valauble --auto name on rebase. * --destination auto: I've got reservations about the discoverability of this, and we don't currently have a good story for a revset alias of sorts that changes behavior depending on the context in which it's used. * A "rebase presets" feature, where we could use the currently-an-error positional argument space for the rebase command to define presets, so that users could define a 'linearize' preset that specifies --revision='orphan()-obsolete()' and --dest=_destautoorphanrebase(SRC). Personally, I find the third option somewhat appealing, but am hesitant to "spend" the functionality space of positional arguments to the rebase command. We should revisit the way we expose this functionality sometime in the 4.7 cycle once we've had a chance to vet the implementation of the functionality. Differential Revision: https://phab.mercurial-scm.org/D2668
author Augie Fackler <augie@google.com>
date Sun, 04 Mar 2018 15:29:41 -0500
parents 2b38c80557a4
children fbd168455b26
comparison
equal deleted inserted replaced
37786:cc932c15b9ee 37787:92213f6745ed
13 error, 13 error,
14 obsutil, 14 obsutil,
15 scmutil, 15 scmutil,
16 stack 16 stack
17 ) 17 )
18
19 def orphanpossibledestination(repo, rev):
20 """Return all changesets that may be a new parent for orphan `rev`.
21
22 This function works fine on non-orphan revisions, it's just silly
23 because there's no destination implied by obsolete markers, so
24 it'll return nothing.
25 """
26 tonode = repo.changelog.node
27 parents = repo.changelog.parentrevs
28 torev = repo.changelog.rev
29 dest = set()
30 tovisit = list(parents(rev))
31 while tovisit:
32 r = tovisit.pop()
33 succsets = obsutil.successorssets(repo, tonode(r))
34 if not succsets:
35 # if there are no successors for r, r was probably pruned
36 # and we should walk up to r's parents to try and find
37 # some successors.
38 tovisit.extend(parents(r))
39 else:
40 # We should probably pick only one destination from split
41 # (case where '1 < len(ss)'), This could be the currently
42 # tipmost, but the correct result is less clear when
43 # results of the split have been moved such that they
44 # reside on multiple branches.
45 for ss in succsets:
46 for n in ss:
47 dr = torev(n)
48 if dr != -1:
49 dest.add(dr)
50 return dest
18 51
19 def _destupdateobs(repo, clean): 52 def _destupdateobs(repo, clean):
20 """decide of an update destination from obsolescence markers""" 53 """decide of an update destination from obsolescence markers"""
21 node = None 54 node = None
22 wc = repo[None] 55 wc = repo[None]