annotate hgext3rd/evolve/evolvecmd.py @ 3506:6b4272bbb65d

evolve: update code for not implicitly converting ctx to revision Mercurial core 38f480502043 removed the capacity to implicitly convert contexts to revisions using `int(ctx)`. Update Evolve code to explicitly call rev instead.
author Boris Feld <boris.feld@octobus.net>
date Mon, 26 Feb 2018 13:59:30 +0100
parents edabac9e9dc5
children d90e0faaec80
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,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
17 context,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
18 copies,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
19 error,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
20 hg,
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
21 lock as lockmod,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
22 merge,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
23 node,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
24 obsolete,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
25 phases,
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
26 scmutil,
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
27 util,
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
28 )
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
29
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
30 from mercurial.i18n import _
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
31
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
32 from . import (
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
33 cmdrewrite,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
34 compat,
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
35 exthelper,
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
36 rewriteutil,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
37 state,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
38 utility,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
39 )
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
40
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
41 TROUBLES = compat.TROUBLES
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
42 shorttemplate = utility.shorttemplate
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
43 _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
44 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
45
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
46 eh = exthelper.exthelper()
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
47 _bookmarksupdater = rewriteutil.bookmarksupdater
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
48 mergetoolopts = cmdutil.mergetoolopts
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
49
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
50 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
51 progresscb, category):
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
52 """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
53
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
54 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
55 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
56 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
57 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
58 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
59 """
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
60 wlock = lock = tr = None
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
61 try:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
62 wlock = repo.wlock()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
63 lock = repo.lock()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
64 tr = repo.transaction("evolve")
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
65 if 'orphan' == category:
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
66 result = _solveunstable(ui, repo, ctx, evolvestate,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
67 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
68 elif 'phasedivergent' == category:
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
69 result = _solvebumped(ui, repo, ctx, evolvestate,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
70 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
71 elif 'contentdivergent' == category:
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
72 result = _solvedivergent(ui, repo, ctx, evolvestate,
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
73 dryrun, confirm, progresscb)
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
74 else:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
75 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
76 tr.close()
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
77 return result
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
78 finally:
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
79 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
80
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
81 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
82 progresscb=None):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
83 """ 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
84
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
85 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
86 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
87 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
88 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
89 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
90 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
91 pctx = orig.p1()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
92 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
93 if len(orig.parents()) == 2:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
94 if not pctx.obsolete():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
95 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
96 keepbranch = orig.p2().branch() != orig.branch()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
97 elif orig.p2().obsolete():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
98 hint = _("Redo the merge (%s) and use `hg prune <old> "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
99 "--succ <new>` to obsolete the old one") % orig.hex()[:12]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
100 ui.warn(_("warning: no support for evolving merge changesets "
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
101 "with two obsolete parents yet\n") +
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
102 _("(%s)\n") % hint)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
103 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
104
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
105 if not pctx.obsolete():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
106 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
107 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
108 obs = pctx
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
109 newer = compat.successorssets(repo, obs.node())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
110 # 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
111 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
112 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
113 " 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
114 obs)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
115 obs = obs.parents()[0]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
116 newer = compat.successorssets(repo, obs.node())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
117 if len(newer) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
118 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
119 "destination\n") % obs
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
120 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
121 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
122 targets = newer[0]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
123 assert targets
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
124 if len(targets) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
125 # 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
126 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
127 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
128 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
129 if len(roots) > 1 or len(heads) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
130 msg = "cannot solve split across two branches\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
131 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
132 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
133 target = repo[heads.first()]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
134 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
135 target = targets[0]
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
136 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
137 target = repo[target]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
138 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
139 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
140 displayer.show(orig)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
141 repo.ui.write(_('atop:'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
142 displayer.show(target)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
143 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
144 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
145 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
146 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
147 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
148 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
149 repo.ui.write(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
150 return (False, '')
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 repo.ui.note(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
153 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
154 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
155 try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
156 newid = relocate(repo, orig, target, pctx, keepbranch)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
157 return (True, newid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
158 except MergeFailure:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
159 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
160 evolvestate.addopts(ops)
3462
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
161 evolvestate.save()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
162 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
163 repo.ui.write_err(
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
164 _("fix conflict and run 'hg evolve --continue'"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
165 " or use '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
166 raise
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
167
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
168 def _solvebumped(ui, repo, bumped, 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
169 progresscb=None):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
170 """Stabilize a bumped changeset
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
171
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
172 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
173 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
174 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
175 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
176 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
177 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
178 repo = repo.unfiltered()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
179 bumped = repo[bumped.rev()]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
180 # 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
181 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
182 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
183 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
184 return (False, '')
3506
6b4272bbb65d evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents: 3503
diff changeset
185 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
186 # 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
187 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
188 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
189 '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
190 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
191 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
192
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
193 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
194 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
195 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
196 displayer.show(bumped)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
197 repo.ui.write(_('atop:'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
198 displayer.show(prec)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
199 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
200 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
201 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
202 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
203 repo.ui.write(todo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
204 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
205 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
206 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
207 (TROUBLES['PHASEDIVERGENT'], bumped)))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
208 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
209 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
210 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
211 newid = tmpctx = None
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
212 tmpctx = bumped
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
213 # Basic check for common parent. Far too complicated and fragile
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
214 tr = repo.currenttransaction()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
215 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
216 bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
3506
6b4272bbb65d evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents: 3503
diff changeset
217 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
218 # 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
219 repo.ui.status(
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
220 _('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
221 try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
222 tmpid = relocate(repo, bumped, prec.p1())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
223 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
224 tmpctx = repo[tmpid]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
225 obsolete.createmarkers(repo, [(bumped, (tmpctx,))])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
226 except MergeFailure:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
227 repo.vfs.write('graftstate', bumped.hex() + '\n')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
228 repo.ui.write_err(_('evolution failed!\n'))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
229 msg = _("fix conflict and run 'hg evolve --continue'\n")
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
230 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
231 raise
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
232 # 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
233 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
234 files = set()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
235 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
236 precmanifest = prec.manifest().copy()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
237 # 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
238 # 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
239 # this is fishy
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
240 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
241 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
242 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
243 del precmanifest[key]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
244 if precvalue != val:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
245 files.add(key)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
246 files.update(precmanifest) # add missing files
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
247 # commit it
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
248 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
249 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
250 if path in bumped:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
251 fctx = bumped[path]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
252 flags = fctx.flags()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
253 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
254 return mctx
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
255 return None
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
256 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
257 text += bumped.description()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
258
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
259 new = context.memctx(repo,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
260 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
261 text=text,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
262 files=files,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
263 filectxfn=filectxfn,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
264 user=bumped.user(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
265 date=bumped.date(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
266 extra=bumped.extra())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
267
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
268 newid = repo.commitctx(new)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
269 if newid is None:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
270 obsolete.createmarkers(repo, [(tmpctx, ())])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
271 newid = prec.node()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
272 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
273 phases.retractboundary(repo, tr, bumped.phase(), [newid])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
274 obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
275 flag=obsolete.bumpedfix)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
276 bmupdate(newid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
277 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
278 # 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
279 with repo.dirstate.parentchange():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
280 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
281 return (True, newid)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
282
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
283 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
284 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
285 """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
286
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
287 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
288 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
289 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
290 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
291 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
292 """
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
293 repo = repo.unfiltered()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
294 divergent = repo[divergent.rev()]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
295 base, others = divergentdata(divergent)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
296 if len(others) > 1:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
297 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
298 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
299 " into multiple ones:\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
300 "|[%s]\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
301 "| 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
302 "| 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
303 "such as:\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
304 "| - hg touch -D\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
305 "| - hg prune\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
306 "| \n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
307 "| 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
308 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
309 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
310 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
311 other = others[0]
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
312 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
313 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
314 "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
315 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
316 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
317 "| 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
318 "| `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
319 ui.write_err(hint)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
320 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
321 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
322 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
323 "(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
324 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
325 "| 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
326 "| 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
327 "| 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
328 "| this command again.\n"
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
329 "| - 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
330 "| - 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
331 ) % {'d': divergent, 'o': other}
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
332 ui.write_err(msg)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
333 ui.write_err(hint)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
334 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
335
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
336 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
337 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
338 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
339 displayer.show(divergent)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
340 ui.write(_('with: '))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
341 displayer.show(other)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
342 ui.write(_('base: '))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
343 displayer.show(base)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
344 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
345 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
346 if dryrun:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
347 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
348 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
349 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
350 '%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
351 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
352 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
353 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
354 % divergent))
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
355 return (False, '')
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
356 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
357 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
358 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
359 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
360 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
361 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
362 stats = merge.update(repo,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
363 other.node(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
364 branchmerge=True,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
365 force=False,
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
366 ancestor=base.node(),
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
367 mergeancestor=True)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
368 hg._showstats(repo, stats)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
369 if stats[3]:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
370 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
371 "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
372 if stats[3] > 0:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
373 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
374 '(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
375 hint="""/!\ You can try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
376 /!\ * 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
377 /!\ * 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
378 /!\ * 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
379 /!\ * 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
380 /!\ * 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
381 """)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
382 if progresscb:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
383 progresscb()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
384 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
385 tr = repo.currenttransaction()
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
386 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
387 try:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
388 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
389 with repo.dirstate.parentchange():
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
390 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
391 oldlen = len(repo)
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
392 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
393 if oldlen == len(repo):
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
394 new = divergent
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
395 # no changes
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
396 else:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
397 new = repo['.']
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
398 obsolete.createmarkers(repo, [(other, (new,))])
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
399 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
400 return (True, new.node())
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
401 finally:
e147c18ed064 evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3461
diff changeset
402 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
403
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
404 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
405 pass
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
406
3469
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
407 def _orderrevs(repo, revs):
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
408 """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
409
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
410 revs is a list of unstable revisions.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
411
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
412 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
413 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
414 eventually.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
415
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
416 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
417 revision on its final stabilized destination.
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
418 """
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
419 # Step 1: Build the dependency graph
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
420 dependencies, rdependencies = utility.builddependencies(repo, revs)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
421 # Step 2: Build the ordering
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
422 # 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
423 # 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
424 # 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
425 # 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
426 # built
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
427 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
428 if not dependencies[r]])
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
429 ordering = []
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
430 while solvablerevs:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
431 rev = solvablerevs.popleft()
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
432 for dependent in rdependencies[rev]:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
433 dependencies[dependent].remove(rev)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
434 if not dependencies[dependent]:
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
435 solvablerevs.append(dependent)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
436 del dependencies[rev]
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
437 ordering.append(rev)
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
438
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
439 ordering.extend(sorted(dependencies))
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
440 return ordering
e97bfd529e72 evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3466
diff changeset
441
3463
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
442 def relocate(repo, orig, dest, pctx=None, keepbranch=False):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
443 """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
444
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
445 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
446 """
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
447 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
448 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
449 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
450 "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
451 "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
452 "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
453
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
454 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
455 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
456 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
457 "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
458 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
459 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
460
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
461 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
462
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
463 cache = {}
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
464 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
465 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
466 for sha1 in sha1s:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
467 ctx = None
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
468 try:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
469 ctx = unfi[sha1]
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
470 except error.RepoLookupError:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
471 continue
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
472
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
473 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
474 continue
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
475
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
476 successors = compat.successorssets(repo, ctx.node(), cache)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
477
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
478 # 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
479 # 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
480 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
481 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
482 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
483 else:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
484 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
485 '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
486
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
487 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
488 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
489 try:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
490 r = _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
491 if r[-1]: # some conflict
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
492 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
493 '(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
494 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
495 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
496 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
497 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
498 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
499 # fix up dirstate for copies and renames
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
500 compat.duplicatecopies(repo, repo[None], dest.rev(), orig.p1().rev())
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
501
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
502 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
503 pass
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
504 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
505 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
506 raise
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
507 _finalizerelocate(repo, orig, dest, nodenew, tr)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
508 return nodenew
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
509
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
510 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
511 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
512 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
513 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
514 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
515 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
516 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
517
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
518 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
519 try:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
520 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
521 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
522 # 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
523 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
524 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
525 finally:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
526 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
527 return nodenew
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
528
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
529 def _finalizerelocate(repo, orig, dest, nodenew, tr):
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
530 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
531 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
532 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
533 bmchanges = []
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
534
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
535 if nodenew 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 obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
537 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
538 bmchanges.append((book, nodenew))
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
539 else:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
540 obsolete.createmarkers(repo, [(repo[nodesrc], ())])
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
541 # 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
542 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
543 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
544 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
545 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
546 if bmchanges:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
547 compat.bookmarkapplychanges(repo, tr, bmchanges)
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 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
550 """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
551 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
552 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
553 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
554 dest,
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
555 branchmerge=False,
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
556 force=True)
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
557 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
558 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
559 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
560 if keepbranch:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
561 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
562 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
563 # uurrgs
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
564 # 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
565 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
566 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
567 else:
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
568 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
569 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
570
f994c480cea9 evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3462
diff changeset
571 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
572
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
573 instabilities_map = {
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
574 'contentdivergent': "content-divergent",
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
575 'phasedivergent': "phase-divergent"
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
576 }
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
577
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
578 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
579 """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
580 revs = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
581 if allopt or revopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
582 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
583 if revopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
584 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
585 elif not anyopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
586 topic = getattr(repo, 'currenttopic', '')
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
587 if topic:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
588 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
589 elif targetcat == 'orphan':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
590 revs = _aspiringdescendant(repo,
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
591 repo.revs('(.::) - obsolete()::'))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
592 revs = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
593 if targetcat == 'contentdivergent':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
594 # 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
595 revs = _dedupedivergents(repo, revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
596 elif anyopt:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
597 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
598 elif targetcat == 'orphan':
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
599 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
600 if 1 < len(revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
601 msg = "multiple evolve candidates"
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
602 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
603 % ', '.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
604 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
605 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
606 revs = set([repo['.'].rev()])
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
607 return revs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
608
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
609 def _dedupedivergents(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
610 """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
611 lowest revision numbers
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
612 """
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
613 repo = repo.unfiltered()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
614 res = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
615 # 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
616 discarded = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
617 for rev in revs:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
618 if rev in discarded:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
619 continue
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
620 divergent = repo[rev]
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
621 base, others = divergentdata(divergent)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
622 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
623 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
624 discarded.update(othersrevs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
625 return res
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
626
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
627 def divergentdata(ctx):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
628 """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
629
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
630 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
631
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
632 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
633 """
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
634 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
635 for base in repo.set('reverse(allprecursors(%d))', ctx.rev()):
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
636 newer = compat.successorssets(ctx._repo, base.node())
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
637 # 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
638 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
639 if newer:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
640 return base, tuple(ctx._repo[o] for o in newer[0])
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
641 raise error.Abort("base of divergent changeset %s not found" % ctx,
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
642 hint='this case is not yet handled')
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
643
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
644 def _aspiringdescendant(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
645 """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
646 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
647 target = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
648 result = set(target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
649 paths = collections.defaultdict(set)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
650 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
651 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
652 paths[d].add(r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
653
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
654 result = set(target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
655 tovisit = list(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
656 while tovisit:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
657 base = tovisit.pop()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
658 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
659 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
660 tovisit.append(unstable)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
661 result.add(unstable)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
662 return sorted(result - target)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
663
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
664 def _aspiringchildren(repo, revs):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
665 """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
666 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
667 target = set(revs)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
668 result = []
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
669 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
670 dest = _possibledestination(repo, r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
671 if target & dest:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
672 result.append(r)
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
673 return result
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
674
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
675 def _possibledestination(repo, rev):
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
676 """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
677 tonode = repo.changelog.node
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
678 parents = repo.changelog.parentrevs
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
679 torev = repo.changelog.rev
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
680 dest = set()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
681 tovisit = list(parents(rev))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
682 while tovisit:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
683 r = tovisit.pop()
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
684 succsets = compat.successorssets(repo, tonode(r))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
685 if not succsets:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
686 tovisit.extend(parents(r))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
687 else:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
688 # 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
689 # (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
690 # 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
691 # multiple branches.
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
692 for ss in succsets:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
693 for n in ss:
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
694 dest.add(torev(n))
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
695 return dest
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
696
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
697 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
698 """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
699 no troubles can be resolved"""
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
700 troublecategories = ['phasedivergent', 'contentdivergent', 'orphan']
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
701 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
702 msg = None
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
703 hint = None
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
704
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
705 troubled = {
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
706 "orphan": repo.revs("orphan()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
707 "contentdivergent": repo.revs("contentdivergent()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
708 "phasedivergent": repo.revs("phasedivergent()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
709 "all": repo.revs("troubled()"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
710 }
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
711
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
712 hintmap = {
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
713 '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
714 '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
715 "--phase-divergent or"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
716 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
717 '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
718 " or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
719 '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
720 '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
721 " or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
722 '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
723 '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
724 " --phase-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
725 '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
726 " (or --rev) and"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
727 " --phase-divergent or"
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
728 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
729 '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
730 " and --phase-divergent or --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
731 '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
732 " --content-divergent"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
733 '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
734 " and --content-divergent or "
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
735 "--orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
736 '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
737 "and --orphan"),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
738 }
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
739
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
740 if revopt:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
741 revs = scmutil.revrange(repo, revopt)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
742 if not revs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
743 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
744 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
745 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
746 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
747 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
748 if revs & troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
749 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
750 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
751 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
752
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
753 elif anyopt:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
754 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
755 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
756 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
757 if troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
758 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
759 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
760 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
761
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
762 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
763 # 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
764 if targetcat == 'orphan':
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
765 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
766 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
767 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
768
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
769 p1 = repo['.'].rev()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
770 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
771 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
772 if p1 in troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
773 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
774 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
775 hint = hintmap['+'.join(othertroubles)]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
776 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
777 length = len(troubled[targetcat])
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
778 if length:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
779 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
780 "or --rev") % (length, targetcat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
781 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
782 othertroubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
783 for cat in unselectedcategories:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
784 if troubled[cat]:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
785 othertroubles.append(cat)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
786 if othertroubles:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
787 hint = hintmap['any+' + ('+'.join(othertroubles))]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
788 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
789 msg = _("no troubled changesets")
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
790
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
791 assert msg is not None
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
792 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
793 if hint:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
794 ui.write_err("(%s)\n" % hint)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
795 return 2
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
796 else:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
797 return 1
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
798
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
799 def _preparelistctxs(items, condition):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
800 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
801
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
802 def _formatctx(fm, ctx):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
803 fm.data(node=ctx.hex())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
804 fm.data(desc=ctx.description())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
805 fm.data(date=ctx.date())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
806 fm.data(user=ctx.user())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
807
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
808 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
809 """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
810 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
811 showunstable = 'orphan' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
812 showbumped = 'phasedivergent' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
813 showdivergent = 'contentdivergent' in troublecategories
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
814
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
815 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
816 if opts.get('rev'):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
817 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
818
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
819 fm = ui.formatter('evolvelist', opts)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
820 for rev in revs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
821 ctx = repo[rev]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
822 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
823 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
824 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
825 lambda p: not p.mutable())
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
826 dsets = divergentsets(repo, ctx)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
827
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
828 fm.startitem()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
829 # plain formatter section
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
830 hashlen, desclen = 12, 60
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
831 desc = ctx.description()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
832 if desc:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
833 desc = desc.splitlines()[0]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
834 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
835 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
836 fm.plain('%s\n' % desc)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
837 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
838
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
839 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
840 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
841 unpar[:hashlen],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
842 TROUBLES['ORPHAN']))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
843 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
844 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
845 obspar[:hashlen]))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
846 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
847 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
848 (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen]))
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
849
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
850 if dsets and showdivergent:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
851 for dset in dsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
852 fm.plain(' %s: ' % TROUBLES['CONTENTDIVERGENT'])
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
853 first = True
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
854 for n in dset['divergentnodes']:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
855 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
856 first = False
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
857 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
858 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
859 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
860 fm.plain("\n")
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 # templater-friendly section
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
863 _formatctx(fm, ctx)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
864 troubles = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
865 for unpar in unpars:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
866 troubles.append({'troubletype': TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
867 'sourcenode': unpar, 'sourcetype': 'orphanparent'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
868 for obspar in obspars:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
869 troubles.append({'troubletype': TROUBLES['ORPHAN'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
870 'sourcenode': obspar,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
871 'sourcetype': 'obsoleteparent'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
872 for imprec in imprecs:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
873 troubles.append({'troubletype': TROUBLES['PHASEDIVERGENT'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
874 'sourcenode': imprec,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
875 'sourcetype': 'immutableprecursor'})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
876 for dset in dsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
877 divnodes = [{'node': node.hex(n),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
878 'phase': repo[n].phasestr(),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
879 } for n in dset['divergentnodes']]
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
880 troubles.append({'troubletype': TROUBLES['CONTENTDIVERGENT'],
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
881 'commonprecursor': node.hex(dset['commonprecursor']),
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
882 'divergentnodes': divnodes})
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
883 fm.data(troubles=troubles)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
884
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
885 fm.end()
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
886
3466
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
887 def _checkevolveopts(repo, opts):
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
888 """ 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
889 if any """
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
890
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
891 if opts['continue']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
892 if opts['any']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
893 raise error.Abort('cannot specify both "--any" and "--continue"')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
894 if opts['all']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
895 raise error.Abort('cannot specify both "--all" and "--continue"')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
896
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
897 if opts['rev']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
898 if opts['any']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
899 raise error.Abort('cannot specify both "--rev" and "--any"')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
900 if opts['all']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
901 raise error.Abort('cannot specify both "--rev" and "--all"')
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
902
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
903 # Backward compatibility
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
904 if opts['unstable']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
905 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
906 "use 'evolve --orphan'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
907 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
908
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
909 opts['orphan'] = opts['divergent']
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
910
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
911 if opts['divergent']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
912 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
913 "use 'evolve --content-divergent'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
914 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
915
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
916 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
917
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
918 if opts['bumped']:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
919 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
920 "use 'evolve --phase-divergent'")
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
921 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
922
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
923 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
924
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
925 return opts
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
926
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
927 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
928 if showprogress:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
929 ui.progress(_('evolve'), None)
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
930 if repo['.'] != startnode:
0a8e3130ad00 evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3465
diff changeset
931 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
932
3465
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
933 def divergentsets(repo, ctx):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
934 """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
935 cache = {}
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
936 base = {}
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
937 for n in compat.allprecursors(repo.obsstore, [ctx.node()]):
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
938 if n == ctx.node():
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
939 # 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
940 continue
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
941 nsuccsets = compat.successorssets(repo, n, cache)
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
942 for nsuccset in nsuccsets:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
943 if ctx.node() in nsuccset:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
944 # 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
945 continue
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
946 if tuple(nsuccset) in base:
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
947 # 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
948 continue
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
949 base[tuple(nsuccset)] = n
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
950 divergence = []
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
951 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
952 divergence.append({
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
953 'divergentnodes': divset,
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
954 'commonprecursor': b
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
955 })
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
956
ffe566999920 evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3464
diff changeset
957 return divergence
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
958
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
959 @eh.command(
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
960 '^evolve|stabilize|solve',
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
961 [('n', 'dry-run', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
962 _('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
963 ('', 'confirm', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
964 _('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
965 ('A', 'any', False,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
966 _('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
967 'directory')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
968 ('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
969 ('', 'bumped', False, _('solves only bumped changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
970 ('', '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
971 ('', 'divergent', False, _('solves only divergent changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
972 ('', '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
973 ('', 'unstable', False, _('solves only unstable changesets')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
974 ('', '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
975 ('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
976 'current working directory and its descendants')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
977 ('c', 'continue', False, _('continue an interrupted evolution')),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
978 ('l', 'list', False, 'provide details on troubled changesets in the repo'),
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
979 ] + mergetoolopts,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
980 _('[OPTIONS]...')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
981 )
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
982 def evolve(ui, repo, **opts):
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
983 """solve troubled changesets in your repository
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
984
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
985 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
986 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
987 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
988
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
989 - update working copy to a successor
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
990 - rebase an unstable changeset
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
991 - 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
992 - fuse divergent changesets back together
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
993
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
994 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
995 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
996 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
997 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
998 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
999 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
1000 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
1001 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
1002 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
1003
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1004 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
1005 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
1006 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
1007
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1008 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
1009 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
1010 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
1011 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
1012 explicitly request such behavior (see below).
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1013
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1014 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
1015 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
1016 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
1017 working copy parent.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1018 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
1019 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
1020 evolving all branches.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1021
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1022 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
1023 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
1024 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
1025 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
1026 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
1027 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
1028
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1029 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
1030 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
1031
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1032 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
1033 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
1034 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
1035 ``--rev`` and ``--any``.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1036
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1037 ``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
1038 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
1039
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1040 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
1041 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
1042 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
1043 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
1044 (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
1045 ``--rev``, ``--all``, or ``--any``.
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1046
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1047 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
1048 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
1049 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
1050 """
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1051
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1052 opts = _checkevolveopts(repo, opts)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1053 # Options
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1054 contopt = opts['continue']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1055 anyopt = opts['any']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1056 allopt = opts['all']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1057 startnode = repo['.']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1058 dryrunopt = opts['dry_run']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1059 confirmopt = opts['confirm']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1060 revopt = opts['rev']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1061
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1062 troublecategories = ['phase_divergent', 'content_divergent', 'orphan']
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1063 specifiedcategories = [t.replace('_', '')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1064 for t in troublecategories
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1065 if opts[t]]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1066 if opts['list']:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1067 compat.startpager(ui, 'evolve')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1068 listtroubles(ui, repo, specifiedcategories, **opts)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1069 return
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 targetcat = 'orphan'
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1072 if 1 < len(specifiedcategories):
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1073 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
1074 raise error.Abort(msg)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1075 elif len(specifiedcategories) == 1:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1076 targetcat = specifiedcategories[0]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1077 elif repo['.'].obsolete():
3484
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
1078 displayer = compat.changesetdisplayer(ui, repo,
6d180db0e3e8 branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3482
diff changeset
1079 {'template': shorttemplate})
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1080 # 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
1081 try:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1082 ctx = repo[utility._singlesuccessor(repo, repo['.'])]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1083 except utility.MultipleSuccessorsError as exc:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1084 repo.ui.write_err('parent is obsolete with multiple successors:\n')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1085 for ln in exc.successorssets:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1086 for n in ln:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1087 displayer.show(repo[n])
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1088 return 2
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1089
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1090 ui.status(_('update:'))
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1091 if not ui.quiet:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1092 displayer.show(ctx)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1093
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1094 if dryrunopt:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1095 return 0
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1096 res = hg.update(repo, ctx.rev())
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1097 if ctx != startnode:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1098 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
1099 return res
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1100
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1101 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
1102 troubled = set(repo.revs('troubled()'))
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1103
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1104 # Progress handling
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1105 seen = 1
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1106 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
1107 showprogress = allopt
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1108
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1109 def progresscb():
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1110 if revopt or allopt:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1111 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
1112
3477
713e26a647f5 evolve: create a state object in all case
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3470
diff changeset
1113 evolvestate = state.cmdstate(repo)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1114 # Continuation handling
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1115 if contopt:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1116 if not evolvestate:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1117 raise error.Abort('no evolve to continue')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1118 evolvestate.load()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1119 orig = repo[evolvestate['current']]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1120 with repo.wlock(), repo.lock():
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1121 ctx = orig
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1122 source = ctx.extra().get('source')
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1123 extra = {}
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1124 if source:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1125 extra['source'] = source
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1126 extra['intermediate-source'] = ctx.hex()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1127 else:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1128 extra['source'] = ctx.hex()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1129 user = ctx.user()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1130 date = ctx.date()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1131 message = ctx.description()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1132 ui.status(_('evolving %d:%s "%s"\n') % (ctx.rev(), ctx,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1133 message.split('\n', 1)[0]))
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1134 targetphase = max(ctx.phase(), phases.draft)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1135 overrides = {('phases', 'new-commit'): targetphase}
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1136
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1137 with repo.ui.configoverride(overrides, 'evolve-continue'):
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1138 node = repo.commit(text=message, user=user,
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1139 date=date, extra=extra)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1140
3490
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1141 # resolving conflicts can lead to empty wdir and node can be None in
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1142 # those cases
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1143 if node is not None:
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1144 obsolete.createmarkers(repo, [(ctx, (repo[node],))])
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1145 else:
51c0a23b519e evolve: handle case when newnode can be None while continuing evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3484
diff changeset
1146 obsolete.createmarkers(repo, [(ctx, (repo['.'],))])
3494
14cd04ff968e evolve: show the updated working directory after `hg evolve --continue`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3493
diff changeset
1147
3503
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1148 # make sure we are continuing evolve and not `hg next --evolve`
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1149 if evolvestate['command'] == 'evolve':
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1150 evolvestate['replacements'][ctx.node()] = node
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1151 category = evolvestate['category']
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1152 confirm = evolvestate['confirm']
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1153 startnode = evolvestate['startnode']
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1154 unfi = repo.unfiltered()
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1155 for rev in evolvestate['revs']:
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1156 # XXX: prevent this lookup by storing nodes instead of revnums
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1157 curctx = unfi[rev]
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1158 if (curctx.node() not in evolvestate['replacements'] and
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1159 curctx.node() not in evolvestate['skippedrevs']):
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1160 newnode = _solveone(ui, repo, curctx, evolvestate, False,
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1161 confirm, progresscb, category)
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1162 if newnode[0]:
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1163 evolvestate['replacements'][curctx.node()] = newnode[1]
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1164 else:
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1165 evolvestate['skippedrevs'].append(curctx.node())
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1166
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1167 _cleanup(ui, repo, unfi[startnode], True)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1168 evolvestate.delete()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1169 return
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1170
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1171 cmdutil.bailifchanged(repo)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1172
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1173 revs = _selectrevs(repo, allopt, revopt, anyopt, targetcat)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1174
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1175 if not revs:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1176 return _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1177
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1178 # For the progress bar to show
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1179 count = len(revs)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1180 # Order the revisions
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1181 if targetcat == 'orphan':
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1182 revs = _orderrevs(repo, revs)
3480
1799fc777f30 evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3479
diff changeset
1183
3495
a7cac3fcc49d evolve: store the skippedrevs in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3494
diff changeset
1184 # cbor does not know how to serialize sets, using list for skippedrevs
3493
4544067b831b evolve: make `hg evolve --continue` respect `--confirm`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3492
diff changeset
1185 stateopts = {'category': targetcat, 'replacements': {}, 'revs': revs,
3495
a7cac3fcc49d evolve: store the skippedrevs in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3494
diff changeset
1186 'confirm': confirmopt, 'startnode': startnode.node(),
3503
edabac9e9dc5 evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3501
diff changeset
1187 'skippedrevs': [], 'command': 'evolve'}
3480
1799fc777f30 evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3479
diff changeset
1188 evolvestate.addopts(stateopts)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1189 for rev in revs:
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1190 curctx = repo[rev]
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1191 progresscb()
3478
4a1ccae58323 evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3477
diff changeset
1192 ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt, confirmopt,
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1193 progresscb, targetcat)
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1194 seen += 1
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1195 if ret[0]:
3481
93bb36b4a666 evolve: store the replacements in the evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3480
diff changeset
1196 evolvestate['replacements'][curctx.node()] = [ret[1]]
3495
a7cac3fcc49d evolve: store the skippedrevs in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3494
diff changeset
1197 else:
a7cac3fcc49d evolve: store the skippedrevs in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3494
diff changeset
1198 evolvestate['skippedrevs'].append(curctx.node())
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1199 progresscb()
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
1200 _cleanup(ui, repo, startnode, showprogress)