Mercurial > evolve
annotate hgext3rd/evolve/evolvecmd.py @ 3843:f0096db2a7b1
evolve: improve error messages when conflicts occur
This patch improves the error messages when conflicts occur.
First, we drop the line 'evolution failed', that is not the best line we can
show and evolution didn't failed, it's just interrupted by the conflicts and
when user will run `hg evolve --continue`, things will be fine. I still remember
when I first saw 'evolution failed', I got a bit scare as am I in a recoverable
position or not. So let's drop this scary line.
Second, we replace the error messages to say `resolve conflicts and see
help-topic`. The help topic was added recently and documents all the three flags
very well. Addition of tests also showed that all the three flags works fine
with all the three instability type. So we should advertise them more.
Third, we now raise the error with our error message rather than raising
MergeFailure and having evolution related text in hint or stderr above. This
increase the focus on the error message we want to show.
After this patch, I think error messages by evolve in case of conflicts will be
same in every case.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 12 Jun 2018 19:00:12 +0530 |
parents | b293cce4ff55 |
children | 5c964ebe4d4b |
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, |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
30 simplemerge, |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
31 util, |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
32 ) |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
33 |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
34 from mercurial.i18n import _ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
35 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
36 from . import ( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
37 cmdrewrite, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
38 compat, |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
39 exthelper, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
40 rewriteutil, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
41 state, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
42 utility, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
43 ) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
44 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
45 TROUBLES = compat.TROUBLES |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
46 shorttemplate = utility.shorttemplate |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
47 _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
|
48 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
|
49 |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
50 eh = exthelper.exthelper() |
3579
3a4552b30ba8
compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3577
diff
changeset
|
51 mergetoolopts = commands.mergetoolopts |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
52 |
3821
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
53 abortmessage = _("see `hg help evolve.interrupted`\n") |
3796
ededd22e7c7b
evolve: show `hg help evolve.interrupted-evolve` in error when conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3795
diff
changeset
|
54 |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
55 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
|
56 progresscb, category): |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
57 """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
|
58 |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 """ |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
65 wlock = lock = tr = None |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
66 try: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
67 wlock = repo.wlock() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
68 lock = repo.lock() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
69 tr = repo.transaction("evolve") |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
70 if 'orphan' == category: |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
71 result = _solveunstable(ui, repo, ctx, evolvestate, |
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
72 dryrun, confirm, progresscb) |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
73 elif 'phasedivergent' == category: |
3609
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
74 result = _solvephasedivergence(ui, repo, ctx, evolvestate, |
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
75 dryrun, confirm, progresscb) |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
76 elif 'contentdivergent' == category: |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
77 result = _solvedivergent(ui, repo, ctx, evolvestate, |
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
78 dryrun, confirm, progresscb) |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
79 else: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
80 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
|
81 tr.close() |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
82 return result |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
83 finally: |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
84 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
|
85 |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
86 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
|
87 progresscb=None): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
88 """ 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
|
89 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
96 pctx = orig.p1() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
97 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
|
98 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
|
99 p1obs = orig.p1().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
100 p2obs = orig.p2().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
101 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
|
102 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
|
103 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
|
104 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
|
105 pass |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
106 else: |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
107 # 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
|
108 # 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
|
109 evolvestate['orphanmerge'] = True |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
110 # 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
|
111 # 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
|
112 # first parent |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
113 pctx = orig.p2() |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
114 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
|
115 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
116 if not pctx.obsolete(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
117 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
|
118 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
119 obs = pctx |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
120 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
|
121 # 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
|
122 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
|
123 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
|
124 " 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
|
125 obs) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
126 obs = obs.parents()[0] |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
127 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
|
128 if len(newer) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
129 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
|
130 "destination\n") % obs |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
131 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
132 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
133 targets = newer[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
134 assert targets |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
135 if len(targets) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
136 # 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
|
137 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
|
138 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
|
139 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
|
140 if len(roots) > 1 or len(heads) > 1: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
141 cheader = _("ancestor '%s' split over multiple topological" |
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
142 " 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
|
143 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
|
144 cheader) |
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
145 if selectedrev is None: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
146 msg = _("could not solve instability, " |
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
147 "ambiguous destination: " |
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
148 "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
|
149 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
|
150 return (False, '') |
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
151 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
|
152 else: |
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
153 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
|
154 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
155 target = targets[0] |
3484
6d180db0e3e8
branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3482
diff
changeset
|
156 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
|
157 target = repo[target] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
158 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
|
159 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
|
160 displayer.show(orig) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
161 repo.ui.write(_('atop:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
162 displayer.show(target) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
163 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
|
164 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
|
165 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
166 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
167 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
|
168 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
169 repo.ui.write(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
170 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
171 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
172 repo.ui.note(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
173 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
174 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
175 try: |
3638
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
176 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
|
177 keepbranch, 'orphan') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
178 return (True, newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
179 except MergeFailure: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
180 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
|
181 evolvestate.addopts(ops) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
182 evolvestate.save() |
3843
f0096db2a7b1
evolve: improve error messages when conflicts occur
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3842
diff
changeset
|
183 raise error.Abort(_("fix conflicts and see `hg help " |
f0096db2a7b1
evolve: improve error messages when conflicts occur
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3842
diff
changeset
|
184 "evolve.interrupted`")) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
185 |
3609
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
186 def _solvephasedivergence(ui, repo, bumped, evolvestate, dryrun=False, |
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
187 confirm=False, progresscb=None): |
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
188 """Stabilize a phase divergent changeset |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
189 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
190 returns a tuple (bool, newnode) where, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
191 bool: a boolean value indicating whether the instability was solved |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
192 newnode: if bool is True, then the newnode of the resultant commit |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
193 formed. newnode can be node, when resolution led to no new |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
194 commit. If bool is False, this is ''. |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
195 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
196 repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
197 bumped = repo[bumped.rev()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
198 # For now we deny bumped merge |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
199 if len(bumped.parents()) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
200 msg = _('skipping %s : we do not handle merge yet\n') % bumped |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
201 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
202 return (False, '') |
3506
6b4272bbb65d
evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents:
3503
diff
changeset
|
203 prec = repo.set('last(allprecursors(%d) and public())', bumped.rev()).next() |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
204 # For now we deny target merge |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
205 if len(prec.parents()) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
206 msg = _('skipping: %s: public version is a merge, ' |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
207 'this is not handled yet\n') % prec |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
208 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
209 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
210 |
3484
6d180db0e3e8
branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3482
diff
changeset
|
211 displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate}) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
212 if not ui.quiet or confirm: |
3501
7c8150697810
color: add some colors to evolve command itself
Boris Feld <boris.feld@octobus.net>
parents:
3495
diff
changeset
|
213 repo.ui.write(_('recreate:'), label='evolve.operation') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
214 displayer.show(bumped) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
215 repo.ui.write(_('atop:')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
216 displayer.show(prec) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
217 if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
218 raise error.Abort(_('evolve aborted by user')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
219 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
220 todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1()) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
221 repo.ui.write(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
222 repo.ui.write(('hg update %s;\n' % prec)) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
223 repo.ui.write(('hg revert --all --rev %s;\n' % bumped)) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
224 repo.ui.write(('hg commit --msg "%s update to %s"\n' % |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
225 (TROUBLES['PHASEDIVERGENT'], bumped))) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
226 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
227 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
228 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
229 tmpctx = bumped |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
230 |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
231 # Checking for whether the phase-divergent changeset has common parents as |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
232 # it's precursors. Phase-divergent changeset and precursor having different |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
233 # parents is a result of when the changeset is rebased, grabbed, histedit or |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
234 # evolved or any other operation which can change parent. In such cases, |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
235 # when parents are not same, we first rebase the divergent changeset onto |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
236 # parent or precursor and then perform later steps |
3506
6b4272bbb65d
evolve: update code for not implicitly converting ctx to revision
Boris Feld <boris.feld@octobus.net>
parents:
3503
diff
changeset
|
237 if not list(repo.set('parents(%d) and parents(%d)', bumped.rev(), prec.rev())): |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
238 # Need to rebase the changeset at the right place |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
239 repo.ui.status( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
240 _('rebasing to destination parent: %s\n') % prec.p1()) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
241 try: |
3638
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
242 tmpid = relocate(repo, bumped, prec.p1(), evolvestate, |
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
243 category='phasedivergent') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
244 if tmpid is not None: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
245 tmpctx = repo[tmpid] |
3694
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
246 obsolete.createmarkers(repo, [(bumped, (tmpctx,))], |
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
247 operation='evolve') |
3757
2bc60fcac354
evolve: make `--abort` strip the temporary revs created during resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3756
diff
changeset
|
248 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
|
249 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
|
250 evolvestate['current'] = bumped.hex() |
3631
8db32b33cdf1
evolve: store the precursor of phase-divergent in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3630
diff
changeset
|
251 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
|
252 evolvestate.save() |
3843
f0096db2a7b1
evolve: improve error messages when conflicts occur
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3842
diff
changeset
|
253 raise error.Abort(_("fix conflicts and see `hg help " |
f0096db2a7b1
evolve: improve error messages when conflicts occur
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3842
diff
changeset
|
254 "evolve.interrupted`")) |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
255 |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
256 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
|
257 |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
258 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
|
259 |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
260 tr = repo.currenttransaction() |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
261 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
|
262 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
|
263 newid = None |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
264 replacementnode = None |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
265 |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
266 # 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
|
267 # changeset |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
268 rebasedbmupdate = None |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
269 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
|
270 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
|
271 bumped = tmpctx |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
272 |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
273 # 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
|
274 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
|
275 files = set() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
276 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
|
277 precmanifest = prec.manifest().copy() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
278 # 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
|
279 # 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
|
280 # this is fishy |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
281 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
|
282 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
|
283 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
|
284 del precmanifest[key] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
285 if precvalue != val: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
286 files.add(key) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
287 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
|
288 |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
289 # commit it |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
290 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
|
291 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
|
292 if path in bumped: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
293 fctx = bumped[path] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
294 flags = fctx.flags() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
295 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
|
296 return mctx |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
297 return None |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
298 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
|
299 text += bumped.description() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
300 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
301 new = context.memctx(repo, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
302 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
|
303 text=text, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
304 files=files, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
305 filectxfn=filectxfn, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
306 user=bumped.user(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
307 date=bumped.date(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
308 extra=bumped.extra()) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
309 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
310 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
|
311 replacementnode = newid |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
312 if newid is None: |
3694
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
313 obsolete.createmarkers(repo, [(tmpctx, ())], operation='evolve') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
314 newid = prec.node() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
315 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
316 phases.retractboundary(repo, tr, bumped.phase(), [newid]) |
3694
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
317 obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], |
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
318 flag=obsolete.bumpedfix, operation='evolve') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
319 bmupdate(newid) |
3624
6756f2a85f5b
evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3623
diff
changeset
|
320 # if rebased happened, update bookmarks from there too |
6756f2a85f5b
evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3623
diff
changeset
|
321 if rebasedbmupdate: |
6756f2a85f5b
evolve: make sure bookmarks are moved after phase-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3623
diff
changeset
|
322 rebasedbmupdate(newid) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
323 repo.ui.status(_('committed as %s\n') % node.short(newid)) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
324 # reroute the working copy parent to the new changeset |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
325 with repo.dirstate.parentchange(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
326 repo.dirstate.setparents(newid, node.nullid) |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
327 return (True, replacementnode) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
328 |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
329 def _solvedivergent(ui, repo, divergent, evolvestate, dryrun=False, |
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
330 confirm=False, progresscb=None): |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
331 """tries to solve content-divergence of a changeset |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
332 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
333 returns a tuple (bool, newnode) where, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
334 bool: a boolean value indicating whether the instability was solved |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
335 newnode: if bool is True, then the newnode of the resultant commit |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
336 formed. newnode can be node, when resolution led to no new |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
337 commit. If bool is False, this is ''. |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
338 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
339 repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
340 divergent = repo[divergent.rev()] |
3734
aae54e80c95c
evolve: store divergent nodes in evolvestate when resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
341 evolvestate['divergent'] = divergent.node() |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
342 # sometimes we will relocate a node in case of different parents and we can |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
343 # encounter conflicts after relocation is done while solving |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
344 # content-divergence and if the user calls `hg evolve --stop`, we need to |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
345 # strip that relocated commit. However if `--all` is passed, we need to |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
346 # reset this value for each content-divergence resolution which we are doing |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
347 # below. |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
348 evolvestate['relocated'] = None |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
349 evolvestate['relocating'] = False |
3825
b5dfa78073b9
evolve: store the old other divergent node after relocation in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3824
diff
changeset
|
350 # in case or relocation we get a new other node, we need to store the old |
b5dfa78073b9
evolve: store the old other divergent node after relocation in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3824
diff
changeset
|
351 # other for purposes like `--abort` or `--stop` |
b5dfa78073b9
evolve: store the old other divergent node after relocation in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3824
diff
changeset
|
352 evolvestate['old-other'] = None |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
353 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
|
354 |
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
355 # 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
|
356 if len(others) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
357 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
|
358 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
|
359 " into multiple ones:\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
360 "|[%s]\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
361 "| 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
|
362 "| 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
|
363 "such as:\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
364 "| - hg touch -D\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
365 "| - hg prune\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
366 "| \n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
367 "| 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
|
368 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr) |
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 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
371 other = others[0] |
3734
aae54e80c95c
evolve: store divergent nodes in evolvestate when resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
372 evolvestate['other-divergent'] = other.node() |
3788
ae30da2e210d
evolve: store the base of content-divergents in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3787
diff
changeset
|
373 evolvestate['base'] = base.node() |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
374 |
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
375 # 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
|
376 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
|
377 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
|
378 "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
|
379 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
380 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
|
381 "| 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
|
382 "| `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
|
383 ui.write_err(hint) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
384 return (False, '') |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
385 |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
386 otherp1 = other.p1().rev() |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
387 divp1 = divergent.p1().rev() |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
388 gca = repo.revs("ancestor(%d, %d)" % (otherp1, divp1)) |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
389 |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
390 # is relocation of one of the changeset required |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
391 relocatereq = False |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
392 |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
393 # testing how both the divergent changesets are arranged, there can be 4 |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
394 # possible cases here: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
395 # |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
396 # 1) both have the same parents |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
397 # 2) both have different parents but greatest common anscestor of them is |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
398 # parent of one of them |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
399 # 3) both have different parents and gca is not parent of any of them |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
400 # 4) one of them is parent of other |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
401 # |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
402 # we are handling 1) very good now. |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
403 # for 2) we will relocate one which is behind to the parent of ahead one and |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
404 # then solve the content-divergence the way we solve 1) |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
405 # for 3) and 4), we still have to decide |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
406 if otherp1 in gca and divp1 in gca: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
407 # both are on the same parents |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
408 pass |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
409 elif otherp1 in gca and divp1 not in gca: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
410 relocatereq = True |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
411 pass |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
412 elif divp1 in gca and otherp1 not in gca: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
413 relocatereq = True |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
414 divergent, other = other, divergent |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
415 else: |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
416 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
|
417 "(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
|
418 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
|
419 "| 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
|
420 "| 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
|
421 "| 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
|
422 "| this command again.\n" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
423 "| - 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
|
424 "| - 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
|
425 ) % {'d': divergent, 'o': other} |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
426 ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
427 ui.write_err(hint) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
428 return (False, '') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
429 |
3484
6d180db0e3e8
branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3482
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 displayer.show(divergent) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
434 ui.write(_('with: ')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
435 displayer.show(other) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
436 ui.write(_('base: ')) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
437 displayer.show(base) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
438 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
|
439 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
|
440 if dryrun: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
441 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
|
442 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
|
443 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
|
444 '%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
|
445 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
|
446 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
|
447 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
|
448 % divergent)) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
449 return (False, '') |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
450 |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
451 # relocate the other divergent if required |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
452 if relocatereq: |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
453 # relocating will help us understand during the time of conflicts that |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
454 # whether conflicts occur at reloacting or they occured at merging |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
455 # content divergent changesets |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
456 evolvestate['relocating'] = True |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
457 ui.status(_('rebasing "other" content-divergent changeset %s on' |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
458 ' %s\n' % (other, divergent.p1()))) |
3811
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
459 try: |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
460 newother = relocate(repo, other, divergent.p1(), evolvestate, |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
461 keepbranch=True) |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
462 except MergeFailure: |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
463 evolvestate['current'] = other.node() |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
464 evolvestate.save() |
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
465 raise |
3825
b5dfa78073b9
evolve: store the old other divergent node after relocation in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3824
diff
changeset
|
466 evolvestate['old-other'] = other.node() |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
467 other = repo[newother] |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
468 evolvestate['relocating'] = False |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
469 evolvestate['relocated'] = other.node() |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
470 evolvestate['temprevs'].append(other.node()) |
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
471 evolvestate['other-divergent'] = other.node() |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
472 |
3808
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
473 _mergecontentdivergents(repo, progresscb, divergent, other, base, |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
474 evolvestate) |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
475 return _completecontentdivergent(ui, repo, progresscb, divergent, other, |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
476 base, evolvestate) |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
477 |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
478 def _mergecontentdivergents(repo, progresscb, divergent, other, base, |
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
479 evolvestate): |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
480 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
|
481 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
|
482 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
|
483 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
|
484 # 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
|
485 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
|
486 (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
|
487 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
488 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
489 stats = merge.update(repo, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
490 other.node(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
491 branchmerge=True, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
492 force=False, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
493 ancestor=base.node(), |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
494 mergeancestor=True) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
495 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
|
496 |
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
497 # 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
|
498 if compat.hasconflict(stats): |
3807
03ccdc753582
evolve: commit the transaction if conflicts occur while merging content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3805
diff
changeset
|
499 tr = repo.currenttransaction() |
03ccdc753582
evolve: commit the transaction if conflicts occur while merging content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3805
diff
changeset
|
500 tr.close() |
3736
4b8c63d14f18
evolve: store the evolvestate file when encountering conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3735
diff
changeset
|
501 evolvestate.save() |
3842
b293cce4ff55
evolve: point to `hg help evolve.interrupted` while resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3832
diff
changeset
|
502 raise error.Abort(_("fix conflicts and see `hg help " |
b293cce4ff55
evolve: point to `hg help evolve.interrupted` while resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3832
diff
changeset
|
503 "evolve.interrupted`")) |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
504 |
3737
5b0bd82ea914
evolve: add logic to continue interrupted content-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3736
diff
changeset
|
505 def _completecontentdivergent(ui, repo, progresscb, divergent, other, |
3789
13eef43a961f
evolve: pass the base revision in _completecontentdivergent()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3788
diff
changeset
|
506 base, evolvestate): |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
507 """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
|
508 # 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
|
509 # resume resolution |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
510 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
511 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
512 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
|
513 tr = repo.currenttransaction() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
514 assert tr is not None |
3831
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
515 # whether to store the obsmarker in the evolvestate |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
516 storemarker = False |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
517 try: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
518 repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve') |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
519 with repo.dirstate.parentchange(): |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
520 repo.dirstate.setparents(divergent.node(), node.nullid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
521 oldlen = len(repo) |
3787
dc81a788f278
evolve: use cmdrewrite.amend() instead of creating a new commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3774
diff
changeset
|
522 # temporary hack because we can't use cmdrewrite.amend() during an |
dc81a788f278
evolve: use cmdrewrite.amend() instead of creating a new commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3774
diff
changeset
|
523 # interrupted evolve |
dc81a788f278
evolve: use cmdrewrite.amend() instead of creating a new commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3774
diff
changeset
|
524 evolvestate.delete() |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
525 |
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
526 # merge the branches |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
527 mergebranches(repo, divergent, other, base) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
528 # merge the commit messages |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
529 desc, conflicts = mergecommitmessages(base.description(), |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
530 divergent.description(), |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
531 other.description()) |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
532 if conflicts: |
3802
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
533 |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
534 prefixes = ("HG: Conflicts while merging changeset description of" |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
535 " content-divergent changesets.\nHG: Resolve conflicts" |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
536 " in commit messages to continue.\n\n") |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
537 |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
538 resolveddesc = ui.edit(prefixes + desc, ui.username(), action='desc') |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
539 # make sure we remove the prefixes part from final commit message |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
540 if prefixes in resolveddesc: |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
541 # hack, we should find something better |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
542 resolveddesc = resolveddesc[len(prefixes):] |
4bad80f1aad3
evolve: pop up editor if conflicts occur while merging commit messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3801
diff
changeset
|
543 desc = resolveddesc |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
544 |
3792
bb7d1616407f
evolve: return the new node formed only as the replacement
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3790
diff
changeset
|
545 # new node if any formed as the replacement |
bb7d1616407f
evolve: return the new node formed only as the replacement
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3790
diff
changeset
|
546 newnode = None |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
547 |
3787
dc81a788f278
evolve: use cmdrewrite.amend() instead of creating a new commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3774
diff
changeset
|
548 # XXX: we should not use amend here, rather create a new commit |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
549 cmdrewrite.amend(ui, repo, message=desc, logfile='') |
3787
dc81a788f278
evolve: use cmdrewrite.amend() instead of creating a new commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3774
diff
changeset
|
550 # XXX: we can get rid of this len() call also by creating a new commit |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
551 if oldlen == len(repo): |
3831
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
552 # no changes |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
553 new = divergent |
3831
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
554 storemarker = True |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
555 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
556 new = repo['.'] |
3792
bb7d1616407f
evolve: return the new node formed only as the replacement
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3790
diff
changeset
|
557 newnode = new.node() |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
558 |
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
559 # creating markers and moving phases post-resolution |
3694
c0d5e0929f8b
compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3676
diff
changeset
|
560 obsolete.createmarkers(repo, [(other, (new,))], operation='evolve') |
3831
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
561 if storemarker: |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
562 # storing the marker in the evolvestate |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
563 # we just store the precursors and successor pair for now, we might |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
564 # want to store more data and serialize obsmarker in a better way in |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
565 # future |
987e335dbe11
evolve: store the obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3830
diff
changeset
|
566 evolvestate['obsmarkers'].append((other.node(), new.node())) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
567 phases.retractboundary(repo, tr, other.phase(), [new.node()]) |
3792
bb7d1616407f
evolve: return the new node formed only as the replacement
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3790
diff
changeset
|
568 return (True, newnode) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
569 finally: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
570 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
|
571 |
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
572 def mergebranches(repo, divergent, other, base): |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
573 """merges the branch information for content-divergent changesets and sets |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
574 the dirstate branch accordingly |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
575 If unable to merge, prompts user to select a branch |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
576 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
577 If the branch name is different from the branch of divergent changeset, it |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
578 sets the current branch using repo.dirstate.setbranch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
579 """ |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
580 divbranch = divergent.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
581 basebranch = base.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
582 othbranch = other.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
583 # content divergent changes were on different branches, ask user to |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
584 # select one |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
585 if divbranch != othbranch: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
586 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
587 if basebranch == othbranch and basebranch != divbranch: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
588 # we will be amending the divergent changeset so branch will be |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
589 # preserved |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
590 pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
591 elif basebranch == divbranch and basebranch != othbranch: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
592 repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
593 else: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
594 # all the three branches are different |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
595 index = repo.ui.promptchoice(_("content divergent changesets on " |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
596 "different branches.\nchoose branch" |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
597 " for the resolution changeset. (a) " |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
598 "%s or (b) %s or (c) %s? $$ &a $$ &b" |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
599 " $$ &c") % |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
600 (basebranch, divbranch, othbranch), 0) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
601 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
602 if index == 0: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
603 repo.dirstate.setbranch(basebranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
604 elif index == 1: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
605 pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
606 elif index == 2: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
607 repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
608 |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
609 def mergecommitmessages(basedesc, divdesc, othdesc): |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
610 """merges the commit messages and return the new merged message and whether |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
611 there were conflicts or not while merging the messages""" |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
612 |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
613 merger = simplemerge.Merge3Text(basedesc, divdesc, othdesc) |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
614 mdesc = [] |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
615 kwargs = {} |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
616 kwargs['name_base'] = 'base' |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
617 kwargs['base_marker'] = '|||||||' |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
618 for line in merger.merge_lines(name_a='divergent', name_b='other', |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
619 **kwargs): |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
620 mdesc.append(line) |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
621 |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
622 return ''.join(mdesc), merger.conflicts |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
623 |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
624 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
|
625 pass |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
626 |
3469
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
627 def _orderrevs(repo, revs): |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
628 """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
|
629 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
630 revs is a list of unstable revisions. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
631 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
632 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
|
633 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
|
634 eventually. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
635 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
636 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
|
637 revision on its final stabilized destination. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
638 """ |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
639 # Step 1: Build the dependency graph |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
640 dependencies, rdependencies = utility.builddependencies(repo, revs) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
641 # Step 2: Build the ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
642 # 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
|
643 # 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
|
644 # 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
|
645 # 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
|
646 # built |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
647 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
|
648 if not dependencies[r]]) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
649 ordering = [] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
650 while solvablerevs: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
651 rev = solvablerevs.popleft() |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
652 for dependent in rdependencies[rev]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
653 dependencies[dependent].remove(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
654 if not dependencies[dependent]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
655 solvablerevs.append(dependent) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
656 del dependencies[rev] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
657 ordering.append(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
658 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
659 ordering.extend(sorted(dependencies)) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
660 return ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
661 |
3638
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
662 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
|
663 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
|
664 """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
|
665 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
666 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
|
667 """ |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 "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
|
672 "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
|
673 "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
|
674 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
675 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
|
676 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
|
677 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
|
678 "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
|
679 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
|
680 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
|
681 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
682 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
|
683 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
684 cache = {} |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
685 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
|
686 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
|
687 for sha1 in sha1s: |
3676
cded30ad25e4
compat: rename resolvepartialhexnodeid to resolvehexnodeidprefix
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3674
diff
changeset
|
688 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
|
689 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
|
690 else: |
51adc7e6a617
compat: fallback to compatible partial lookup prior to 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3666
diff
changeset
|
691 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
|
692 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
|
693 continue |
3665
0f0f31351d6d
compat: avoid using partial node ID in lookup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3653
diff
changeset
|
694 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
|
695 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
|
696 continue |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
697 |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
698 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
|
699 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
700 # 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
|
701 # 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
|
702 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
|
703 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
|
704 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
|
705 else: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
706 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
|
707 '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
|
708 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
709 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
|
710 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
|
711 try: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 '(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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 # 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
|
722 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
|
723 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
724 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
|
725 pass |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
726 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
|
727 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
|
728 raise |
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
729 _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
|
730 return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
731 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 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
|
738 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
|
739 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
740 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
|
741 try: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
742 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
|
743 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
|
744 # 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
|
745 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
|
746 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
|
747 finally: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
748 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
|
749 return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
750 |
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
751 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
|
752 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
|
753 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
|
754 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
|
755 bmchanges = [] |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
756 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
757 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
|
758 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
|
759 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
|
760 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
|
761 bmchanges.append((book, nodenew)) |
3653
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
762 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
|
763 else: |
3636
92a2d3217de9
evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3635
diff
changeset
|
764 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
|
765 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
|
766 "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
|
767 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
|
768 # 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
|
769 for book in oldbookmarks: |
3653
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
770 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
|
771 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
|
772 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
|
773 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
|
774 if bmchanges: |
3699
67d6cc7e0979
compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3698
diff
changeset
|
775 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
|
776 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
777 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
|
778 """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
|
779 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
|
780 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
|
781 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
|
782 dest, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
783 branchmerge=False, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
784 force=True) |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
785 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
|
786 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
|
787 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
|
788 if keepbranch: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
789 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
|
790 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
|
791 # uurrgs |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
792 # 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
|
793 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
|
794 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
|
795 else: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
796 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
|
797 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
|
798 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
799 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
|
800 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
801 instabilities_map = { |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
802 'contentdivergent': "content-divergent", |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
803 'phasedivergent': "phase-divergent" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
804 } |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
805 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
806 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
|
807 """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
|
808 revs = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
809 if allopt or revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
810 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
|
811 if revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
812 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
|
813 elif not anyopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
814 topic = getattr(repo, 'currenttopic', '') |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
815 if topic: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
816 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
|
817 elif targetcat == 'orphan': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
818 revs = _aspiringdescendant(repo, |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
819 repo.revs('(.::) - obsolete()::')) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
820 revs = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
821 if targetcat == 'contentdivergent': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
822 # 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
|
823 revs = _dedupedivergents(repo, revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
824 elif anyopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
825 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
|
826 elif targetcat == 'orphan': |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
827 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
|
828 if 1 < len(revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
829 msg = "multiple evolve candidates" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
830 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
|
831 % ', '.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
|
832 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
|
833 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
|
834 revs = set([repo['.'].rev()]) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
835 return revs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
836 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
837 def _dedupedivergents(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
838 """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
|
839 lowest revision numbers |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
840 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
841 repo = repo.unfiltered() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
842 res = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
843 # 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
|
844 discarded = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
845 for rev in revs: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
846 if rev in discarded: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
847 continue |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
848 divergent = repo[rev] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
849 base, others = divergentdata(divergent) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
850 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
|
851 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
|
852 discarded.update(othersrevs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
853 return res |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
854 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
855 def divergentdata(ctx): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
856 """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
|
857 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
858 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
|
859 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
860 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
|
861 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
862 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
|
863 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
|
864 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
|
865 # 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
|
866 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
|
867 if newer: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
868 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
|
869 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
|
870 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
|
871 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
872 def _aspiringdescendant(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
873 """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
|
874 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
|
875 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
876 result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
877 paths = collections.defaultdict(set) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
878 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
|
879 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
|
880 paths[d].add(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
881 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
882 result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
883 tovisit = list(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
884 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
885 base = tovisit.pop() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
886 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
|
887 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
|
888 tovisit.append(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
889 result.add(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
890 return sorted(result - target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
891 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
892 def _aspiringchildren(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
893 """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
|
894 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
|
895 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
896 result = [] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
897 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
|
898 dest = _possibledestination(repo, r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
899 if target & dest: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
900 result.append(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
901 return result |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
902 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
903 def _possibledestination(repo, rev): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
904 """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
|
905 tonode = repo.changelog.node |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
906 parents = repo.changelog.parentrevs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
907 torev = repo.changelog.rev |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
908 dest = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
909 tovisit = list(parents(rev)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
910 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
911 r = tovisit.pop() |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
912 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
|
913 if not succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
914 tovisit.extend(parents(r)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
915 else: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
916 # 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
|
917 # (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
|
918 # 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
|
919 # multiple branches. |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
920 for ss in succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
921 for n in ss: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
922 dest.add(torev(n)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
923 return dest |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
924 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
925 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
|
926 """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
|
927 no troubles can be resolved""" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
928 troublecategories = ['phasedivergent', 'contentdivergent', 'orphan'] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
929 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
|
930 msg = None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
931 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
|
932 retoverride = None |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
933 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
934 troubled = { |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
935 "orphan": repo.revs("orphan()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
936 "contentdivergent": repo.revs("contentdivergent()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
937 "phasedivergent": repo.revs("phasedivergent()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
938 "all": repo.revs("troubled()"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
939 } |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
940 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
941 hintmap = { |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
942 '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
|
943 '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
|
944 "--phase-divergent or" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
945 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
946 '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
|
947 " or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
948 '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
|
949 '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
|
950 " or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
951 '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
|
952 '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
|
953 " --phase-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
954 '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
|
955 " (or --rev) and" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
956 " --phase-divergent or" |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
957 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
958 '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
|
959 " and --phase-divergent or --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
960 '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
|
961 " --content-divergent"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
962 '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
|
963 " and --content-divergent or " |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
964 "--orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
965 '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
|
966 "and --orphan"), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
967 } |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
968 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
969 if revopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
970 revs = scmutil.revrange(repo, revopt) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
971 if not revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
972 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
|
973 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
974 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
|
975 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
976 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
977 if revs & troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
978 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
979 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
980 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
981 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
982 elif anyopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
983 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
|
984 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
985 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
986 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
987 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
988 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
989 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
990 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
991 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
992 # 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
|
993 if targetcat == 'orphan': |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
994 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
|
995 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
996 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
|
997 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
998 p1 = repo['.'].rev() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
999 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1000 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1001 if p1 in troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1002 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1003 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1004 hint = hintmap['+'.join(othertroubles)] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1005 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1006 length = len(troubled[targetcat]) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1007 if length: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1008 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
|
1009 "or --rev") % (length, targetcat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1010 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1011 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1012 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1013 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1014 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1015 if othertroubles: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1016 hint = hintmap['any+' + ('+'.join(othertroubles))] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1017 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1018 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
|
1019 # 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
|
1020 retoverride = 0 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1021 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1022 assert msg is not None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1023 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
|
1024 if hint: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1025 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
|
1026 ret = 2 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1027 else: |
3649
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1028 ret = 1 |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1029 |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1030 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
|
1031 return retoverride |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1032 return ret |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1033 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1034 def _preparelistctxs(items, condition): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1035 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
|
1036 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1037 def _formatctx(fm, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1038 fm.data(node=ctx.hex()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1039 fm.data(desc=ctx.description()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1040 fm.data(date=ctx.date()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1041 fm.data(user=ctx.user()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1042 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1043 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
|
1044 """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
|
1045 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
|
1046 showunstable = 'orphan' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1047 showbumped = 'phasedivergent' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1048 showdivergent = 'contentdivergent' in troublecategories |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1049 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1050 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
|
1051 if opts.get('rev'): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1052 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
|
1053 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1054 fm = ui.formatter('evolvelist', opts) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1055 for rev in revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1056 ctx = repo[rev] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1057 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
|
1058 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
|
1059 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
|
1060 lambda p: not p.mutable()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1061 dsets = divergentsets(repo, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1062 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1063 fm.startitem() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1064 # plain formatter section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1065 hashlen, desclen = 12, 60 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1066 desc = ctx.description() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1067 if desc: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1068 desc = desc.splitlines()[0] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1069 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
|
1070 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
|
1071 fm.plain('%s\n' % desc) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1072 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
|
1073 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1074 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
|
1075 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
|
1076 unpar[:hashlen], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1077 TROUBLES['ORPHAN'])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1078 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
|
1079 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
|
1080 obspar[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1081 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
|
1082 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
|
1083 (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1084 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1085 if dsets and showdivergent: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1086 for dset in dsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1087 fm.plain(' %s: ' % TROUBLES['CONTENTDIVERGENT']) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1088 first = True |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1089 for n in dset['divergentnodes']: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1090 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
|
1091 first = False |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1092 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
|
1093 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
|
1094 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
|
1095 fm.plain("\n") |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1096 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1097 # templater-friendly section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1098 _formatctx(fm, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1099 troubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1100 for unpar in unpars: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1101 troubles.append({'troubletype': TROUBLES['ORPHAN'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1102 'sourcenode': unpar, 'sourcetype': 'orphanparent'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1103 for obspar in obspars: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1104 troubles.append({'troubletype': TROUBLES['ORPHAN'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1105 'sourcenode': obspar, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1106 'sourcetype': 'obsoleteparent'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1107 for imprec in imprecs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1108 troubles.append({'troubletype': TROUBLES['PHASEDIVERGENT'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1109 'sourcenode': imprec, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1110 'sourcetype': 'immutableprecursor'}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1111 for dset in dsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1112 divnodes = [{'node': node.hex(n), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1113 'phase': repo[n].phasestr(), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1114 } for n in dset['divergentnodes']] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1115 troubles.append({'troubletype': TROUBLES['CONTENTDIVERGENT'], |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1116 'commonprecursor': node.hex(dset['commonprecursor']), |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1117 'divergentnodes': divnodes}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1118 fm.data(troubles=troubles) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1119 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1120 fm.end() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1121 |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1122 def _checkevolveopts(repo, opts): |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1123 """ 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
|
1124 if any """ |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1125 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1126 if opts['continue']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1127 if opts['any']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1128 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
|
1129 if opts['all']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1130 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
|
1131 if opts['rev']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1132 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
|
1133 if opts['stop']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1134 raise error.Abort(_('cannot specify both "--stop" and' |
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1135 ' "--continue"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1136 if opts['abort']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1137 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
|
1138 ' "--continue"')) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1139 |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1140 if opts['stop']: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1141 if opts['any']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1142 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
|
1143 if opts['all']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1144 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
|
1145 if opts['rev']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1146 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
|
1147 if opts['abort']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1148 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
|
1149 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1150 if opts['abort']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1151 if opts['any']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1152 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
|
1153 if opts['all']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1154 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
|
1155 if opts['rev']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1156 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
|
1157 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1158 if opts['rev']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1159 if opts['any']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1160 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
|
1161 if opts['all']: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1162 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
|
1163 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1164 # Backward compatibility |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1165 if opts['unstable']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1166 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
|
1167 "use 'evolve --orphan'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1168 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
|
1169 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1170 opts['orphan'] = opts['divergent'] |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1171 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1172 if opts['divergent']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1173 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
|
1174 "use 'evolve --content-divergent'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1175 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
|
1176 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1177 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
|
1178 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1179 if opts['bumped']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1180 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
|
1181 "use 'evolve --phase-divergent'") |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1182 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
|
1183 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1184 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
|
1185 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1186 return opts |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1187 |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1188 def _cleanup(ui, repo, startnode, showprogress, shouldupdate): |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1189 if showprogress: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1190 ui.progress(_('evolve'), None) |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1191 |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1192 if not shouldupdate: |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1193 unfi = repo.unfiltered() |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1194 succ = utility._singlesuccessor(repo, unfi[startnode]) |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1195 hg.updaterepo(repo, repo[succ].node(), False) |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1196 if repo['.'] != startnode: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1197 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
|
1198 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1199 def divergentsets(repo, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1200 """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
|
1201 cache = {} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1202 base = {} |
3707
95ee7bf46ade
compat: handle lack of allpredecessors for Mercurial 4.3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3702
diff
changeset
|
1203 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
|
1204 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
|
1205 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
|
1206 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
|
1207 if n == ctx.node(): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1208 # 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
|
1209 continue |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
1210 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
|
1211 for nsuccset in nsuccsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1212 if ctx.node() in nsuccset: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1213 # 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
|
1214 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1215 if tuple(nsuccset) in base: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1216 # 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
|
1217 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1218 base[tuple(nsuccset)] = n |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1219 divergence = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1220 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
|
1221 divergence.append({ |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1222 'divergentnodes': divset, |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1223 'commonprecursor': b |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1224 }) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1225 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1226 return divergence |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1227 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1228 @eh.command( |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1229 '^evolve|stabilize|solve', |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1230 [('n', 'dry-run', False, |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1231 _('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
|
1232 ('', 'confirm', False, |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1233 _('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
|
1234 ('A', 'any', False, |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1235 _('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
|
1236 'directory')), |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1237 ('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
|
1238 ('', 'bumped', False, _('solves only bumped changesets')), |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1239 ('', '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
|
1240 ('', 'divergent', False, _('solves only divergent changesets')), |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1241 ('', '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
|
1242 ('', 'unstable', False, _('solves only unstable changesets')), |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1243 ('', '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
|
1244 ('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
|
1245 'current working directory and its descendants')), |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1246 ('', 'update', True, _('update to the head of evolved changesets')), |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1247 ('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
|
1248 ('', '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
|
1249 ('', '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
|
1250 ('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
|
1251 ' in the repo')), |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1252 ] + mergetoolopts, |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1253 _('[OPTIONS]...') |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1254 ) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1255 def evolve(ui, repo, **opts): |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1256 """solve troubled changesets in your repository |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1257 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1258 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
|
1259 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
|
1260 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
|
1261 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1262 - update working copy to a successor |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1263 - rebase an unstable changeset |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1264 - 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
|
1265 - fuse divergent changesets back together |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1266 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 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
|
1273 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
|
1274 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
|
1275 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
|
1276 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1277 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
|
1278 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
|
1279 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
|
1280 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 explicitly request such behavior (see below). |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1286 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1287 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
|
1288 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
|
1289 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
|
1290 working copy parent. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1291 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
|
1292 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
|
1293 evolving all branches. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1294 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1295 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
|
1296 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
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1302 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
|
1303 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
|
1304 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1305 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
|
1306 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
|
1307 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
|
1308 ``--rev`` and ``--any``. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1309 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1310 ``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
|
1311 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
|
1312 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1313 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
|
1314 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
|
1315 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
|
1316 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
|
1317 (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
|
1318 ``--rev``, ``--all``, or ``--any``. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1319 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1320 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
|
1321 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
|
1322 categories of troubles with the --unstable, --divergent or --bumped flags. |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1323 |
3821
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1324 Interrupted |
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1325 =========== |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1326 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1327 The `hg evolve` command is an all purpose tool that solve all kind of |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1328 instabilities in your repository. Sometimes, instability resolution will lead |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1329 to merge conflict that cannot be solved without a human intervention (same as |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1330 `hg merge`). This can lead to an "interrupted state" where human assistance is |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1331 requested. There are three things which you can do when you face a similar |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1332 situation: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1333 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1334 - `hg evolve --continue`: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1335 fix all the conflicts using `hg resolve` and then run this to continue the |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1336 interrupted evolve |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1337 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1338 - `hg evolve --stop`: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1339 stops the current interrupted evolve,. keeping all the successful steps, |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1340 but delaying to resolution of the remaining step for later. |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1341 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1342 - `hg evolve --abort`: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1343 aborts the interrupted evolve and undoes all the resolution which have |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1344 happened |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1345 """ |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1346 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1347 opts = _checkevolveopts(repo, opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1348 # Options |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1349 contopt = opts['continue'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1350 anyopt = opts['any'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1351 allopt = opts['all'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1352 startnode = repo['.'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1353 dryrunopt = opts['dry_run'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1354 confirmopt = opts['confirm'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1355 revopt = opts['rev'] |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1356 stopopt = opts['stop'] |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1357 abortopt = opts['abort'] |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1358 shouldupdate = opts['update'] |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1359 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1360 troublecategories = ['phase_divergent', 'content_divergent', 'orphan'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1361 specifiedcategories = [t.replace('_', '') |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1362 for t in troublecategories |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1363 if opts[t]] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1364 if opts['list']: |
3701
29c413a7dfb5
compat: drop compatibility layer for pager
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3700
diff
changeset
|
1365 ui.pager('evolve') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1366 listtroubles(ui, repo, specifiedcategories, **opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1367 return |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1368 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1369 targetcat = 'orphan' |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1370 if 1 < len(specifiedcategories): |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1371 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
|
1372 raise error.Abort(msg) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1373 elif len(specifiedcategories) == 1: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1374 targetcat = specifiedcategories[0] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1375 elif repo['.'].obsolete(): |
3484
6d180db0e3e8
branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3482
diff
changeset
|
1376 displayer = compat.changesetdisplayer(ui, repo, |
6d180db0e3e8
branching: merge with stable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3482
diff
changeset
|
1377 {'template': shorttemplate}) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1378 # 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
|
1379 try: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1380 ctx = repo[utility._singlesuccessor(repo, repo['.'])] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1381 except utility.MultipleSuccessorsError as exc: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1382 repo.ui.write_err(_('parent is obsolete with multiple' |
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1383 ' successors:\n')) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1384 for ln in exc.successorssets: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1385 for n in ln: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1386 displayer.show(repo[n]) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1387 return 2 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1388 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1389 ui.status(_('update:')) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1390 if not ui.quiet: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1391 displayer.show(ctx) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1392 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1393 if dryrunopt: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1394 return 0 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1395 res = hg.update(repo, ctx.rev()) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1396 if ctx != startnode: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1397 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
|
1398 return res |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1399 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1400 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
|
1401 troubled = set(repo.revs('troubled()')) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1402 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1403 # Progress handling |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1404 seen = 1 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1405 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
|
1406 showprogress = allopt |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1407 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1408 def progresscb(): |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1409 if revopt or allopt: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1410 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
|
1411 |
3477
713e26a647f5
evolve: create a state object in all case
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3470
diff
changeset
|
1412 evolvestate = state.cmdstate(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1413 # Continuation handling |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1414 if contopt: |
3556
b0438c9101ad
evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3555
diff
changeset
|
1415 if not evolvestate: |
3582
8d93f76aa04d
evolvecmd: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3579
diff
changeset
|
1416 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
|
1417 evolvestate.load() |
3557
77a400149758
evolve: move deletion of evolvestate out of continueevolve() function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3556
diff
changeset
|
1418 continueevolve(ui, repo, evolvestate, progresscb) |
3558
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1419 if evolvestate['command'] != 'evolve': |
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1420 evolvestate.delete() |
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1421 return |
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1422 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
|
1423 evolvestate.delete() |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1424 elif stopopt: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1425 if not evolvestate: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1426 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
|
1427 evolvestate.load() |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1428 stopevolve(ui, repo, evolvestate) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1429 evolvestate.delete() |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1430 return |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1431 elif abortopt: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1432 if not evolvestate: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1433 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
|
1434 evolvestate.load() |
3776
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1435 # `hg next --evolve` in play |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1436 if evolvestate['command'] != 'evolve': |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1437 pctx = repo['.'] |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1438 hg.updaterepo(repo, pctx.node(), True) |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1439 ui.status(_('evolve aborted\n')) |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1440 ui.status(_('working directory is now at %s\n') |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1441 % pctx.hex()[:12]) |
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1442 return 0 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1443 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
|
1444 else: |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1445 cmdutil.bailifchanged(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1446 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1447 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
|
1448 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1449 if not revs: |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1450 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
|
1451 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1452 # 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
|
1453 count = len(revs) |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1454 # Order the revisions |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1455 if targetcat == 'orphan': |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1456 revs = _orderrevs(repo, revs) |
3480
1799fc777f30
evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3479
diff
changeset
|
1457 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1458 # 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
|
1459 stateopts = {'category': targetcat, 'replacements': {}, |
31569df48c82
evolve: explicitly turn revs to list before storing into evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3624
diff
changeset
|
1460 '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
|
1461 'startnode': startnode.node(), 'skippedrevs': [], |
3653
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1462 'command': 'evolve', 'orphanmerge': False, |
3830
e0a20dc69126
evolve: store obsmarkers to be deleted in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3829
diff
changeset
|
1463 'bookmarkchanges': [], 'temprevs': [], 'obsmarkers': []} |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1464 evolvestate.addopts(stateopts) |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1465 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
|
1466 curctx = repo[rev] |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1467 progresscb() |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1468 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
|
1469 progresscb, targetcat) |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1470 seen += 1 |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1471 if ret[0]: |
3753
a558c8adc5af
evolve: don't make values of replacements dict lists
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3742
diff
changeset
|
1472 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
|
1473 else: |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1474 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
|
1475 |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1476 if evolvestate['orphanmerge']: |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1477 # 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
|
1478 # 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
|
1479 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
|
1480 confirmopt, progresscb, targetcat) |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1481 if ret[0]: |
3753
a558c8adc5af
evolve: don't make values of replacements dict lists
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3742
diff
changeset
|
1482 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
|
1483 else: |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1484 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
|
1485 |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1486 evolvestate['orphanmerge'] = False |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1487 |
3558
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1488 progresscb() |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1489 _cleanup(ui, repo, startnode, showprogress, shouldupdate) |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1490 |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1491 def stopevolve(ui, repo, evolvestate): |
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1492 """logic for handling of `hg evolve --stop`""" |
3826
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1493 updated = False |
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1494 pctx = None |
3827
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1495 if (evolvestate['command'] == 'evolve' and |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1496 evolvestate['category'] == 'contentdivergent' and |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1497 evolvestate['relocated']): |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1498 oldother = evolvestate['old-other'] |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1499 if oldother: |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1500 with repo.wlock(), repo.lock(): |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1501 repo = repo.unfiltered() |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1502 hg.updaterepo(repo, oldother, True) |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1503 strips = [evolvestate['relocated']] |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1504 repair.strip(ui, repo, strips, False) |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1505 updated = True |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1506 pctx = repo[oldother] |
3826
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1507 if not updated: |
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1508 pctx = repo['.'] |
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1509 hg.updaterepo(repo, pctx.node(), True) |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1510 ui.status(_('stopped the interrupted evolve\n')) |
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1511 ui.status(_('working directory is now at %s\n') % pctx) |
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1512 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1513 def abortevolve(ui, repo, evolvestate): |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1514 """ 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
|
1515 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1516 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
|
1517 repo = repo.unfiltered() |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1518 evolvedctx = [] |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1519 # 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
|
1520 cleanup = True |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1521 startnode = evolvestate['startnode'] |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1522 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
|
1523 if new: |
a19703c6d2bb
evolve: check for None before adding in set of revisions to strip
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3754
diff
changeset
|
1524 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
|
1525 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
|
1526 if temp: |
2bc60fcac354
evolve: make `--abort` strip the temporary revs created during resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3756
diff
changeset
|
1527 evolvedctx.append(repo[temp]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1528 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
|
1529 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1530 # 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
|
1531 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
|
1532 if immutable: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1533 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
|
1534 % ', '.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
|
1535 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
|
1536 cleanup = False |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1537 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1538 # 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
|
1539 descendants = set() |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1540 if evolvedrevs: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1541 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
|
1542 if descendants - set(evolvedrevs): |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1543 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
|
1544 "branch\n")) |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1545 cleanup = False |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1546 |
3832
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1547 # finding the indices of the obsmarkers to be stripped and stripping |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1548 # them |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1549 if evolvestate['obsmarkers']: |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1550 stripmarkers = set() |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1551 for m in evolvestate['obsmarkers']: |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1552 m = (m[0], m[1]) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1553 stripmarkers.add(m) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1554 indices = [] |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1555 allmarkers = obsutil.getmarkers(repo) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1556 for i, m in enumerate(allmarkers): |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1557 marker = (m.prednode(), m.succnodes()[0]) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1558 if marker in stripmarkers: |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1559 indices.append(i) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1560 |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1561 repair.deleteobsmarkers(repo.obsstore, indices) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1562 repo.ui.debug('deleted %d obsmarkers\n' % len(indices)) |
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1563 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1564 if cleanup: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1565 if evolvedrevs: |
3643
01108d67523f
style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3642
diff
changeset
|
1566 strippoints = [c.node() |
01108d67523f
style: fix a couple of pyflakes complains
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3642
diff
changeset
|
1567 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
|
1568 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1569 # updating the working directory |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1570 hg.updaterepo(repo, startnode, True) |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1571 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1572 # 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
|
1573 if evolvedrevs: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1574 # 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
|
1575 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
|
1576 |
3653
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1577 tr = None |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1578 try: |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1579 tr = repo.transaction('evolve') |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1580 # restoring bookmarks at there original place |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1581 bmchanges = evolvestate['bookmarkchanges'] |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1582 if bmchanges: |
3699
67d6cc7e0979
compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3698
diff
changeset
|
1583 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
|
1584 tr.close() |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1585 finally: |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1586 tr.release() |
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1587 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1588 evolvestate.delete() |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1589 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
|
1590 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
|
1591 % node.hex(startnode)[:12]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1592 else: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1593 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
|
1594 "evolve --stop' to stop evolve")) |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1595 |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1596 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
|
1597 """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
|
1598 |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1599 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
|
1600 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
|
1601 evolvestate['category'] == 'orphan'): |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1602 _completeorphan(ui, repo, evolvestate) |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1603 elif evolvestate['category'] == 'phasedivergent': |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1604 _completephasedivergent(ui, repo, evolvestate) |
3737
5b0bd82ea914
evolve: add logic to continue interrupted content-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3736
diff
changeset
|
1605 elif evolvestate['category'] == 'contentdivergent': |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1606 _continuecontentdivergent(ui, repo, evolvestate, progresscb) |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1607 else: |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1608 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
|
1609 " 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
|
1610 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
|
1611 |
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1612 # 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
|
1613 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
|
1614 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
|
1615 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
|
1616 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
|
1617 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
|
1618 # 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
|
1619 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
|
1620 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
|
1621 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
|
1622 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
|
1623 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
|
1624 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
|
1625 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
|
1626 else: |
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1627 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
|
1628 return |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1629 |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1630 def _continuecontentdivergent(ui, repo, evolvestate, progresscb): |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1631 """function to continue the interrupted content-divergence resolution.""" |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1632 tr = None |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1633 try: |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1634 tr = repo.transaction('evolve') |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1635 divergent = evolvestate['divergent'] |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1636 other = evolvestate['other-divergent'] |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1637 base = evolvestate['base'] |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1638 repo = repo.unfiltered() |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1639 ret = _completecontentdivergent(ui, repo, progresscb, |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1640 repo[divergent], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1641 repo[other], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1642 repo[base], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1643 evolvestate) |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1644 evolvestate['replacements'][divergent] = ret[1] |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1645 tr.close() |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1646 finally: |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1647 tr.release() |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
1648 |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1649 def _completephasedivergent(ui, repo, evolvestate): |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1650 """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
|
1651 |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1652 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
|
1653 phase-divergence""" |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1654 |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1655 tr = None |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1656 try: |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1657 # need to start transaction for bookmark changes |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1658 tr = repo.transaction('evolve') |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1659 node = _completerelocation(ui, repo, evolvestate) |
3772
6240579fd0c0
evolve: fix storage of replacements and temprevs node in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3760
diff
changeset
|
1660 evolvestate['temprevs'].append(node) |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1661 # 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
|
1662 # those cases |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1663 ctx = repo[evolvestate['current']] |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1664 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
|
1665 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
|
1666 |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1667 # now continuing the phase-divergence resolution part |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1668 prec = repo[evolvestate['precursor']] |
3772
6240579fd0c0
evolve: fix storage of replacements and temprevs node in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3760
diff
changeset
|
1669 retvalue = _resolvephasedivergent(ui, repo, prec, ctx, newctx) |
6240579fd0c0
evolve: fix storage of replacements and temprevs node in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3760
diff
changeset
|
1670 evolvestate['replacements'][ctx.node()] = retvalue[1] |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1671 tr.close() |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1672 finally: |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1673 tr.release() |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
1674 |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1675 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
|
1676 """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
|
1677 |
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1678 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
|
1679 # 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
|
1680 # those cases |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1681 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
|
1682 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
|
1683 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
|
1684 " 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
|
1685 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
|
1686 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
|
1687 |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1688 # 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
|
1689 if evolvestate['command'] == 'evolve': |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1690 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
|
1691 if evolvestate['orphanmerge']: |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1692 # 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
|
1693 # 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
|
1694 # 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
|
1695 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
|
1696 evolvestate['orphanmerge'] = False |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1697 |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1698 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
|
1699 """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
|
1700 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
|
1701 """ |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
1702 |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1703 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
|
1704 ctx = orig |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1705 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
|
1706 extra = {} |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1707 if source: |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1708 extra['source'] = source |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1709 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
|
1710 else: |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1711 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
|
1712 user = ctx.user() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1713 date = ctx.date() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1714 message = ctx.description() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1715 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
|
1716 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
|
1717 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
|
1718 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
|
1719 |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1720 ctxparents = orig.parents() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 # 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
|
1726 # 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
|
1727 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
|
1728 # 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
|
1729 # 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
|
1730 # 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
|
1731 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
|
1732 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
|
1733 ctxparents[1].node()) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1734 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
|
1735 # 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
|
1736 # 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
|
1737 # 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
|
1738 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
|
1739 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
|
1740 currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1741 |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1742 else: |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1743 # 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
|
1744 # 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
|
1745 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
|
1746 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
|
1747 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
|
1748 currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1749 pass |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1750 |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
1751 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
|
1752 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
|
1753 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
|
1754 return node |