Mercurial > evolve
annotate hgext3rd/evolve/evolvecmd.py @ 3469:e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
_orderrevs() is a function which is used to order the revs in which the
instability needs to be solved if we have multiple revisions to resolve.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 21 Jan 2018 20:33:39 +0530 |
parents | 0a8e3130ad00 |
children | ece5cd58147d |
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, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
35 rewriteutil, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
36 state, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
37 utility, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
38 ) |
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 TROUBLES = compat.TROUBLES |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
41 shorttemplate = utility.shorttemplate |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
42 _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
|
43 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
|
44 |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
45 _bookmarksupdater = rewriteutil.bookmarksupdater |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
46 |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
47 def _solveone(ui, repo, ctx, dryrun, confirm, progresscb, category): |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
48 """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
|
49 |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 """ |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
56 wlock = lock = tr = None |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
57 try: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
58 wlock = repo.wlock() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
59 lock = repo.lock() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
60 tr = repo.transaction("evolve") |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
61 if 'orphan' == category: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
62 result = _solveunstable(ui, repo, ctx, dryrun, confirm, progresscb) |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
63 elif 'phasedivergent' == category: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
64 result = _solvebumped(ui, repo, ctx, dryrun, confirm, progresscb) |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
65 elif 'contentdivergent' == category: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
66 result = _solvedivergent(ui, repo, ctx, dryrun, confirm, |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
67 progresscb) |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
68 else: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
69 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
|
70 tr.close() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
71 return result |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
72 finally: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
73 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
|
74 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
75 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
76 progresscb=None): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
77 """ 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
|
78 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
85 pctx = orig.p1() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
86 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
|
87 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
|
88 if not pctx.obsolete(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
89 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
|
90 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
|
91 elif orig.p2().obsolete(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
92 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
|
93 "--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
|
94 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
|
95 "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
|
96 _("(%s)\n") % hint) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
97 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
98 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
99 if not pctx.obsolete(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
100 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
|
101 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
102 obs = pctx |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
103 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
|
104 # 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
|
105 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
|
106 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
|
107 " 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
|
108 obs) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
109 obs = obs.parents()[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
110 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
|
111 if len(newer) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
112 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
|
113 "destination\n") % obs |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
114 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
115 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
116 targets = newer[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
117 assert targets |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
118 if len(targets) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
119 # 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
126 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
127 target = repo[heads.first()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
128 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
129 target = targets[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
130 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
131 target = repo[target] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
132 if not ui.quiet or confirm: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
133 repo.ui.write(_('move:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
134 displayer.show(orig) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
135 repo.ui.write(_('atop:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
136 displayer.show(target) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
137 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
|
138 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
|
139 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
140 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
141 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
|
142 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
143 repo.ui.write(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
144 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
145 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
146 repo.ui.note(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
147 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
148 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
149 try: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
150 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
|
151 return (True, newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
152 except MergeFailure: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
153 ops = {'current': orig.node()} |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
154 evolvestate = state.cmdstate(repo, opts=ops) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
155 evolvestate.save() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
156 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
|
157 repo.ui.write_err( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
158 _("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
|
159 " 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
|
160 raise |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
161 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
162 def _solvebumped(ui, repo, bumped, dryrun=False, confirm=False, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
163 progresscb=None): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
164 """Stabilize a bumped changeset |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
165 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
172 repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
173 bumped = repo[bumped.rev()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
174 # 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
|
175 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
|
176 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
|
177 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
178 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
179 prec = repo.set('last(allprecursors(%d) and public())', bumped).next() |
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 target merge |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
181 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
|
182 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
|
183 '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
|
184 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
185 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
186 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
187 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
188 if not ui.quiet or confirm: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
189 repo.ui.write(_('recreate:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
190 displayer.show(bumped) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
191 repo.ui.write(_('atop:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
192 displayer.show(prec) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
193 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
|
194 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
|
195 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
196 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
|
197 repo.ui.write(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 (TROUBLES['PHASEDIVERGENT'], bumped))) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
202 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
203 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
204 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
205 newid = tmpctx = None |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
206 tmpctx = bumped |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
207 # 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
|
208 tr = repo.currenttransaction() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
209 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
|
210 bmupdate = _bookmarksupdater(repo, bumped.node(), tr) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
211 if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
212 # 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
|
213 repo.ui.status( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
214 _('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
|
215 try: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
216 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
|
217 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
|
218 tmpctx = repo[tmpid] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
219 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
|
220 except MergeFailure: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
221 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
|
222 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
|
223 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
|
224 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
|
225 raise |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
226 # 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
|
227 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
|
228 files = set() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
229 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
|
230 precmanifest = prec.manifest().copy() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
231 # 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
|
232 # 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
|
233 # this is fishy |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 del precmanifest[key] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
238 if precvalue != val: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
239 files.add(key) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
240 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
|
241 # commit it |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
242 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
|
243 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
|
244 if path in bumped: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
245 fctx = bumped[path] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
246 flags = fctx.flags() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
247 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
|
248 return mctx |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
249 return None |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
250 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
|
251 text += bumped.description() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
252 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
253 new = context.memctx(repo, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
254 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
|
255 text=text, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
256 files=files, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
257 filectxfn=filectxfn, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
258 user=bumped.user(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
259 date=bumped.date(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
260 extra=bumped.extra()) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
261 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
262 newid = repo.commitctx(new) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
263 if newid is None: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
264 obsolete.createmarkers(repo, [(tmpctx, ())]) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
265 newid = prec.node() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
266 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
267 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
|
268 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
|
269 flag=obsolete.bumpedfix) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
270 bmupdate(newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
271 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
|
272 # 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
|
273 with repo.dirstate.parentchange(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
274 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
|
275 return (True, newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
276 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
277 def _solvedivergent(ui, repo, divergent, dryrun=False, confirm=False, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
278 progresscb=None): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
279 """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
|
280 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
287 repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
288 divergent = repo[divergent.rev()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
289 base, others = divergentdata(divergent) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
290 if len(others) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
291 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
|
292 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
|
293 " into multiple ones:\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
294 "|[%s]\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
295 "| 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
|
296 "| 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
|
297 "such as:\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
298 "| - hg touch -D\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
299 "| - hg prune\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
300 "| \n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
301 "| 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
|
302 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
303 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
304 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
305 other = others[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
306 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
|
307 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
|
308 "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
|
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 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
|
311 "| 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
|
312 "| `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
|
313 ui.write_err(hint) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
314 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
315 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
|
316 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
|
317 "(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
|
318 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
|
319 "| 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
|
320 "| 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
|
321 "| 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
|
322 "| this command again.\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
323 "| - 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
|
324 "| - 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
|
325 ) % {'d': divergent, 'o': other} |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
326 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
327 ui.write_err(hint) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
328 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
329 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
330 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
331 if not ui.quiet or confirm: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
332 ui.write(_('merge:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
333 displayer.show(divergent) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
334 ui.write(_('with: ')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
335 displayer.show(other) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
336 ui.write(_('base: ')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
337 displayer.show(base) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
338 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
|
339 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
|
340 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 '%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
|
345 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
|
346 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
|
347 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
|
348 % divergent)) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
349 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 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
|
354 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
355 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
356 stats = merge.update(repo, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
357 other.node(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
358 branchmerge=True, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
359 force=False, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
360 ancestor=base.node(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
361 mergeancestor=True) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
362 hg._showstats(repo, stats) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
363 if stats[3]: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
364 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
|
365 "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
|
366 if stats[3] > 0: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
367 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
|
368 '(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
|
369 hint="""/!\ You can try: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
370 /!\ * 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
|
371 /!\ * 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
|
372 /!\ * 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
|
373 /!\ * 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
|
374 /!\ * 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
|
375 """) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
376 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
377 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
378 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
|
379 tr = repo.currenttransaction() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
380 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
|
381 try: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
382 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
|
383 with repo.dirstate.parentchange(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
384 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
|
385 oldlen = len(repo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
386 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
|
387 if oldlen == len(repo): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
388 new = divergent |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
389 # no changes |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
390 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
391 new = repo['.'] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
392 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
|
393 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
|
394 return (True, new.node()) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
395 finally: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
396 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
|
397 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
398 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
|
399 pass |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
400 |
3469
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
401 def _orderrevs(repo, revs): |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
402 """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
|
403 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
404 revs is a list of unstable revisions. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
405 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
406 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
|
407 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
|
408 eventually. |
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 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
|
411 revision on its final stabilized destination. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
412 """ |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
413 # Step 1: Build the dependency graph |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
414 dependencies, rdependencies = utility.builddependencies(repo, revs) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
415 # Step 2: Build the ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
416 # 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
|
417 # 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
|
418 # 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
|
419 # 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
|
420 # built |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
421 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
|
422 if not dependencies[r]]) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
423 ordering = [] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
424 while solvablerevs: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
425 rev = solvablerevs.popleft() |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
426 for dependent in rdependencies[rev]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
427 dependencies[dependent].remove(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
428 if not dependencies[dependent]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
429 solvablerevs.append(dependent) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
430 del dependencies[rev] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
431 ordering.append(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
432 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
433 ordering.extend(sorted(dependencies)) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
434 return ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
435 |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
436 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
|
437 """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
|
438 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
439 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
|
440 """ |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
441 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
|
442 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
|
443 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
|
444 "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
|
445 "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
|
446 "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
|
447 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 "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
|
452 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
|
453 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
|
454 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
455 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
|
456 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
457 cache = {} |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
458 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
|
459 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
|
460 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
|
461 ctx = None |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
462 try: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
463 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
|
464 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
|
465 continue |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
466 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
467 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
|
468 continue |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
469 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
470 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
|
471 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
472 # 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
|
473 # 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
|
474 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
|
475 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
|
476 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
|
477 else: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
478 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
|
479 '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
|
480 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
481 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
|
482 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
|
483 try: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 '(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
|
488 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
|
489 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
|
490 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
|
491 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
|
492 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
|
493 # 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
|
494 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
|
495 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
496 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
|
497 pass |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
498 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
|
499 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
|
500 raise |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
501 _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
|
502 return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
503 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
512 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
|
513 try: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
514 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
|
515 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
|
516 # 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
|
517 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
|
518 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
|
519 finally: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
520 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
|
521 return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
522 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
523 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
|
524 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
|
525 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
|
526 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
|
527 bmchanges = [] |
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 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
|
530 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
|
531 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
|
532 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
|
533 else: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
534 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
|
535 # 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 if bmchanges: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
541 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
|
542 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
543 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
|
544 """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
|
545 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
|
546 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
|
547 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
|
548 dest, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
549 branchmerge=False, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
550 force=True) |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 if keepbranch: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
555 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
|
556 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
|
557 # uurrgs |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
558 # 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
|
559 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
|
560 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
|
561 else: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
562 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
|
563 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
|
564 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
565 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
|
566 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
567 instabilities_map = { |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
568 'contentdivergent': "content-divergent", |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
569 'phasedivergent': "phase-divergent" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
570 } |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
571 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
572 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
|
573 """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
|
574 revs = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
575 if allopt or revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
576 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
|
577 if revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
578 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
|
579 elif not anyopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
580 topic = getattr(repo, 'currenttopic', '') |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
581 if topic: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
582 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
|
583 elif targetcat == 'orphan': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
584 revs = _aspiringdescendant(repo, |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
585 repo.revs('(.::) - obsolete()::')) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
586 revs = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
587 if targetcat == 'contentdivergent': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
588 # 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
|
589 revs = _dedupedivergents(repo, revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
590 elif anyopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
591 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
|
592 elif targetcat == 'orphan': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
593 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
|
594 if 1 < len(revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
595 msg = "multiple evolve candidates" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
596 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
|
597 % ', '.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
|
598 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
|
599 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
|
600 revs = set([repo['.'].rev()]) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
601 return revs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
602 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
603 def _dedupedivergents(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
604 """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
|
605 lowest revision numbers |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
606 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
607 repo = repo.unfiltered() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
608 res = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
609 # 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
|
610 discarded = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
611 for rev in revs: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
612 if rev in discarded: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
613 continue |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
614 divergent = repo[rev] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
615 base, others = divergentdata(divergent) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
616 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
|
617 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
|
618 discarded.update(othersrevs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
619 return res |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
620 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
621 def divergentdata(ctx): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
622 """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
|
623 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
624 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
|
625 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
626 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
|
627 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
628 repo = ctx._repo.unfiltered() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
629 for base in repo.set('reverse(allprecursors(%d))', ctx): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
630 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
|
631 # 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
|
632 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
|
633 if newer: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
634 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
|
635 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
|
636 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
|
637 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
638 def _aspiringdescendant(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
639 """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
|
640 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
|
641 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
642 result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
643 paths = collections.defaultdict(set) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
644 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
|
645 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
|
646 paths[d].add(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
647 |
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 tovisit = list(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
650 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
651 base = tovisit.pop() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
652 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
|
653 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
|
654 tovisit.append(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
655 result.add(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
656 return sorted(result - target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
657 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
658 def _aspiringchildren(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
659 """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
|
660 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
|
661 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
662 result = [] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
663 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
|
664 dest = _possibledestination(repo, r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
665 if target & dest: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
666 result.append(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
667 return result |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
668 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
669 def _possibledestination(repo, rev): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
670 """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
|
671 tonode = repo.changelog.node |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
672 parents = repo.changelog.parentrevs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
673 torev = repo.changelog.rev |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
674 dest = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
675 tovisit = list(parents(rev)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
676 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
677 r = tovisit.pop() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
678 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
|
679 if not succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
680 tovisit.extend(parents(r)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
681 else: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
682 # 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
|
683 # (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
|
684 # 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
|
685 # multiple branches. |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
686 for ss in succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
687 for n in ss: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
688 dest.add(torev(n)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
689 return dest |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
690 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
691 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
|
692 """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
|
693 no troubles can be resolved""" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
694 troublecategories = ['phasedivergent', 'contentdivergent', 'orphan'] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
695 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
|
696 msg = None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
697 hint = None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
698 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
699 troubled = { |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
700 "orphan": repo.revs("orphan()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
701 "contentdivergent": repo.revs("contentdivergent()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
702 "phasedivergent": repo.revs("phasedivergent()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
703 "all": repo.revs("troubled()"), |
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 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
706 hintmap = { |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
707 '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
|
708 '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
|
709 "--phase-divergent or" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
710 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
711 '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
|
712 " or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
713 '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
|
714 '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
|
715 " or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
716 '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
|
717 '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
|
718 " --phase-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
719 '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
|
720 " (or --rev) and" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
721 " --phase-divergent or" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
722 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
723 '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
|
724 " and --phase-divergent or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
725 '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
|
726 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
727 '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
|
728 " and --content-divergent or " |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
729 "--orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
730 '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
|
731 "and --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
732 } |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
733 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
734 if revopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
735 revs = scmutil.revrange(repo, revopt) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
736 if not revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
737 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
|
738 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
739 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
|
740 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
741 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
742 if revs & troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
743 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
744 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
745 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
746 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
747 elif anyopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
748 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
|
749 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
750 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
751 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
752 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
753 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
754 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
755 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
756 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
757 # 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
|
758 if targetcat == 'orphan': |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
759 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
|
760 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
761 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
|
762 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
763 p1 = repo['.'].rev() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
764 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
765 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
766 if p1 in troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
767 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
768 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
769 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
770 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
771 length = len(troubled[targetcat]) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
772 if length: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
773 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
|
774 "or --rev") % (length, targetcat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
775 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
776 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
777 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
778 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
779 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
780 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
781 hint = hintmap['any+' + ('+'.join(othertroubles))] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
782 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
783 msg = _("no troubled changesets") |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
784 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
785 assert msg is not None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
786 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
|
787 if hint: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
788 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
|
789 return 2 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
790 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
791 return 1 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
792 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
793 def _preparelistctxs(items, condition): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
794 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
|
795 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
796 def _formatctx(fm, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
797 fm.data(node=ctx.hex()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
798 fm.data(desc=ctx.description()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
799 fm.data(date=ctx.date()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
800 fm.data(user=ctx.user()) |
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 listtroubles(ui, repo, troublecategories, **opts): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
803 """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
|
804 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
|
805 showunstable = 'orphan' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
806 showbumped = 'phasedivergent' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
807 showdivergent = 'contentdivergent' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
808 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
809 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
|
810 if opts.get('rev'): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
811 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
|
812 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
813 fm = ui.formatter('evolvelist', opts) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
814 for rev in revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
815 ctx = repo[rev] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
816 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
|
817 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
|
818 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
|
819 lambda p: not p.mutable()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
820 dsets = divergentsets(repo, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
821 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
822 fm.startitem() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
823 # plain formatter section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
824 hashlen, desclen = 12, 60 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
825 desc = ctx.description() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
826 if desc: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
827 desc = desc.splitlines()[0] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
828 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
|
829 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
|
830 fm.plain('%s\n' % desc) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
831 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
|
832 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
833 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
|
834 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
|
835 unpar[:hashlen], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
836 TROUBLES['ORPHAN'])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
837 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
|
838 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
|
839 obspar[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
840 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
|
841 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
|
842 (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
843 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
844 if dsets and showdivergent: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
845 for dset in dsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
846 fm.plain(' %s: ' % TROUBLES['CONTENTDIVERGENT']) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
847 first = True |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
848 for n in dset['divergentnodes']: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
849 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
|
850 first = False |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 fm.plain("\n") |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
855 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
856 # templater-friendly section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
857 _formatctx(fm, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
858 troubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
859 for unpar in unpars: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
860 troubles.append({'troubletype': TROUBLES['ORPHAN'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
861 'sourcenode': unpar, 'sourcetype': 'orphanparent'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
862 for obspar in obspars: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
863 troubles.append({'troubletype': TROUBLES['ORPHAN'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
864 'sourcenode': obspar, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
865 'sourcetype': 'obsoleteparent'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
866 for imprec in imprecs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
867 troubles.append({'troubletype': TROUBLES['PHASEDIVERGENT'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
868 'sourcenode': imprec, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
869 'sourcetype': 'immutableprecursor'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
870 for dset in dsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
871 divnodes = [{'node': node.hex(n), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
872 'phase': repo[n].phasestr(), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
873 } for n in dset['divergentnodes']] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
874 troubles.append({'troubletype': TROUBLES['CONTENTDIVERGENT'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
875 'commonprecursor': node.hex(dset['commonprecursor']), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
876 'divergentnodes': divnodes}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
877 fm.data(troubles=troubles) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
878 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
879 fm.end() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
880 |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
881 def _checkevolveopts(repo, opts): |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
882 """ 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
|
883 if any """ |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
884 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
885 if opts['continue']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
886 if opts['any']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
887 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
|
888 if opts['all']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
889 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
|
890 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
891 if opts['rev']: |
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 "--rev" and "--any"') |
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 "--rev" and "--all"') |
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 # Backward compatibility |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
898 if opts['unstable']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
899 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
|
900 "use 'evolve --orphan'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
901 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
|
902 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
903 opts['orphan'] = opts['divergent'] |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
904 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
905 if opts['divergent']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
906 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
|
907 "use 'evolve --content-divergent'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
908 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
|
909 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
910 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
|
911 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
912 if opts['bumped']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
913 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
|
914 "use 'evolve --phase-divergent'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
915 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
|
916 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
917 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
|
918 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
919 return opts |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
920 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
921 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
|
922 if showprogress: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
923 ui.progress(_('evolve'), None) |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
924 if repo['.'] != startnode: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
925 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
|
926 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
927 def divergentsets(repo, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
928 """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
|
929 cache = {} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
930 base = {} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
931 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
|
932 if n == ctx.node(): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
933 # 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
|
934 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
935 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
|
936 for nsuccset in nsuccsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
937 if ctx.node() in nsuccset: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
938 # 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
|
939 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
940 if tuple(nsuccset) in base: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
941 # 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
|
942 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
943 base[tuple(nsuccset)] = n |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
944 divergence = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
945 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
|
946 divergence.append({ |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
947 'divergentnodes': divset, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
948 'commonprecursor': b |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
949 }) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
950 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
951 return divergence |