annotate hgext3rd/evolve/evolvecmd.py @ 3702:f6979d64b9fb

evolve: point to '--abort' in error message The way to escape and evolve run has been updated and we need to tell our user about it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 22 Apr 2018 11:40:17 +0200
parents 29c413a7dfb5
children 95ee7bf46ade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
1 # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
2 # Logilab SA <contact@logilab.fr>
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
3 # Pierre-Yves David <pierre-yves.david@ens-lyon.org>
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
4 # Patrick Mezard <patrick@mezard.eu>
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
5 #
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
8
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
9 """logic related to hg evolve command"""
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
10
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
11 import collections
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
12 import re
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
13
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
14 from mercurial import (
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
15 bookmarks as bookmarksmod,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
16 cmdutil,
3579
3a4552b30ba8 compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3577
diff changeset
17 commands,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
18 context,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
19 copies,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
20 error,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
21 hg,
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
22 lock as lockmod,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
23 merge,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
24 node,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
25 obsolete,
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
26 obsutil,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
27 phases,
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
28 repair,
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
29 scmutil,
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
30 util,
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
31 )
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
32
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
33 from mercurial.i18n import _
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
34
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
35 from . import (
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
36 cmdrewrite,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
37 compat,
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
38 exthelper,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
39 rewriteutil,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
40 state,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
41 utility,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
42 )
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
43
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
44 TROUBLES = compat.TROUBLES
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
45 shorttemplate = utility.shorttemplate
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
46 _bookmarksupdater = rewriteutil.bookmarksupdater
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
47 sha1re = re.compile(r'\b[0-9a-f]{6,40}\b')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
48
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
49 eh = exthelper.exthelper()
3579
3a4552b30ba8 compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3577
diff changeset
50 mergetoolopts = commands.mergetoolopts
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
51
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
52 def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
53 progresscb, category):
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
54 """Resolve the troubles affecting one revision
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
55
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
56 returns a tuple (bool, newnode) where,
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
57 bool: a boolean value indicating whether the instability was solved
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
58 newnode: if bool is True, then the newnode of the resultant commit
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
59 formed. newnode can be node, when resolution led to no new
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
60 commit. If bool is False, this is ''.
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
61 """
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
62 wlock = lock = tr = None
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
63 try:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
64 wlock = repo.wlock()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
65 lock = repo.lock()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
66 tr = repo.transaction("evolve")
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
67 if 'orphan' == category:
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
68 result = _solveunstable(ui, repo, ctx, evolvestate,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
69 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
70 elif 'phasedivergent' == category:
3609
1c8dec54450a evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3608
diff changeset
71 result = _solvephasedivergence(ui, repo, ctx, evolvestate,
1c8dec54450a evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3608
diff changeset
72 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
73 elif 'contentdivergent' == category:
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
74 result = _solvedivergent(ui, repo, ctx, evolvestate,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
75 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
76 else:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
77 assert False, "unknown trouble category: %s" % (category)
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
78 tr.close()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
79 return result
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
80 finally:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
81 lockmod.release(tr, lock, wlock)
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
82
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
83 def _solveunstable(ui, repo, orig, evolvestate, dryrun=False, confirm=False,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
84 progresscb=None):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
85 """ Tries to stabilize the changeset orig which is orphan.
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
86
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
87 returns a tuple (bool, newnode) where,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
88 bool: a boolean value indicating whether the instability was solved
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
89 newnode: if bool is True, then the newnode of the resultant commit
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
90 formed. newnode can be node, when resolution led to no new
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
91 commit. If bool is False, this is ''.
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
92 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
93 pctx = orig.p1()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
94 keepbranch = orig.p1().branch() != orig.branch()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
95 if len(orig.parents()) == 2:
3545
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
96 p1obs = orig.p1().obsolete()
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
97 p2obs = orig.p2().obsolete()
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
98 if not p1obs and p2obs:
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
99 pctx = orig.p2() # second parent is obsolete ?
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
100 keepbranch = orig.p2().branch() != orig.branch()
3545
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
101 elif not p2obs and p1obs:
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
102 pass
6aff754c2457 evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3543
diff changeset
103 else:
3573
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
104 # store that we are resolving an orphan merge with both parents
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
105 # obsolete and proceed with first parent
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
106 evolvestate['orphanmerge'] = True
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
107 # we should process the second parent first, so that in case of
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
108 # no-conflicts the first parent is processed later and preserved as
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
109 # first parent
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
110 pctx = orig.p2()
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
111 keepbranch = orig.p2().branch() != orig.branch()
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
112
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
113 if not pctx.obsolete():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
114 ui.warn(_("cannot solve instability of %s, skipping\n") % orig)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
115 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
116 obs = pctx
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
117 newer = obsutil.successorssets(repo, obs.node())
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
118 # search of a parent which is not killed
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
119 while not newer or newer == [()]:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
120 ui.debug("stabilize target %s is plain dead,"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
121 " trying to stabilize on its parent\n" %
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
122 obs)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
123 obs = obs.parents()[0]
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
124 newer = obsutil.successorssets(repo, obs.node())
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
125 if len(newer) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
126 msg = _("skipping %s: divergent rewriting. can't choose "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
127 "destination\n") % obs
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
128 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
129 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
130 targets = newer[0]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
131 assert targets
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
132 if len(targets) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
133 # split target, figure out which one to pick, are they all in line?
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
134 targetrevs = [repo[r].rev() for r in targets]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
135 roots = repo.revs('roots(%ld)', targetrevs)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
136 heads = repo.revs('heads(%ld)', targetrevs)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
137 if len(roots) > 1 or len(heads) > 1:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
138 cheader = _("ancestor '%s' split over multiple topological"
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
139 " branches.\nchoose an evolve destination:") % orig
3541
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
140 selectedrev = utility.revselectionprompt(ui, repo, list(heads),
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
141 cheader)
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
142 if selectedrev is None:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
143 msg = _("could not solve instability, "
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
144 "ambiguous destination: "
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
145 "parent split across two branches\n")
3541
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
146 ui.write_err(msg)
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
147 return (False, '')
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
148 target = repo[selectedrev]
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
149 else:
bc47c09c9782 evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3529
diff changeset
150 target = repo[heads.first()]
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
151 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
152 target = targets[0]
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
153 displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate})
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
154 target = repo[target]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
155 if not ui.quiet or confirm:
3501
7c8150697810 color: add some colors to evolve command itself
Boris Feld <boris.feld@octobus.net>
parents: 3495
diff changeset
156 repo.ui.write(_('move:'), label='evolve.operation')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
157 displayer.show(orig)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
158 repo.ui.write(_('atop:'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
159 displayer.show(target)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
160 if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y':
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
161 raise error.Abort(_('evolve aborted by user'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
162 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
163 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
164 todo = 'hg rebase -r %s -d %s\n' % (orig, target)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
165 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
166 repo.ui.write(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
167 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
168 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
169 repo.ui.note(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
170 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
171 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
172 try:
3638
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
173 newid = relocate(repo, orig, target, evolvestate, pctx,
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
174 keepbranch, 'orphan')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
175 return (True, newid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
176 except MergeFailure:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
177 ops = {'current': orig.node()}
3479
4b9fc8c85ee4 evolvecmd: use the evolvestate object passed as argument in _solveunstable
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3478
diff changeset
178 evolvestate.addopts(ops)
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
179 evolvestate.save()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
180 repo.ui.write_err(_('evolve failed!\n'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
181 repo.ui.write_err(
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
182 _("fix conflict and run 'hg evolve --continue'"
3702
f6979d64b9fb evolve: point to '--abort' in error message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3701
diff changeset
183 " or use 'hg evolve --abort' to abort\n"))
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
184 raise
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
185
3609
1c8dec54450a evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3608
diff changeset
186 def _solvephasedivergence(ui, repo, bumped, evolvestate, dryrun=False,
1c8dec54450a evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3608
diff changeset
187 confirm=False, progresscb=None):
1c8dec54450a evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3608
diff changeset
188 """Stabilize a phase divergent changeset
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
189
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
190 returns a tuple (bool, newnode) where,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
191 bool: a boolean value indicating whether the instability was solved
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
192 newnode: if bool is True, then the newnode of the resultant commit
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
193 formed. newnode can be node, when resolution led to no new
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
194 commit. If bool is False, this is ''.
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
195 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
196 repo = repo.unfiltered()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
197 bumped = repo[bumped.rev()]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
198 # For now we deny bumped merge
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
199 if len(bumped.parents()) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
200 msg = _('skipping %s : we do not handle merge yet\n') % bumped
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
201 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
202 return (False, '')
3506
6b4272bbb65d evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents: 3503
diff changeset
203 prec = repo.set('last(allprecursors(%d) and public())', bumped.rev()).next()
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
204 # For now we deny target merge
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
205 if len(prec.parents()) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
206 msg = _('skipping: %s: public version is a merge, '
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
207 'this is not handled yet\n') % prec
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
208 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
209 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
210
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
211 displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate})
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
212 if not ui.quiet or confirm:
3501
7c8150697810 color: add some colors to evolve command itself
Boris Feld <boris.feld@octobus.net>
parents: 3495
diff changeset
213 repo.ui.write(_('recreate:'), label='evolve.operation')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
214 displayer.show(bumped)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
215 repo.ui.write(_('atop:'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
216 displayer.show(prec)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
217 if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y':
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
218 raise error.Abort(_('evolve aborted by user'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
219 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
220 todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
221 repo.ui.write(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
222 repo.ui.write(('hg update %s;\n' % prec))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
223 repo.ui.write(('hg revert --all --rev %s;\n' % bumped))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
224 repo.ui.write(('hg commit --msg "%s update to %s"\n' %
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
225 (TROUBLES['PHASEDIVERGENT'], bumped)))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
226 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
227 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
228 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
229 tmpctx = bumped
3622
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
230
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
231 # Checking for whether the phase-divergent changeset has common parents as
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
232 # it's precursors. Phase-divergent changeset and precursor having different
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
233 # parents is a result of when the changeset is rebased, grabbed, histedit or
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
234 # evolved or any other operation which can change parent. In such cases,
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
235 # when parents are not same, we first rebase the divergent changeset onto
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
236 # parent or precursor and then perform later steps
3506
6b4272bbb65d evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents: 3503
diff changeset
237 if not list(repo.set('parents(%d) and parents(%d)', bumped.rev(), prec.rev())):
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
238 # Need to rebase the changeset at the right place
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
239 repo.ui.status(
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
240 _('rebasing to destination parent: %s\n') % prec.p1())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
241 try:
3638
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
242 tmpid = relocate(repo, bumped, prec.p1(), evolvestate,
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
243 category='phasedivergent')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
244 if tmpid is not None:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
245 tmpctx = repo[tmpid]
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
246 obsolete.createmarkers(repo, [(bumped, (tmpctx,))],
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
247 operation='evolve')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
248 except MergeFailure:
3628
170b99a9c0b4 evolve: write data to evolvestate in case on conflicts in phase-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3627
diff changeset
249 evolvestate['current'] = bumped.hex()
3631
8db32b33cdf1 evolve: store the precursor of phase-divergent in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3630
diff changeset
250 evolvestate['precursor'] = prec.hex()
3628
170b99a9c0b4 evolve: write data to evolvestate in case on conflicts in phase-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3627
diff changeset
251 evolvestate.save()
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
252 repo.ui.write_err(_('evolution failed!\n'))
3702
f6979d64b9fb evolve: point to '--abort' in error message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3701
diff changeset
253 msg = _("fix conflict then run 'hg evolve --continue' or "
f6979d64b9fb evolve: point to '--abort' in error message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3701
diff changeset
254 "use `hg evolve --abort`\n")
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
255 repo.ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
256 raise
3622
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
257
3632
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
258 return _resolvephasedivergent(ui, repo, prec, bumped, tmpctx)
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
259
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
260 def _resolvephasedivergent(ui, repo, prec, bumped, tmpctx=None):
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
261
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
262 tr = repo.currenttransaction()
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
263 assert tr is not None
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
264 bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
265 newid = None
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
266
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
267 # function to update the bookmark from the rebased changeset to new resolved
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
268 # changeset
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
269 rebasedbmupdate = None
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
270 if tmpctx and tmpctx.node() != bumped.node():
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
271 rebasedbmupdate = _bookmarksupdater(repo, tmpctx.node(), tr)
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
272 bumped = tmpctx
8d38b88233cb evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3631
diff changeset
273
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
274 # Create the new commit context
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
275 repo.ui.status(_('computing new diff\n'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
276 files = set()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
277 copied = copies.pathcopies(prec, bumped)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
278 precmanifest = prec.manifest().copy()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
279 # 3.3.2 needs a list.
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
280 # future 3.4 don't detect the size change during iteration
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
281 # this is fishy
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
282 for key, val in list(bumped.manifest().iteritems()):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
283 precvalue = precmanifest.get(key, None)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
284 if precvalue is not None:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
285 del precmanifest[key]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
286 if precvalue != val:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
287 files.add(key)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
288 files.update(precmanifest) # add missing files
3622
534af64b0107 evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3616
diff changeset
289
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
290 # commit it
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
291 if files: # something to commit!
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
292 def filectxfn(repo, ctx, path):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
293 if path in bumped:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
294 fctx = bumped[path]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
295 flags = fctx.flags()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
296 mctx = compat.memfilectx(repo, ctx, fctx, flags, copied, path)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
297 return mctx
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
298 return None
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
299 text = '%s update to %s:\n\n' % (TROUBLES['PHASEDIVERGENT'], prec)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
300 text += bumped.description()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
301
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
302 new = context.memctx(repo,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
303 parents=[prec.node(), node.nullid],
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
304 text=text,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
305 files=files,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
306 filectxfn=filectxfn,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
307 user=bumped.user(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
308 date=bumped.date(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
309 extra=bumped.extra())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
310
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
311 newid = repo.commitctx(new)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
312 if newid is None:
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
313 obsolete.createmarkers(repo, [(tmpctx, ())], operation='evolve')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
314 newid = prec.node()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
315 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
316 phases.retractboundary(repo, tr, bumped.phase(), [newid])
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
317 obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
318 flag=obsolete.bumpedfix, operation='evolve')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
319 bmupdate(newid)
3624
6756f2a85f5b evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3623
diff changeset
320 # if rebased happened, update bookmarks from there too
6756f2a85f5b evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3623
diff changeset
321 if rebasedbmupdate:
6756f2a85f5b evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3623
diff changeset
322 rebasedbmupdate(newid)
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
323 repo.ui.status(_('committed as %s\n') % node.short(newid))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
324 # reroute the working copy parent to the new changeset
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
325 with repo.dirstate.parentchange():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
326 repo.dirstate.setparents(newid, node.nullid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
327 return (True, newid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
328
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
329 def _solvedivergent(ui, repo, divergent, evolvestate, dryrun=False,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
330 confirm=False, progresscb=None):
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
331 """tries to solve content-divergence of a changeset
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
332
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
333 returns a tuple (bool, newnode) where,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
334 bool: a boolean value indicating whether the instability was solved
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
335 newnode: if bool is True, then the newnode of the resultant commit
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
336 formed. newnode can be node, when resolution led to no new
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
337 commit. If bool is False, this is ''.
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
338 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
339 repo = repo.unfiltered()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
340 divergent = repo[divergent.rev()]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
341 base, others = divergentdata(divergent)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
342 if len(others) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
343 othersstr = "[%s]" % (','.join([str(i) for i in others]))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
344 msg = _("skipping %d:%s with a changeset that got split"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
345 " into multiple ones:\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
346 "|[%s]\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
347 "| This is not handled by automatic evolution yet\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
348 "| You have to fallback to manual handling with commands "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
349 "such as:\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
350 "| - hg touch -D\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
351 "| - hg prune\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
352 "| \n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
353 "| You should contact your local evolution Guru for help.\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
354 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
355 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
356 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
357 other = others[0]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
358 if len(other.parents()) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
359 msg = _("skipping %s: %s changeset can't be "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
360 "a merge (yet)\n") % (divergent, TROUBLES['CONTENTDIVERGENT'])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
361 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
362 hint = _("You have to fallback to solving this by hand...\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
363 "| This probably means redoing the merge and using \n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
364 "| `hg prune` to kill older version.\n")
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
365 ui.write_err(hint)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
366 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
367 if other.p1() not in divergent.parents():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
368 msg = _("skipping %s: have a different parent than %s "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
369 "(not handled yet)\n") % (divergent, other)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
370 hint = _("| %(d)s, %(o)s are not based on the same changeset.\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
371 "| With the current state of its implementation, \n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
372 "| evolve does not work in that case.\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
373 "| rebase one of them next to the other and run \n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
374 "| this command again.\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
375 "| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
376 "| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
377 ) % {'d': divergent, 'o': other}
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
378 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
379 ui.write_err(hint)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
380 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
381
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
382 displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate})
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
383 if not ui.quiet or confirm:
3501
7c8150697810 color: add some colors to evolve command itself
Boris Feld <boris.feld@octobus.net>
parents: 3495
diff changeset
384 ui.write(_('merge:'), label='evolve.operation')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
385 displayer.show(divergent)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
386 ui.write(_('with: '))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
387 displayer.show(other)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
388 ui.write(_('base: '))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
389 displayer.show(base)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
390 if confirm and ui.prompt(_('perform evolve? [Ny]'), 'n') != 'y':
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
391 raise error.Abort(_('evolve aborted by user'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
392 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
393 ui.write(('hg update -c %s &&\n' % divergent))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
394 ui.write(('hg merge %s &&\n' % other))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
395 ui.write(('hg commit -m "auto merge resolving conflict between '
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
396 '%s and %s"&&\n' % (divergent, other)))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
397 ui.write(('hg up -C %s &&\n' % base))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
398 ui.write(('hg revert --all --rev tip &&\n'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
399 ui.write(('hg commit -m "`hg log -r %s --template={desc}`";\n'
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
400 % divergent))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
401 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
402 if divergent not in repo[None].parents():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
403 repo.ui.status(_('updating to "local" conflict\n'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
404 hg.update(repo, divergent.rev())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
405 repo.ui.note(_('merging %s changeset\n') % TROUBLES['CONTENTDIVERGENT'])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
406 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
407 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
408 stats = merge.update(repo,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
409 other.node(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
410 branchmerge=True,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
411 force=False,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
412 ancestor=base.node(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
413 mergeancestor=True)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
414 hg._showstats(repo, stats)
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3609
diff changeset
415 if compat.hasconflict(stats):
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
416 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
417 "or 'hg update -C .' to abort\n"))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
418 raise error.Abort('merge conflict between several amendments '
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
419 '(this is not automated yet)',
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
420 hint="""/!\ You can try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
421 /!\ * manual merge + resolve => new cset X
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
422 /!\ * hg up to the parent of the amended changeset (which are named W and Z)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
423 /!\ * hg revert --all -r X
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
424 /!\ * hg ci -m "same message as the amended changeset" => new cset Y
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
425 /!\ * hg prune -n Y W Z
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
426 """)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
427 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
428 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
429 emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
430 tr = repo.currenttransaction()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
431 assert tr is not None
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
432 try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
433 repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
434 with repo.dirstate.parentchange():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
435 repo.dirstate.setparents(divergent.node(), node.nullid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
436 oldlen = len(repo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
437 cmdrewrite.amend(ui, repo, message='', logfile='')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
438 if oldlen == len(repo):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
439 new = divergent
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
440 # no changes
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
441 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
442 new = repo['.']
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
443 obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
444 phases.retractboundary(repo, tr, other.phase(), [new.node()])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
445 return (True, new.node())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
446 finally:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
447 repo.ui.restoreconfig(emtpycommitallowed)
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
448
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
449 class MergeFailure(error.Abort):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
450 pass
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
451
3469
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
452 def _orderrevs(repo, revs):
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
453 """Compute an ordering to solve instability for the given revs
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
454
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
455 revs is a list of unstable revisions.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
456
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
457 Returns the same revisions ordered to solve their instability from the
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
458 bottom to the top of the stack that the stabilization process will produce
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
459 eventually.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
460
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
461 This ensures the minimal number of stabilizations, as we can stabilize each
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
462 revision on its final stabilized destination.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
463 """
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
464 # Step 1: Build the dependency graph
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
465 dependencies, rdependencies = utility.builddependencies(repo, revs)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
466 # Step 2: Build the ordering
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
467 # Remove the revisions with no dependency(A) and add them to the ordering.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
468 # Removing these revisions leads to new revisions with no dependency (the
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
469 # one depending on A) that we can remove from the dependency graph and add
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
470 # to the ordering. We progress in a similar fashion until the ordering is
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
471 # built
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
472 solvablerevs = collections.deque([r for r in sorted(dependencies.keys())
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
473 if not dependencies[r]])
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
474 ordering = []
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
475 while solvablerevs:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
476 rev = solvablerevs.popleft()
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
477 for dependent in rdependencies[rev]:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
478 dependencies[dependent].remove(rev)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
479 if not dependencies[dependent]:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
480 solvablerevs.append(dependent)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
481 del dependencies[rev]
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
482 ordering.append(rev)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
483
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
484 ordering.extend(sorted(dependencies))
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
485 return ordering
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
486
3638
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
487 def relocate(repo, orig, dest, evolvestate, pctx=None, keepbranch=False,
7bc4a72b8a0b evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3636
diff changeset
488 category=None):
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
489 """rewrites the orig rev on dest rev
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
490
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
491 returns the node of new commit which is formed
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
492 """
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
493 if orig.rev() == dest.rev():
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
494 raise error.Abort(_('tried to relocate a node on top of itself'),
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
495 hint=_("This shouldn't happen. If you still "
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
496 "need to move changesets, please do so "
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
497 "manually with nothing to rebase - working "
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
498 "directory parent is also destination"))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
499
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
500 if pctx is None:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
501 if len(orig.parents()) == 2:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
502 raise error.Abort(_("tried to relocate a merge commit without "
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
503 "specifying which parent should be moved"),
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
504 hint=_("Specify the parent by passing in pctx"))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
505 pctx = orig.p1()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
506
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
507 commitmsg = orig.description()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
508
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
509 cache = {}
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
510 sha1s = re.findall(sha1re, commitmsg)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
511 unfi = repo.unfiltered()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
512 for sha1 in sha1s:
3676
cded30ad25e4 compat: rename resolvepartialhexnodeid to resolvehexnodeidprefix
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3674
diff changeset
513 if util.safehasattr(scmutil, 'resolvehexnodeidprefix'): # > hg-4.6
cded30ad25e4 compat: rename resolvepartialhexnodeid to resolvehexnodeidprefix
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3674
diff changeset
514 fullnode = scmutil.resolvehexnodeidprefix(unfi, sha1)
3674
51adc7e6a617 compat: fallback to compatible partial lookup prior to 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3666
diff changeset
515 else:
51adc7e6a617 compat: fallback to compatible partial lookup prior to 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3666
diff changeset
516 fullnode = unfi.changelog.index.partialmatch(sha1)
3665
0f0f31351d6d compat: avoid using partial node ID in lookup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3653
diff changeset
517 if fullnode is None:
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
518 continue
3665
0f0f31351d6d compat: avoid using partial node ID in lookup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3653
diff changeset
519 ctx = unfi[fullnode]
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
520 if not ctx.obsolete():
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
521 continue
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
522
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
523 successors = obsutil.successorssets(repo, ctx.node(), cache)
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
524
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
525 # We can't make any assumptions about how to update the hash if the
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
526 # cset in question was split or diverged.
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
527 if len(successors) == 1 and len(successors[0]) == 1:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
528 newsha1 = node.hex(successors[0][0])
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
529 commitmsg = commitmsg.replace(sha1, newsha1[:len(sha1)])
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
530 else:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
531 repo.ui.note(_('The stale commit message reference to %s could '
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
532 'not be updated\n') % sha1)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
533
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
534 tr = repo.currenttransaction()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
535 assert tr is not None
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
536 try:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
537 r = _evolvemerge(repo, orig, dest, pctx, keepbranch)
3616
f6d629514607 compat: use updateresult API if available
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3609
diff changeset
538 if compat.hasconflict(r): # some conflict
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
539 raise error.Abort(_('unresolved merge conflicts '
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
540 '(see hg help resolve)'))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
541 nodenew = _relocatecommit(repo, orig, commitmsg)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
542 except error.Abort as exc:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
543 with repo.dirstate.parentchange():
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
544 repo.setparents(repo['.'].node(), node.nullid)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
545 repo.dirstate.write(tr)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
546 # fix up dirstate for copies and renames
3700
2577fdc3a458 compat: drop compatibility layer for duplicatecopies
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3699
diff changeset
547 copies.duplicatecopies(repo, repo[None], dest.rev(), orig.p1().rev())
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
548
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
549 class LocalMergeFailure(MergeFailure, exc.__class__):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
550 pass
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
551 exc.__class__ = LocalMergeFailure
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
552 tr.close() # to keep changes in this transaction (e.g. dirstate)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
553 raise
3639
95a767b2769e evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3638
diff changeset
554 _finalizerelocate(repo, orig, dest, nodenew, tr, category, evolvestate)
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
555 return nodenew
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
556
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
557 def _relocatecommit(repo, orig, commitmsg):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
558 if commitmsg is None:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
559 commitmsg = orig.description()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
560 extra = dict(orig.extra())
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
561 if 'branch' in extra:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
562 del extra['branch']
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
563 extra['rebase_source'] = orig.hex()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
564
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
565 backup = repo.ui.backupconfig('phases', 'new-commit')
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
566 try:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
567 targetphase = max(orig.phase(), phases.draft)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
568 repo.ui.setconfig('phases', 'new-commit', targetphase, 'evolve')
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
569 # Commit might fail if unresolved files exist
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
570 nodenew = repo.commit(text=commitmsg, user=orig.user(),
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
571 date=orig.date(), extra=extra)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
572 finally:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
573 repo.ui.restoreconfig(backup)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
574 return nodenew
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
575
3639
95a767b2769e evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3638
diff changeset
576 def _finalizerelocate(repo, orig, dest, nodenew, tr, category, evolvestate):
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
577 destbookmarks = repo.nodebookmarks(dest.node())
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
578 nodesrc = orig.node()
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
579 oldbookmarks = repo.nodebookmarks(nodesrc)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
580 bmchanges = []
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
581
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
582 if nodenew is not None:
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
583 obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))],
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
584 operation='evolve')
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
585 for book in oldbookmarks:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
586 bmchanges.append((book, nodenew))
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
587 evolvestate['bookmarkchanges'].append((book, nodesrc))
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
588 else:
3636
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
589 if category == 'orphan':
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
590 repo.ui.status(_("evolution of %d:%s created no changes "
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
591 "to commit\n") % (orig.rev(), orig))
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
592 obsolete.createmarkers(repo, [(repo[nodesrc], ())], operation='evolve')
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
593 # Behave like rebase, move bookmarks to dest
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
594 for book in oldbookmarks:
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
595 evolvestate['bookmarkchanges'].append((book, nodesrc))
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
596 bmchanges.append((book, dest.node()))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
597 for book in destbookmarks: # restore bookmark that rebase move
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
598 bmchanges.append((book, dest.node()))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
599 if bmchanges:
3699
67d6cc7e0979 compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3698
diff changeset
600 repo._bookmarks.applychanges(repo, tr, bmchanges)
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
601
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
602 def _evolvemerge(repo, orig, dest, pctx, keepbranch):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
603 """Used by the evolve function to merge dest on top of pctx.
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
604 return the same tuple as merge.graft"""
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
605 if repo['.'].rev() != dest.rev():
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
606 merge.update(repo,
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
607 dest,
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
608 branchmerge=False,
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
609 force=True)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
610 if repo._activebookmark:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
611 repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
612 bookmarksmod.deactivate(repo)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
613 if keepbranch:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
614 repo.dirstate.setbranch(orig.branch())
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
615 if util.safehasattr(repo, 'currenttopic'):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
616 # uurrgs
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
617 # there no other topic setter yet
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
618 if not orig.topic() and repo.vfs.exists('topic'):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
619 repo.vfs.unlink('topic')
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
620 else:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
621 with repo.vfs.open('topic', 'w') as f:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
622 f.write(orig.topic())
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
623
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
624 return merge.graft(repo, orig, pctx, ['destination', 'evolving'], True)
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
625
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
626 instabilities_map = {
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
627 'contentdivergent': "content-divergent",
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
628 'phasedivergent': "phase-divergent"
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
629 }
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
630
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
631 def _selectrevs(repo, allopt, revopt, anyopt, targetcat):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
632 """select troubles in repo matching according to given options"""
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
633 revs = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
634 if allopt or revopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
635 revs = repo.revs("%s()" % targetcat)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
636 if revopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
637 revs = scmutil.revrange(repo, revopt) & revs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
638 elif not anyopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
639 topic = getattr(repo, 'currenttopic', '')
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
640 if topic:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
641 revs = repo.revs('topic(%s)', topic) & revs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
642 elif targetcat == 'orphan':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
643 revs = _aspiringdescendant(repo,
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
644 repo.revs('(.::) - obsolete()::'))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
645 revs = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
646 if targetcat == 'contentdivergent':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
647 # Pick one divergent per group of divergents
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
648 revs = _dedupedivergents(repo, revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
649 elif anyopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
650 revs = repo.revs('first(%s())' % (targetcat))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
651 elif targetcat == 'orphan':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
652 revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::')))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
653 if 1 < len(revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
654 msg = "multiple evolve candidates"
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
655 hint = (_("select one of %s with --rev")
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
656 % ', '.join([str(repo[r]) for r in sorted(revs)]))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
657 raise error.Abort(msg, hint=hint)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
658 elif instabilities_map.get(targetcat, targetcat) in repo['.'].instabilities():
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
659 revs = set([repo['.'].rev()])
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
660 return revs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
661
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
662 def _dedupedivergents(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
663 """Dedupe the divergents revs in revs to get one from each group with the
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
664 lowest revision numbers
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
665 """
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
666 repo = repo.unfiltered()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
667 res = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
668 # To not reevaluate divergents of the same group once one is encountered
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
669 discarded = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
670 for rev in revs:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
671 if rev in discarded:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
672 continue
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
673 divergent = repo[rev]
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
674 base, others = divergentdata(divergent)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
675 othersrevs = [o.rev() for o in others]
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
676 res.add(min([divergent.rev()] + othersrevs))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
677 discarded.update(othersrevs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
678 return res
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
679
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
680 def divergentdata(ctx):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
681 """return base, other part of a conflict
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
682
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
683 This only return the first one.
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
684
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
685 XXX this woobly function won't survive XXX
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
686 """
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
687 repo = ctx._repo.unfiltered()
3506
6b4272bbb65d evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents: 3503
diff changeset
688 for base in repo.set('reverse(allprecursors(%d))', ctx.rev()):
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
689 newer = obsutil.successorssets(ctx._repo, base.node())
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
690 # drop filter and solution including the original ctx
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
691 newer = [n for n in newer if n and ctx.node() not in n]
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
692 if newer:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
693 return base, tuple(ctx._repo[o] for o in newer[0])
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
694 raise error.Abort(_("base of divergent changeset %s not found") % ctx,
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
695 hint=_('this case is not yet handled'))
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
696
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
697 def _aspiringdescendant(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
698 """Return a list of changectx which can be stabilized on top of pctx or
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
699 one of its descendants recursively. Empty list if none can be found."""
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
700 target = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
701 result = set(target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
702 paths = collections.defaultdict(set)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
703 for r in repo.revs('orphan() - %ld', revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
704 for d in _possibledestination(repo, r):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
705 paths[d].add(r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
706
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
707 result = set(target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
708 tovisit = list(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
709 while tovisit:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
710 base = tovisit.pop()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
711 for unstable in paths[base]:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
712 if unstable not in result:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
713 tovisit.append(unstable)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
714 result.add(unstable)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
715 return sorted(result - target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
716
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
717 def _aspiringchildren(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
718 """Return a list of changectx which can be stabilized on top of pctx or
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
719 one of its descendants. Empty list if none can be found."""
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
720 target = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
721 result = []
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
722 for r in repo.revs('orphan() - %ld', revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
723 dest = _possibledestination(repo, r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
724 if target & dest:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
725 result.append(r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
726 return result
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
727
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
728 def _possibledestination(repo, rev):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
729 """return all changesets that may be a new parent for REV"""
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
730 tonode = repo.changelog.node
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
731 parents = repo.changelog.parentrevs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
732 torev = repo.changelog.rev
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
733 dest = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
734 tovisit = list(parents(rev))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
735 while tovisit:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
736 r = tovisit.pop()
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
737 succsets = obsutil.successorssets(repo, tonode(r))
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
738 if not succsets:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
739 tovisit.extend(parents(r))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
740 else:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
741 # We should probably pick only one destination from split
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
742 # (case where '1 < len(ss)'), This could be the currently tipmost
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
743 # but logic is less clear when result of the split are now on
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
744 # multiple branches.
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
745 for ss in succsets:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
746 for n in ss:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
747 dest.add(torev(n))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
748 return dest
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
749
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
750 def _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
751 """Used by the evolve function to display an error message when
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
752 no troubles can be resolved"""
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
753 troublecategories = ['phasedivergent', 'contentdivergent', 'orphan']
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
754 unselectedcategories = [c for c in troublecategories if c != targetcat]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
755 msg = None
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
756 hint = None
3649
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
757 retoverride = None
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
758
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
759 troubled = {
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
760 "orphan": repo.revs("orphan()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
761 "contentdivergent": repo.revs("contentdivergent()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
762 "phasedivergent": repo.revs("phasedivergent()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
763 "all": repo.revs("troubled()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
764 }
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
765
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
766 hintmap = {
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
767 'phasedivergent': _("do you want to use --phase-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
768 'phasedivergent+contentdivergent': _("do you want to use "
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
769 "--phase-divergent or"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
770 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
771 'phasedivergent+orphan': _("do you want to use --phase-divergent"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
772 " or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
773 'contentdivergent': _("do you want to use --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
774 'contentdivergent+orphan': _("do you want to use --content-divergent"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
775 " or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
776 'orphan': _("do you want to use --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
777 'any+phasedivergent': _("do you want to use --any (or --rev) and"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
778 " --phase-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
779 'any+phasedivergent+contentdivergent': _("do you want to use --any"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
780 " (or --rev) and"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
781 " --phase-divergent or"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
782 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
783 'any+phasedivergent+orphan': _("do you want to use --any (or --rev)"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
784 " and --phase-divergent or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
785 'any+contentdivergent': _("do you want to use --any (or --rev) and"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
786 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
787 'any+contentdivergent+orphan': _("do you want to use --any (or --rev)"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
788 " and --content-divergent or "
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
789 "--orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
790 'any+orphan': _("do you want to use --any (or --rev)"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
791 "and --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
792 }
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
793
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
794 if revopt:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
795 revs = scmutil.revrange(repo, revopt)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
796 if not revs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
797 msg = _("set of specified revisions is empty")
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
798 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
799 msg = _("no %s changesets in specified revisions") % targetcat
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
800 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
801 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
802 if revs & troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
803 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
804 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
805 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
806
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
807 elif anyopt:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
808 msg = _("no %s changesets to evolve") % targetcat
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
809 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
810 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
811 if troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
812 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
813 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
814 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
815
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
816 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
817 # evolve without any option = relative to the current wdir
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
818 if targetcat == 'orphan':
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
819 msg = _("nothing to evolve on current working copy parent")
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
820 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
821 msg = _("current working copy parent is not %s") % targetcat
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
822
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
823 p1 = repo['.'].rev()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
824 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
825 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
826 if p1 in troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
827 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
828 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
829 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
830 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
831 length = len(troubled[targetcat])
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
832 if length:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
833 hint = _("%d other %s in the repository, do you want --any "
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
834 "or --rev") % (length, targetcat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
835 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
836 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
837 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
838 if troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
839 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
840 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
841 hint = hintmap['any+' + ('+'.join(othertroubles))]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
842 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
843 msg = _("no troubled changesets")
3649
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
844 # Exit with a 0 (success) status in this case.
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
845 retoverride = 0
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
846
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
847 assert msg is not None
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
848 ui.write_err("%s\n" % msg)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
849 if hint:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
850 ui.write_err("(%s)\n" % hint)
3649
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
851 ret = 2
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
852 else:
3649
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
853 ret = 1
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
854
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
855 if retoverride is not None:
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
856 return retoverride
4fcf815916f5 evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents: 3643
diff changeset
857 return ret
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
858
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
859 def _preparelistctxs(items, condition):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
860 return [item.hex() for item in items if condition(item)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
861
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
862 def _formatctx(fm, ctx):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
863 fm.data(node=ctx.hex())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
864 fm.data(desc=ctx.description())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
865 fm.data(date=ctx.date())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
866 fm.data(user=ctx.user())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
867
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
868 def listtroubles(ui, repo, troublecategories, **opts):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
869 """Print all the troubles for the repo (or given revset)"""
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
870 troublecategories = troublecategories or ['contentdivergent', 'orphan', 'phasedivergent']
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
871 showunstable = 'orphan' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
872 showbumped = 'phasedivergent' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
873 showdivergent = 'contentdivergent' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
874
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
875 revs = repo.revs('+'.join("%s()" % t for t in troublecategories))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
876 if opts.get('rev'):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
877 revs = scmutil.revrange(repo, opts.get('rev'))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
878
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
879 fm = ui.formatter('evolvelist', opts)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
880 for rev in revs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
881 ctx = repo[rev]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
882 unpars = _preparelistctxs(ctx.parents(), lambda p: p.orphan())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
883 obspars = _preparelistctxs(ctx.parents(), lambda p: p.obsolete())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
884 imprecs = _preparelistctxs(repo.set("allprecursors(%n)", ctx.node()),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
885 lambda p: not p.mutable())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
886 dsets = divergentsets(repo, ctx)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
887
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
888 fm.startitem()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
889 # plain formatter section
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
890 hashlen, desclen = 12, 60
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
891 desc = ctx.description()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
892 if desc:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
893 desc = desc.splitlines()[0]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
894 desc = (desc[:desclen] + '...') if len(desc) > desclen else desc
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
895 fm.plain('%s: ' % ctx.hex()[:hashlen])
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
896 fm.plain('%s\n' % desc)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
897 fm.data(node=ctx.hex(), rev=ctx.rev(), desc=desc, phase=ctx.phasestr())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
898
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
899 for unpar in unpars if showunstable else []:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
900 fm.plain(' %s: %s (%s parent)\n' % (TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
901 unpar[:hashlen],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
902 TROUBLES['ORPHAN']))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
903 for obspar in obspars if showunstable else []:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
904 fm.plain(' %s: %s (obsolete parent)\n' % (TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
905 obspar[:hashlen]))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
906 for imprec in imprecs if showbumped else []:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
907 fm.plain(' %s: %s (immutable precursor)\n' %
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
908 (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen]))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
909
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
910 if dsets and showdivergent:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
911 for dset in dsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
912 fm.plain(' %s: ' % TROUBLES['CONTENTDIVERGENT'])
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
913 first = True
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
914 for n in dset['divergentnodes']:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
915 t = "%s (%s)" if first else " %s (%s)"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
916 first = False
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
917 fm.plain(t % (node.hex(n)[:hashlen], repo[n].phasestr()))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
918 comprec = node.hex(dset['commonprecursor'])[:hashlen]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
919 fm.plain(" (precursor %s)\n" % comprec)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
920 fm.plain("\n")
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
921
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
922 # templater-friendly section
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
923 _formatctx(fm, ctx)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
924 troubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
925 for unpar in unpars:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
926 troubles.append({'troubletype': TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
927 'sourcenode': unpar, 'sourcetype': 'orphanparent'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
928 for obspar in obspars:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
929 troubles.append({'troubletype': TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
930 'sourcenode': obspar,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
931 'sourcetype': 'obsoleteparent'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
932 for imprec in imprecs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
933 troubles.append({'troubletype': TROUBLES['PHASEDIVERGENT'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
934 'sourcenode': imprec,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
935 'sourcetype': 'immutableprecursor'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
936 for dset in dsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
937 divnodes = [{'node': node.hex(n),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
938 'phase': repo[n].phasestr(),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
939 } for n in dset['divergentnodes']]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
940 troubles.append({'troubletype': TROUBLES['CONTENTDIVERGENT'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
941 'commonprecursor': node.hex(dset['commonprecursor']),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
942 'divergentnodes': divnodes})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
943 fm.data(troubles=troubles)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
944
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
945 fm.end()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
946
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
947 def _checkevolveopts(repo, opts):
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
948 """ check the options passed to `hg evolve` and warn for deprecation warning
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
949 if any """
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
950
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
951 if opts['continue']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
952 if opts['any']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
953 raise error.Abort(_('cannot specify both "--any" and "--continue"'))
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
954 if opts['all']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
955 raise error.Abort(_('cannot specify both "--all" and "--continue"'))
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
956 if opts['rev']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
957 raise error.Abort(_('cannot specify both "--rev" and "--continue"'))
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
958 if opts['stop']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
959 raise error.Abort(_('cannot specify both "--stop" and'
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
960 ' "--continue"'))
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
961 if opts['abort']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
962 raise error.Abort(_('cannot specify both "--abort" and'
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
963 ' "--continue"'))
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
964
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
965 if opts['stop']:
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
966 if opts['any']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
967 raise error.Abort(_('cannot specify both "--any" and "--stop"'))
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
968 if opts['all']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
969 raise error.Abort(_('cannot specify both "--all" and "--stop"'))
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
970 if opts['rev']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
971 raise error.Abort(_('cannot specify both "--rev" and "--stop"'))
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
972 if opts['abort']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
973 raise error.Abort(_('cannot specify both "--abort" and "--stop"'))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
974
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
975 if opts['abort']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
976 if opts['any']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
977 raise error.Abort(_('cannot specify both "--any" and "--abort"'))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
978 if opts['all']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
979 raise error.Abort(_('cannot specify both "--all" and "--abort"'))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
980 if opts['rev']:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
981 raise error.Abort(_('cannot specify both "--rev" and "--abort"'))
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
982
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
983 if opts['rev']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
984 if opts['any']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
985 raise error.Abort(_('cannot specify both "--rev" and "--any"'))
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
986 if opts['all']:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
987 raise error.Abort(_('cannot specify both "--rev" and "--all"'))
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
988
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
989 # Backward compatibility
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
990 if opts['unstable']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
991 msg = ("'evolve --unstable' is deprecated, "
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
992 "use 'evolve --orphan'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
993 repo.ui.deprecwarn(msg, '4.4')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
994
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
995 opts['orphan'] = opts['divergent']
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
996
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
997 if opts['divergent']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
998 msg = ("'evolve --divergent' is deprecated, "
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
999 "use 'evolve --content-divergent'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1000 repo.ui.deprecwarn(msg, '4.4')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1001
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1002 opts['content_divergent'] = opts['divergent']
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1003
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1004 if opts['bumped']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1005 msg = ("'evolve --bumped' is deprecated, "
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1006 "use 'evolve --phase-divergent'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1007 repo.ui.deprecwarn(msg, '4.4')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1008
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1009 opts['phase_divergent'] = opts['bumped']
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1010
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1011 return opts
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1012
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1013 def _cleanup(ui, repo, startnode, showprogress):
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1014 if showprogress:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1015 ui.progress(_('evolve'), None)
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1016 if repo['.'] != startnode:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1017 ui.status(_('working directory is now at %s\n') % repo['.'])
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
1018
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1019 def divergentsets(repo, ctx):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1020 """Compute sets of commits divergent with a given one"""
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1021 cache = {}
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1022 base = {}
3698
4819656d1134 compat: from compatibility layer for allprecursors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3697
diff changeset
1023 for n in obsutil.allpredecessors(repo.obsstore, [ctx.node()]):
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1024 if n == ctx.node():
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1025 # a node can't be a base for divergence with itself
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1026 continue
3697
6aff4bb3970d compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
1027 nsuccsets = obsutil.successorssets(repo, n, cache)
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1028 for nsuccset in nsuccsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1029 if ctx.node() in nsuccset:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1030 # we are only interested in *other* successor sets
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1031 continue
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1032 if tuple(nsuccset) in base:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1033 # we already know the latest base for this divergency
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1034 continue
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1035 base[tuple(nsuccset)] = n
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1036 divergence = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1037 for divset, b in base.iteritems():
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1038 divergence.append({
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1039 'divergentnodes': divset,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1040 'commonprecursor': b
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1041 })
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1042
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
1043 return divergence
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1044
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1045 @eh.command(
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1046 '^evolve|stabilize|solve',
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1047 [('n', 'dry-run', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1048 _('do not perform actions, just print what would be done')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1049 ('', 'confirm', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1050 _('ask for confirmation before performing the action')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1051 ('A', 'any', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1052 _('also consider troubled changesets unrelated to current working '
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1053 'directory')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1054 ('r', 'rev', [], _('solves troubles of these revisions')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1055 ('', 'bumped', False, _('solves only bumped changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1056 ('', 'phase-divergent', False, _('solves only phase-divergent changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1057 ('', 'divergent', False, _('solves only divergent changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1058 ('', 'content-divergent', False, _('solves only content-divergent changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1059 ('', 'unstable', False, _('solves only unstable changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1060 ('', 'orphan', False, _('solves only orphan changesets (default)')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1061 ('a', 'all', False, _('evolve all troubled changesets related to the '
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1062 'current working directory and its descendants')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1063 ('c', 'continue', False, _('continue an interrupted evolution')),
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1064 ('', 'stop', False, _('stop the interrupted evolution')),
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1065 ('', 'abort', False, _('abort the interrupted evolution')),
3640
5a127bc27419 evolve: internationalize the entry of --list in hg evolve help
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3639
diff changeset
1066 ('l', 'list', False, _('provide details on troubled changesets'
5a127bc27419 evolve: internationalize the entry of --list in hg evolve help
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3639
diff changeset
1067 ' in the repo')),
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1068 ] + mergetoolopts,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1069 _('[OPTIONS]...')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1070 )
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1071 def evolve(ui, repo, **opts):
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1072 """solve troubled changesets in your repository
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1073
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1074 Modifying history can lead to various types of troubled changesets:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1075 unstable, bumped, or divergent. The evolve command resolves your troubles
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1076 by executing one of the following actions:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1077
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1078 - update working copy to a successor
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1079 - rebase an unstable changeset
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1080 - extract the desired changes from a bumped changeset
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1081 - fuse divergent changesets back together
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1082
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1083 If you pass no arguments, evolve works in automatic mode: it will execute a
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1084 single action to reduce instability related to your working copy. There are
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1085 two cases for this action. First, if the parent of your working copy is
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1086 obsolete, evolve updates to the parent's successor. Second, if the working
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1087 copy parent is not obsolete but has obsolete predecessors, then evolve
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1088 determines if there is an unstable changeset that can be rebased onto the
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1089 working copy parent in order to reduce instability.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1090 If so, evolve rebases that changeset. If not, evolve refuses to guess your
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1091 intention, and gives a hint about what you might want to do next.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1092
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1093 Any time evolve creates a changeset, it updates the working copy to the new
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1094 changeset. (Currently, every successful evolve operation involves an update
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1095 as well; this may change in future.)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1096
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1097 Automatic mode only handles common use cases. For example, it avoids taking
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1098 action in the case of ambiguity, and it ignores unstable changesets that
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1099 are not related to your working copy.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1100 It also refuses to solve bumped or divergent changesets unless you
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1101 explicitly request such behavior (see below).
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1102
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1103 Eliminating all instability around your working copy may require multiple
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1104 invocations of :hg:`evolve`. Alternately, use ``--all`` to recursively
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1105 select and evolve all unstable changesets that can be rebased onto the
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1106 working copy parent.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1107 This is more powerful than successive invocations, since ``--all`` handles
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1108 ambiguous cases (e.g. unstable changesets with multiple children) by
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1109 evolving all branches.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1110
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1111 When your repository cannot be handled by automatic mode, you might need to
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1112 use ``--rev`` to specify a changeset to evolve. For example, if you have
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1113 an unstable changeset that is not related to the working copy parent,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1114 you could use ``--rev`` to evolve it. Or, if some changeset has multiple
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1115 unstable children, evolve in automatic mode refuses to guess which one to
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1116 evolve; you have to use ``--rev`` in that case.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1117
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1118 Alternately, ``--any`` makes evolve search for the next evolvable changeset
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1119 regardless of whether it is related to the working copy parent.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1120
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1121 You can supply multiple revisions to evolve multiple troubled changesets
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1122 in a single invocation. In revset terms, ``--any`` is equivalent to ``--rev
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1123 first(unstable())``. ``--rev`` and ``--all`` are mutually exclusive, as are
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1124 ``--rev`` and ``--any``.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1125
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1126 ``hg evolve --any --all`` is useful for cleaning up instability across all
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1127 branches, letting evolve figure out the appropriate order and destination.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1128
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1129 When you have troubled changesets that are not unstable, :hg:`evolve`
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1130 refuses to consider them unless you specify the category of trouble you
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1131 wish to resolve, with ``--bumped`` or ``--divergent``. These options are
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1132 currently mutually exclusive with each other and with ``--unstable``
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1133 (the default). You can combine ``--bumped`` or ``--divergent`` with
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1134 ``--rev``, ``--all``, or ``--any``.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1135
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1136 You can also use the evolve command to list the troubles affecting your
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1137 repository by using the --list flag. You can choose to display only some
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1138 categories of troubles with the --unstable, --divergent or --bumped flags.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1139 """
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1140
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1141 opts = _checkevolveopts(repo, opts)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1142 # Options
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1143 contopt = opts['continue']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1144 anyopt = opts['any']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1145 allopt = opts['all']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1146 startnode = repo['.']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1147 dryrunopt = opts['dry_run']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1148 confirmopt = opts['confirm']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1149 revopt = opts['rev']
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1150 stopopt = opts['stop']
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1151 abortopt = opts['abort']
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1152
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1153 troublecategories = ['phase_divergent', 'content_divergent', 'orphan']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1154 specifiedcategories = [t.replace('_', '')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1155 for t in troublecategories
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1156 if opts[t]]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1157 if opts['list']:
3701
29c413a7dfb5 compat: drop compatibility layer for pager
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3700
diff changeset
1158 ui.pager('evolve')
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1159 listtroubles(ui, repo, specifiedcategories, **opts)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1160 return
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1161
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1162 targetcat = 'orphan'
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1163 if 1 < len(specifiedcategories):
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1164 msg = _('cannot specify more than one trouble category to solve (yet)')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1165 raise error.Abort(msg)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1166 elif len(specifiedcategories) == 1:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1167 targetcat = specifiedcategories[0]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1168 elif repo['.'].obsolete():
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
1169 displayer = compat.changesetdisplayer(ui, repo,
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
1170 {'template': shorttemplate})
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1171 # no args and parent is obsolete, update to successors
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1172 try:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1173 ctx = repo[utility._singlesuccessor(repo, repo['.'])]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1174 except utility.MultipleSuccessorsError as exc:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
1175 repo.ui.write_err(_('parent is obsolete with multiple'
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
1176 ' successors:\n'))
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1177 for ln in exc.successorssets:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1178 for n in ln:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1179 displayer.show(repo[n])
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1180 return 2
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1181
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1182 ui.status(_('update:'))
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1183 if not ui.quiet:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1184 displayer.show(ctx)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1185
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1186 if dryrunopt:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1187 return 0
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1188 res = hg.update(repo, ctx.rev())
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1189 if ctx != startnode:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1190 ui.status(_('working directory is now at %s\n') % ctx)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1191 return res
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1192
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1193 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1194 troubled = set(repo.revs('troubled()'))
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1195
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1196 # Progress handling
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1197 seen = 1
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1198 count = allopt and len(troubled) or 1
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1199 showprogress = allopt
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1200
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1201 def progresscb():
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1202 if revopt or allopt:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1203 ui.progress(_('evolve'), seen, unit=_('changesets'), total=count)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1204
3477
713e26a647f5 evolve: create a state object in all case
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3470
diff changeset
1205 evolvestate = state.cmdstate(repo)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1206 # Continuation handling
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1207 if contopt:
3556
b0438c9101ad evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3555
diff changeset
1208 if not evolvestate:
3582
8d93f76aa04d evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3579
diff changeset
1209 raise error.Abort(_('no interrupted evolve to continue'))
3556
b0438c9101ad evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3555
diff changeset
1210 evolvestate.load()
3557
77a400149758 evolve: move deletion of evolvestate out of continueevolve() function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3556
diff changeset
1211 continueevolve(ui, repo, evolvestate, progresscb)
3558
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1212 if evolvestate['command'] != 'evolve':
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1213 evolvestate.delete()
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1214 return
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1215 startnode = repo.unfiltered()[evolvestate['startnode']]
3557
77a400149758 evolve: move deletion of evolvestate out of continueevolve() function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3556
diff changeset
1216 evolvestate.delete()
3577
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1217 elif stopopt:
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1218 if not evolvestate:
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1219 raise error.Abort(_('no interrupted evolve to stop'))
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1220 evolvestate.load()
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1221 pctx = repo['.']
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1222 hg.updaterepo(repo, pctx.node(), True)
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1223 ui.status(_('stopped the interrupted evolve\n'))
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1224 ui.status(_('working directory is now at %s\n') % pctx)
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1225 evolvestate.delete()
279d8b610ac5 evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3573
diff changeset
1226 return
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1227 elif abortopt:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1228 if not evolvestate:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1229 raise error.Abort(_('no interrupted evolve to stop'))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1230 evolvestate.load()
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1231 return abortevolve(ui, repo, evolvestate)
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1232 else:
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1233 cmdutil.bailifchanged(repo)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1234
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1235 revs = _selectrevs(repo, allopt, revopt, anyopt, targetcat)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1236
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1237 if not revs:
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1238 return _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1239
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1240 # For the progress bar to show
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1241 count = len(revs)
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1242 # Order the revisions
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1243 if targetcat == 'orphan':
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1244 revs = _orderrevs(repo, revs)
3480
1799fc777f30 evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3479
diff changeset
1245
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1246 # cbor does not know how to serialize sets, using list for skippedrevs
3627
31569df48c82 evolve: explicitly turn revs to list before storing into evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3624
diff changeset
1247 stateopts = {'category': targetcat, 'replacements': {},
31569df48c82 evolve: explicitly turn revs to list before storing into evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3624
diff changeset
1248 'revs': list(revs), 'confirm': confirmopt,
31569df48c82 evolve: explicitly turn revs to list before storing into evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3624
diff changeset
1249 'startnode': startnode.node(), 'skippedrevs': [],
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1250 'command': 'evolve', 'orphanmerge': False,
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1251 'bookmarkchanges': []}
3555
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1252 evolvestate.addopts(stateopts)
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1253 for rev in revs:
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1254 curctx = repo[rev]
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1255 progresscb()
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1256 ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt, confirmopt,
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1257 progresscb, targetcat)
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1258 seen += 1
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1259 if ret[0]:
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1260 evolvestate['replacements'][curctx.node()] = [ret[1]]
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1261 else:
60e132e20b14 evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3554
diff changeset
1262 evolvestate['skippedrevs'].append(curctx.node())
3573
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1263
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1264 if evolvestate['orphanmerge']:
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1265 # we were processing an orphan merge with both parents obsolete,
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1266 # stabilized for second parent, re-stabilize for the first parent
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1267 ret = _solveone(ui, repo, repo[ret[1]], evolvestate, dryrunopt,
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1268 confirmopt, progresscb, targetcat)
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1269 if ret[0]:
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1270 evolvestate['replacements'][curctx.node()] = [ret[1]]
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1271 else:
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1272 evolvestate['skippedrevs'].append(curctx.node())
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1273
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1274 evolvestate['orphanmerge'] = False
d53277cdc1e7 evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3571
diff changeset
1275
3558
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1276 progresscb()
cec6e21b3bcf evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3557
diff changeset
1277 _cleanup(ui, repo, startnode, showprogress)
3554
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1278
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1279 def abortevolve(ui, repo, evolvestate):
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1280 """ logic for handling of `hg evolve --abort`"""
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1281
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1282 with repo.wlock(), repo.lock():
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1283 evolvedctx = []
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1284 # boolean value to say whether we should strip or not
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1285 cleanup = True
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1286 startnode = evolvestate['startnode']
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1287 for old, new in evolvestate['replacements'].iteritems():
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1288 evolvedctx.append(repo[new[0]])
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1289 evolvedrevs = [c.rev() for c in evolvedctx]
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1290
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1291 # checking if phase changed of any of the evolved rev
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1292 immutable = [c for c in evolvedctx if not c.mutable()]
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1293 if immutable:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1294 repo.ui.warn(_("cannot clean up public changesets: %s\n")
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1295 % ', '.join(str(c) for c in immutable),
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1296 hint=_("see 'hg help phases' for details"))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1297 cleanup = False
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1298
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1299 # checking no new changesets are created on evolved revs
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1300 descendants = set()
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1301 if evolvedrevs:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1302 descendants = set(repo.changelog.descendants(evolvedrevs))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1303 if descendants - set(evolvedrevs):
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1304 repo.ui.warn(_("warning: new changesets detected on destination "
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1305 "branch\n"))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1306 cleanup = False
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1307
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1308 if cleanup:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1309 if evolvedrevs:
3643
01108d67523f style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3642
diff changeset
1310 strippoints = [c.node()
01108d67523f style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3642
diff changeset
1311 for c in repo.set('roots(%ld)', evolvedrevs)]
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1312
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1313 # updating the working directory
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1314 hg.updaterepo(repo, startnode, True)
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1315
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1316 # Strip from the first evolved revision
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1317 if evolvedrevs:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1318 # no backup of evolved cset versions needed
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1319 repair.strip(repo.ui, repo, strippoints, False)
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1320
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1321 tr = None
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1322 try:
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1323 tr = repo.transaction('evolve')
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1324 # restoring bookmarks at there original place
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1325 bmchanges = evolvestate['bookmarkchanges']
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1326 if bmchanges:
3699
67d6cc7e0979 compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3698
diff changeset
1327 repo._bookmarks.applychanges(repo, tr, bmchanges)
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1328 tr.close()
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1329 finally:
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1330 tr.release()
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3649
diff changeset
1331
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1332 evolvestate.delete()
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1333 ui.status(_('evolve aborted\n'))
3643
01108d67523f style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3642
diff changeset
1334 ui.status(_('working directory is now at %s\n')
01108d67523f style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3642
diff changeset
1335 % node.hex(startnode)[:12])
3642
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1336 else:
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1337 raise error.Abort(_("unable to abort interrupted evolve, use 'hg "
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1338 "evolve --stop' to stop evolve"))
319b1f0f4de2 evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3640
diff changeset
1339
3554
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1340 def continueevolve(ui, repo, evolvestate, progresscb):
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1341 """logic for handling of `hg evolve --continue`"""
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1342
3554
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1343 with repo.wlock(), repo.lock():
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1344 if (evolvestate['command'] == 'next' or
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1345 evolvestate['category'] == 'orphan'):
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1346 _completeorphan(ui, repo, evolvestate)
3633
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1347 elif evolvestate['category'] == 'phasedivergent':
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1348 _completephasedivergent(ui, repo, evolvestate)
3554
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1349 else:
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1350 repo.ui.status(_("continuing interrupted '%s' resolution is not yet"
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1351 " supported\n") % evolvestate['category'])
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1352 return
3554
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1353
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1354 # make sure we are continuing evolve and not `hg next --evolve`
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1355 if evolvestate['command'] == 'evolve':
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1356 category = evolvestate['category']
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1357 confirm = evolvestate['confirm']
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1358 unfi = repo.unfiltered()
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1359 for rev in evolvestate['revs']:
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1360 # XXX: prevent this lookup by storing nodes instead of revnums
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1361 curctx = unfi[rev]
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1362 if (curctx.node() not in evolvestate['replacements'] and
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1363 curctx.node() not in evolvestate['skippedrevs']):
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1364 newnode = _solveone(ui, repo, curctx, evolvestate, False,
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1365 confirm, progresscb, category)
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1366 if newnode[0]:
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1367 evolvestate['replacements'][curctx.node()] = newnode[1]
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1368 else:
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1369 evolvestate['skippedrevs'].append(curctx.node())
f045fafd3484 evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3545
diff changeset
1370 return
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1371
3633
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1372 def _completephasedivergent(ui, repo, evolvestate):
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1373 """function to complete the interrupted phase-divergence resolution.
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1374
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1375 First completes the relocation of the commit and then process resolving
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1376 phase-divergence"""
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1377
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1378 tr = None
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1379 try:
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1380 # need to start transaction for bookmark changes
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1381 tr = repo.transaction('evolve')
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1382 node = _completerelocation(ui, repo, evolvestate)
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1383 # resolving conflicts can lead to empty wdir and node can be None in
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1384 # those cases
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1385 ctx = repo[evolvestate['current']]
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1386 newctx = repo[node] if node is not None else repo['.']
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
1387 obsolete.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
3633
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1388
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1389 # now continuing the phase-divergence resolution part
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1390 prec = repo[evolvestate['precursor']]
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1391 _resolvephasedivergent(ui, repo, prec, ctx, newctx)
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1392 evolvestate['replacements'][ctx.node()] = node
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1393 tr.close()
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1394 finally:
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1395 tr.release()
ed3032ee53eb evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3632
diff changeset
1396
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1397 def _completeorphan(ui, repo, evolvestate):
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1398 """function to complete the interrupted orphan resolution"""
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1399
3630
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1400 node = _completerelocation(ui, repo, evolvestate)
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1401 # resolving conflicts can lead to empty wdir and node can be None in
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1402 # those cases
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1403 ctx = repo[evolvestate['current']]
3636
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
1404 if node is None:
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
1405 repo.ui.status(_("evolution of %d:%s created no changes"
92a2d3217de9 evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3635
diff changeset
1406 " to commit\n") % (ctx.rev(), ctx))
3630
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1407 newctx = repo[node] if node is not None else repo['.']
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3676
diff changeset
1408 obsolete.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
3630
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1409
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1410 # make sure we are continuing evolve and not `hg next --evolve`
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1411 if evolvestate['command'] == 'evolve':
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1412 evolvestate['replacements'][ctx.node()] = node
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1413 if evolvestate['orphanmerge']:
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1414 # processing a merge changeset with both parents obsoleted,
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1415 # stabilized on second parent, insert in front of list to
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1416 # re-process to stabilize on first parent
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1417 evolvestate['revs'].insert(0, repo[node].rev())
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1418 evolvestate['orphanmerge'] = False
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1419
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1420 def _completerelocation(ui, repo, evolvestate):
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1421 """function to complete the interrupted relocation of a commit
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1422 return the new node formed
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1423 """
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1424
3629
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1425 orig = repo[evolvestate['current']]
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1426 ctx = orig
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1427 source = ctx.extra().get('source')
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1428 extra = {}
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1429 if source:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1430 extra['source'] = source
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1431 extra['intermediate-source'] = ctx.hex()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1432 else:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1433 extra['source'] = ctx.hex()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1434 user = ctx.user()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1435 date = ctx.date()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1436 message = ctx.description()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1437 ui.status(_('evolving %d:%s "%s"\n') % (ctx.rev(), ctx,
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1438 message.split('\n', 1)[0]))
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1439 targetphase = max(ctx.phase(), phases.draft)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1440 overrides = {('phases', 'new-commit'): targetphase}
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1441
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1442 ctxparents = orig.parents()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1443 if len(ctxparents) == 2:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1444 currentp1 = repo.dirstate.parents()[0]
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1445 p1obs = ctxparents[0].obsolete()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1446 p2obs = ctxparents[1].obsolete()
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1447 # asumming that the parent of current wdir is successor of one
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1448 # of p1 or p2 of the original changeset
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1449 if p1obs and not p2obs:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1450 # p1 is obsolete and p2 is not obsolete, current working
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1451 # directory parent should be successor of p1, so we should
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1452 # set dirstate parents to (succ of p1, p2)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1453 with repo.dirstate.parentchange():
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1454 repo.dirstate.setparents(currentp1,
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1455 ctxparents[1].node())
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1456 elif p2obs and not p1obs:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1457 # p2 is obsolete and p1 is not obsolete, current working
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1458 # directory parent should be successor of p2, so we should
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1459 # set dirstate parents to (succ of p2, p1)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1460 with repo.dirstate.parentchange():
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1461 repo.dirstate.setparents(ctxparents[0].node(),
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1462 currentp1)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1463
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1464 else:
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1465 # both the parents were obsoleted, if orphanmerge is set, we
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1466 # are processing the second parent first (to keep parent order)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1467 if evolvestate.get('orphanmerge'):
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1468 with repo.dirstate.parentchange():
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1469 repo.dirstate.setparents(ctxparents[0].node(),
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1470 currentp1)
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1471 pass
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1472
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1473 with repo.ui.configoverride(overrides, 'evolve-continue'):
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1474 node = repo.commit(text=message, user=user,
f23946bf6625 evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3628
diff changeset
1475 date=date, extra=extra)
3630
2789c0ec2ad7 evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3629
diff changeset
1476 return node