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