author | Sushil khanchi <sushilkhanchi97@gmail.com> |
Wed, 27 Nov 2019 12:34:19 +0530 | |
changeset 5016 | 64868b7dc112 |
parent 5014 | 35870ce163ee |
child 5017 | b302066725c3 |
permissions | -rw-r--r-- |
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 |
error, |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
20 |
encoding, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
21 |
hg, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
22 |
merge, |
4311
8aa28e68ac44
evolve: detect unresolved conflict during evolve --continue (issue5966)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4297
diff
changeset
|
23 |
mergeutil, |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
24 |
node as nodemod, |
3462
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, |
4752
8a73a8df63b6
py3: convert opts keys to bytes before passing to core APIs
Martin von Zweigbergk <martinvonz@google.com>
parents:
4747
diff
changeset
|
28 |
pycompat, |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
29 |
repair, |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
30 |
scmutil, |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
31 |
simplemerge, |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
32 |
util, |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
33 |
) |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
34 |
|
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
35 |
from mercurial.i18n import _ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
36 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
37 |
from . import ( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
38 |
cmdrewrite, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
39 |
compat, |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
40 |
exthelper, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
41 |
rewriteutil, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
42 |
state, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
43 |
utility, |
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 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
46 |
TROUBLES = compat.TROUBLES |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
47 |
shorttemplate = utility.shorttemplate |
4153
e1f6f9da82c1
utility: add a template alias that will be used in evolve msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4122
diff
changeset
|
48 |
stacktemplate = utility.stacktemplate |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
49 |
_bookmarksupdater = rewriteutil.bookmarksupdater |
4801
16c1398b0063
python3: prefix all regex to work with python 2 and 3
Raphaël Gomès <rgomes@octobus.net>
parents:
4798
diff
changeset
|
50 |
sha1re = re.compile(br'\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
|
51 |
|
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
52 |
eh = exthelper.exthelper() |
3579
3a4552b30ba8
compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3577
diff
changeset
|
53 |
mergetoolopts = commands.mergetoolopts |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
54 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
55 |
abortmessage = _(b"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
|
56 |
|
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
57 |
def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm, |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
58 |
progresscb, category, lastsolved=None, stacktmplt=False): |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
59 |
"""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
|
60 |
|
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
formed. newnode can be node, when resolution led to no new |
4297
699e25687cc5
issue-6028: resolves 6028 - return (False, ".") instead of (False, '')
James Reynolds <james.glenn.reynolds@gmail.com>
parents:
4269
diff
changeset
|
65 |
commit. If bool is False, this is ".". |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
66 |
""" |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
67 |
tr = repo.currenttransaction() |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
68 |
assert tr is not None |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
69 |
displayer = None |
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
70 |
if stacktmplt: |
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
71 |
displayer = compat.changesetdisplayer(ui, repo, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
72 |
{b'template': stacktemplate}) |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
73 |
else: |
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
74 |
displayer = compat.changesetdisplayer(ui, repo, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
75 |
{b'template': shorttemplate}) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
76 |
if b'orphan' == category: |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
77 |
result = _solveunstable(ui, repo, ctx, evolvestate, displayer, |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
78 |
dryrun, confirm, progresscb, |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
79 |
lastsolved=lastsolved) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
80 |
elif b'phasedivergent' == category: |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
81 |
result = _solvephasedivergence(ui, repo, ctx, evolvestate, |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
82 |
displayer, dryrun, confirm, |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
83 |
progresscb) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
84 |
elif b'contentdivergent' == category: |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
85 |
result = _solvedivergent(ui, repo, ctx, evolvestate, displayer, |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
86 |
dryrun, confirm, progresscb) |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
87 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
88 |
assert False, b"unknown trouble category: %s" % (category) |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
89 |
return result |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
90 |
|
4154
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
91 |
def _solveunstable(ui, repo, orig, evolvestate, displayer, dryrun=False, |
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
92 |
confirm=False, progresscb=None, lastsolved=None): |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
93 |
""" 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
|
94 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
formed. newnode can be node, when resolution led to no new |
4297
699e25687cc5
issue-6028: resolves 6028 - return (False, ".") instead of (False, '')
James Reynolds <james.glenn.reynolds@gmail.com>
parents:
4269
diff
changeset
|
99 |
commit. If bool is False, this is ".". |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
100 |
""" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
101 |
pctx = orig.p1() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
p1obs = orig.p1().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
105 |
p2obs = orig.p2().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
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
|
110 |
pass |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
111 |
else: |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
112 |
# 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
|
113 |
# obsolete and proceed with first parent |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
114 |
evolvestate[b'orphanmerge'] = True |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
115 |
# 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
|
116 |
# 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
|
117 |
# first parent |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
118 |
pctx = orig.p2() |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
119 |
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
|
120 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
121 |
if not pctx.obsolete(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
122 |
ui.warn(_(b"cannot solve instability of %s, skipping\n") % orig) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
123 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
124 |
obs = pctx |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
125 |
newer = obsutil.successorssets(repo, obs.node()) |
4825
9af212b8565a
evolve: test that target is not orig in _solveunstable() (issue6097)
Anton Shestakov <av6@dwimlabs.net>
parents:
4774
diff
changeset
|
126 |
# search of a parent which is not killed, but also isn't the orig |
5012
5b5cfb9b0a0b
evolve: remove the unnecessary condition to check empty successors set
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5011
diff
changeset
|
127 |
while not newer or newer[0][0] == orig.node(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
128 |
ui.debug(b"stabilize target %s is plain dead," |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
129 |
b" trying to stabilize on its parent\n" % |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
130 |
obs) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
131 |
obs = obs.parents()[0] |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
132 |
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
|
133 |
if len(newer) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
134 |
msg = _(b"skipping %s: divergent rewriting. can't choose " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
135 |
b"destination\n") % obs |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
136 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
137 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
138 |
targets = newer[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
139 |
assert targets |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
140 |
if len(targets) > 1: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
141 |
# 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
|
142 |
targetrevs = [repo[r].rev() for r in targets] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
143 |
roots = repo.revs(b'roots(%ld)', targetrevs) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
144 |
heads = repo.revs(b'heads(%ld)', targetrevs) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
145 |
if len(roots) > 1 or len(heads) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
146 |
cheader = _(b"ancestor '%s' split over multiple topological" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
147 |
b" 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
|
148 |
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
|
149 |
cheader) |
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
150 |
if selectedrev is None: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
151 |
msg = _(b"could not solve instability, " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
152 |
b"ambiguous destination: " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
153 |
b"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
|
154 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
155 |
return (False, b".") |
3541
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
156 |
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
|
157 |
else: |
bc47c09c9782
evolve: prompt user to select destination for stabilization in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3529
diff
changeset
|
158 |
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
|
159 |
else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
160 |
target = targets[0] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
161 |
target = repo[target] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
162 |
if not ui.quiet or confirm: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
163 |
repo.ui.write(_(b'move:'), label=b'evolve.operation') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
164 |
displayer.show(orig) |
4122
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
165 |
if lastsolved is None or target != repo[lastsolved]: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
166 |
repo.ui.write(_(b'atop:')) |
4122
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
167 |
displayer.show(target) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
168 |
if confirm and ui.prompt(b'perform evolve? [Ny]', b'n') != b'y': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
169 |
raise error.Abort(_(b'evolve aborted by user')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
170 |
todo = b'hg rebase -r %s -d %s\n' % (orig, target) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
171 |
if dryrun: |
4599
93ffedae6ec6
evolve: _solveunstable() update progress only once
Martin von Zweigbergk <martinvonz@google.com>
parents:
4598
diff
changeset
|
172 |
if progresscb: |
93ffedae6ec6
evolve: _solveunstable() update progress only once
Martin von Zweigbergk <martinvonz@google.com>
parents:
4598
diff
changeset
|
173 |
progresscb() |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
174 |
repo.ui.write(todo) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
175 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
176 |
else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
177 |
repo.ui.note(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
178 |
if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
179 |
progresscb() |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
180 |
with state.saver(evolvestate, {b'current': orig.node()}): |
3638
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
181 |
newid = relocate(repo, orig, target, evolvestate, pctx, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
182 |
keepbranch, b'orphan') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
183 |
return (True, newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
184 |
|
4154
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
185 |
def _solvephasedivergence(ui, repo, bumped, evolvestate, displayer, |
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
186 |
dryrun=False, confirm=False, progresscb=None): |
3609
1c8dec54450a
evolve: replace bumped in function name to phasedivergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3608
diff
changeset
|
187 |
"""Stabilize a phase divergent changeset |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
188 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
189 |
returns a tuple (bool, newnode) where, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
190 |
bool: a boolean value indicating whether the instability was solved |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
191 |
newnode: if bool is True, then the newnode of the resultant commit |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
192 |
formed. newnode can be node, when resolution led to no new |
4297
699e25687cc5
issue-6028: resolves 6028 - return (False, ".") instead of (False, '')
James Reynolds <james.glenn.reynolds@gmail.com>
parents:
4269
diff
changeset
|
193 |
commit. If bool is False, this is ".". |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
194 |
""" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
195 |
repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
196 |
bumped = repo[bumped.rev()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
197 |
# For now we deny bumped merge |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
198 |
if len(bumped.parents()) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
199 |
msg = _(b'skipping %s : we do not handle merge yet\n') % bumped |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
200 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
201 |
return (False, b".") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
202 |
prec = next(repo.set(b'last(allpredecessors(%d) and public())', bumped.rev())) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
203 |
# For now we deny target merge |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
204 |
if len(prec.parents()) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
205 |
msg = _(b'skipping: %s: public version is a merge, ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
206 |
b'this is not handled yet\n') % prec |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
207 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
208 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
209 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
210 |
if not ui.quiet or confirm: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
211 |
repo.ui.write(_(b'recreate:'), label=b'evolve.operation') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
212 |
displayer.show(bumped) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
213 |
repo.ui.write(_(b'atop:')) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
214 |
displayer.show(prec) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
215 |
if confirm and ui.prompt(_(b'perform evolve? [Ny]'), b'n') != b'y': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
216 |
raise error.Abort(_(b'evolve aborted by user')) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
217 |
if dryrun: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
218 |
todo = b'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1()) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
219 |
repo.ui.write(todo) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
220 |
repo.ui.write((b'hg update %s;\n' % prec)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
221 |
repo.ui.write((b'hg revert --all --rev %s;\n' % bumped)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
222 |
repo.ui.write((b'hg commit --msg "%s update to %s"\n' % |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
223 |
(TROUBLES['PHASEDIVERGENT'], bumped))) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
224 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
225 |
if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
226 |
progresscb() |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
227 |
|
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
228 |
# 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
|
229 |
# it's precursors. Phase-divergent changeset and precursor having different |
4054
46cd437fd3d2
pick: fix last references of grab in code
Boris Feld <boris.feld@octobus.net>
parents:
3981
diff
changeset
|
230 |
# parents is a result of when the changeset is rebased, picked, histedit or |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
231 |
# 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
|
232 |
# 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
|
233 |
# parent or precursor and then perform later steps |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
234 |
if not list(repo.set(b'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
|
235 |
# 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
|
236 |
repo.ui.status( |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
237 |
_(b'rebasing to destination parent: %s\n') % prec.p1()) |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
238 |
with state.saver(evolvestate, {b'current': bumped.hex(), |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
239 |
b'precursor': prec.hex()}): |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
240 |
newnode = relocate(repo, bumped, prec.p1(), evolvestate, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
241 |
category=b'phasedivergent') |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
242 |
if newnode is not None: |
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
243 |
new = repo[newnode] |
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
244 |
obsolete.createmarkers(repo, [(bumped, (new,))], |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
245 |
operation=b'evolve') |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
246 |
bumped = new |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
247 |
evolvestate[b'temprevs'].append(newnode) |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
248 |
|
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
249 |
return _resolvephasedivergent(ui, repo, prec, bumped) |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
250 |
|
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
251 |
def _resolvephasedivergent(ui, repo, prec, bumped): |
4465
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
252 |
"""final step of a phase divergence resolution |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
253 |
|
4465
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
254 |
This will create a new changesets (or nothing when applicable), the two |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
255 |
changesets needs to be on the same parents. |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
256 |
""" |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
257 |
tr = repo.currenttransaction() |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
258 |
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
|
259 |
|
4465
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
260 |
cl = repo.changelog |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
261 |
prec_parent = cl.parentrevs(prec.rev()) |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
262 |
bump_parent = cl.parentrevs(bumped.rev()) |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
263 |
assert prec_parent == bump_parent, (prec_parent, bump_parent) |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
264 |
|
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
265 |
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
|
266 |
newid = None |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
267 |
replacementnode = None |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
268 |
|
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
269 |
# Create the new commit context. This is done by applying the changes from |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
270 |
# the precursor to the bumped node onto the precursor. This is effectively |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
271 |
# like reverting to the bumped node. |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
272 |
wctx = context.overlayworkingctx(repo) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
273 |
wctx.setbase(prec) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
274 |
merge.update(repo, bumped.node(), ancestor=prec, mergeancestor=True, |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
275 |
branchmerge=True, force=False, wc=wctx) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
276 |
if not wctx.isempty(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
277 |
text = b'%s update to %s:\n\n' % (TROUBLES['PHASEDIVERGENT'], prec) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
278 |
text += bumped.description() |
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
279 |
memctx = wctx.tomemctx(text, |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
280 |
parents=(prec.node(), nodemod.nullid), |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
281 |
date=bumped.date(), |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
282 |
extra=bumped.extra(), |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
283 |
user=bumped.user()) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
284 |
newid = repo.commitctx(memctx) |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
285 |
replacementnode = newid |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
286 |
if newid is None: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
287 |
repo.ui.status(_(b'no changes to commit\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
288 |
obsolete.createmarkers(repo, [(bumped, ())], operation=b'evolve') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
289 |
newid = prec.node() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
290 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
291 |
repo.ui.status(_(b'committed as %s\n') % nodemod.short(newid)) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
292 |
phases.retractboundary(repo, tr, bumped.phase(), [newid]) |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
293 |
obsolete.createmarkers(repo, [(bumped, (repo[newid],))], |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
294 |
flag=obsolete.bumpedfix, operation=b'evolve') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
295 |
bmupdate(newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
296 |
# 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
|
297 |
with repo.dirstate.parentchange(): |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
298 |
repo.dirstate.setparents(newid, nodemod.nullid) |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
299 |
return (True, replacementnode) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
300 |
|
4154
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
301 |
def _solvedivergent(ui, repo, divergent, evolvestate, displayer, dryrun=False, |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
302 |
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
|
303 |
"""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
|
304 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
formed. newnode can be node, when resolution led to no new |
4297
699e25687cc5
issue-6028: resolves 6028 - return (False, ".") instead of (False, '')
James Reynolds <james.glenn.reynolds@gmail.com>
parents:
4269
diff
changeset
|
309 |
commit. If bool is False, this is ".". |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
310 |
""" |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
311 |
repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
312 |
divergent = repo[divergent.rev()] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
313 |
evolvestate[b'divergent'] = divergent.node() |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
314 |
evolvestate[b'orig-divergent'] = divergent.node() |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
315 |
# 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
|
316 |
# 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
|
317 |
# 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
|
318 |
# 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
|
319 |
# 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
|
320 |
# below. |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
321 |
evolvestate[b'relocated-other'] = None |
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
322 |
evolvestate[b'relocating-other'] = False |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
323 |
evolvestate[b'relocated-div'] = None |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
324 |
evolvestate[b'relocating-div'] = False |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
325 |
evolvestate[b'relocation-req'] = False |
3825
b5dfa78073b9
evolve: store the old other divergent node after relocation in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3824
diff
changeset
|
326 |
# 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
|
327 |
# other for purposes like `--abort` or `--stop` |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
328 |
evolvestate[b'old-other'] = None |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
329 |
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
|
330 |
|
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
331 |
# 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
|
332 |
if len(others) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
333 |
othersstr = b"[%s]" % (b','.join([bytes(i) for i in others])) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
334 |
msg = _(b"skipping %s: %s with a changeset that got split" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
335 |
b" into multiple ones:\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
336 |
b"|[%s]\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
337 |
b"| This is not handled by automatic evolution yet\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
338 |
b"| You have to fallback to manual handling with commands " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
339 |
b"such as:\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
340 |
b"| - hg touch -D\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
341 |
b"| - hg prune\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
342 |
b"| \n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
343 |
b"| You should contact your local evolution Guru for help.\n" |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
344 |
) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
345 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
346 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
347 |
other = others[0] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
348 |
evolvestate[b'other-divergent'] = other.node() |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
349 |
evolvestate[b'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
|
350 |
|
4467
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
351 |
def swapnodes(div, other): |
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
352 |
div, other = other, div |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
353 |
evolvestate[b'divergent'] = div.node() |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
354 |
evolvestate[b'other-divergent'] = other.node() |
4467
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
355 |
return div, other |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
356 |
# haspubdiv: to keep track if we are solving public content-divergence |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
357 |
haspubdiv = False |
4444
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
358 |
if not (divergent.mutable() and other.mutable()): |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
359 |
haspubdiv = True |
4444
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
360 |
# for simplicity, we keep public one to local side while merging |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
361 |
# (as divergent is kept at local side, pinning public -> divergent) |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
362 |
if divergent.mutable(): |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
363 |
publicdiv = other |
4467
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
364 |
divergent, other = swapnodes(divergent, other) |
4444
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
365 |
else: |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
366 |
publicdiv = divergent |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
367 |
evolvestate[b'public-divergent'] = publicdiv.node() |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
368 |
# 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
|
369 |
if len(other.parents()) > 1: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
370 |
msg = _(b"skipping %s: %s changeset can't be " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
371 |
b"a merge (yet)\n") % (divergent, TROUBLES['CONTENTDIVERGENT']) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
372 |
ui.write_err(msg) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
373 |
hint = _(b"You have to fallback to solving this by hand...\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
374 |
b"| This probably means redoing the merge and using \n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
375 |
b"| `hg prune` to kill older version.\n") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
376 |
ui.write_err(hint) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
377 |
return (False, b".") |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
378 |
|
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
379 |
otherp1 = other.p1().rev() |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
380 |
divp1 = divergent.p1().rev() |
3848
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
381 |
|
3850
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
382 |
# finding single successors of otherp1 and divp1 |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
383 |
try: |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
384 |
otherp1 = utility._singlesuccessor(repo, other.p1()) |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
385 |
except utility.MultipleSuccessorsError: |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
386 |
pass |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
387 |
|
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
388 |
try: |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
389 |
divp1 = utility._singlesuccessor(repo, divergent.p1()) |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
390 |
except utility.MultipleSuccessorsError: |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
391 |
pass |
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
392 |
|
3848
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
393 |
# the changeset on which resolution changeset will be based on |
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
394 |
resolutionparent = repo[divp1].node() |
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
395 |
|
4984
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
396 |
# the nullrev has to be handled specially because -1 is overloaded to both |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
397 |
# mean nullrev (this meaning is used for the result of changectx.rev(), as |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
398 |
# called above) and the tipmost revision (this meaning is used for the %d |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
399 |
# format specifier, as used below) |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
400 |
if nodemod.nullrev in (otherp1, divp1): |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
401 |
# nullrev is the only possible ancestor if otherp1 or divp1 is nullrev |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
402 |
gca = [nodemod.nullrev] |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
403 |
else: |
b779b40f996e
evolve: fix content-divergence resolution when p1 is null (issue6201)
Manuel Jacob <me@manueljacob.de>
parents:
4857
diff
changeset
|
404 |
gca = repo.revs(b"ancestor(%d, %d)" % (otherp1, divp1)) |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
405 |
# divonly: non-obsolete csets which are topological ancestor of "divergent" |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
406 |
# but not "other" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
407 |
divonly = repo.revs(b"only(%d, %d) - obsolete()" % (divergent.rev(), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
408 |
other.rev())) |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
409 |
# otheronly: non-obsolete csets which are topological ancestor of "other" |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
410 |
# but not "div" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
411 |
otheronly = repo.revs(b"only(%d, %d) - obsolete()" % (other.rev(), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
412 |
divergent.rev())) |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
413 |
# make it exclusive set |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
414 |
divonly = set(divonly) - {divergent.rev()} |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
415 |
otheronly = set(otheronly) - {other.rev()} |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
416 |
# 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
|
417 |
relocatereq = False |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
418 |
|
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
419 |
# 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
|
420 |
# possible cases here: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
421 |
# |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
422 |
# 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
|
423 |
# 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
|
424 |
# 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
|
425 |
# 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
|
426 |
# 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
|
427 |
# |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
428 |
# 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
|
429 |
# 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
|
430 |
# 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
|
431 |
# 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
|
432 |
if otherp1 in gca and divp1 in gca: |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
433 |
if otherp1 == other.p1().rev() and divp1 == divergent.p1().rev(): |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
434 |
# both are on the same parents |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
435 |
pass |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
436 |
else: |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
437 |
# both are not on the same parent but have same parents's succs. |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
438 |
if otheronly and divonly: |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
439 |
# case: we have visible csets on both side diverging from |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
440 |
# tca of "divergent" and "other". We still need to decide what |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
441 |
# to do in this case |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
442 |
pass |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
443 |
if otheronly: |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
444 |
relocatereq = True |
4443
fc2214916f50
evolve: add condition in case of pubdiv to not swap the two div csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4442
diff
changeset
|
445 |
if not haspubdiv: |
fc2214916f50
evolve: add condition in case of pubdiv to not swap the two div csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4442
diff
changeset
|
446 |
# can't swap when public divergence, as public can't move |
4467
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
447 |
divergent, other = swapnodes(divergent, other) |
4443
fc2214916f50
evolve: add condition in case of pubdiv to not swap the two div csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4442
diff
changeset
|
448 |
resolutionparent = repo[otherp1].node() |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
449 |
elif divonly: |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
450 |
relocatereq = True |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
451 |
else: |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
452 |
# no extra cset on either side; so not considering relocation |
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
453 |
pass |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
454 |
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
|
455 |
relocatereq = True |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
456 |
pass |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
457 |
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
|
458 |
relocatereq = True |
4444
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
459 |
|
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
460 |
# When public branch is behind to the mutable branch, for now we |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
461 |
# relocate mutable cset to public one's side in every case. |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
462 |
# |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
463 |
# This behaviour might be sub optimal when ancestors of mutable |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
464 |
# cset has changes its relocated descendant rely on. |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
465 |
# |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
466 |
# Otherwise, we are going to rebase the "behind" branch up to the new |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
467 |
# brancmap level. |
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
468 |
if not haspubdiv: |
4467
6fc5e162ea84
evolve: refactor the code which swap two nodes (in divergence resolution)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4466
diff
changeset
|
469 |
divergent, other = swapnodes(divergent, other) |
4444
ea336a6592cc
evolve: test a common case of public divergence
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4443
diff
changeset
|
470 |
resolutionparent = divergent.p1().node() |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
471 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
472 |
msg = _(b"skipping %s: have a different parent than %s " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
473 |
b"(not handled yet)\n") % (divergent, other) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
474 |
hint = _(b"| %(d)s, %(o)s are not based on the same changeset.\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
475 |
b"| With the current state of its implementation, \n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
476 |
b"| evolve does not work in that case.\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
477 |
b"| rebase one of them next to the other and run \n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
478 |
b"| this command again.\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
479 |
b"| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
480 |
b"| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
481 |
) % {b'd': divergent, b'o': other} |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
482 |
ui.write_err(msg) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
483 |
ui.write_err(hint) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
484 |
return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
485 |
|
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
486 |
if not ui.quiet or confirm: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
487 |
ui.write(_(b'merge:'), label=b'evolve.operation') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
488 |
displayer.show(divergent) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
489 |
ui.write(_(b'with: ')) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
490 |
displayer.show(other) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
491 |
ui.write(_(b'base: ')) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
492 |
displayer.show(base) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
493 |
if confirm and ui.prompt(_(b'perform evolve? [Ny]'), b'n') != b'y': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
494 |
raise error.Abort(_(b'evolve aborted by user')) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
495 |
if dryrun: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
496 |
ui.write((b'hg update -c %s &&\n' % divergent)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
497 |
ui.write((b'hg merge %s &&\n' % other)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
498 |
ui.write((b'hg commit -m "auto merge resolving conflict between ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
499 |
b'%s and %s"&&\n' % (divergent, other))) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
500 |
ui.write((b'hg up -C %s &&\n' % base)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
501 |
ui.write((b'hg revert --all --rev tip &&\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
502 |
ui.write((b'hg commit -m "`hg log -r %s --template={desc}`";\n' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
503 |
% divergent)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
504 |
return (False, b".") |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
505 |
|
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
506 |
if relocatereq: |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
507 |
evolvestate[b'relocation-req'] = True |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
508 |
evolvestate[b'resolutionparent'] = resolutionparent |
4991
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
509 |
try: |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
510 |
succsdivp1 = utility._singlesuccessor(repo, divergent.p1()) |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
511 |
except utility.MultipleSuccessorsError: |
5003
ad1ea34335cb
evolve: fix a typo
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5000
diff
changeset
|
512 |
msg = _(b"ambiguous orphan resolution parent for %s") |
4992
1eab41625dee
evolve: abort if deciding resolution parent is ambiguous
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4991
diff
changeset
|
513 |
raise error.Abort(msg % divergent.hex()[:12]) |
4991
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
514 |
# relocate divergent cset to its obsolete parent's successsor |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
515 |
if succsdivp1 != divergent.p1().rev(): |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
516 |
evolvestate[b'relocating-div'] = True |
4991
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
517 |
ui.status(_(b'rebasing "divergent" content-divergent changeset %s on' |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
518 |
b' %s\n' % (divergent, repo[succsdivp1]))) |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
519 |
with state.saver(evolvestate, {b'current': divergent.node()}): |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
520 |
newdivergent = relocate(repo, divergent, repo[succsdivp1], |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
521 |
evolvestate, keepbranch=True) |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
522 |
divergent = repo[newdivergent] |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
523 |
evolvestate[b'relocating-div'] = False |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
524 |
evolvestate[b'relocated-div'] = divergent.node() |
4991
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
525 |
evolvestate[b'temprevs'].append(divergent.node()) |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
526 |
evolvestate[b'divergent'] = divergent.node() |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
527 |
|
4850
6d898fa6e5c3
evolve: check that relocating makes sense in _solvedivergent() (issue5958)
Anton Shestakov <av6@dwimlabs.net>
parents:
4825
diff
changeset
|
528 |
# Sometimes we already have the other cset where we want it |
6d898fa6e5c3
evolve: check that relocating makes sense in _solvedivergent() (issue5958)
Anton Shestakov <av6@dwimlabs.net>
parents:
4825
diff
changeset
|
529 |
if relocatereq and other == divergent.p1(): |
6d898fa6e5c3
evolve: check that relocating makes sense in _solvedivergent() (issue5958)
Anton Shestakov <av6@dwimlabs.net>
parents:
4825
diff
changeset
|
530 |
relocatereq = False |
6d898fa6e5c3
evolve: check that relocating makes sense in _solvedivergent() (issue5958)
Anton Shestakov <av6@dwimlabs.net>
parents:
4825
diff
changeset
|
531 |
|
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
532 |
# 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
|
533 |
if relocatereq: |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
534 |
# 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
|
535 |
# 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
|
536 |
# content divergent changesets |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
537 |
evolvestate[b'relocating-other'] = True |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
538 |
ui.status(_(b'rebasing "other" content-divergent changeset %s on' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
539 |
b' %s\n' % (other, divergent.p1()))) |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
540 |
with state.saver(evolvestate, {b'current': other.node()}): |
3811
3273b178c202
evolve: store the evolvestate if relocation results in conflicts
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3809
diff
changeset
|
541 |
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
|
542 |
keepbranch=True) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
543 |
evolvestate[b'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
|
544 |
other = repo[newother] |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
545 |
evolvestate[b'relocating-other'] = False |
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
546 |
evolvestate[b'relocated-other'] = other.node() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
547 |
evolvestate[b'temprevs'].append(other.node()) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
548 |
evolvestate[b'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
|
549 |
|
3808
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
550 |
_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
|
551 |
evolvestate) |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
552 |
res, newnode = _completecontentdivergent(ui, repo, progresscb, divergent, |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
553 |
other, base, evolvestate) |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
554 |
if not haspubdiv: |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
555 |
return (res, newnode) |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
556 |
else: |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
557 |
# we have content-divergence with a public cset: |
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
558 |
# after performing content divergence resolution steps, possbile cases: |
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
559 |
# 1) merging results in a new node: |
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
560 |
# we need to perform phase divergence resolution |
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
561 |
# 2) merging leads to same content as public cset: |
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
562 |
# divergence has been resolved by creating markers |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
563 |
if not res: |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
564 |
# resolution was not successful, return |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
565 |
return (res, newnode) |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
566 |
if newnode == publicdiv.node(): |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
567 |
# case 2) |
4747
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
568 |
pubstr = bytes(publicdiv) |
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
569 |
othstr = bytes(other) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
570 |
msg = _(b'content divergence resolution between %s ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
571 |
b'(public) and %s has same content as %s, ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
572 |
b'discarding %s\n') |
4583
4fcf9a71befc
evolve: show a status message when merging leads to public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4580
diff
changeset
|
573 |
msg %= (pubstr, othstr, pubstr, othstr) |
4fcf9a71befc
evolve: show a status message when merging leads to public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4580
diff
changeset
|
574 |
repo.ui.status(msg) |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
575 |
return (res, newnode) |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
576 |
# case 1) |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
577 |
prec = publicdiv |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
578 |
bumped = repo[newnode] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
579 |
return _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped) |
3808
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
580 |
|
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
581 |
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
|
582 |
evolvestate): |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
583 |
if divergent not in repo[None].parents(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
584 |
repo.ui.note(_(b"updating to \"local\" side of the conflict: %s\n") % |
4633
61c2518cd6d2
evolve: move status msg to verbose mode in content-divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4624
diff
changeset
|
585 |
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
|
586 |
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
|
587 |
# merging the two content-divergent changesets |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
588 |
repo.ui.note(_(b"merging \"other\" %s changeset '%s'\n") % |
4633
61c2518cd6d2
evolve: move status msg to verbose mode in content-divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4624
diff
changeset
|
589 |
(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
|
590 |
if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
591 |
progresscb() |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
592 |
with state.saver(evolvestate): |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
593 |
mergeancestor = repo.changelog.isancestor(divergent.node(), |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
594 |
other.node()) |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
595 |
stats = merge.update(repo, |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
596 |
other.node(), |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
597 |
branchmerge=True, |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
598 |
force=False, |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
599 |
ancestor=base.node(), |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
600 |
mergeancestor=mergeancestor) |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
601 |
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
|
602 |
|
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
603 |
# conflicts while merging content-divergent changesets |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
604 |
if compat.hasconflict(stats): |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
605 |
hint = _(b"see 'hg help evolve.interrupted'") |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
606 |
raise error.InterventionRequired(_(b"unresolved merge conflicts"), |
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
607 |
hint=hint) |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
608 |
|
3737
5b0bd82ea914
evolve: add logic to continue interrupted content-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3736
diff
changeset
|
609 |
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
|
610 |
base, evolvestate): |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
611 |
"""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
|
612 |
# 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
|
613 |
# resume resolution |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
614 |
if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
615 |
progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
616 |
tr = repo.currenttransaction() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
617 |
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
|
618 |
# 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
|
619 |
storemarker = False |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
620 |
resparent = evolvestate[b'resolutionparent'] |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
621 |
|
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
622 |
# whether we are solving public divergence |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
623 |
haspubdiv = False |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
624 |
if evolvestate.get(b'public-divergent'): |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
625 |
haspubdiv = True |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
626 |
publicnode = evolvestate[b'public-divergent'] |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
627 |
publicdiv = repo[publicnode] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
628 |
othernode = evolvestate[b'other-divergent'] |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
629 |
otherdiv = repo[othernode] |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
630 |
|
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
631 |
with repo.dirstate.parentchange(): |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
632 |
repo.dirstate.setparents(publicnode, nodemod.nullid) |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
633 |
dirstatedance(repo, divergent, publicnode, None) |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
634 |
# check if node to be committed has changes same as public one |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
635 |
s = publicdiv.status() |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
636 |
if not (s.added or s.removed or s.deleted or s.modified): |
4438
a6bdb02a1902
evolve: warn user if cset desc is being lost
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4431
diff
changeset
|
637 |
# warn user if metadata is being lost |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
638 |
warnmetadataloss(repo, publicdiv, otherdiv) |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
639 |
# no changes, create markers to resolve divergence |
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
640 |
obsolete.createmarkers(repo, [(otherdiv, (publicdiv,))], |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
641 |
operation=b'evolve') |
4416
b2a8e67b0933
evolve: handle a case in pubic-div when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4415
diff
changeset
|
642 |
return (True, publicnode) |
3846
f9dad99a90d5
evolve: create a new commit instead of amending one of the divergents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3845
diff
changeset
|
643 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
644 |
with repo.dirstate.parentchange(): |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
645 |
repo.dirstate.setparents(resparent, nodemod.nullid) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
646 |
|
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
647 |
dirstatedance(repo, divergent, resparent, None) |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
648 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
649 |
# merge the branches |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
650 |
mergebranches(repo, divergent, other, base) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
651 |
# merge the commit messages |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
652 |
desc = mergecommitmessages(ui, base.description(), |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
653 |
divergent.description(), |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
654 |
other.description()) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
655 |
user = utility.mergeusers(ui, base, divergent, other) |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
656 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
657 |
mergehook(repo, base, divergent, other) |
3879
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
658 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
659 |
date = divergent.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
660 |
if other.date() != divergent.date(): |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
661 |
basedate = base.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
662 |
if other.date() == basedate: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
663 |
date = divergent.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
664 |
elif divergent.date() == basedate: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
665 |
date = other.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
666 |
else: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
667 |
date = max(divergent.date(), other.date()) |
4998
88b816a9d990
evolve: preserve date when resolving content-divergence (issue6202)
Manuel Jacob <me@manueljacob.de>
parents:
4992
diff
changeset
|
668 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
669 |
# new node if any formed as the replacement |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
670 |
newnode = repo.commit(text=desc, user=user, date=date) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
671 |
if newnode == divergent.node() or newnode is None: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
672 |
# no changes |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
673 |
new = divergent |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
674 |
storemarker = True |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
675 |
repo.ui.status(_(b"nothing changed\n")) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
676 |
hg.updaterepo(repo, divergent.rev(), False) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
677 |
else: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
678 |
new = repo[newnode] |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
679 |
newnode = new.node() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
680 |
hg.updaterepo(repo, new.rev(), False) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
681 |
if haspubdiv and publicdiv == divergent: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
682 |
bypassphase(repo, (divergent, new), operation=b'evolve') |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
683 |
else: |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
684 |
obsolete.createmarkers(repo, [(divergent, (new,))], |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
685 |
operation=b'evolve') |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
686 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
687 |
# creating markers and moving phases post-resolution |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
688 |
if haspubdiv and publicdiv == other: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
689 |
bypassphase(repo, (other, new), operation=b'evolve') |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
690 |
else: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
691 |
obsolete.createmarkers(repo, [(other, (new,))], operation=b'evolve') |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
692 |
if storemarker: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
693 |
# storing the marker in the evolvestate |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
694 |
# we just store the precursors and successor pair for now, we might |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
695 |
# want to store more data and serialize obsmarker in a better way in |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
696 |
# future |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
697 |
evolvestate[b'obsmarkers'].append((other.node(), new.node())) |
3846
f9dad99a90d5
evolve: create a new commit instead of amending one of the divergents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3845
diff
changeset
|
698 |
|
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
699 |
phases.retractboundary(repo, tr, other.phase(), [new.node()]) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
700 |
return (True, newnode) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
701 |
|
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
702 |
def warnmetadataloss(repo, local, other): |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
703 |
"""warn the user for the metadata being lost while resolving |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
704 |
public content-divergence""" |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
705 |
|
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
706 |
# needtowarn: aspects where we need to warn user |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
707 |
needtowarn = [b'branch', b'topic', b'close'] |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
708 |
aspects = set() |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
709 |
localextra = local.extra() |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
710 |
otherextra = other.extra() |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
711 |
|
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
712 |
for asp in needtowarn: |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
713 |
otherasp = otherextra.get(asp) |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
714 |
localasp = localextra.get(asp) |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
715 |
if otherasp and otherasp != localasp: |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
716 |
aspects.add(asp) |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
717 |
|
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
718 |
if other.description() != local.description(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
719 |
aspects.add(b'description') |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
720 |
|
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
721 |
if aspects: |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
722 |
# warn user |
4747
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
723 |
locstr = bytes(local) |
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
724 |
othstr = bytes(other) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
725 |
if b'close' in aspects: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
726 |
filteredasp = aspects - {b'close'} |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
727 |
if filteredasp: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
728 |
msg = _(b'other divergent changeset %s is a closed branch head ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
729 |
b'and differs from local %s by "%s" only,' % |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
730 |
(othstr, locstr, b', '.join(sorted(filteredasp)))) |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
731 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
732 |
msg = _(b'other divergent changeset %s is a closed branch head ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
733 |
b'and has same content as local %s,' % (othstr, locstr)) |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
734 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
735 |
msg = _(b'other divergent changeset %s has same content as local %s' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
736 |
b' and differs by "%s" only,' % |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
737 |
(othstr, locstr, b', '.join(sorted(aspects)))) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
738 |
msg += _(b' discarding %s\n' % othstr) |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
739 |
repo.ui.warn(msg) |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
740 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
741 |
def bypassphase(repo, relation, flag=0, metadata=None, operation=b'evolve'): |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
742 |
"""function to create a single obsmarker relation even for public csets |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
743 |
where relation should be a single pair (prec, succ)""" |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
744 |
|
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
745 |
# prepare metadata |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
746 |
if metadata is None: |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
747 |
metadata = {} |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
748 |
if b'user' not in metadata: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
749 |
luser = repo.ui.config(b'devel', b'user.obsmarker') or repo.ui.username() |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
750 |
metadata[b'user'] = encoding.fromlocal(luser) |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
751 |
# Operation metadata handling |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
752 |
useoperation = repo.ui.configbool(b'experimental', |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
753 |
b'evolution.track-operation') |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
754 |
if useoperation and operation: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
755 |
metadata[b'operation'] = operation |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
756 |
|
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
757 |
# Effect flag metadata handling |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
758 |
saveeffectflag = repo.ui.configbool(b'experimental', |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
759 |
b'evolution.effect-flags') |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
760 |
with repo.transaction(b'add-obsolescence-marker') as tr: |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
761 |
prec, succ = relation |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
762 |
nprec = prec.node() |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
763 |
npare = None |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
764 |
nsucs = [succ.node()] |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
765 |
if not nsucs: |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
766 |
npare = tuple(p.node() for p in prec.parents()) |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
767 |
if nprec in nsucs: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
768 |
raise error.Abort(_(b"changeset %s cannot obsolete itself") % prec) |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
769 |
|
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
770 |
if saveeffectflag: |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
771 |
# The effect flag is saved in a versioned field name for |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
772 |
# future evolution |
4431
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
773 |
try: |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
774 |
effectflag = obsutil.geteffectflag(prec, (succ,)) |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
775 |
except TypeError: |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
776 |
# hg <= 4.7 |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
777 |
effectflag = obsutil.geteffectflag((prec, (succ,))) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
778 |
metadata[obsutil.EFFECTFLAGFIELD] = b"%d" % effectflag |
4382
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
779 |
|
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
780 |
# create markers |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
781 |
repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare, |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
782 |
metadata=metadata, ui=repo.ui) |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
783 |
repo.filteredrevcache.clear() |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
784 |
|
3847
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
785 |
def dirstatedance(repo, oldparent, newparent, match): |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
786 |
"""utility function to fix the dirstate when we change parents from |
4427
9e2ee7dc5e34
evolve: fix a typo from directory to dirty
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4426
diff
changeset
|
787 |
oldparent to newparent with a dirty working directory using |
3847
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
788 |
repo.dirstate.setparents() |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
789 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
790 |
Lets refer oldparent as Pold |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
791 |
newparent as Pnew |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
792 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
793 |
Now when we are on oldparent with a dirty working directory, there are three |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
794 |
types of files which we are concerned about. They are files having modified, |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
795 |
added and removed status. |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
796 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
797 |
Lets refer modified files as Fm |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
798 |
added files as Fa |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
799 |
removed files as Fr |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
800 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
801 |
Now, between Pold and Pnew, files can be modified, files can be added, files |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
802 |
can be removed. |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
803 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
804 |
Lets refer modification of a file between Pold to Pnew as Cm |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
805 |
addition of a file between Pold to Pnew as Ca |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
806 |
removal of a file between Pold to Pnew as Cr |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
807 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
808 |
Now let's play combinations and permutations: |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
809 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
810 |
|---------------------------------------------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
811 |
| Type of file | Changes between | End status with Pnew as | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
812 |
| in wdir | Pold -> Pnew | wdir parent | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
813 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
814 |
| | | | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
815 |
| Fm | Cm | Modified or clean | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
816 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
817 |
| Fm | Cr | Added | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
818 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
819 |
| Fm | Ca | Not possible (1) | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
820 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
821 |
| Fa | Ca | Modified or clean | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
822 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
823 |
| Fa | Cm | Not possible (2) | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
824 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
825 |
| Fa | Cr | Not possible (2) | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
826 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
827 |
| Fr | Cr | File should be untracked (3)| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
828 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
829 |
| Fr | Ca | Not possible (4) | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
830 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
831 |
| Fr | Cm | Removed | |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
832 |
|--------------|------------------|-----------------------------| |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
833 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
834 |
(1): File is modified in wdir, it means file was present in Pold, so |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
835 |
addition of that file between Pold to Pnew is not possible |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
836 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
837 |
(2): File was added in wdir, it means file was not present in Pold, so |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
838 |
deletion or modification of that file from Pold to Pnew is not possible |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
839 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
840 |
(3): File should be dropped from the dirstate, Pnew has it removed, so no |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
841 |
need to mark that removed again |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
842 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
843 |
(4): File was removed in wdir, it means file was present in Pold, so |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
844 |
addition of that file between Pold to Pnew is not possible |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
845 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
846 |
""" |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
847 |
|
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
848 |
# falling back to an existing function, in future we should have logic in |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
849 |
# this function only |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
850 |
cmdrewrite._uncommitdirstate(repo, oldparent, match, True) |
8bad32e1e6c1
evolve: introduce a dirstatedance() fn to fix dirstate after parent change
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3846
diff
changeset
|
851 |
|
3879
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
852 |
def mergehook(repo, base, divergent, other): |
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
853 |
"""function which extensions can wrap and merge data introduced by them |
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
854 |
while resolving content-divergence""" |
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
855 |
pass |
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
856 |
|
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
857 |
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
|
858 |
"""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
|
859 |
the dirstate branch accordingly |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
860 |
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
|
861 |
|
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
862 |
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
|
863 |
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
|
864 |
""" |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
865 |
divbranch = divergent.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
866 |
basebranch = base.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
867 |
othbranch = other.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
868 |
# 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
|
869 |
# select one |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
870 |
if divbranch != othbranch: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
871 |
|
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
872 |
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
|
873 |
# 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
|
874 |
# preserved |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
875 |
pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
876 |
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
|
877 |
repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
878 |
else: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
879 |
# all the three branches are different |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
880 |
index = repo.ui.promptchoice(_(b"content divergent changesets on " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
881 |
b"different branches.\nchoose branch" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
882 |
b" for the resolution changeset. (a) " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
883 |
b"%s or (b) %s or (c) %s? $$ &a $$ &b" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
884 |
b" $$ &c") % |
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
885 |
(basebranch, divbranch, othbranch), 0) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
886 |
|
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
887 |
if index == 0: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
888 |
repo.dirstate.setbranch(basebranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
889 |
elif index == 1: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
890 |
pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
891 |
elif index == 2: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
892 |
repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
893 |
|
3878
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
894 |
def mergecommitmessages(ui, basedesc, divdesc, othdesc): |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
895 |
"""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
|
896 |
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
|
897 |
|
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
898 |
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
|
899 |
mdesc = [] |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
900 |
kwargs = {} |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
901 |
kwargs['name_base'] = b'base' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
902 |
kwargs['base_marker'] = b'|||||||' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
903 |
for line in merger.merge_lines(name_a=b'divergent', name_b=b'other', |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
904 |
**kwargs): |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
905 |
mdesc.append(line) |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
906 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
907 |
desc = b''.join(mdesc) |
3878
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
908 |
if merger.conflicts: |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
909 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
910 |
prefixes = (b"HG: Conflicts while merging changeset description of" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
911 |
b" content-divergent changesets.\nHG: Resolve conflicts" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
912 |
b" in commit messages to continue.\n\n") |
3878
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
913 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
914 |
resolveddesc = ui.edit(prefixes + desc, ui.username(), action=b'desc') |
3878
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
915 |
# make sure we remove the prefixes part from final commit message |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
916 |
if prefixes in resolveddesc: |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
917 |
# hack, we should find something better |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
918 |
resolveddesc = resolveddesc[len(prefixes):] |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
919 |
desc = resolveddesc |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
920 |
|
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
921 |
return desc |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
922 |
|
3469
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
923 |
def _orderrevs(repo, revs): |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
924 |
"""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
|
925 |
|
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
926 |
revs is a list of unstable revisions. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
927 |
|
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
928 |
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
|
929 |
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
|
930 |
eventually. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
931 |
|
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
932 |
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
|
933 |
revision on its final stabilized destination. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
934 |
""" |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
935 |
# Step 1: Build the dependency graph |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
936 |
dependencies, rdependencies = utility.builddependencies(repo, revs) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
937 |
# Step 2: Build the ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
938 |
# 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
|
939 |
# 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
|
940 |
# 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
|
941 |
# 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
|
942 |
# built |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
943 |
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
|
944 |
if not dependencies[r]]) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
945 |
ordering = [] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
946 |
while solvablerevs: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
947 |
rev = solvablerevs.popleft() |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
948 |
for dependent in rdependencies[rev]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
949 |
dependencies[dependent].remove(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
950 |
if not dependencies[dependent]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
951 |
solvablerevs.append(dependent) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
952 |
del dependencies[rev] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
953 |
ordering.append(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
954 |
|
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
955 |
ordering.extend(sorted(dependencies)) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
956 |
return ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
957 |
|
3638
7bc4a72b8a0b
evolve: add evolvestate as an argument to evolvecmd.relocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3636
diff
changeset
|
958 |
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
|
959 |
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
|
960 |
"""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
|
961 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
962 |
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
|
963 |
""" |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
964 |
if orig.rev() == dest.rev(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
965 |
msg = _(b'tried to relocate a node on top of itself') |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
966 |
hint = _(b"This shouldn't happen. If you still need to move changesets, " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
967 |
b"please do so manually with nothing to rebase - working " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
968 |
b"directory parent is also destination") |
4269
d2599da04bb5
evolve: update the abort to a ProgrammingError
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4265
diff
changeset
|
969 |
raise error.ProgrammingError(msg, hint=hint) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
970 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
971 |
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
|
972 |
if len(orig.parents()) == 2: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
973 |
msg = _(b"tried to relocate a merge commit without specifying which " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
974 |
b"parent should be moved") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
975 |
hint = _(b"Specify the parent by passing in pctx") |
4269
d2599da04bb5
evolve: update the abort to a ProgrammingError
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4265
diff
changeset
|
976 |
raise error.ProgrammingError(msg, hint) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
977 |
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
|
978 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
979 |
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
|
980 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
981 |
cache = {} |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
982 |
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
|
983 |
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
|
984 |
for sha1 in sha1s: |
3676
cded30ad25e4
compat: rename resolvepartialhexnodeid to resolvehexnodeidprefix
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3674
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
else: |
51adc7e6a617
compat: fallback to compatible partial lookup prior to 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3666
diff
changeset
|
988 |
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
|
989 |
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
|
990 |
continue |
3665
0f0f31351d6d
compat: avoid using partial node ID in lookup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3653
diff
changeset
|
991 |
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
|
992 |
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
|
993 |
continue |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
994 |
|
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
995 |
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
|
996 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
997 |
# 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
|
998 |
# 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
|
999 |
if len(successors) == 1 and len(successors[0]) == 1: |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
1000 |
newsha1 = nodemod.hex(successors[0][0]) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1001 |
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
|
1002 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1003 |
repo.ui.note(_(b'The stale commit message reference to %s could ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1004 |
b'not be updated\n') % sha1) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1005 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1006 |
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
|
1007 |
assert tr is not None |
4590
784ad6f60571
evolve: don't use exception for local flow control
Martin von Zweigbergk <martinvonz@google.com>
parents:
4589
diff
changeset
|
1008 |
r = _evolvemerge(repo, orig, dest, pctx, keepbranch) |
784ad6f60571
evolve: don't use exception for local flow control
Martin von Zweigbergk <martinvonz@google.com>
parents:
4589
diff
changeset
|
1009 |
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
|
1010 |
with repo.dirstate.parentchange(): |
3978
fb8e44c70798
evolve: set the second parent if we get conflicts while evolving
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3977
diff
changeset
|
1011 |
repo.setparents(dest.node(), orig.node()) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1012 |
repo.dirstate.write(tr) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1013 |
hint = _(b"see 'hg help evolve.interrupted'") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1014 |
raise error.InterventionRequired(_(b"unresolved merge conflicts"), |
4676
b6c819facbe8
evolvecmd: the proper way to deal with conflicts is to resolve them
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
1015 |
hint=hint) |
4590
784ad6f60571
evolve: don't use exception for local flow control
Martin von Zweigbergk <martinvonz@google.com>
parents:
4589
diff
changeset
|
1016 |
nodenew = _relocatecommit(repo, orig, commitmsg) |
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
1017 |
_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
|
1018 |
return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1019 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1020 |
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
|
1021 |
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
|
1022 |
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
|
1023 |
extra = dict(orig.extra()) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1024 |
if b'branch' in extra: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1025 |
del extra[b'branch'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1026 |
extra[b'rebase_source'] = orig.hex() |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1027 |
|
5006
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1028 |
targetphase = max(orig.phase(), phases.draft) |
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1029 |
configoverride = repo.ui.configoverride({ |
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1030 |
(b'phases', b'new-commit'): targetphase |
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1031 |
}, source=b'evolve') |
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1032 |
with configoverride: |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1033 |
# Commit might fail if unresolved files exist |
5006
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1034 |
return repo.commit(text=commitmsg, user=orig.user(), |
93014d9726d5
evolve: use ui.configoverride() instead of ui.backupconfig()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5005
diff
changeset
|
1035 |
date=orig.date(), extra=extra) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1036 |
|
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
1037 |
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
|
1038 |
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
|
1039 |
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
|
1040 |
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
|
1041 |
bmchanges = [] |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1042 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1043 |
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
|
1044 |
obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))], |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1045 |
operation=b'evolve') |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1046 |
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
|
1047 |
bmchanges.append((book, nodenew)) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1048 |
evolvestate[b'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
|
1049 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1050 |
if category == b'orphan': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1051 |
repo.ui.status(_(b"evolution of %d:%s created no changes " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1052 |
b"to commit\n") % (orig.rev(), orig)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1053 |
obsolete.createmarkers(repo, [(repo[nodesrc], ())], operation=b'evolve') |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1054 |
# 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
|
1055 |
for book in oldbookmarks: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1056 |
evolvestate[b'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
|
1057 |
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
|
1058 |
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
|
1059 |
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
|
1060 |
if bmchanges: |
3699
67d6cc7e0979
compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3698
diff
changeset
|
1061 |
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
|
1062 |
|
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1063 |
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
|
1064 |
"""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
|
1065 |
return the same tuple as merge.graft""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1066 |
if repo[b'.'].rev() != dest.rev(): |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1067 |
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
|
1068 |
dest, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1069 |
branchmerge=False, |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1070 |
force=True) |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1071 |
if repo._activebookmark: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1072 |
repo.ui.status(_(b"(leaving bookmark %s)\n") % repo._activebookmark) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1073 |
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
|
1074 |
if keepbranch: |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1075 |
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
|
1076 |
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
|
1077 |
# uurrgs |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1078 |
# there no other topic setter yet |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1079 |
if not orig.topic() and repo.vfs.exists(b'topic'): |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1080 |
repo.vfs.unlink(b'topic') |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1081 |
else: |
4812
67567d7f1174
python3: enforce byte prefix for vfs.open()
Raphaël Gomès <rgomes@octobus.net>
parents:
4807
diff
changeset
|
1082 |
with repo.vfs.open(b'topic', b'w') as f: |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1083 |
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
|
1084 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1085 |
return merge.graft(repo, orig, pctx, [b'destination', b'evolving'], True) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1086 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1087 |
instabilities_map = { |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1088 |
b'contentdivergent': b"content-divergent", |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1089 |
b'phasedivergent': b"phase-divergent" |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1090 |
} |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1091 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1092 |
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
|
1093 |
"""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
|
1094 |
revs = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1095 |
if allopt or revopt: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1096 |
revs = repo.revs(b"%s()" % targetcat) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1097 |
if revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1098 |
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
|
1099 |
elif not anyopt: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1100 |
topic = getattr(repo, 'currenttopic', b'') |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1101 |
if topic: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1102 |
revs = repo.revs(b'topic(%s)', topic) & revs |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1103 |
elif targetcat == b'orphan': |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1104 |
revs = _aspiringdescendant(repo, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1105 |
repo.revs(b'(.::) - obsolete()::')) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1106 |
revs = set(revs) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1107 |
if targetcat == b'contentdivergent': |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1108 |
# 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
|
1109 |
revs = _dedupedivergents(repo, revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1110 |
elif anyopt: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1111 |
revs = repo.revs(b'first(%s())' % (targetcat)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1112 |
elif targetcat == b'orphan': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1113 |
revs = set(_aspiringchildren(repo, repo.revs(b'(.::) - obsolete()::'))) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1114 |
if 1 < len(revs): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1115 |
msg = b"multiple evolve candidates" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1116 |
hint = (_(b"select one of %s with --rev") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1117 |
% b', '.join([bytes(repo[r]) for r in sorted(revs)])) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1118 |
raise error.Abort(msg, hint=hint) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1119 |
elif instabilities_map.get(targetcat, targetcat) in repo[b'.'].instabilities(): |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1120 |
revs = set([repo[b'.'].rev()]) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1121 |
return revs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1122 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1123 |
def _dedupedivergents(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1124 |
"""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
|
1125 |
lowest revision numbers |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1126 |
""" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1127 |
repo = repo.unfiltered() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1128 |
res = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1129 |
# 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
|
1130 |
discarded = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1131 |
for rev in revs: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1132 |
if rev in discarded: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1133 |
continue |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1134 |
divergent = repo[rev] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1135 |
base, others = divergentdata(divergent) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1136 |
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
|
1137 |
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
|
1138 |
discarded.update(othersrevs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1139 |
return res |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1140 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1141 |
def divergentdata(ctx): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1142 |
"""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
|
1143 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1144 |
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
|
1145 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1146 |
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
|
1147 |
""" |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1148 |
repo = ctx._repo.unfiltered() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1149 |
for base in repo.set(b'reverse(allpredecessors(%d))', ctx.rev()): |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
1150 |
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
|
1151 |
# 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
|
1152 |
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
|
1153 |
if newer: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1154 |
return base, tuple(ctx._repo[o] for o in newer[0]) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1155 |
raise error.Abort(_(b"base of divergent changeset %s not found") % ctx, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1156 |
hint=_(b'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
|
1157 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1158 |
def _aspiringdescendant(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1159 |
"""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
|
1160 |
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
|
1161 |
target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1162 |
result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1163 |
paths = collections.defaultdict(set) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1164 |
for r in repo.revs(b'orphan() - %ld', revs): |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1165 |
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
|
1166 |
paths[d].add(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1167 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1168 |
result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1169 |
tovisit = list(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1170 |
while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1171 |
base = tovisit.pop() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1172 |
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
|
1173 |
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
|
1174 |
tovisit.append(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1175 |
result.add(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1176 |
return sorted(result - target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1177 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1178 |
def _aspiringchildren(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1179 |
"""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
|
1180 |
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
|
1181 |
target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1182 |
result = [] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1183 |
for r in repo.revs(b'orphan() - %ld', revs): |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1184 |
dest = _possibledestination(repo, r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1185 |
if target & dest: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1186 |
result.append(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1187 |
return result |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1188 |
|
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1189 |
def _possibledestination(repo, rev): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1190 |
"""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
|
1191 |
tonode = repo.changelog.node |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1192 |
parents = repo.changelog.parentrevs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1193 |
torev = repo.changelog.rev |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1194 |
dest = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1195 |
tovisit = list(parents(rev)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1196 |
while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1197 |
r = tovisit.pop() |
4230
e796835fe6b3
evolvecmd: _possibledestination() skip visiting empty parent
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4209
diff
changeset
|
1198 |
if r == -1: |
e796835fe6b3
evolvecmd: _possibledestination() skip visiting empty parent
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4209
diff
changeset
|
1199 |
continue |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
1200 |
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
|
1201 |
if not succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1202 |
tovisit.extend(parents(r)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1203 |
else: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1204 |
# 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
|
1205 |
# (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
|
1206 |
# 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
|
1207 |
# multiple branches. |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1208 |
for ss in succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1209 |
for n in ss: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1210 |
dest.add(torev(n)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1211 |
return dest |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1212 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1213 |
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
|
1214 |
"""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
|
1215 |
no troubles can be resolved""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1216 |
troublecategories = [b'phasedivergent', b'contentdivergent', b'orphan'] |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1217 |
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
|
1218 |
msg = None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1219 |
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
|
1220 |
retoverride = None |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1221 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1222 |
troubled = { |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1223 |
b"orphan": repo.revs(b"orphan()"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1224 |
b"contentdivergent": repo.revs(b"contentdivergent()"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1225 |
b"phasedivergent": repo.revs(b"phasedivergent()"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1226 |
b"all": repo.revs(b"unstable()"), |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1227 |
} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1228 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1229 |
hintmap = { |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1230 |
b'phasedivergent': _(b"do you want to use --phase-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1231 |
b'phasedivergent+contentdivergent': _(b"do you want to use " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1232 |
b"--phase-divergent or" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1233 |
b" --content-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1234 |
b'phasedivergent+orphan': _(b"do you want to use --phase-divergent" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1235 |
b" or --orphan"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1236 |
b'contentdivergent': _(b"do you want to use --content-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1237 |
b'contentdivergent+orphan': _(b"do you want to use --content-divergent" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1238 |
b" or --orphan"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1239 |
b'orphan': _(b"do you want to use --orphan"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1240 |
b'any+phasedivergent': _(b"do you want to use --any (or --rev) and" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1241 |
b" --phase-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1242 |
b'any+phasedivergent+contentdivergent': _(b"do you want to use --any" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1243 |
b" (or --rev) and" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1244 |
b" --phase-divergent or" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1245 |
b" --content-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1246 |
b'any+phasedivergent+orphan': _(b"do you want to use --any (or --rev)" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1247 |
b" and --phase-divergent or --orphan"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1248 |
b'any+contentdivergent': _(b"do you want to use --any (or --rev) and" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1249 |
b" --content-divergent"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1250 |
b'any+contentdivergent+orphan': _(b"do you want to use --any (or --rev)" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1251 |
b" and --content-divergent or " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1252 |
b"--orphan"), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1253 |
b'any+orphan': _(b"do you want to use --any (or --rev)" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1254 |
b"and --orphan"), |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1255 |
} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1256 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1257 |
if revopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1258 |
revs = scmutil.revrange(repo, revopt) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1259 |
if not revs: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1260 |
msg = _(b"set of specified revisions is empty") |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1261 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1262 |
msg = _(b"no %s changesets in specified revisions") % targetcat |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1263 |
othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1264 |
for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1265 |
if revs & troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1266 |
othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1267 |
if othertroubles: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1268 |
hint = hintmap[b'+'.join(othertroubles)] |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1269 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1270 |
elif anyopt: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1271 |
msg = _(b"no %s changesets to evolve") % targetcat |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1272 |
othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1273 |
for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1274 |
if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1275 |
othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1276 |
if othertroubles: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1277 |
hint = hintmap[b'+'.join(othertroubles)] |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1278 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1279 |
else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1280 |
# evolve without any option = relative to the current wdir |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1281 |
if targetcat == b'orphan': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1282 |
msg = _(b"nothing to evolve on current working copy parent") |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1283 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1284 |
msg = _(b"current working copy parent is not %s") % targetcat |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1285 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1286 |
p1 = repo[b'.'].rev() |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1287 |
othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1288 |
for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1289 |
if p1 in troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1290 |
othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1291 |
if othertroubles: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1292 |
hint = hintmap[b'+'.join(othertroubles)] |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1293 |
else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1294 |
length = len(troubled[targetcat]) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1295 |
if length: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1296 |
hint = _(b"%d other %s in the repository, do you want --any " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1297 |
b"or --rev") % (length, targetcat) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1298 |
else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1299 |
othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1300 |
for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1301 |
if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1302 |
othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1303 |
if othertroubles: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1304 |
hint = hintmap[b'any+' + (b'+'.join(othertroubles))] |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1305 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1306 |
msg = _(b"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
|
1307 |
# 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
|
1308 |
retoverride = 0 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1309 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1310 |
assert msg is not None |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1311 |
ui.write_err(b"%s\n" % msg) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1312 |
if hint: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1313 |
ui.write_err(b"(%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
|
1314 |
ret = 2 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1315 |
else: |
3649
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1316 |
ret = 1 |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1317 |
|
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1318 |
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
|
1319 |
return retoverride |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1320 |
return ret |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1321 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1322 |
def _preparelistctxs(items, condition): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1323 |
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
|
1324 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1325 |
def _formatctx(fm, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1326 |
fm.data(node=ctx.hex()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1327 |
fm.data(desc=ctx.description()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1328 |
fm.data(date=ctx.date()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1329 |
fm.data(user=ctx.user()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1330 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1331 |
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
|
1332 |
"""Print all the troubles for the repo (or given revset)""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1333 |
troublecategories = troublecategories or [b'contentdivergent', b'orphan', b'phasedivergent'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1334 |
showunstable = b'orphan' in troublecategories |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1335 |
showbumped = b'phasedivergent' in troublecategories |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1336 |
showdivergent = b'contentdivergent' in troublecategories |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1337 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1338 |
revs = repo.revs(b'+'.join(b"%s()" % t for t in troublecategories)) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1339 |
if opts.get('rev'): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1340 |
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
|
1341 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1342 |
fm = ui.formatter(b'evolvelist', pycompat.byteskwargs(opts)) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1343 |
for rev in revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1344 |
ctx = repo[rev] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1345 |
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
|
1346 |
obspars = _preparelistctxs(ctx.parents(), lambda p: p.obsolete()) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1347 |
imprecs = _preparelistctxs(repo.set(b"allpredecessors(%n)", ctx.node()), |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1348 |
lambda p: not p.mutable()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1349 |
dsets = divergentsets(repo, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1350 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1351 |
fm.startitem() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1352 |
# plain formatter section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1353 |
hashlen, desclen = 12, 60 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1354 |
desc = ctx.description() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1355 |
if desc: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1356 |
desc = desc.splitlines()[0] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1357 |
desc = (desc[:desclen] + b'...') if len(desc) > desclen else desc |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1358 |
fm.plain(b'%s: ' % ctx.hex()[:hashlen]) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1359 |
fm.plain(b'%s\n' % desc) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1360 |
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
|
1361 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1362 |
for unpar in unpars if showunstable else []: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1363 |
fm.plain(b' %s: %s (%s parent)\n' % (TROUBLES['ORPHAN'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1364 |
unpar[:hashlen], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1365 |
TROUBLES['ORPHAN'])) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1366 |
for obspar in obspars if showunstable else []: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1367 |
fm.plain(b' %s: %s (obsolete parent)\n' % (TROUBLES['ORPHAN'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1368 |
obspar[:hashlen])) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1369 |
for imprec in imprecs if showbumped else []: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1370 |
fm.plain(b' %s: %s (immutable precursor)\n' % |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1371 |
(TROUBLES['PHASEDIVERGENT'], imprec[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1372 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1373 |
if dsets and showdivergent: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1374 |
for dset in dsets: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1375 |
fm.plain(b' %s: ' % TROUBLES['CONTENTDIVERGENT']) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1376 |
first = True |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1377 |
for n in dset[b'divergentnodes']: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1378 |
t = b"%s (%s)" if first else b" %s (%s)" |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1379 |
first = False |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
1380 |
fm.plain(t % (nodemod.hex(n)[:hashlen], repo[n].phasestr())) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1381 |
comprec = nodemod.hex(dset[b'commonprecursor'])[:hashlen] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1382 |
fm.plain(b" (precursor %s)\n" % comprec) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1383 |
fm.plain(b"\n") |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1384 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1385 |
# templater-friendly section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1386 |
_formatctx(fm, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1387 |
troubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1388 |
for unpar in unpars: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1389 |
troubles.append({b'troubletype': TROUBLES['ORPHAN'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1390 |
b'sourcenode': unpar, b'sourcetype': b'orphanparent'}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1391 |
for obspar in obspars: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1392 |
troubles.append({b'troubletype': TROUBLES['ORPHAN'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1393 |
b'sourcenode': obspar, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1394 |
b'sourcetype': b'obsoleteparent'}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1395 |
for imprec in imprecs: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1396 |
troubles.append({b'troubletype': TROUBLES['PHASEDIVERGENT'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1397 |
b'sourcenode': imprec, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1398 |
b'sourcetype': b'immutableprecursor'}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1399 |
for dset in dsets: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1400 |
divnodes = [{b'node': nodemod.hex(n), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1401 |
b'phase': repo[n].phasestr(), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1402 |
} for n in dset[b'divergentnodes']] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1403 |
troubles.append({b'troubletype': TROUBLES['CONTENTDIVERGENT'], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1404 |
b'commonprecursor': nodemod.hex(dset[b'commonprecursor']), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1405 |
b'divergentnodes': divnodes}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1406 |
fm.data(troubles=troubles) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1407 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1408 |
fm.end() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1409 |
|
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1410 |
def _checkevolveopts(repo, opts): |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1411 |
""" 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
|
1412 |
if any """ |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1413 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1414 |
if opts['continue']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1415 |
if opts['any']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1416 |
raise error.Abort(_(b'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
|
1417 |
if opts['all']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1418 |
raise error.Abort(_(b'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
|
1419 |
if opts['rev']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1420 |
raise error.Abort(_(b'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
|
1421 |
if opts['stop']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1422 |
raise error.Abort(_(b'cannot specify both "--stop" and' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1423 |
b' "--continue"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1424 |
if opts['abort']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1425 |
raise error.Abort(_(b'cannot specify both "--abort" and' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1426 |
b' "--continue"')) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1427 |
|
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1428 |
if opts['stop']: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1429 |
if opts['any']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1430 |
raise error.Abort(_(b'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
|
1431 |
if opts['all']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1432 |
raise error.Abort(_(b'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
|
1433 |
if opts['rev']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1434 |
raise error.Abort(_(b'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
|
1435 |
if opts['abort']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1436 |
raise error.Abort(_(b'cannot specify both "--abort" and "--stop"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1437 |
|
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1438 |
if opts['abort']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1439 |
if opts['any']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1440 |
raise error.Abort(_(b'cannot specify both "--any" and "--abort"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1441 |
if opts['all']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1442 |
raise error.Abort(_(b'cannot specify both "--all" and "--abort"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1443 |
if opts['rev']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1444 |
raise error.Abort(_(b'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
|
1445 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1446 |
if opts['rev']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1447 |
if opts['any']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1448 |
raise error.Abort(_(b'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
|
1449 |
if opts['all']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1450 |
raise error.Abort(_(b'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
|
1451 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1452 |
# Backward compatibility |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1453 |
if opts['unstable']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1454 |
msg = (b"'evolve --unstable' is deprecated, " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1455 |
b"use 'evolve --orphan'") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1456 |
repo.ui.deprecwarn(msg, b'4.4') |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1457 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1458 |
opts['orphan'] = opts['divergent'] |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1459 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1460 |
if opts['divergent']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1461 |
msg = (b"'evolve --divergent' is deprecated, " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1462 |
b"use 'evolve --content-divergent'") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1463 |
repo.ui.deprecwarn(msg, b'4.4') |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1464 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1465 |
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
|
1466 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1467 |
if opts['bumped']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1468 |
msg = (b"'evolve --bumped' is deprecated, " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1469 |
b"use 'evolve --phase-divergent'") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1470 |
repo.ui.deprecwarn(msg, b'4.4') |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1471 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1472 |
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
|
1473 |
|
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1474 |
return opts |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1475 |
|
4601
e5aa1e23d146
evolve: move progress-clearing out of _cleanup()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4600
diff
changeset
|
1476 |
def _cleanup(ui, repo, startnode, shouldupdate): |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1477 |
if not shouldupdate: |
4377
c2f9de28415a
evolve: document the "if not shouldupdate" block
Martin von Zweigbergk <martinvonz@google.com>
parents:
4376
diff
changeset
|
1478 |
# Move back to startnode, or to its successor if the start node is |
c2f9de28415a
evolve: document the "if not shouldupdate" block
Martin von Zweigbergk <martinvonz@google.com>
parents:
4376
diff
changeset
|
1479 |
# obsolete (perhaps made obsolete by the current `hg evolve`) |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1480 |
unfi = repo.unfiltered() |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1481 |
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
|
1482 |
hg.updaterepo(repo, repo[succ].node(), False) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1483 |
if repo[b'.'].node() != startnode: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1484 |
ui.status(_(b'working directory is now at %s\n') % repo[b'.']) |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1485 |
|
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1486 |
def divergentsets(repo, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1487 |
"""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
|
1488 |
cache = {} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1489 |
base = {} |
4258
697ec7c2f325
compat: drop 4.3 compatiblity code for `obsutil.allprecursors` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4257
diff
changeset
|
1490 |
for n in obsutil.allpredecessors(repo.obsstore, [ctx.node()]): |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1491 |
if n == ctx.node(): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1492 |
# 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
|
1493 |
continue |
3697
6aff4bb3970d
compat: drop compatibility layer for successorssets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3694
diff
changeset
|
1494 |
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
|
1495 |
for nsuccset in nsuccsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1496 |
if ctx.node() in nsuccset: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1497 |
# 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
|
1498 |
continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1499 |
if tuple(nsuccset) in base: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1500 |
# 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
|
1501 |
continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1502 |
base[tuple(nsuccset)] = n |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1503 |
divergence = [] |
4714
c51fc0ae7a7e
py3: switch from iteritems() to items()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4706
diff
changeset
|
1504 |
for divset, b in base.items(): |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1505 |
divergence.append({ |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1506 |
b'divergentnodes': divset, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1507 |
b'commonprecursor': b |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1508 |
}) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1509 |
|
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1510 |
return divergence |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1511 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1512 |
@eh.command( |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1513 |
b'evolve|stabilize|solve', |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1514 |
[(b'n', b'dry-run', False, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1515 |
_(b'do not perform actions, just print what would be done')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1516 |
(b'', b'confirm', False, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1517 |
_(b'ask for confirmation before performing the action')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1518 |
(b'A', b'any', False, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1519 |
_(b'also consider troubled changesets unrelated to current working ' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1520 |
b'directory')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1521 |
(b'r', b'rev', [], _(b'solves troubles of these revisions'), _(b'REV')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1522 |
(b'', b'bumped', False, _(b'solves only bumped changesets (DEPRECATED)')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1523 |
(b'', b'phase-divergent', False, _(b'solves only phase-divergent changesets')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1524 |
(b'', b'divergent', False, _(b'solves only divergent changesets (DEPRECATED)')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1525 |
(b'', b'content-divergent', False, _(b'solves only content-divergent changesets')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1526 |
(b'', b'unstable', False, _(b'solves only unstable changesets (DEPRECATED)')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1527 |
(b'', b'orphan', False, _(b'solves only orphan changesets (default)')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1528 |
(b'a', b'all', None, _(b'evolve all troubled changesets related to the current' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1529 |
b' working directory and its descendants (default)')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1530 |
(b'', b'update', False, _(b'update to the head of evolved changesets')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1531 |
(b'c', b'continue', False, _(b'continue an interrupted evolution')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1532 |
(b'', b'stop', False, _(b'stop the interrupted evolution')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1533 |
(b'', b'abort', False, _(b'abort the interrupted evolution')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1534 |
(b'l', b'list', False, _(b'provide details on troubled changesets' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1535 |
b' in the repo')), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1536 |
] + mergetoolopts, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1537 |
_(b'[OPTIONS]...'), |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4857
diff
changeset
|
1538 |
helpbasic=True, |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4857
diff
changeset
|
1539 |
**compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1540 |
) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1541 |
def evolve(ui, repo, **opts): |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1542 |
"""solve troubled changesets in your repository |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1543 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1544 |
Modifying history can lead to various types of troubled changesets: |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1545 |
orphan, phase-divergent, or content-divergent. The evolve command resolves |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1546 |
your troubles by executing one of the following actions: |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1547 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1548 |
- update working copy to a successor |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1549 |
- rebase an orphan changeset |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1550 |
- extract the desired changes from a phase-divergent changeset |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1551 |
- fuse content-divergent changesets back together |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1552 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1553 |
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
|
1554 |
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
|
1555 |
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
|
1556 |
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
|
1557 |
copy parent is not obsolete but has obsolete predecessors, then evolve |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1558 |
determines if there is an orphan changeset that can be rebased onto the |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1559 |
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
|
1560 |
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
|
1561 |
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
|
1562 |
|
4751
d0965c5c5335
evolve: further clarify when update is performed
kevpeng@google.com
parents:
4708
diff
changeset
|
1563 |
When ``--update`` is used, successful evolve operations update the working |
d0965c5c5335
evolve: further clarify when update is performed
kevpeng@google.com
parents:
4708
diff
changeset
|
1564 |
directory to the newly created changesets. Moreover, an update will always |
d0965c5c5335
evolve: further clarify when update is performed
kevpeng@google.com
parents:
4708
diff
changeset
|
1565 |
be performed if the current working directory parent is obsolete. |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1566 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1567 |
Automatic mode only handles common use cases. For example, it avoids taking |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1568 |
action in the case of ambiguity, and it ignores orphan changesets that are |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1569 |
not related to your working copy. |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1570 |
It also refuses to solve phase-divergent or content-divergent changesets |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1571 |
unless you explicitly request such behavior (see below). |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1572 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1573 |
Eliminating all instability around your working copy may require multiple |
4605
f8790714b741
evolve: mention that --all is the default behavior now
Anton Shestakov <av6@dwimlabs.net>
parents:
4604
diff
changeset
|
1574 |
invocations of :hg:`evolve` if you use ``--rev`` or ``--no-all``. Use |
f8790714b741
evolve: mention that --all is the default behavior now
Anton Shestakov <av6@dwimlabs.net>
parents:
4604
diff
changeset
|
1575 |
``--all`` (which is the default behavior) to recursively select and evolve |
f8790714b741
evolve: mention that --all is the default behavior now
Anton Shestakov <av6@dwimlabs.net>
parents:
4604
diff
changeset
|
1576 |
all orphan changesets that can be rebased onto the working copy parent. |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1577 |
This is more powerful than successive invocations, since ``--all`` handles |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1578 |
ambiguous cases (e.g. orphan changesets with multiple children) by evolving |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1579 |
all branches. |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1580 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1581 |
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
|
1582 |
use ``--rev`` to specify a changeset to evolve. For example, if you have |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1583 |
an orphan changeset that is not related to the working copy parent, |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1584 |
you could use ``--rev`` to evolve it. Or, if some changeset has multiple |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1585 |
orphan children, evolve in automatic mode refuses to guess which one to |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1586 |
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
|
1587 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1588 |
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
|
1589 |
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
|
1590 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1591 |
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
|
1592 |
in a single invocation. In revset terms, ``--any`` is equivalent to ``--rev |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1593 |
first(orphan())``. ``--rev`` and ``--all`` are mutually exclusive, as are |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1594 |
``--rev`` and ``--any``. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1595 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1596 |
``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
|
1597 |
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
|
1598 |
|
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1599 |
When you have troubled changesets that are not orphan, :hg:`evolve` refuses |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1600 |
to consider them unless you specify the category of trouble you |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1601 |
wish to resolve, with ``--phase-divergent`` or ``--content-divergent``. |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1602 |
These options are currently mutually exclusive with each other and with |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1603 |
``--orphan`` (the default). You can combine ``--phase-divergent`` or |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1604 |
``--content-divergent`` with ``--rev``, ``--all``, or ``--any``. |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1605 |
|
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1606 |
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
|
1607 |
repository by using the --list flag. You can choose to display only some |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1608 |
categories of troubles with the --orphan, --content-divergent or |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1609 |
--phase-divergent flags. |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1610 |
|
3821
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1611 |
Interrupted |
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1612 |
=========== |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1613 |
|
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1614 |
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
|
1615 |
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
|
1616 |
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
|
1617 |
`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
|
1618 |
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
|
1619 |
situation: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1620 |
|
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1621 |
- `hg evolve --continue`: |
4676
b6c819facbe8
evolvecmd: the proper way to deal with conflicts is to resolve them
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
1622 |
resolve all the conflicts using `hg resolve` and then run this to |
b6c819facbe8
evolvecmd: the proper way to deal with conflicts is to resolve them
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
1623 |
continue the interrupted evolve |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1624 |
|
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1625 |
- `hg evolve --stop`: |
4265
4d62095d9fe6
evolve: fix a documentation typo
Eric Spishak-Thomas <spishak@google.com>
parents:
4235
diff
changeset
|
1626 |
stops the current interrupted evolve, keeping all the successful steps, |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1627 |
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
|
1628 |
|
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1629 |
- `hg evolve --abort`: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1630 |
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
|
1631 |
happened |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1632 |
""" |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1633 |
with repo.wlock(), repo.lock(): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1634 |
return _performevolve(ui, repo, **opts) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1635 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1636 |
def _performevolve(ui, repo, **opts): |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1637 |
opts = _checkevolveopts(repo, opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1638 |
# Options |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1639 |
contopt = opts['continue'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1640 |
anyopt = opts['any'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1641 |
allopt = opts['all'] |
4580
3ef96578da43
evolve: use --all by default (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
4577
diff
changeset
|
1642 |
if allopt is None: |
3ef96578da43
evolve: use --all by default (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
4577
diff
changeset
|
1643 |
allopt = True |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1644 |
startnode = repo[b'.'].node() |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1645 |
dryrunopt = opts['dry_run'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1646 |
confirmopt = opts['confirm'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1647 |
revopt = opts['rev'] |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1648 |
stopopt = opts['stop'] |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1649 |
abortopt = opts['abort'] |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1650 |
shouldupdate = opts['update'] |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1651 |
|
4762
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1652 |
troublecategories = { |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1653 |
b'phasedivergent': r'phase_divergent', |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1654 |
b'contentdivergent': r'content_divergent', |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1655 |
b'orphan': r'orphan', |
4762
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1656 |
} |
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1657 |
specifiedcategories = [k for k, v in troublecategories.items() if opts[v]] |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1658 |
if opts['list']: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1659 |
ui.pager(b'evolve') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1660 |
listtroubles(ui, repo, specifiedcategories, **opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1661 |
return |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1662 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1663 |
targetcat = b'orphan' |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1664 |
if 1 < len(specifiedcategories): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1665 |
msg = _(b'cannot specify more than one trouble category to solve (yet)') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1666 |
raise error.Abort(msg) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1667 |
elif len(specifiedcategories) == 1: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1668 |
targetcat = specifiedcategories[0] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1669 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1670 |
ui.setconfig(b'ui', b'forcemerge', opts.get('tool', r''), b'evolve') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1671 |
|
3477
713e26a647f5
evolve: create a state object in all case
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3470
diff
changeset
|
1672 |
evolvestate = state.cmdstate(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1673 |
# Continuation handling |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1674 |
if contopt: |
3556
b0438c9101ad
evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3555
diff
changeset
|
1675 |
if not evolvestate: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1676 |
raise error.Abort(_(b'no interrupted evolve to continue')) |
3556
b0438c9101ad
evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3555
diff
changeset
|
1677 |
evolvestate.load() |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
1678 |
continueevolve(ui, repo, evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1679 |
if evolvestate[b'command'] != b'evolve': |
3558
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1680 |
evolvestate.delete() |
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1681 |
return |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1682 |
startnode = repo.unfiltered()[evolvestate[b'startnode']] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1683 |
if b'update' in evolvestate: |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1684 |
shouldupdate = evolvestate[b'update'] |
3557
77a400149758
evolve: move deletion of evolvestate out of continueevolve() function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3556
diff
changeset
|
1685 |
evolvestate.delete() |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1686 |
elif stopopt: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1687 |
if not evolvestate: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1688 |
raise error.Abort(_(b'no interrupted evolve to stop')) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1689 |
evolvestate.load() |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1690 |
stopevolve(ui, repo, evolvestate) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1691 |
evolvestate.delete() |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1692 |
return |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1693 |
elif abortopt: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1694 |
if not evolvestate: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1695 |
raise error.Abort(_(b'no interrupted evolve to abort')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1696 |
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
|
1697 |
# `hg next --evolve` in play |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1698 |
if evolvestate[b'command'] != b'evolve': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1699 |
pctx = repo[b'.'] |
3776
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1700 |
hg.updaterepo(repo, pctx.node(), True) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1701 |
ui.status(_(b'evolve aborted\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1702 |
ui.status(_(b'working directory is now at %s\n') |
3776
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1703 |
% pctx.hex()[:12]) |
3981
b4d0245c7f40
evolve: delete evolvestate after aborting interrupted `next --evolve`
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3978
diff
changeset
|
1704 |
evolvestate.delete() |
3776
2d450974bb1c
evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3707
diff
changeset
|
1705 |
return 0 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1706 |
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
|
1707 |
else: |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1708 |
cmdutil.bailifchanged(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1709 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1710 |
obswdir = repo[b'.'].obsolete() |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1711 |
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
|
1712 |
|
4695
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1713 |
if not (revs or obswdir): |
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1714 |
return _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat) |
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1715 |
obswdironly = not revs and obswdir |
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1716 |
|
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1717 |
if obswdir: |
4348
398c33b17d76
evolve: make sure we don't stop after evolution of obsparent (issue5881)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4347
diff
changeset
|
1718 |
result = solveobswdp(ui, repo, opts) |
398c33b17d76
evolve: make sure we don't stop after evolution of obsparent (issue5881)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4347
diff
changeset
|
1719 |
if result != 0 or result is True: |
4682
8195452be71d
evolve: clarify why returning by adding inline doc
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4681
diff
changeset
|
1720 |
# return as solving obswdp wasn't successful |
4348
398c33b17d76
evolve: make sure we don't stop after evolution of obsparent (issue5881)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4347
diff
changeset
|
1721 |
return result |
4695
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1722 |
if obswdironly: |
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1723 |
return 0 |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1724 |
|
4612
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1725 |
# Progress handling |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1726 |
seen = 1 |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1727 |
showprogress = allopt or revopt |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1728 |
count = len(revs) |
4612
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1729 |
|
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1730 |
def progresscb(): |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1731 |
if showprogress: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1732 |
compat.progress(ui, _(b'evolve'), seen, unit=_(b'changesets'), |
4612
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1733 |
total=count) |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1734 |
|
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1735 |
# Order the revisions |
3845
5c964ebe4d4b
evolve: always order the revs to be evolved
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3843
diff
changeset
|
1736 |
revs = _orderrevs(repo, revs) |
3480
1799fc777f30
evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3479
diff
changeset
|
1737 |
|
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1738 |
# cbor does not know how to serialize sets, using list for skippedrevs |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1739 |
stateopts = {b'category': targetcat, b'replacements': {}, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1740 |
b'revs': list(revs), b'confirm': confirmopt, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1741 |
b'startnode': startnode, b'skippedrevs': [], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1742 |
b'command': b'evolve', b'orphanmerge': False, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1743 |
b'bookmarkchanges': [], b'temprevs': [], b'obsmarkers': [], |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1744 |
b'update': shouldupdate} |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1745 |
evolvestate.addopts(stateopts) |
4122
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
1746 |
# lastsolved: keep track of successor of last troubled cset we evolved |
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
1747 |
# to confirm that if atop msg should be suppressed to remove redundancy |
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
1748 |
lastsolved = None |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
1749 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1750 |
activetopic = getattr(repo, 'currenttopic', b'') |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1751 |
tr = repo.transaction(b"evolve") |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1752 |
with util.acceptintervention(tr): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1753 |
for rev in revs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1754 |
lastsolved = _solveonerev(ui, repo, rev, evolvestate, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1755 |
activetopic, dryrunopt, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1756 |
confirmopt, progresscb, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1757 |
targetcat, lastsolved) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1758 |
seen += 1 |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1759 |
|
4601
e5aa1e23d146
evolve: move progress-clearing out of _cleanup()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4600
diff
changeset
|
1760 |
if showprogress: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1761 |
compat.progress(ui, _(b'evolve'), None) |
4601
e5aa1e23d146
evolve: move progress-clearing out of _cleanup()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4600
diff
changeset
|
1762 |
|
e5aa1e23d146
evolve: move progress-clearing out of _cleanup()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4600
diff
changeset
|
1763 |
_cleanup(ui, repo, startnode, 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
|
1764 |
|
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1765 |
def _solveonerev(ui, repo, rev, evolvestate, activetopic, dryrunopt, confirmopt, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1766 |
progresscb, targetcat, lastsolved): |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1767 |
"""solves one trouble, including orphan merges |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1768 |
|
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1769 |
Like _solveone(), this solves one trouble. Unlike _solveone(), it |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1770 |
stabilizes for both parents of orphan merges. |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1771 |
""" |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1772 |
curctx = repo[rev] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1773 |
revtopic = getattr(curctx, 'topic', lambda: b'')() |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1774 |
topicidx = getattr(curctx, 'topicidx', lambda: None)() |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1775 |
stacktmplt = False |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1776 |
# check if revision being evolved is in active topic to make sure |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1777 |
# that we can use stack aliases s# in evolve msgs. |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1778 |
if activetopic and (activetopic == revtopic) and topicidx is not None: |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1779 |
stacktmplt = True |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1780 |
progresscb() |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1781 |
ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1782 |
confirmopt, progresscb, targetcat, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1783 |
lastsolved=lastsolved, stacktmplt=stacktmplt) |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1784 |
if ret[0]: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1785 |
evolvestate[b'replacements'][curctx.node()] = ret[1] |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1786 |
lastsolved = ret[1] |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1787 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1788 |
evolvestate[b'skippedrevs'].append(curctx.node()) |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1789 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1790 |
if evolvestate[b'orphanmerge']: |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1791 |
# we were processing an orphan merge with both parents obsolete, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1792 |
# stabilized for second parent, re-stabilize for the first parent |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1793 |
ret = _solveone(ui, repo, repo[ret[1]], evolvestate, dryrunopt, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1794 |
confirmopt, progresscb, targetcat, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1795 |
stacktmplt=stacktmplt) |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1796 |
if ret[0]: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1797 |
evolvestate[b'replacements'][curctx.node()] = ret[1] |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1798 |
lastsolved = ret[1] |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1799 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1800 |
evolvestate[b'skippedrevs'].append(curctx.node()) |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1801 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1802 |
evolvestate[b'orphanmerge'] = False |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1803 |
return lastsolved |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1804 |
|
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1805 |
def solveobswdp(ui, repo, opts): |
4378
0b97d4bea7e0
evolve: add description of function solveobswdp
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4377
diff
changeset
|
1806 |
"""this function updates to the successor of obsolete wdir parent""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1807 |
oldid = repo[b'.'].node() |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1808 |
startctx = repo[b'.'] |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1809 |
dryrunopt = opts.get('dry_run', False) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1810 |
displayer = compat.changesetdisplayer(ui, repo, |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1811 |
{b'template': shorttemplate}) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1812 |
try: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1813 |
ctx = repo[utility._singlesuccessor(repo, repo[b'.'])] |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1814 |
except utility.MultipleSuccessorsError as exc: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1815 |
repo.ui.write_err(_(b'parent is obsolete with multiple' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1816 |
b' successors:\n')) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1817 |
for ln in exc.successorssets: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1818 |
for n in ln: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1819 |
displayer.show(repo[n]) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1820 |
return 2 |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1821 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1822 |
ui.status(_(b'update:')) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1823 |
if not ui.quiet: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1824 |
displayer.show(ctx) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1825 |
|
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1826 |
if dryrunopt: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1827 |
return 0 |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1828 |
res = hg.update(repo, ctx.rev()) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1829 |
newid = ctx.node() |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1830 |
|
4376
0fbf895ce160
evolve: make "startnode" consistently be a node, not a context
Martin von Zweigbergk <martinvonz@google.com>
parents:
4375
diff
changeset
|
1831 |
if ctx != startctx: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1832 |
with repo.wlock(), repo.lock(), repo.transaction(b'evolve') as tr: |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1833 |
bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1834 |
bmupdater(newid) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1835 |
ui.status(_(b'working directory is now at %s\n') % ctx) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1836 |
return res |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1837 |
|
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1838 |
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
|
1839 |
"""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
|
1840 |
updated = False |
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1841 |
pctx = None |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1842 |
if (evolvestate[b'command'] == b'evolve' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1843 |
and evolvestate[b'category'] == b'contentdivergent' |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
1844 |
and evolvestate[b'relocated-other']): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1845 |
oldother = evolvestate[b'old-other'] |
3827
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1846 |
if oldother: |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1847 |
with repo.wlock(), repo.lock(): |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1848 |
repo = repo.unfiltered() |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1849 |
hg.updaterepo(repo, oldother, True) |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
1850 |
strips = [evolvestate[b'relocated-other']] |
3827
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1851 |
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
|
1852 |
updated = True |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1853 |
pctx = repo[oldother] |
3826
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1854 |
if not updated: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1855 |
pctx = repo[b'.'] |
3826
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1856 |
hg.updaterepo(repo, pctx.node(), True) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1857 |
ui.status(_(b'stopped the interrupted evolve\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1858 |
ui.status(_(b'working directory is now at %s\n') % pctx) |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1859 |
|
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1860 |
def abortevolve(ui, repo, evolvestate): |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1861 |
""" 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
|
1862 |
|
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1863 |
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
|
1864 |
repo = repo.unfiltered() |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1865 |
evolvedctx = [] |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1866 |
# 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
|
1867 |
cleanup = True |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1868 |
startnode = evolvestate[b'startnode'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1869 |
for old, new in evolvestate[b'replacements'].items(): |
3755
a19703c6d2bb
evolve: check for None before adding in set of revisions to strip
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3754
diff
changeset
|
1870 |
if new: |
a19703c6d2bb
evolve: check for None before adding in set of revisions to strip
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3754
diff
changeset
|
1871 |
evolvedctx.append(repo[new]) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1872 |
for temp in evolvestate[b'temprevs']: |
3757
2bc60fcac354
evolve: make `--abort` strip the temporary revs created during resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3756
diff
changeset
|
1873 |
if temp: |
2bc60fcac354
evolve: make `--abort` strip the temporary revs created during resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3756
diff
changeset
|
1874 |
evolvedctx.append(repo[temp]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1875 |
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
|
1876 |
|
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1877 |
# 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
|
1878 |
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
|
1879 |
if immutable: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1880 |
repo.ui.warn(_(b"cannot clean up public changesets: %s\n") |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1881 |
% b', '.join(bytes(c) for c in immutable), |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1882 |
hint=_(b"see 'hg help phases' for details")) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1883 |
cleanup = False |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1884 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1885 |
# checking no new changesets are created on evolved revs |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1886 |
descendants = set() |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1887 |
if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1888 |
descendants = set(repo.changelog.descendants(evolvedrevs)) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1889 |
if descendants - set(evolvedrevs): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1890 |
repo.ui.warn(_(b"warning: new changesets detected on destination " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1891 |
b"branch\n")) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1892 |
cleanup = False |
3832
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1893 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1894 |
# finding the indices of the obsmarkers to be stripped and stripping |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1895 |
# them |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1896 |
if evolvestate[b'obsmarkers']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1897 |
stripmarkers = set() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1898 |
for m in evolvestate[b'obsmarkers']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1899 |
m = (m[0], m[1]) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1900 |
stripmarkers.add(m) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1901 |
indices = [] |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1902 |
allmarkers = obsutil.getmarkers(repo) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1903 |
for i, m in enumerate(allmarkers): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1904 |
marker = (m.prednode(), m.succnodes()[0]) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1905 |
if marker in stripmarkers: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1906 |
indices.append(i) |
3832
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1907 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1908 |
repair.deleteobsmarkers(repo.obsstore, indices) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1909 |
repo.ui.debug(b'deleted %d obsmarkers\n' % len(indices)) |
3832
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1910 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1911 |
if cleanup: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1912 |
if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1913 |
strippoints = [c.node() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1914 |
for c in repo.set(b'roots(%ld)', evolvedrevs)] |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1915 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1916 |
# updating the working directory |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1917 |
hg.updaterepo(repo, startnode, True) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1918 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1919 |
# Strip from the first evolved revision |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1920 |
if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1921 |
# no backup of evolved cset versions needed |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1922 |
repair.strip(repo.ui, repo, strippoints, False) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1923 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1924 |
with repo.transaction(b'evolve') as tr: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1925 |
# restoring bookmarks at there original place |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1926 |
bmchanges = evolvestate[b'bookmarkchanges'] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1927 |
if bmchanges: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1928 |
repo._bookmarks.applychanges(repo, tr, bmchanges) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1929 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1930 |
evolvestate.delete() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1931 |
ui.status(_(b'evolve aborted\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1932 |
ui.status(_(b'working directory is now at %s\n') |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1933 |
% nodemod.hex(startnode)[:12]) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1934 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1935 |
raise error.Abort(_(b"unable to abort interrupted evolve, use 'hg " |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1936 |
b"evolve --stop' to stop evolve")) |
3653
d9682c41ea2f
evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3649
diff
changeset
|
1937 |
|
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1938 |
def hgabortevolve(ui, repo): |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1939 |
"""logic for aborting evolve using 'hg abort'""" |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1940 |
with repo.wlock(), repo.lock(): |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1941 |
evolvestate = state.cmdstate(repo) |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1942 |
evolvestate.load() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1943 |
if evolvestate[b'command'] != b'evolve': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1944 |
pctx = repo[b'.'] |
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1945 |
hg.updaterepo(repo, pctx.node(), True) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1946 |
ui.status(_(b'evolve aborted\n')) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1947 |
ui.status(_(b'working directory is now at %s\n') |
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1948 |
% pctx.hex()[:12]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1949 |
evolvestate.delete() |
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1950 |
return 0 |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1951 |
return abortevolve(ui, repo, evolvestate) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1952 |
|
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
1953 |
def continueevolve(ui, repo, evolvestate): |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1954 |
"""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
|
1955 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1956 |
ms = merge.mergestate.read(repo) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1957 |
mergeutil.checkunresolved(ms) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1958 |
if (evolvestate[b'command'] == b'next' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1959 |
or evolvestate[b'category'] == b'orphan'): |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1960 |
_completeorphan(ui, repo, evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1961 |
elif evolvestate[b'category'] == b'phasedivergent': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1962 |
_completephasedivergent(ui, repo, evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1963 |
elif evolvestate[b'category'] == b'contentdivergent': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1964 |
_continuecontentdivergent(ui, repo, evolvestate, None) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1965 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1966 |
repo.ui.status(_(b"continuing interrupted '%s' resolution is not yet" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1967 |
b" supported\n") % evolvestate[b'category']) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1968 |
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
|
1969 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1970 |
# make sure we are continuing evolve and not `hg next --evolve` |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1971 |
if evolvestate[b'command'] != b'evolve': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1972 |
return |
4589
5ba885e2ef5e
evolve: reduce indentation with an early return statement
Martin von Zweigbergk <martinvonz@google.com>
parents:
4588
diff
changeset
|
1973 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1974 |
# Progress handling |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1975 |
seen = 1 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1976 |
count = len(evolvestate[b'revs']) |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
1977 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1978 |
def progresscb(): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1979 |
compat.progress(ui, _(b'evolve'), seen, unit=_(b'changesets'), |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1980 |
total=count) |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
1981 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1982 |
category = evolvestate[b'category'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1983 |
confirm = evolvestate[b'confirm'] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1984 |
unfi = repo.unfiltered() |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1985 |
# lastsolved: keep track of successor of last troubled cset we |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1986 |
# evolved to confirm that if atop msg should be suppressed to remove |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1987 |
# redundancy |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1988 |
lastsolved = None |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1989 |
activetopic = getattr(repo, 'currenttopic', b'') |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1990 |
tr = repo.transaction(b"evolve") |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1991 |
with util.acceptintervention(tr): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1992 |
for rev in evolvestate[b'revs']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1993 |
# XXX: prevent this lookup by storing nodes instead of revnums |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1994 |
curctx = unfi[rev] |
4221
db70de7c1698
evolve: use stack template in --continue case also
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4219
diff
changeset
|
1995 |
|
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1996 |
# check if we can use stack template |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1997 |
revtopic = getattr(curctx, 'topic', lambda: b'')() |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1998 |
topicidx = getattr(curctx, 'topicidx', lambda: None)() |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1999 |
stacktmplt = False |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2000 |
if (activetopic and (activetopic == revtopic) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2001 |
and topicidx is not None): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2002 |
stacktmplt = True |
4608
fe22c36b5563
evolve: use single transaction also when continuing
Martin von Zweigbergk <martinvonz@google.com>
parents:
4607
diff
changeset
|
2003 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2004 |
if (curctx.node() not in evolvestate[b'replacements'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2005 |
and curctx.node() not in evolvestate[b'skippedrevs']): |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2006 |
newnode = _solveone(ui, repo, curctx, evolvestate, False, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2007 |
confirm, progresscb, category, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2008 |
lastsolved=lastsolved, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2009 |
stacktmplt=stacktmplt) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2010 |
if newnode[0]: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2011 |
evolvestate[b'replacements'][curctx.node()] = newnode[1] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2012 |
lastsolved = newnode[1] |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2013 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2014 |
evolvestate[b'skippedrevs'].append(curctx.node()) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2015 |
seen += 1 |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2016 |
|
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2017 |
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
|
2018 |
"""function to continue the interrupted content-divergence resolution.""" |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2019 |
tr = repo.transaction(b'evolve') |
4594
fed1435757ba
evolve: use util.acceptintervention() for closing transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4593
diff
changeset
|
2020 |
with util.acceptintervention(tr): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2021 |
divergent = evolvestate[b'divergent'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2022 |
base = evolvestate[b'base'] |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2023 |
repo = repo.unfiltered() |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2024 |
if evolvestate[b'relocating-div']: |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2025 |
newdiv = _completerelocation(ui, repo, evolvestate) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2026 |
current = repo[evolvestate[b'current']] |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2027 |
obsolete.createmarkers(repo, [(current, (repo[newdiv],))], |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2028 |
operation=b'evolve') |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2029 |
evolvestate[b'relocating-div'] = False |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2030 |
evolvestate[b'relocated-div'] = newdiv |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2031 |
evolvestate[b'temprevs'].append(newdiv) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2032 |
evolvestate[b'divergent'] = newdiv |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2033 |
|
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2034 |
relocatereq = evolvestate[b'relocation-req'] |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2035 |
if relocatereq: |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2036 |
divergent = repo[evolvestate[b'divergent']] |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2037 |
other = repo[evolvestate[b'other-divergent']] |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2038 |
evolvestate[b'relocating-other'] = True |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2039 |
ui.status(_(b'rebasing "other" content-divergent changeset %s on' |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2040 |
b' %s\n' % (other, divergent.p1()))) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2041 |
with state.saver(evolvestate, {b'current': other.node()}): |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2042 |
newother = relocate(repo, other, divergent.p1(), evolvestate, |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2043 |
keepbranch=True) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2044 |
evolvestate[b'old-other'] = other.node() |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2045 |
other = repo[newother] |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2046 |
evolvestate[b'relocating-other'] = False |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2047 |
evolvestate[b'relocated-other'] = other.node() |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2048 |
evolvestate[b'temprevs'].append(other.node()) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2049 |
evolvestate[b'other-divergent'] = other.node() |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2050 |
# continue the resolution by merging the content-divergence |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2051 |
_mergecontentdivergents(repo, progresscb, |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2052 |
repo[divergent], |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2053 |
repo[newother], |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2054 |
repo[base], |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2055 |
evolvestate) |
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2056 |
|
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
2057 |
if evolvestate[b'relocating-other']: |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2058 |
newother = _completerelocation(ui, repo, evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2059 |
current = repo[evolvestate[b'current']] |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2060 |
obsolete.createmarkers(repo, [(current, (repo[newother],))], |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2061 |
operation=b'evolve') |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
2062 |
evolvestate[b'relocating-other'] = False |
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
2063 |
evolvestate[b'relocated-other'] = newother |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2064 |
evolvestate[b'temprevs'].append(newother) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2065 |
evolvestate[b'other-divergent'] = newother |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2066 |
# continue the resolution by merging the content-divergence |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2067 |
_mergecontentdivergents(repo, progresscb, |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2068 |
repo[divergent], |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2069 |
repo[newother], |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2070 |
repo[base], |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2071 |
evolvestate) |
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2072 |
|
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2073 |
divergent = evolvestate[b'divergent'] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2074 |
other = evolvestate[b'other-divergent'] |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2075 |
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
|
2076 |
repo[divergent], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2077 |
repo[other], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2078 |
repo[base], |
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2079 |
evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2080 |
origdivergent = evolvestate[b'orig-divergent'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2081 |
evolvestate[b'replacements'][origdivergent] = ret[1] |
4384
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2082 |
# logic to continue the public content-divergent |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2083 |
publicnode = evolvestate.get(b'public-divergent') |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
2084 |
if publicnode: |
4384
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2085 |
res, newnode = ret |
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2086 |
if not res: |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2087 |
# no need to proceed for phase divergence resolution step |
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2088 |
pass |
4417
b86413cfca4a
evolve: cover continue case in pubdiv when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4416
diff
changeset
|
2089 |
elif newnode == publicnode: |
b86413cfca4a
evolve: cover continue case in pubdiv when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4416
diff
changeset
|
2090 |
# merging had the same changes as public changeset and |
b86413cfca4a
evolve: cover continue case in pubdiv when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4416
diff
changeset
|
2091 |
# divergence has been resolved by creating markers |
b86413cfca4a
evolve: cover continue case in pubdiv when merging results in same as public
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4416
diff
changeset
|
2092 |
pass |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2093 |
else: |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
2094 |
prec = repo[publicnode] |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2095 |
bumped = repo[newnode] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
2096 |
ret = _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped) |
4384
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2097 |
return ret |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2098 |
|
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2099 |
def _completephasedivergent(ui, repo, evolvestate): |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2100 |
"""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
|
2101 |
|
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2102 |
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
|
2103 |
phase-divergence""" |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2104 |
|
4593
f6b9c409c12e
evolve: use context manager for transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4592
diff
changeset
|
2105 |
# need to start transaction for bookmark changes |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2106 |
with repo.transaction(b'evolve'): |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2107 |
node = _completerelocation(ui, repo, evolvestate) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2108 |
evolvestate[b'temprevs'].append(node) |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2109 |
# 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
|
2110 |
# those cases |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2111 |
ctx = repo[evolvestate[b'current']] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2112 |
newctx = repo[node] if node is not None else repo[b'.'] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2113 |
obsolete.createmarkers(repo, [(ctx, (newctx,))], operation=b'evolve') |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2114 |
|
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2115 |
# now continuing the phase-divergence resolution part |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2116 |
prec = repo[evolvestate[b'precursor']] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
2117 |
retvalue = _resolvephasedivergent(ui, repo, prec, newctx) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2118 |
evolvestate[b'replacements'][ctx.node()] = retvalue[1] |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2119 |
|
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2120 |
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
|
2121 |
"""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
|
2122 |
|
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2123 |
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
|
2124 |
# 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
|
2125 |
# those cases |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2126 |
ctx = repo[evolvestate[b'current']] |
3636
92a2d3217de9
evolve: show a message when evolution leads to no changes to commit
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3635
diff
changeset
|
2127 |
if node is None: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2128 |
repo.ui.status(_(b"evolution of %d:%s created no changes" |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2129 |
b" to commit\n") % (ctx.rev(), ctx)) |
4689
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2130 |
replacement = () |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2131 |
else: |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2132 |
replacement = (repo[node],) |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2133 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2134 |
obsolete.createmarkers(repo, [(ctx, replacement)], operation=b'evolve') |
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2135 |
|
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2136 |
# make sure we are continuing evolve and not `hg next --evolve` |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2137 |
if evolvestate[b'command'] == b'evolve': |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2138 |
evolvestate[b'replacements'][ctx.node()] = node |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2139 |
if evolvestate[b'orphanmerge']: |
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2140 |
# 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
|
2141 |
# 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
|
2142 |
# re-process to stabilize on first parent |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2143 |
evolvestate[b'revs'].insert(0, repo[node].rev()) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2144 |
evolvestate[b'orphanmerge'] = False |
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2145 |
|
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2146 |
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
|
2147 |
"""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
|
2148 |
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
|
2149 |
""" |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2150 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2151 |
orig = repo[evolvestate[b'current']] |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2152 |
ctx = orig |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2153 |
source = ctx.extra().get(b'source') |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2154 |
extra = {} |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2155 |
if source: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2156 |
extra[b'source'] = source |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2157 |
extra[b'intermediate-source'] = ctx.hex() |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2158 |
else: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2159 |
extra[b'source'] = ctx.hex() |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2160 |
user = ctx.user() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2161 |
date = ctx.date() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2162 |
message = ctx.description() |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2163 |
ui.status(_(b'evolving %d:%s "%s"\n') % (ctx.rev(), ctx, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2164 |
message.split(b'\n', 1)[0])) |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2165 |
targetphase = max(ctx.phase(), phases.draft) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2166 |
overrides = {(b'phases', b'new-commit'): targetphase} |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2167 |
|
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2168 |
ctxparents = orig.parents() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2169 |
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
|
2170 |
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
|
2171 |
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
|
2172 |
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
|
2173 |
# 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
|
2174 |
# 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
|
2175 |
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
|
2176 |
# 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
|
2177 |
# 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
|
2178 |
# 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
|
2179 |
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
|
2180 |
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
|
2181 |
ctxparents[1].node()) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2182 |
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
|
2183 |
# 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
|
2184 |
# 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
|
2185 |
# 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
|
2186 |
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
|
2187 |
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
|
2188 |
currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2189 |
|
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2190 |
else: |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2191 |
# 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
|
2192 |
# are processing the second parent first (to keep parent order) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2193 |
if evolvestate.get(b'orphanmerge'): |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2194 |
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
|
2195 |
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
|
2196 |
currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2197 |
pass |
3978
fb8e44c70798
evolve: set the second parent if we get conflicts while evolving
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3977
diff
changeset
|
2198 |
else: |
fb8e44c70798
evolve: set the second parent if we get conflicts while evolving
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3977
diff
changeset
|
2199 |
with repo.dirstate.parentchange(): |
fb8e44c70798
evolve: set the second parent if we get conflicts while evolving
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3977
diff
changeset
|
2200 |
repo.dirstate.setparents(repo.dirstate.parents()[0], nodemod.nullid) |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2201 |
|
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2202 |
with repo.ui.configoverride(overrides, b'evolve-continue'): |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2203 |
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
|
2204 |
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
|
2205 |
return node |