Mercurial > evolve
annotate hgext3rd/evolve/evolvecmd.py @ 5921:c04c4383f33e
evolve: drop quotes around node in a content divergence resolution message
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 17 May 2021 19:10:22 +0800 |
parents | 22f4ebf3f7d8 |
children | aca07ac01167 |
rev | line source |
---|---|
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 # Logilab SA <contact@logilab.fr> |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 # Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 # Patrick Mezard <patrick@mezard.eu> |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 # |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
9 """logic related to hg evolve command""" |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
10 |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
11 import collections |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
12 import re |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
13 |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
14 from mercurial import ( |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
15 bookmarks as bookmarksmod, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
16 cmdutil, |
3579
3a4552b30ba8
compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3577
diff
changeset
|
17 commands, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
18 context, |
5181
c979d64a2589
compat: drop 4.5 compatibility layer for log utility
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5179
diff
changeset
|
19 encoding, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
20 error, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
21 hg, |
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 |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
35 from mercurial.utils import stringutil |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
36 |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
37 from mercurial.i18n import _ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
38 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
39 from . import ( |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
40 cmdrewrite, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
41 compat, |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
42 exthelper, |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
43 rewriteutil, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
44 state, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
45 utility, |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
46 ) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
47 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
48 TROUBLES = compat.TROUBLES |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
49 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
|
50 stacktemplate = utility.stacktemplate |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
51 _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
|
52 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
|
53 |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
54 eh = exthelper.exthelper() |
3579
3a4552b30ba8
compat: use mergetoolopts from commands.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3577
diff
changeset
|
55 mergetoolopts = commands.mergetoolopts |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
56 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
57 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
|
58 |
3478
4a1ccae58323
evolvecmd: pass evolvestate object to _solve* functions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3477
diff
changeset
|
59 def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm, |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
60 progresscb, category, stacktmplt=False): |
3461
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
61 """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
|
62 |
6475d2046f87
evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
63 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
|
64 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
|
65 newnode: if bool is True, then the newnode of the resultant commit |
5022
95af630d913a
evolvecmd: fix a typo node->None
Martin von Zweigbergk <martinvonz@google.com>
parents:
5021
diff
changeset
|
66 formed. newnode can be None, 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
|
67 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
|
68 """ |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
69 tr = repo.currenttransaction() |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
70 assert tr is not None |
5397
03ce095dc10d
evolve: refactor some code changes
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5344
diff
changeset
|
71 template = shorttemplate |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
72 if stacktmplt: |
5397
03ce095dc10d
evolve: refactor some code changes
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5344
diff
changeset
|
73 template = stacktemplate |
5695
8c7de8f8bb42
evolve: respect command-templates.oneline-summary if configured
Martin von Zweigbergk <martinvonz@google.com>
parents:
5694
diff
changeset
|
74 display = compat.format_changeset_summary_fn(ui, repo, b'evolve', |
8c7de8f8bb42
evolve: respect command-templates.oneline-summary if configured
Martin von Zweigbergk <martinvonz@google.com>
parents:
5694
diff
changeset
|
75 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
|
76 if b'orphan' == category: |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
77 result = _solveorphan(ui, repo, ctx, evolvestate, display, |
5590
582e3be0a277
evolvecmd: rename _solveunstable() to _solveorphan()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5580
diff
changeset
|
78 dryrun, confirm, 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
|
79 elif b'phasedivergent' == category: |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
80 result = _solvephasedivergence(ui, repo, ctx, evolvestate, |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
81 display, dryrun, confirm, |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
82 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
|
83 elif b'contentdivergent' == category: |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
84 result = _solvedivergent(ui, repo, ctx, evolvestate, display, |
4610
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
85 dryrun, confirm, progresscb) |
c54d4c2c2846
evolve: drop nested locks and transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4608
diff
changeset
|
86 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
|
87 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
|
88 return result |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
89 |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
90 def _solveorphan(ui, repo, orig, evolvestate, display, dryrun=False, |
5590
582e3be0a277
evolvecmd: rename _solveunstable() to _solveorphan()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5580
diff
changeset
|
91 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
|
92 """ 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
|
93 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
100 pctx = orig.p1() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
101 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
|
102 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
|
103 p1obs = orig.p1().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
104 p2obs = orig.p2().obsolete() |
6aff754c2457
evolve: make sure we consider all cases in if-else
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3543
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 pass |
5476
d542e9720b1e
orphan: fix buggy case of try resolving orphan merge two times
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5474
diff
changeset
|
110 elif p1obs and p2obs: |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
111 # 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
|
112 # 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
|
113 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
|
114 # 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
|
115 # 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
|
116 # first parent |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
117 pctx = orig.p2() |
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
118 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
|
119 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
120 if not pctx.obsolete(): |
5477
d60490a28318
evolve: improve warning msg when skipping orphan resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5476
diff
changeset
|
121 ui.warn(_(b"skipping %s, consider including orphan ancestors\n") % 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
|
122 return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
123 obs = pctx |
5050
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
124 try: |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
125 newer = utility._singlesuccessor(repo, obs) |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
126 # search of a parent which isn't the orig |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
127 while repo[newer].node() == orig.node(): |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
128 obs = obs.parents()[0] |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
129 newer = utility._singlesuccessor(repo, obs) |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
130 except utility.MultipleSuccessorsError as exc: |
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
131 if exc.divergenceflag: |
5049
1b393870c6b9
evolve: preliminary indentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5033
diff
changeset
|
132 msg = _(b"skipping %s: divergent rewriting. can't choose " |
1b393870c6b9
evolve: preliminary indentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5033
diff
changeset
|
133 b"destination\n") % obs |
1b393870c6b9
evolve: preliminary indentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5033
diff
changeset
|
134 ui.write_err(msg) |
1b393870c6b9
evolve: preliminary indentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5033
diff
changeset
|
135 return (False, b".") |
5050
f29bd1c7e457
evolve: use utility._singlesuccessor() in _solveunstable()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5049
diff
changeset
|
136 if exc.splitflag: |
5075
fbe614cae40c
evolve: add a new method picksplitsuccessor() in utility.py
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5064
diff
changeset
|
137 splitsucc = utility.picksplitsuccessor(ui, repo, obs, orig) |
fbe614cae40c
evolve: add a new method picksplitsuccessor() in utility.py
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5064
diff
changeset
|
138 if not splitsucc[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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 return (False, b".") |
5075
fbe614cae40c
evolve: add a new method picksplitsuccessor() in utility.py
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5064
diff
changeset
|
144 newer = splitsucc[1] |
fbe614cae40c
evolve: add a new method picksplitsuccessor() in utility.py
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5064
diff
changeset
|
145 target = repo[newer] |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
146 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
|
147 repo.ui.write(_(b'move:'), label=b'evolve.operation') |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
148 display(orig) |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
149 # lastsolved: keep track of successor of last troubled cset we evolved |
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
150 # to confirm that if atop msg should be suppressed to remove redundancy |
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
151 lastsolved = evolvestate.get(b'lastsolved') |
4122
4eb3877540f1
evovle: remove redundancy in evolve output
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4090
diff
changeset
|
152 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
|
153 repo.ui.write(_(b'atop:')) |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
154 display(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
|
155 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
|
156 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
|
157 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
|
158 if dryrun: |
4599
93ffedae6ec6
evolve: _solveunstable() update progress only once
Martin von Zweigbergk <martinvonz@google.com>
parents:
4598
diff
changeset
|
159 if progresscb: |
93ffedae6ec6
evolve: _solveunstable() update progress only once
Martin von Zweigbergk <martinvonz@google.com>
parents:
4598
diff
changeset
|
160 progresscb() |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
161 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
|
162 return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
163 else: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
164 repo.ui.note(todo) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
165 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
166 progresscb() |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
167 with state.saver(evolvestate, {b'current': orig.node()}): |
5020
8f6095e88d1c
evolvecmd: mark relocate() private
Martin von Zweigbergk <martinvonz@google.com>
parents:
5019
diff
changeset
|
168 newid = _relocate(repo, orig, target, evolvestate, pctx, |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
169 keepbranch, b'orphan', update=False) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
170 return (True, newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
171 |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
172 def _solvephasedivergence(ui, repo, bumped, evolvestate, display, |
4154
dd81d7f43857
evolve: extract displayer to _solveone()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4153
diff
changeset
|
173 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
|
174 """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
|
175 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 """ |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
182 repo = repo.unfiltered() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
183 bumped = repo[bumped.rev()] |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
184 # 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 # 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
196 |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
197 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
|
198 repo.ui.write(_(b'recreate:'), label=b'evolve.operation') |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
199 display(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
|
200 repo.ui.write(_(b'atop:')) |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
201 display(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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 (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
|
211 return (False, b".") |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
212 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
213 progresscb() |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
214 |
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
215 # 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
|
216 # 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
|
217 # 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
|
218 # 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
|
219 # 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
|
220 # 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
|
221 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
|
222 # 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
|
223 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
|
224 _(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
|
225 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
|
226 b'precursor': prec.hex()}): |
5020
8f6095e88d1c
evolvecmd: mark relocate() private
Martin von Zweigbergk <martinvonz@google.com>
parents:
5019
diff
changeset
|
227 newnode = _relocate(repo, bumped, prec.p1(), evolvestate, |
8f6095e88d1c
evolvecmd: mark relocate() private
Martin von Zweigbergk <martinvonz@google.com>
parents:
5019
diff
changeset
|
228 category=b'phasedivergent') |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
229 if newnode is not None: |
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
230 new = repo[newnode] |
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
231 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
|
232 operation=b'evolve') |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
233 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
|
234 evolvestate[b'temprevs'].append(newnode) |
3622
534af64b0107
evolvecmd: add a detailed comment and some newlines
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3616
diff
changeset
|
235 |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
236 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
|
237 |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
238 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
|
239 """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
|
240 |
4465
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
241 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
|
242 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
|
243 """ |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
244 tr = repo.currenttransaction() |
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
245 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
|
246 |
4465
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
247 cl = repo.changelog |
6feeaf00db44
doc: clarify _resolvephasedivergent role and constraint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
4464
diff
changeset
|
248 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
|
249 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
|
250 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
|
251 |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
252 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
|
253 newid = None |
3754
73ee40cbfb53
evolve: return the new replacement node to be stored in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3753
diff
changeset
|
254 replacementnode = None |
3632
8d38b88233cb
evolve: move logic to resolve phase-divergence in a new function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3631
diff
changeset
|
255 |
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
256 # 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
|
257 # 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
|
258 # 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
|
259 wctx = context.overlayworkingctx(repo) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
260 wctx.setbase(prec) |
5614
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
261 compat._update(repo, bumped.node(), ancestor=prec, mergeancestor=True, |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
262 branchmerge=False, force=False, wc=wctx) |
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
263 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
|
264 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
|
265 text += bumped.description() |
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
266 memctx = wctx.tomemctx(text, |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
267 parents=(prec.node(), nodemod.nullid), |
5095
2fcaee044a8c
evolve: provide branch argument to overlayworkingctx.tomemctx()
Anton Shestakov <av6@dwimlabs.net>
parents:
5094
diff
changeset
|
268 branch=bumped.branch(), |
4558
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
269 date=bumped.date(), |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
270 extra=bumped.extra(), |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
271 user=bumped.user()) |
63148e999562
evolve: use merge.update() for resolving phase divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
4554
diff
changeset
|
272 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
|
273 replacementnode = newid |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 newid = prec.node() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
278 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
|
279 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
|
280 phases.retractboundary(repo, tr, bumped.phase(), [newid]) |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
281 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
|
282 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
|
283 bmupdate(newid) |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
284 # reroute the working copy parent to the new changeset |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
285 with repo.dirstate.parentchange(), compat.parentchange(repo): |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
286 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
|
287 return (True, replacementnode) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
288 |
5727
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
289 def _pickresolutionparent(ui, repo, divergent, other, base, evolvestate): |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
290 """When the divergent changeset are not based on the same parent, we need |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
291 to find out where the divergence resolution will be based.""" |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
292 |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
293 # 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 |
5858
22f4ebf3f7d8
evolve: update some conditionals
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5857
diff
changeset
|
304 if not divergent.mutable(): |
5575
5c62afe34c96
evolve: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5574
diff
changeset
|
305 # Public divergence: we keep public one to local side while merging |
5556
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
306 # When public branch is behind to the mutable branch, for now we |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
307 # relocate mutable cset to public one's side in every case. |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
308 # |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
309 # This behaviour might be sub optimal when ancestors of mutable |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
310 # cset has changes its relocated descendant rely on. |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
311 # |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
312 # Otherwise, we are going to rebase the "behind" branch up to the new |
1bb1d36e1bc2
evolve: move a comment where it's going to belong
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5555
diff
changeset
|
313 # brancmap level. |
5858
22f4ebf3f7d8
evolve: update some conditionals
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5857
diff
changeset
|
314 resolutionparent = divergent.p1().rev() |
22f4ebf3f7d8
evolve: update some conditionals
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5857
diff
changeset
|
315 evolvestate[b'public-divergent'] = divergent.node() |
5574
e6241483ccec
evolve: no need to return divergent and other
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5573
diff
changeset
|
316 return (True, resolutionparent) |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
317 |
5031
ef1978a0fcc0
evolve: simplify some conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5030
diff
changeset
|
318 otherp1 = succsotherp1 = other.p1().rev() |
ef1978a0fcc0
evolve: simplify some conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5030
diff
changeset
|
319 divp1 = succsdivp1 = divergent.p1().rev() |
5784
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
320 basep1 = succsbasep1 = base.p1().rev() |
3848
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
321 |
5579
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
322 # finding single successors of divp1 and otherp1 |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
323 try: |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
324 succsdivp1 = utility._singlesuccessor(repo, divergent.p1()) |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
325 except utility.MultipleSuccessorsError: |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
326 msg = _(b"skipping %s: ambiguous orphan resolution parent for " |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
327 b"%s\n") % (divergent, divergent) |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
328 ui.write_err(msg) |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
329 return (False, b".") |
3850
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
330 try: |
5030
1403cc7c2cee
evolve: rename some variable ahead of time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5029
diff
changeset
|
331 succsotherp1 = utility._singlesuccessor(repo, other.p1()) |
3850
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
332 except utility.MultipleSuccessorsError: |
5579
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
333 msg = _(b"skipping %s: ambiguous orphan resolution parent for " |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
334 b"%s\n") % (divergent, other) |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
335 ui.write_err(msg) |
6289ddfb9d48
evolve: refactor some error raising logic in content-divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5578
diff
changeset
|
336 return (False, b".") |
5727
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
337 try: |
5782
72f65a647203
divergence-resolution: take parent successors in account
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5778
diff
changeset
|
338 succsbasep1 = utility._singlesuccessor(repo, base.p1()) |
5727
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
339 except utility.MultipleSuccessorsError: |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
340 msg = (b"ambiguous orphan resolution parent for " |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
341 b"%s (base)\n") % base |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
342 ui.debug(msg) |
3850
340cf6fbe9e9
evolve: create resolved cset on successors of current parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3848
diff
changeset
|
343 |
3848
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
344 # the changeset on which resolution changeset will be based on |
5725
e6b0ed34bc18
divergence-resolution: return rev from _pickresolutionparent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5722
diff
changeset
|
345 resolutionparent = succsdivp1 |
3848
90f1a64875ad
evolve: introduce a resolutionparent variable and store it in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3847
diff
changeset
|
346 |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
347 # 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
|
348 # possible cases here: |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
349 # |
5818
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
350 # 1) both have the same parent (or parent's successor) |
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
351 # 2) one of them is parent of other |
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
352 # 3) one of them moved elsewhere |
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
353 # 4) both of them moved elsewhere |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
354 # |
5818
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
355 # we are handling 1) 2) 3) very well now. |
524eb673ac52
divergence-resolution: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5817
diff
changeset
|
356 # for 4), we still have to decide |
5032
31b0b29245bb
evolve: further simplify a conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5031
diff
changeset
|
357 if otherp1 == divp1: |
31b0b29245bb
evolve: further simplify a conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5031
diff
changeset
|
358 # both are on the same parents |
31b0b29245bb
evolve: further simplify a conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5031
diff
changeset
|
359 pass |
5474
86c6c7951f74
evolve: fix content-div resolution when in parent-child form
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5442
diff
changeset
|
360 elif divergent == other.p1(): |
86c6c7951f74
evolve: fix content-div resolution when in parent-child form
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5442
diff
changeset
|
361 # both are in parent-child relation |
86c6c7951f74
evolve: fix content-div resolution when in parent-child form
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5442
diff
changeset
|
362 pass |
5782
72f65a647203
divergence-resolution: take parent successors in account
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5778
diff
changeset
|
363 elif succsbasep1 in (succsdivp1, succsotherp1): |
5783
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
364 # 1) either, only one side moved |
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
365 # -> set parent of moved one as resolution parent |
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
366 # 2) or, both moved but one moved to succs of basep1 |
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
367 # -> set parent of other one as resolution parent |
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
368 # 3) or, both have same parent's successor |
c5c879fed91c
divergence-resolution: add comments to explain a particular case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5782
diff
changeset
|
369 # -> set parent's successor as resolution parent |
5782
72f65a647203
divergence-resolution: take parent successors in account
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5778
diff
changeset
|
370 if succsbasep1 == succsdivp1: |
5730
a119432bafc1
divergence-resolution: deal with simple "just one moved case" earlier
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5727
diff
changeset
|
371 resolutionparent = succsotherp1 |
a119432bafc1
divergence-resolution: deal with simple "just one moved case" earlier
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5727
diff
changeset
|
372 else: |
a119432bafc1
divergence-resolution: deal with simple "just one moved case" earlier
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5727
diff
changeset
|
373 pass |
5784
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
374 # a special case of 3) where parent of moved one is obsolete with a |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
375 # successor. Also, look at section 'D-A3.1' in troubles-handling.rst |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
376 minimal_resolution = ( |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
377 ui.configbool(b'experimental', b'evolution.divergence-resolution-minimal') |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
378 and succsdivp1 == succsotherp1 and basep1 in (divp1, otherp1) |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
379 ) |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
380 if minimal_resolution: |
43a5371fa669
divergence-resolution: add support and doc for a special case in divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5783
diff
changeset
|
381 resolutionparent = otherp1 if basep1 == divp1 else divp1 |
5726
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
382 else: |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
383 # the nullrev has to be handled specially because -1 is overloaded to both |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
384 # mean nullrev (this meaning is used for the result of changectx.rev(), as |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
385 # called above) and the tipmost revision (this meaning is used for the %d |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
386 # format specifier, as used below) |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
387 if nodemod.nullrev in (succsotherp1, succsdivp1): |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
388 # nullrev is the only possible ancestor if succsotherp1 or succsdivp1 is nullrev |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
389 gca = [nodemod.nullrev] |
4442
819bad275701
evolve: add logic to handle a particular case in divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4438
diff
changeset
|
390 else: |
5726
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
391 gca = repo.revs(b"ancestor(%d, %d)" % (succsotherp1, succsdivp1)) |
5785
a9ad01ed1539
divergence-resolution: drop a block of code which is unnecessary now
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5784
diff
changeset
|
392 if succsotherp1 in gca and succsdivp1 not in gca: |
5032
31b0b29245bb
evolve: further simplify a conditional
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5031
diff
changeset
|
393 pass |
5726
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
394 elif succsdivp1 in gca and succsotherp1 not in gca: |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
395 resolutionparent = succsotherp1 |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
396 else: |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
397 msg = _(b"skipping %s: have a different parent than %s " |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
398 b"(not handled yet)\n") % (divergent, other) |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
399 hint = _(b"| %(d)s, %(o)s are not based on the same changeset.\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
400 b"| With the current state of its implementation,\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
401 b"| evolve does not work in that case.\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
402 b"| rebase one of them next to the other and run\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
403 b"| this command again.\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
404 b"| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
405 b"| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
406 ) % {b'd': divergent, b'o': other} |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
407 ui.write_err(msg) |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
408 ui.write_err(hint) |
1319abf8d8c4
divergence-resolution: pre-indent some code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5725
diff
changeset
|
409 return (False, b".") |
5574
e6241483ccec
evolve: no need to return divergent and other
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5573
diff
changeset
|
410 return (True, resolutionparent) |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
411 |
5285
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
412 def _relocatedivergent(repo, orig, dest, evolvestate): |
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
413 """relocates a divergent commit and saves the evolve state""" |
5295
ebfd0d875600
evolve: handle relocation during divergence resolution producing no changes
Martin von Zweigbergk <martinvonz@google.com>
parents:
5293
diff
changeset
|
414 configoverride = repo.ui.configoverride( |
ebfd0d875600
evolve: handle relocation during divergence resolution producing no changes
Martin von Zweigbergk <martinvonz@google.com>
parents:
5293
diff
changeset
|
415 {(b'ui', b'allowemptycommit'): b'true'}, b'evolve' |
ebfd0d875600
evolve: handle relocation during divergence resolution producing no changes
Martin von Zweigbergk <martinvonz@google.com>
parents:
5293
diff
changeset
|
416 ) |
ebfd0d875600
evolve: handle relocation during divergence resolution producing no changes
Martin von Zweigbergk <martinvonz@google.com>
parents:
5293
diff
changeset
|
417 with state.saver(evolvestate, {b'current': orig.node()}), configoverride: |
5285
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
418 return _relocate(repo, orig, dest, evolvestate, keepbranch=True) |
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
419 |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
420 def _solvedivergent(ui, repo, divergent, evolvestate, display, dryrun=False, |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
421 confirm=False, progresscb=None): |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
422 """tries to solve content-divergence of a changeset |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
423 |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
424 returns a tuple (bool, newnode) where, |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
425 bool: a boolean value indicating whether the instability was solved |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
426 newnode: if bool is True, then the newnode of the resultant commit |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
427 formed. newnode can be node, when resolution led to no new |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
428 commit. If bool is False, this is ".". |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
429 """ |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
430 repo = repo.unfiltered() |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
431 base, others = divergentdata(divergent) |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
432 |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
433 # we don't handle split in content-divergence yet |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
434 if len(others) > 1: |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
435 othersstr = b"[%s]" % (b','.join([bytes(i) for i in others])) |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
436 msg = _(b"skipping %s: %s with a changeset that got split" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
437 b" into multiple ones:\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
438 b"|[%s]\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
439 b"| This is not handled by automatic evolution yet\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
440 b"| You have to fallback to manual handling with commands " |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
441 b"such as:\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
442 b"| - hg touch -D\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
443 b"| - hg prune\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
444 b"| \n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
445 b"| You should contact your local evolution Guru for help.\n" |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
446 ) % (divergent, TROUBLES['CONTENTDIVERGENT'], othersstr) |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
447 ui.write_err(msg) |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
448 return (False, b".") |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
449 other = others[0] |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
450 evolvestate[b'orig-divergent'] = divergent.node() |
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
451 if not other.mutable(): |
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
452 divergent, other = other, divergent |
5559
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
453 evolvestate[b'divergent'] = divergent.node() |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
454 evolvestate[b'other-divergent'] = other.node() |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
455 evolvestate[b'base'] = base.node() |
5559
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
456 |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
457 # sometimes we will relocate a node in case of different parents and we can |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
458 # encounter conflicts after relocation is done while solving |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
459 # content-divergence and if the user calls `hg evolve --stop`, we need to |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
460 # strip that relocated commit. However if `--all` is passed, we need to |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
461 # reset this value for each content-divergence resolution which we are doing |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
462 # below. |
5560
b31cd9ee890a
evolve: add some initial values in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5559
diff
changeset
|
463 evolvestate[b'relocate-div'] = False |
b31cd9ee890a
evolve: add some initial values in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5559
diff
changeset
|
464 evolvestate[b'relocate-other'] = False |
5559
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
465 evolvestate[b'relocated-other'] = None |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
466 evolvestate[b'relocating-other'] = False |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
467 evolvestate[b'relocated-div'] = None |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
468 evolvestate[b'relocating-div'] = False |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
469 # in case or relocation we get a new other node, we need to store the old |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
470 # other for purposes like `--abort` or `--stop` |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
471 evolvestate[b'old-other'] = None |
eb09d05f69f3
evolve: move initial evolvestate values to main function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5558
diff
changeset
|
472 evolvestate[b'old-divergent'] = None |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
473 |
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
474 # setup everything before merging two content-divergent csets |
5727
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
475 picked, resolutionparent = _pickresolutionparent(ui, repo, divergent, other, |
bc323205241b
divergence-resolution: pass the base changeset to _pickresolutionparent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5726
diff
changeset
|
476 base, evolvestate) |
5725
e6b0ed34bc18
divergence-resolution: return rev from _pickresolutionparent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5722
diff
changeset
|
477 resolutionparent = repo[resolutionparent].node() |
5576
b4c2cbbde6bd
evolve: rename a func and some updates around it
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5575
diff
changeset
|
478 if not picked: |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
479 return (False, b".") |
5577
2f78cb38620f
evolve: move a line a code block above
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5576
diff
changeset
|
480 evolvestate[b'resolutionparent'] = resolutionparent |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
481 |
5572
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
482 if divergent.p1().node() != resolutionparent: |
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
483 evolvestate[b'relocate-div'] = True |
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
484 if other.p1().node() != resolutionparent: |
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
485 evolvestate[b'relocate-other'] = True |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
486 |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
487 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
|
488 ui.write(_(b'merge:'), label=b'evolve.operation') |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
489 display(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
|
490 ui.write(_(b'with: ')) |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
491 display(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
|
492 ui.write(_(b'base: ')) |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
493 display(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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 % divergent)) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
505 return (False, b".") |
5572
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
506 # relocate divergent cset to resolution parent |
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
507 if evolvestate[b'relocate-div']: |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
508 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
|
509 ui.status(_(b'rebasing "divergent" content-divergent changeset %s on' |
5550
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
510 b' %s\n' % (divergent, repo[resolutionparent]))) |
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
511 newdivergent = _relocatedivergent(repo, divergent, repo[resolutionparent], |
5285
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
512 evolvestate) |
5029
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
513 evolvestate[b'old-divergent'] = divergent.node() |
5517
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
514 evolvestate[b'relocating-div'] = False |
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
515 evolvestate[b'relocated-div'] = newdivergent |
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
516 evolvestate[b'temprevs'].append(newdivergent) |
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
517 evolvestate[b'divergent'] = newdivergent |
4991
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
518 divergent = repo[newdivergent] |
2928f35023a1
evolve: make sure divergence resolution doesn't undo changes (issue6203)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4984
diff
changeset
|
519 |
5575
5c62afe34c96
evolve: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5574
diff
changeset
|
520 # relocate the other divergent to resolution parent |
5572
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
521 if evolvestate[b'relocate-other']: |
3809
f06ff8fee2f6
evolvestate: store info about relocation while resolving content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3808
diff
changeset
|
522 # 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
|
523 # 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
|
524 # content divergent changesets |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
525 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
|
526 ui.status(_(b'rebasing "other" content-divergent changeset %s on' |
5550
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
527 b' %s\n' % (other, repo[resolutionparent]))) |
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
528 newother = _relocatedivergent(repo, other, repo[resolutionparent], 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
|
529 evolvestate[b'old-other'] = other.node() |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
530 evolvestate[b'relocating-other'] = False |
5517
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
531 evolvestate[b'relocated-other'] = newother |
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
532 evolvestate[b'temprevs'].append(newother) |
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
533 evolvestate[b'other-divergent'] = newother |
3805
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
534 other = repo[newother] |
2410e7063692
evolve: implement resolution of content-divergence when on differet parents
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3802
diff
changeset
|
535 |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
536 _mergecontentdivergents(repo, progresscb, divergent, other, base, |
3808
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
537 evolvestate) |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
538 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
|
539 other, base, evolvestate) |
5553
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
540 haspublicdiv = not (divergent.mutable() and other.mutable()) |
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
541 if not haspublicdiv: |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
542 return (res, newnode) |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
543 else: |
5033
7cc3d96eb589
evolve: extract pre merging content-div csets logic to its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5032
diff
changeset
|
544 publicdiv = repo[evolvestate[b'public-divergent']] |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
545 # 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
|
546 # 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
|
547 # 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
|
548 # 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
|
549 # 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
|
550 # 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
|
551 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
|
552 # 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
|
553 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
|
554 if newnode == publicdiv.node(): |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
555 # case 2) |
4747
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
556 pubstr = bytes(publicdiv) |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 return (res, newnode) |
4529
e0eaa33a1f8a
evolve: improve inline documentation for the public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4505
diff
changeset
|
564 # case 1) |
4383
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
565 prec = publicdiv |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
566 bumped = repo[newnode] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
567 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
|
568 |
5551
22c82f714fe1
evolve: rename param `divergent` to `local` in a function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5550
diff
changeset
|
569 def _mergecontentdivergents(repo, progresscb, local, other, base, |
3808
e6c0f45d51ed
evolve: factor out logic to merge content divergent csets in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3807
diff
changeset
|
570 evolvestate): |
5552
4c328eb7196e
evolve: add some assertions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5551
diff
changeset
|
571 assert local != other |
5551
22c82f714fe1
evolve: rename param `divergent` to `local` in a function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5550
diff
changeset
|
572 if local 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
|
573 repo.ui.note(_(b"updating to \"local\" side of the conflict: %s\n") % |
5792
5d00679d78aa
evolve: rely on ctx.__bytes__() for formatting instead of using ctx.hex()[:12]
Anton Shestakov <av6@dwimlabs.net>
parents:
5785
diff
changeset
|
574 local) |
5568
7f8055eb07c7
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5567
diff
changeset
|
575 compat.update(local) |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
576 # merging the two content-divergent changesets |
5921
c04c4383f33e
evolve: drop quotes around node in a content divergence resolution message
Anton Shestakov <av6@dwimlabs.net>
parents:
5858
diff
changeset
|
577 repo.ui.note(_(b"merging \"other\" %s changeset %s\n") % |
5792
5d00679d78aa
evolve: rely on ctx.__bytes__() for formatting instead of using ctx.hex()[:12]
Anton Shestakov <av6@dwimlabs.net>
parents:
5785
diff
changeset
|
578 (TROUBLES['CONTENTDIVERGENT'], other)) |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
579 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
580 progresscb() |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
581 with state.saver(evolvestate): |
5551
22c82f714fe1
evolve: rename param `divergent` to `local` in a function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5550
diff
changeset
|
582 mergeancestor = repo.changelog.isancestor(local.node(), other.node()) |
5614
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
583 stats = compat._update(repo, |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
584 other.node(), |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
585 branchmerge=True, |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
586 force=False, |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
587 ancestor=base.node(), |
24a1ff0677a7
compat: rename update() to _update() to make room for a new update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5608
diff
changeset
|
588 mergeancestor=mergeancestor) |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
589 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
|
590 |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
591 # conflicts while merging content-divergent changesets |
5179
7c41a1ebcf7f
compat: directly use status attribute instead of the compat layer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
5111
diff
changeset
|
592 if stats.unresolvedcount: |
4848
535ab2609e45
cmdstate: introduce a "saver" contextmanager and use it in place of save()
Kyle Lippincott <spectral@google.com>
parents:
4827
diff
changeset
|
593 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
|
594 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
|
595 hint=hint) |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
596 |
3737
5b0bd82ea914
evolve: add logic to continue interrupted content-divergence resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3736
diff
changeset
|
597 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
|
598 base, evolvestate): |
3735
bdf7fb6af7b8
evolve: take out logic to complete phase-divergence in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3734
diff
changeset
|
599 """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
|
600 # 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
|
601 # resume resolution |
3462
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
602 if progresscb: |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
603 progresscb() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
604 tr = repo.currenttransaction() |
e147c18ed064
evolvecmd: move more functions from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3461
diff
changeset
|
605 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
|
606 # 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
|
607 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
|
608 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
|
609 |
3343eac099ec
evolve: add logic to resolve content-divergence with a public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4382
diff
changeset
|
610 # whether we are solving public divergence |
5553
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
611 haspublicdiv = 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
|
612 if evolvestate.get(b'public-divergent'): |
5553
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
613 haspublicdiv = 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
|
614 publicnode = evolvestate[b'public-divergent'] |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
615 publicdiv = repo[publicnode] |
5558
5f2c85ea8b33
evolve: set other side of public content div using mutability
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5557
diff
changeset
|
616 otherdiv = other if other.mutable() else 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
|
617 |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
618 with repo.dirstate.parentchange(), compat.parentchange(repo): |
5512
2df762b9c0c5
dirstate: replace _uncommitdirstate() by core's movedirstate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5431
diff
changeset
|
619 cmdrewrite.movedirstate(repo, repo[publicnode]) |
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
|
620 # 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
|
621 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
|
622 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
|
623 # 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
|
624 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
|
625 # 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
|
626 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
|
627 operation=b'evolve') |
5619
5673730db8d5
evolve: clean merge state when content divergence resolution has no changes
Anton Shestakov <av6@dwimlabs.net>
parents:
5615
diff
changeset
|
628 compat.mergestate.clean(repo) |
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 return (True, publicnode) |
3742
d577cef1f044
evolvecmd: add comments and new lines in content-divergence handling logic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3741
diff
changeset
|
630 |
5111 | 631 with repo.dirstate.parentchange(), compat.parentchange(repo): |
5512
2df762b9c0c5
dirstate: replace _uncommitdirstate() by core's movedirstate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5431
diff
changeset
|
632 cmdrewrite.movedirstate(repo, repo[resparent]) |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
633 |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
634 # merge the branches |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
635 mergebranches(repo, divergent, other, base) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
636 # merge the commit messages |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
637 desc = mergecommitmessages(ui, base.description(), |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
638 divergent.description(), |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
639 other.description()) |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
640 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
|
641 |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
642 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
|
643 |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
644 date = divergent.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
645 if other.date() != divergent.date(): |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
646 basedate = base.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
647 if other.date() == basedate: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
648 date = divergent.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
649 elif divergent.date() == basedate: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
650 date = other.date() |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
651 else: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
652 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
|
653 |
5293
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
654 # We really want a new commit in order to avoid obsmarker cycles (otherwise |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
655 # divergence resolutions done in separate repos may create markers in the |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
656 # opposite directions). For that reason, we set ui.allowemptycommit and |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
657 # also add also add some salt to the commit extras to make sure we don't |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
658 # reuse an existing nodeid. |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
659 with repo.ui.configoverride( |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
660 {(b'ui', b'allowemptycommit'): b'true'}, b'evolve' |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
661 ): |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
662 extra = { |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
663 b'divergence_source_local': divergent.hex(), |
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
664 b'divergence_source_other': other.hex() |
5293
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
665 } |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
666 newnode = repo.commit(text=desc, user=user, date=date, extra=extra) |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
667 new = repo[newnode] |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
668 compat.update(new) |
5553
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
669 if haspublicdiv and publicdiv == divergent: |
5293
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
670 bypassphase(repo, (divergent, new), operation=b'evolve') |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
671 else: |
5293
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
672 obsolete.createmarkers(repo, [(divergent, (new,))], |
13376ca93fa3
evolve: always create commit when resolving divergence
Martin von Zweigbergk <martinvonz@google.com>
parents:
5285
diff
changeset
|
673 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
|
674 |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
675 # creating markers and moving phases post-resolution |
5553
355a7c91ce9a
evolve: rename haspubdiv to haspublicdiv for more clarity
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5552
diff
changeset
|
676 if haspublicdiv and publicdiv == other: |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
677 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
|
678 else: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
679 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
|
680 if storemarker: |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
681 # storing the marker in the evolvestate |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
682 # 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
|
683 # 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
|
684 # future |
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
685 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
|
686 |
5005
e66ba12e5db3
evolve: remove obsolete backup of allowemptycommit config
Martin von Zweigbergk <martinvonz@google.com>
parents:
5004
diff
changeset
|
687 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
|
688 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
|
689 |
4584
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
690 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
|
691 """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
|
692 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
|
693 |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
694 # 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
|
695 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
|
696 aspects = set() |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
697 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
|
698 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
|
699 |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
706 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
|
707 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
|
708 |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
709 if aspects: |
fd8dada76730
evolve: warn user for the metadata being lost in public divergence resolution
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4583
diff
changeset
|
710 # warn user |
4747
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
711 locstr = bytes(local) |
fa6aafa2857d
py3: replace str(ctx) by bytes(ctx)
Martin von Zweigbergk <martinvonz@google.com>
parents:
4738
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 (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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 (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
|
726 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
|
727 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
|
728 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
729 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
|
730 """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
|
731 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
|
732 |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
733 # prepare metadata |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
734 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
|
735 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
|
736 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
|
737 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
|
738 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
|
739 # 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
|
740 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
|
741 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
|
742 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
|
743 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
|
744 |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
745 # 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
|
746 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
|
747 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
|
748 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
|
749 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
|
750 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
|
751 npare = None |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
752 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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
758 if saveeffectflag: |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
759 # 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
|
760 # future evolution |
4431
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
761 try: |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
762 effectflag = obsutil.geteffectflag(prec, (succ,)) |
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
763 except TypeError: |
5193
a4d081923c81
compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents:
5187
diff
changeset
|
764 # hg <= 4.7 (bae6f1418a95) |
4431
f109917f5c28
evolvecmd: compatibility with older geteffectflag() that took a tuple
Anton Shestakov <av6@dwimlabs.net>
parents:
4428
diff
changeset
|
765 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
|
766 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
|
767 |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
768 # create markers |
e6ba7e324015
evolve: introduce function to create a obsmarker relation even for public cset
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4378
diff
changeset
|
769 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
|
770 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
|
771 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
|
772 |
3879
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
773 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
|
774 """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
|
775 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
|
776 pass |
1fa3bf6e9e93
evolvecmd: introduce fn to be wrapped by extensions resolving content-div
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3878
diff
changeset
|
777 |
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
778 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
|
779 """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
|
780 the dirstate branch accordingly |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
781 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
|
782 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
783 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
|
784 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
|
785 """ |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
786 divbranch = divergent.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
787 basebranch = base.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
788 othbranch = other.branch() |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
789 # 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
|
790 # select one |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
791 if divbranch != othbranch: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
792 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
793 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
|
794 # 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
|
795 # preserved |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
796 pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
797 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
|
798 repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
799 else: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
800 # 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 b" $$ &c") % |
3829
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
806 (basebranch, divbranch, othbranch), 0) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
807 |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
808 if index == 0: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
809 repo.dirstate.setbranch(basebranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
810 elif index == 1: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
811 pass |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
812 elif index == 2: |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
813 repo.dirstate.setbranch(othbranch) |
cb45a7173e5b
evolve: factor out logic to merge branches in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3827
diff
changeset
|
814 |
3878
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
815 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
|
816 """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
|
817 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
|
818 |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
819 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
|
820 mdesc = [] |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
821 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
|
822 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
|
823 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
|
824 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
|
825 **kwargs): |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
826 mdesc.append(line) |
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
827 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
828 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
|
829 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
|
830 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
831 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
|
832 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
|
833 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
|
834 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
835 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
|
836 # 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
|
837 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
|
838 # 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
|
839 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
|
840 desc = resolveddesc |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
841 |
dc2b53b3573f
evolvecmd: move remaining logic to merge commit desc to existing utility fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3856
diff
changeset
|
842 return desc |
3801
ee78135b2f45
evolve: merge commit messages while resolving content-divergence (issue5877)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3800
diff
changeset
|
843 |
3469
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
844 def _orderrevs(repo, revs): |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
845 """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
|
846 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
847 revs is a list of unstable revisions. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
848 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
849 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
|
850 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
|
851 eventually. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
852 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
853 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
|
854 revision on its final stabilized destination. |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
855 """ |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
856 # Step 1: Build the dependency graph |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
857 dependencies, rdependencies = utility.builddependencies(repo, revs) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
858 # Step 2: Build the ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
859 # 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
|
860 # 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
|
861 # 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
|
862 # 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
|
863 # built |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
864 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
|
865 if not dependencies[r]]) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
866 ordering = [] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
867 while solvablerevs: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
868 rev = solvablerevs.popleft() |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
869 for dependent in rdependencies[rev]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
870 dependencies[dependent].remove(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
871 if not dependencies[dependent]: |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
872 solvablerevs.append(dependent) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
873 del dependencies[rev] |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
874 ordering.append(rev) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
875 |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
876 ordering.extend(sorted(dependencies)) |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
877 return ordering |
e97bfd529e72
evolve: move _orderrevs() function evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3466
diff
changeset
|
878 |
5775
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
879 def _rewrite_commit_message_hashes(repo, commitmsg): |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
880 """filter a commit description to update has to their successors |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
881 |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
882 The goal of this function is to avoid description referencing obsolete |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
883 hashes when a stack is rewritten or evolved. |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
884 |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
885 Each hash in the description will be detected and, if matching an obsolete |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
886 changeset, it will be replaced by its successors. |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
887 |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
888 Note: They might be case were such behavior might be is wrong, for example |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
889 if the commit message is explicitely referencing an older, obsolete changesets. |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
890 """ |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
891 cache = {} |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
892 sha1s = re.findall(sha1re, commitmsg) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
893 unfi = repo.unfiltered() |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
894 for sha1 in sha1s: |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
895 fullnode = scmutil.resolvehexnodeidprefix(unfi, sha1) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
896 if fullnode is None: |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
897 continue |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
898 ctx = unfi[fullnode] |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
899 if not ctx.obsolete(): |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
900 continue |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
901 |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
902 successors = obsutil.successorssets(repo, ctx.node(), cache=cache) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
903 |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
904 # We can't make any assumptions about how to update the hash if the |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
905 # cset in question was split or diverged. |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
906 if len(successors) == 1 and len(successors[0]) == 1: |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
907 newsha1 = nodemod.hex(successors[0][0]) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
908 commitmsg = commitmsg.replace(sha1, newsha1[:len(sha1)]) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
909 else: |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
910 repo.ui.note(_(b'The stale commit message reference to %s could ' |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
911 b'not be updated\n') % sha1) |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
912 return commitmsg |
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
913 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
914 def use_in_memory_merge(repo): |
5819
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
915 try: |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
916 from mercurial import mergestate as mergestatemod |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
917 mergestatemod.memmergestate |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
918 except (AttributeError, ImportError): |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
919 # no in-memory evolve if Mercurial lacks the required code |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
920 # hg <= 5.5 (19590b126764) |
82040a455e71
evolve: check if in-memory is supported on a good enough level for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
5818
diff
changeset
|
921 return False |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
922 config_value = repo.ui.config(b'experimental', b'evolution.in-memory') |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
923 if config_value == b'force': |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
924 return True |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
925 if repo.ui.hasconfig(b'hooks', b'precommit'): |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
926 return False |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
927 return stringutil.parsebool(config_value) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
928 |
5020
8f6095e88d1c
evolvecmd: mark relocate() private
Martin von Zweigbergk <martinvonz@google.com>
parents:
5019
diff
changeset
|
929 def _relocate(repo, orig, dest, evolvestate, pctx=None, keepbranch=False, |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
930 category=None, update=True): |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
931 """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
|
932 |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
933 Also updates bookmarks and creates obsmarkers. |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
934 |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
935 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
|
936 """ |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
937 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
|
938 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
|
939 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
|
940 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
|
941 b"directory parent is also destination") |
4269
d2599da04bb5
evolve: update the abort to a ProgrammingError
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4265
diff
changeset
|
942 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
|
943 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 |
5775
4a38b12141b5
evolvecmd: extract function for rewriting hashes in commit message
Martin von Zweigbergk <martinvonz@google.com>
parents:
5730
diff
changeset
|
952 commitmsg = _rewrite_commit_message_hashes(repo, orig.description()) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
953 |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
954 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
|
955 assert tr is not None |
5597
0cb1718ed95c
evolvecmd: move bookmark-deactivation out of _relocatecommit()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5596
diff
changeset
|
956 if repo._activebookmark: |
0cb1718ed95c
evolvecmd: move bookmark-deactivation out of _relocatecommit()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5596
diff
changeset
|
957 repo.ui.status(_(b"(leaving bookmark %s)\n") % repo._activebookmark) |
0cb1718ed95c
evolvecmd: move bookmark-deactivation out of _relocatecommit()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5596
diff
changeset
|
958 bookmarksmod.deactivate(repo) |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
959 nodenew = _relocatecommit(repo, orig, dest, pctx, keepbranch, commitmsg, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
960 update) |
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
961 _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
|
962 return nodenew |
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
963 |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
964 def _relocatecommit(repo, orig, dest, pctx, keepbranch, commitmsg, update): |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
965 extra = dict(orig.extra()) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
966 if b'branch' in extra: |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
967 del extra[b'branch'] |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
968 extra[b'rebase_source'] = orig.hex() |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
969 targetphase = max(orig.phase(), phases.draft) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
970 configoverrides = { |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
971 (b'phases', b'new-commit'): targetphase |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
972 } |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
973 with repo.ui.configoverride(configoverrides, source=b'evolve'): |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
974 if not update and use_in_memory_merge(repo): |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
975 try: |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
976 return _relocatecommitinmem( |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
977 repo, orig, dest, pctx, keepbranch, commitmsg, extra |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
978 ) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
979 except error.InMemoryMergeConflictsError: |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
980 repo.ui.status( |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
981 b'hit merge conflicts; retrying merge in working copy\n') |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
982 return _relocatecommitondisk(repo, orig, dest, pctx, keepbranch, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
983 commitmsg, extra) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
984 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
985 def _relocatecommitondisk(repo, orig, dest, pctx, keepbranch, commitmsg, extra): |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
986 """rewrites the orig rev on dest rev on disk |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
987 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
988 Creates the new commit by using the old-fashioned way of creating |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
989 commits by writing files to the working copy. |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
990 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
991 returns the node of new commit which is formed |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
992 """ |
5596
8e0bf4869cad
evolve: deactivate bookmark before updating to destination
Martin von Zweigbergk <martinvonz@google.com>
parents:
5595
diff
changeset
|
993 if repo[b'.'].rev() != dest.rev(): |
8e0bf4869cad
evolve: deactivate bookmark before updating to destination
Martin von Zweigbergk <martinvonz@google.com>
parents:
5595
diff
changeset
|
994 compat._update(repo, dest, branchmerge=False, force=True) |
5594
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
995 if keepbranch: |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
996 repo.dirstate.setbranch(orig.branch()) |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
997 if util.safehasattr(repo, 'currenttopic'): |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
998 # uurrgs |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
999 # there no other topic setter yet |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1000 if not orig.topic() and repo.vfs.exists(b'topic'): |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1001 repo.vfs.unlink(b'topic') |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1002 else: |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1003 with repo.vfs.open(b'topic', b'w') as f: |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1004 f.write(orig.topic()) |
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1005 |
5595
e190a81a3ee8
evolvecmd: inline _evolvemerge() into _relocatecommit()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5594
diff
changeset
|
1006 stats = merge.graft(repo, orig, pctx, [b'destination', b'evolving'], True) |
5594
dcadb8b1d098
evolvecmd: reorder some functions to match order they're called
Martin von Zweigbergk <martinvonz@google.com>
parents:
5593
diff
changeset
|
1007 |
5595
e190a81a3ee8
evolvecmd: inline _evolvemerge() into _relocatecommit()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5594
diff
changeset
|
1008 if stats.unresolvedcount: # some conflict |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1009 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
|
1010 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
|
1011 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
|
1012 |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1013 # Commit might fail if unresolved files exist |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1014 return repo.commit(text=commitmsg, user=orig.user(), |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1015 date=orig.date(), extra=extra) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1016 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1017 def _relocatecommitinmem(repo, orig, dest, pctx, keepbranch, commitmsg, extra): |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1018 """rewrites the orig rev on dest rev in memory |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1019 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1020 Creates the new commit by using the modern way of creating |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1021 commits without writing files to the working copy. |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1022 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1023 returns the node of new commit which is formed |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1024 """ |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1025 wctx = context.overlayworkingctx(repo) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1026 wctx.setbase(dest) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1027 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1028 stats = merge.graft( |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1029 repo, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1030 orig, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1031 pctx, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1032 [b'destination', b'evolving'], |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1033 keepparent=True, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1034 wctx=wctx |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1035 ) |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1036 |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1037 if stats.unresolvedcount: # some conflict |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1038 raise error.InMemoryMergeConflictsError() |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1039 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1040 branch = None |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1041 if keepbranch: |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1042 branch = orig.branch() |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1043 # FIXME: We call _compact() because it's required to correctly detect |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1044 # changed files. This was added to fix a regression shortly before the 5.5 |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1045 # release. A proper fix will be done in the default branch. |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1046 wctx._compact() |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1047 memctx = wctx.tomemctx( |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1048 commitmsg, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1049 date=orig.date(), |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1050 extra=extra, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1051 user=orig.user(), |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1052 branch=branch, |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1053 ) |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1054 if memctx.isempty() and not repo.ui.configbool(b'ui', b'allowemptycommit'): |
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1055 return None |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1056 return repo.commitctx(memctx) |
5777
c5dfbbe4363d
evolve: when relocating, optionally first try to do it using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5775
diff
changeset
|
1057 |
3639
95a767b2769e
evolve: add evolvestate as an argument to _finalizerelocate()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3638
diff
changeset
|
1058 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
|
1059 if nodenew is not None: |
5021
edcff79a3192
evolvecmd: avoid a ctx->node->ctx conversion
Martin von Zweigbergk <martinvonz@google.com>
parents:
5020
diff
changeset
|
1060 obsolete.createmarkers(repo, [(orig, (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
|
1061 operation=b'evolve') |
5592
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1062 bmdest = nodenew |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1063 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
|
1064 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
|
1065 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
|
1066 b"to commit\n") % (orig.rev(), orig)) |
5021
edcff79a3192
evolvecmd: avoid a ctx->node->ctx conversion
Martin von Zweigbergk <martinvonz@google.com>
parents:
5020
diff
changeset
|
1067 obsolete.createmarkers(repo, [(orig, ())], 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
|
1068 # Behave like rebase, move bookmarks to dest |
5592
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1069 bmdest = dest.node() |
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1070 |
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1071 nodesrc = orig.node() |
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1072 oldbookmarks = repo.nodebookmarks(nodesrc) |
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1073 if oldbookmarks: |
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1074 bmchanges = [] |
3463
f994c480cea9
evolvecmd: move more chunks of code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3462
diff
changeset
|
1075 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
|
1076 evolvestate[b'bookmarkchanges'].append((book, nodesrc)) |
5592
95949b06bd48
evolvecmd: simplify code for moving bookmarks when relocating node
Martin von Zweigbergk <martinvonz@google.com>
parents:
5591
diff
changeset
|
1077 bmchanges.append((book, bmdest)) |
3699
67d6cc7e0979
compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3698
diff
changeset
|
1078 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
|
1079 |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1080 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
|
1081 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
|
1082 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
|
1083 } |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1084 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1085 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
|
1086 """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
|
1087 revs = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1088 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
|
1089 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
|
1090 if revopt: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1091 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
|
1092 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 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
|
1098 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
|
1099 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
|
1100 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
|
1101 # 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
|
1102 revs = _dedupedivergents(repo, revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 % 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
|
1111 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
|
1112 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
|
1113 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
|
1114 return revs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1115 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1116 def _dedupedivergents(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1117 """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
|
1118 lowest revision numbers |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1119 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1120 repo = repo.unfiltered() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1121 res = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1122 # 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
|
1123 discarded = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1124 for rev in revs: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1125 if rev in discarded: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1126 continue |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1127 divergent = repo[rev] |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1128 base, others = divergentdata(divergent) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1129 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
|
1130 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
|
1131 discarded.update(othersrevs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1132 return res |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1133 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1134 def divergentdata(ctx): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1135 """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
|
1136 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1137 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
|
1138 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1139 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
|
1140 """ |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1141 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
|
1142 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
|
1143 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
|
1144 # 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
|
1145 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
|
1146 if newer: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1147 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
|
1148 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
|
1149 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
|
1150 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1151 def _aspiringdescendant(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1152 """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
|
1153 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
|
1154 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1155 result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1156 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
|
1157 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
|
1158 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
|
1159 paths[d].add(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1160 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1161 result = set(target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1162 tovisit = list(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1163 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1164 base = tovisit.pop() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1165 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
|
1166 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
|
1167 tovisit.append(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1168 result.add(unstable) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1169 return sorted(result - target) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1170 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1171 def _aspiringchildren(repo, revs): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1172 """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
|
1173 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
|
1174 target = set(revs) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1175 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
|
1176 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
|
1177 dest = _possibledestination(repo, r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1178 if target & dest: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1179 result.append(r) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1180 return result |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1181 |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1182 def _possibledestination(repo, rev): |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1183 """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
|
1184 tonode = repo.changelog.node |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1185 parents = repo.changelog.parentrevs |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1186 torev = repo.changelog.rev |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1187 dest = set() |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1188 tovisit = list(parents(rev)) |
5264
6d0d9ba04a1d
evolve: provide cache to successorssets() in _possibledestination()
Anton Shestakov <av6@dwimlabs.net>
parents:
5212
diff
changeset
|
1189 cache = {} |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1190 while tovisit: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1191 r = tovisit.pop() |
4230
e796835fe6b3
evolvecmd: _possibledestination() skip visiting empty parent
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4209
diff
changeset
|
1192 if r == -1: |
e796835fe6b3
evolvecmd: _possibledestination() skip visiting empty parent
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4209
diff
changeset
|
1193 continue |
5264
6d0d9ba04a1d
evolve: provide cache to successorssets() in _possibledestination()
Anton Shestakov <av6@dwimlabs.net>
parents:
5212
diff
changeset
|
1194 succsets = obsutil.successorssets(repo, tonode(r), cache=cache) |
3464
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1195 if not succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1196 tovisit.extend(parents(r)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1197 else: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1198 # 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
|
1199 # (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
|
1200 # 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
|
1201 # multiple branches. |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1202 for ss in succsets: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1203 for n in ss: |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1204 dest.add(torev(n)) |
908d2b5dfa7e
evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3463
diff
changeset
|
1205 return dest |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1206 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1207 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
|
1208 """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
|
1209 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
|
1210 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
|
1211 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
|
1212 msg = None |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1213 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
|
1214 retoverride = None |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1215 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 } |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1222 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 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
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 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
|
1241 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
|
1242 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
|
1243 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
|
1244 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
|
1245 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
|
1246 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
|
1247 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
|
1248 b"and --orphan"), |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1249 } |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1250 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1251 if revopt: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1252 revs = scmutil.revrange(repo, revopt) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1253 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
|
1254 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
|
1255 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
|
1256 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
|
1257 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1258 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1259 if revs & troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1260 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1261 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
|
1262 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
|
1263 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1264 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
|
1265 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
|
1266 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1267 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1268 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1269 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1270 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
|
1271 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
|
1272 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1273 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1274 # 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
|
1275 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
|
1276 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
|
1277 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
|
1278 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
|
1279 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1280 p1 = repo[b'.'].rev() |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1281 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1282 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1283 if p1 in troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1284 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1285 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
|
1286 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
|
1287 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1288 length = len(troubled[targetcat]) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1289 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
|
1290 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
|
1291 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
|
1292 else: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1293 othertroubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1294 for cat in unselectedcategories: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1295 if troubled[cat]: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1296 othertroubles.append(cat) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 # 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
|
1302 retoverride = 0 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1303 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1304 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
|
1305 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
|
1306 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
|
1307 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
|
1308 ret = 2 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1309 else: |
3649
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1310 ret = 1 |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1311 |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1312 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
|
1313 return retoverride |
4fcf815916f5
evolve: do not exit 1 when there are no troubled changesets (issue5823)
Kyle Lippincott <spectral@google.com>
parents:
3643
diff
changeset
|
1314 return ret |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1315 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1316 def _preparelistctxs(items, condition): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1317 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
|
1318 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1319 def _formatctx(fm, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1320 fm.data(node=ctx.hex()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1321 fm.data(desc=ctx.description()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1322 fm.data(date=ctx.date()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1323 fm.data(user=ctx.user()) |
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 listtroubles(ui, repo, troublecategories, **opts): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1326 """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
|
1327 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
|
1328 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
|
1329 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
|
1330 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
|
1331 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1332 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
|
1333 if opts.get('rev'): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1334 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
|
1335 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1336 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
|
1337 for rev in revs: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1338 ctx = repo[rev] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1339 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
|
1340 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
|
1341 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
|
1342 lambda p: not p.mutable()) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1343 dsets = divergentsets(repo, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1344 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1345 fm.startitem() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1346 # plain formatter section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1347 hashlen, desclen = 12, 60 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1348 desc = ctx.description() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1349 if desc: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1350 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
|
1351 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
|
1352 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
|
1353 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
|
1354 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
|
1355 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1356 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
|
1357 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
|
1358 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
|
1359 TROUBLES['ORPHAN'])) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1360 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
|
1361 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
|
1362 obspar[:hashlen])) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1363 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
|
1364 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
|
1365 (TROUBLES['PHASEDIVERGENT'], imprec[:hashlen])) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1366 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1367 if dsets and showdivergent: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 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
|
1373 first = False |
3977
a0a4f4de9ea3
evolvecmd: import mercurial.node module as nodemod
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3927
diff
changeset
|
1374 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
|
1375 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
|
1376 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
|
1377 fm.plain(b"\n") |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1378 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1379 # templater-friendly section |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1380 _formatctx(fm, ctx) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1381 troubles = [] |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1382 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
|
1383 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
|
1384 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
|
1385 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
|
1386 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
|
1387 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
|
1388 b'sourcetype': b'obsoleteparent'}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1389 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
|
1390 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
|
1391 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
|
1392 b'sourcetype': b'immutableprecursor'}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1393 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
|
1394 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
|
1395 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
|
1396 } 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
|
1397 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
|
1398 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
|
1399 b'divergentnodes': divnodes}) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1400 fm.data(troubles=troubles) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1401 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1402 fm.end() |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1403 |
3466
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1404 def _checkevolveopts(repo, opts): |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1405 """ 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
|
1406 if any """ |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1407 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1408 if opts['continue']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1409 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
|
1410 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
|
1411 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
|
1412 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
|
1413 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
|
1414 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
|
1415 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
|
1416 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
|
1417 b' "--continue"')) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1418 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
|
1419 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
|
1420 b' "--continue"')) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1421 |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1422 if opts['stop']: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1423 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
|
1424 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 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
|
1431 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1432 if opts['abort']: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1433 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
|
1434 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
|
1435 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
|
1436 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
|
1437 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
|
1438 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
|
1439 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1440 if opts['rev']: |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1441 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
|
1442 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
|
1443 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
|
1444 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
|
1445 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1446 # Backward compatibility |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1447 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
|
1448 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
|
1449 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
|
1450 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
|
1451 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1452 opts['orphan'] = opts['divergent'] |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1453 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1454 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
|
1455 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
|
1456 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
|
1457 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
|
1458 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1459 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
|
1460 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1461 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
|
1462 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
|
1463 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
|
1464 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
|
1465 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1466 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
|
1467 |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1468 return opts |
0a8e3130ad00
evolvecmd: move more core from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3465
diff
changeset
|
1469 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1470 def _cleanup(ui, repo, startnode, shouldupdate, headnode): |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1471 """Update to the right destination after evolving, if necessary |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1472 |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1473 headnode is the last node created by the evolve operation (which |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1474 we may need to update to when using in-memory merge) |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1475 """ |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1476 # If --update was passed, we should update to some head of the evolved set, |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1477 # but we only need to do that in the in-memory case. If --update was not |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1478 # passed, we should still update the working copy to its successor if there |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1479 # is one. |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1480 if shouldupdate: |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1481 if use_in_memory_merge(repo) and headnode: |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1482 compat.update(repo[headnode]) |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1483 else: |
4377
c2f9de28415a
evolve: document the "if not shouldupdate" block
Martin von Zweigbergk <martinvonz@google.com>
parents:
4376
diff
changeset
|
1484 # 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
|
1485 # 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
|
1486 unfi = repo.unfiltered() |
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1487 succ = utility._singlesuccessor(repo, unfi[startnode]) |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1488 compat.update(repo[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
|
1489 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
|
1490 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
|
1491 |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1492 def divergentsets(repo, ctx): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1493 """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
|
1494 cache = {} |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1495 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
|
1496 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
|
1497 if n == ctx.node(): |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1498 # 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
|
1499 continue |
5048
3947964a4ce7
evolve: provide cache argument to obsutil.successorssets() correctly
Anton Shestakov <av6@dwimlabs.net>
parents:
4998
diff
changeset
|
1500 nsuccsets = obsutil.successorssets(repo, n, cache=cache) |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1501 for nsuccset in nsuccsets: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1502 if ctx.node() in nsuccset: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1503 # 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
|
1504 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1505 if tuple(nsuccset) in base: |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1506 # 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
|
1507 continue |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1508 base[tuple(nsuccset)] = n |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1509 divergence = [] |
4714
c51fc0ae7a7e
py3: switch from iteritems() to items()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4706
diff
changeset
|
1510 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
|
1511 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
|
1512 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
|
1513 b'commonprecursor': b |
3465
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1514 }) |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1515 |
ffe566999920
evolvecmd: move code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3464
diff
changeset
|
1516 return divergence |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1517 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1518 @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
|
1519 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
|
1520 [(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
|
1521 _(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
|
1522 (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
|
1523 _(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
|
1524 (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
|
1525 _(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
|
1526 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
|
1527 (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
|
1528 (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
|
1529 (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
|
1530 (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
|
1531 (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
|
1532 (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
|
1533 (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
|
1534 (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
|
1535 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
|
1536 (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
|
1537 (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
|
1538 (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
|
1539 (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
|
1540 (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
|
1541 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
|
1542 ] + mergetoolopts, |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1543 _(b'[OPTIONS]...'), |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4857
diff
changeset
|
1544 helpbasic=True, |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4857
diff
changeset
|
1545 **compat.helpcategorykwargs('CATEGORY_CHANGE_MANAGEMENT') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1546 ) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1547 def evolve(ui, repo, **opts): |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1548 """solve troubled changesets in your repository |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1549 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1550 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
|
1551 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
|
1552 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
|
1553 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1554 - 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
|
1555 - rebase an orphan changeset |
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1556 - 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
|
1557 - 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
|
1558 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1559 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
|
1560 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
|
1561 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
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 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
|
1567 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
|
1568 |
4751
d0965c5c5335
evolve: further clarify when update is performed
kevpeng@google.com
parents:
4708
diff
changeset
|
1569 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
|
1570 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
|
1571 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
|
1572 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 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
|
1577 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
|
1578 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1579 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
|
1580 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
|
1581 ``--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
|
1582 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
|
1583 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
|
1584 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
|
1585 all branches. |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1586 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1587 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
|
1588 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
|
1589 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
|
1590 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
|
1591 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
|
1592 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
|
1593 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1594 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
|
1595 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
|
1596 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1597 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
|
1598 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
|
1599 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
|
1600 ``--rev`` and ``--any``. |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1601 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1602 ``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
|
1603 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
|
1604 |
4180
96525b95d083
evolvecmd: use modern vocabulary in help text for evolve
Anton Shestakov <av6@dwimlabs.net>
parents:
4179
diff
changeset
|
1605 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
|
1606 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
|
1607 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
|
1608 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
|
1609 ``--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
|
1610 ``--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
|
1611 |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1612 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
|
1613 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
|
1614 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
|
1615 --phase-divergent flags. |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1616 |
3821
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1617 Interrupted |
f67ac33c07d2
evolve: rename help topic evolve.interrupted-evolve to evolve.interrupted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3811
diff
changeset
|
1618 =========== |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1619 |
5210
b9b71fdea693
evolve: fix some documentation grammar/typos
Eric Spishak-Thomas <emspishak@gmail.com>
parents:
5111
diff
changeset
|
1620 The `hg evolve` command is an all purpose tool that solves all kinds of |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1621 instabilities in your repository. Sometimes, instability resolution will lead |
5210
b9b71fdea693
evolve: fix some documentation grammar/typos
Eric Spishak-Thomas <emspishak@gmail.com>
parents:
5111
diff
changeset
|
1622 to merge conflicts that cannot be solved without human intervention (same as |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1623 `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
|
1624 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
|
1625 situation: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1626 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1627 - `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
|
1628 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
|
1629 continue the interrupted evolve |
3795
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1630 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1631 - `hg evolve --stop`: |
4265
4d62095d9fe6
evolve: fix a documentation typo
Eric Spishak-Thomas <spishak@google.com>
parents:
4235
diff
changeset
|
1632 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
|
1633 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
|
1634 |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1635 - `hg evolve --abort`: |
b8b4ff86feb8
evolve: add a help topic `Interrupted-Evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3794
diff
changeset
|
1636 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
|
1637 happened |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1638 """ |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1639 with repo.wlock(), repo.lock(): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1640 return _performevolve(ui, repo, **opts) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1641 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1642 def _performevolve(ui, repo, **opts): |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1643 opts = _checkevolveopts(repo, opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1644 # Options |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1645 contopt = opts['continue'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1646 anyopt = opts['any'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1647 allopt = opts['all'] |
4580
3ef96578da43
evolve: use --all by default (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
4577
diff
changeset
|
1648 if allopt is None: |
3ef96578da43
evolve: use --all by default (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
4577
diff
changeset
|
1649 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
|
1650 startnode = repo[b'.'].node() |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1651 dryrunopt = opts['dry_run'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1652 confirmopt = opts['confirm'] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1653 revopt = opts['rev'] |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1654 stopopt = opts['stop'] |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1655 abortopt = opts['abort'] |
3774
4736d0bb81bf
evolve: add an `--update` flag to `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3772
diff
changeset
|
1656 shouldupdate = opts['update'] |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1657 |
4762
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1658 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
|
1659 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
|
1660 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
|
1661 b'orphan': r'orphan', |
4762
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1662 } |
75bc0a51809a
py3: redefine "troublecategories" in evolve as a dict
Martin von Zweigbergk <martinvonz@google.com>
parents:
4752
diff
changeset
|
1663 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
|
1664 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
|
1665 ui.pager(b'evolve') |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1666 listtroubles(ui, repo, specifiedcategories, **opts) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1667 return |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1668 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1669 targetcat = b'orphan' |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1670 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
|
1671 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
|
1672 raise error.Abort(msg) |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1673 elif len(specifiedcategories) == 1: |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1674 targetcat = specifiedcategories[0] |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1675 |
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 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
|
1677 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1678 headnode = None |
3477
713e26a647f5
evolve: create a state object in all case
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3470
diff
changeset
|
1679 evolvestate = state.cmdstate(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1680 # Continuation handling |
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1681 if contopt: |
3556
b0438c9101ad
evolve: load evolvestate before passing to continueevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3555
diff
changeset
|
1682 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
|
1683 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
|
1684 evolvestate.load() |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1685 headnode = 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
|
1686 if evolvestate[b'command'] != b'evolve': |
3558
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1687 evolvestate.delete() |
cec6e21b3bcf
evolve: de-duplicate some function calls
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3557
diff
changeset
|
1688 return |
5691
6eb9f82b43ba
evolve: remove spurious "working directory is now at ..." messages
Martin von Zweigbergk <martinvonz@google.com>
parents:
5620
diff
changeset
|
1689 startnode = evolvestate[b'startnode'] |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1690 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
|
1691 shouldupdate = evolvestate[b'update'] |
3557
77a400149758
evolve: move deletion of evolvestate out of continueevolve() function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3556
diff
changeset
|
1692 evolvestate.delete() |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1693 elif stopopt: |
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
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 stop')) |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1696 evolvestate.load() |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1697 stopevolve(ui, repo, evolvestate) |
5811
4688b7eb7e40
evolve: preserve wdir when using --stop
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5793
diff
changeset
|
1698 if evolvestate[b'command'] != b'evolve': |
4688b7eb7e40
evolve: preserve wdir when using --stop
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5793
diff
changeset
|
1699 evolvestate.delete() |
4688b7eb7e40
evolve: preserve wdir when using --stop
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5793
diff
changeset
|
1700 return |
4688b7eb7e40
evolve: preserve wdir when using --stop
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5793
diff
changeset
|
1701 startnode = repo.unfiltered()[evolvestate[b'startnode']] |
3577
279d8b610ac5
evolve: add a `--stop` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3573
diff
changeset
|
1702 evolvestate.delete() |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1703 elif abortopt: |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1704 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
|
1705 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
|
1706 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
|
1707 # `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
|
1708 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
|
1709 pctx = repo[b'.'] |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1710 compat.clean_update(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
|
1711 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
|
1712 ui.status(_(b'working directory is now at %s\n') |
5792
5d00679d78aa
evolve: rely on ctx.__bytes__() for formatting instead of using ctx.hex()[:12]
Anton Shestakov <av6@dwimlabs.net>
parents:
5785
diff
changeset
|
1713 % pctx) |
3981
b4d0245c7f40
evolve: delete evolvestate after aborting interrupted `next --evolve`
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3978
diff
changeset
|
1714 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
|
1715 return 0 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1716 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
|
1717 else: |
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1718 cmdutil.bailifchanged(repo) |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1719 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1720 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
|
1721 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
|
1722 |
4695
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1723 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
|
1724 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
|
1725 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
|
1726 |
4c9f9dac8977
evolve: fix the code flow pattern of solving obswdir par and troubled revs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4694
diff
changeset
|
1727 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
|
1728 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
|
1729 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
|
1730 # 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
|
1731 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
|
1732 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
|
1733 return 0 |
3470
ece5cd58147d
evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3469
diff
changeset
|
1734 |
4612
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1735 # Progress handling |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1736 seen = 1 |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1737 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
|
1738 count = len(revs) |
4612
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1739 |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1740 def progresscb(): |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1741 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
|
1742 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
|
1743 total=count) |
c289f06028d0
evolve: move more of the progress-related variables together
Martin von Zweigbergk <martinvonz@google.com>
parents:
4611
diff
changeset
|
1744 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1745 # Order the revisions |
3845
5c964ebe4d4b
evolve: always order the revs to be evolved
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3843
diff
changeset
|
1746 revs = _orderrevs(repo, revs) |
3480
1799fc777f30
evolve: store the target category in evolvestate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3479
diff
changeset
|
1747 |
3555
60e132e20b14
evolve: move the handling for non-continue part in else conditional
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3554
diff
changeset
|
1748 # 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
|
1749 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
|
1750 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
|
1751 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
|
1752 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
|
1753 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
|
1754 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
|
1755 evolvestate.addopts(stateopts) |
4155
cc3a0b13ae57
evolve: use stack alias s# in `hg evolve` msgs
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4154
diff
changeset
|
1756 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1757 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
|
1758 tr = repo.transaction(b"evolve") |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1759 with util.acceptintervention(tr): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1760 for rev in revs: |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1761 (solved, newnode) = _solveonerev(ui, repo, rev, evolvestate, |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1762 activetopic, dryrunopt, |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1763 confirmopt, progresscb, |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1764 targetcat) |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1765 if solved: |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1766 headnode = newnode |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1767 seen += 1 |
3573
d53277cdc1e7
evolve: handle stabilization of merge changeset with both parents obsoleted
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3571
diff
changeset
|
1768 |
4601
e5aa1e23d146
evolve: move progress-clearing out of _cleanup()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4600
diff
changeset
|
1769 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
|
1770 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
|
1771 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1772 _cleanup(ui, repo, startnode, shouldupdate, headnode) |
3554
f045fafd3484
evolve: move the logic of continuation handling of `hg evolve` in own fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3545
diff
changeset
|
1773 |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1774 def _solveonerev(ui, repo, rev, evolvestate, activetopic, dryrunopt, confirmopt, |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
1775 progresscb, targetcat): |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1776 """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
|
1777 |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1778 Like _solveone(), this solves one trouble. Unlike _solveone(), it |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1779 stabilizes for both parents of orphan merges. Returns the same value as |
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1780 _solveone(). |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1781 """ |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1782 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
|
1783 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
|
1784 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
|
1785 stacktmplt = False |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1786 # 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
|
1787 # 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
|
1788 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
|
1789 stacktmplt = True |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1790 progresscb() |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1791 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
|
1792 confirmopt, progresscb, targetcat, |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
1793 stacktmplt=stacktmplt) |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1794 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
|
1795 evolvestate[b'replacements'][curctx.node()] = ret[1] |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
1796 evolvestate[b'lastsolved'] = ret[1] |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1797 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
|
1798 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
|
1799 |
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 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
|
1801 # 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
|
1802 # 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
|
1803 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
|
1804 confirmopt, progresscb, targetcat, |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1805 stacktmplt=stacktmplt) |
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1806 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
|
1807 evolvestate[b'replacements'][curctx.node()] = ret[1] |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
1808 evolvestate[b'lastsolved'] = ret[1] |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1809 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
|
1810 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
|
1811 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1812 evolvestate[b'orphanmerge'] = False |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
1813 return ret |
4606
6c3f4cfa582e
evolve: extract function for solving one revision, including merges
Martin von Zweigbergk <martinvonz@google.com>
parents:
4605
diff
changeset
|
1814 |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1815 def solveobswdp(ui, repo, opts): |
4378
0b97d4bea7e0
evolve: add description of function solveobswdp
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4377
diff
changeset
|
1816 """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
|
1817 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
|
1818 startctx = repo[b'.'] |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1819 dryrunopt = opts.get('dry_run', False) |
5695
8c7de8f8bb42
evolve: respect command-templates.oneline-summary if configured
Martin von Zweigbergk <martinvonz@google.com>
parents:
5694
diff
changeset
|
1820 display = compat.format_changeset_summary_fn(ui, repo, b'evolve', |
8c7de8f8bb42
evolve: respect command-templates.oneline-summary if configured
Martin von Zweigbergk <martinvonz@google.com>
parents:
5694
diff
changeset
|
1821 shorttemplate) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 b' successors:\n')) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1827 for ln in exc.successorssets: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1828 for n in ln: |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
1829 display(repo[n]) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1830 return 2 |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1831 |
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 ui.status(_(b'update:')) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1833 if not ui.quiet: |
5694
bfdd8866f0b7
evolve: make the `displayer` we pass around just a function
Martin von Zweigbergk <martinvonz@google.com>
parents:
5693
diff
changeset
|
1834 display(ctx) |
4347
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1835 |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1836 if dryrunopt: |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1837 return 0 |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1838 res = hg.update(repo, ctx.rev()) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1839 newid = ctx.node() |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1840 |
4376
0fbf895ce160
evolve: make "startnode" consistently be a node, not a context
Martin von Zweigbergk <martinvonz@google.com>
parents:
4375
diff
changeset
|
1841 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
|
1842 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
|
1843 bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr) |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1844 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
|
1845 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
|
1846 return res |
59745d6d626d
evolve: extract "update" code into its own function
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4344
diff
changeset
|
1847 |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1848 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
|
1849 """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
|
1850 updated = False |
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1851 pctx = None |
5029
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1852 divrelocated = evolvestate.get(b'relocated-div') |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1853 otherrelocated = evolvestate.get(b'relocated-other') |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1854 strips = [] |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1855 if divrelocated: |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1856 strips.append(divrelocated) |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1857 if otherrelocated: |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1858 strips.append(otherrelocated) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1859 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
|
1860 and evolvestate[b'category'] == b'contentdivergent' |
5029
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1861 and strips): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1862 oldother = evolvestate[b'old-other'] |
5029
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1863 olddiv = evolvestate[b'old-divergent'] |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1864 if olddiv: |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1865 with repo.wlock(), repo.lock(): |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1866 repo = repo.unfiltered() |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1867 pctx = repo[olddiv] |
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1868 compat.clean_update(pctx) |
5029
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1869 repair.strip(ui, repo, strips, False) |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1870 updated = True |
421b295e32b4
evolve: add logic to cover --stop when "divergent" relocation in play
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5022
diff
changeset
|
1871 elif oldother: |
3827
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1872 with repo.wlock(), repo.lock(): |
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1873 repo = repo.unfiltered() |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1874 pctx = repo[oldother] |
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1875 compat.clean_update(pctx) |
3827
82c72eb37f85
evolve: strip the relocation commit on `hg evolve --stop`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3826
diff
changeset
|
1876 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
|
1877 updated = True |
3826
8e8bd5bb2f90
evolve: declare updated and pctx variables in stopevolve()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3825
diff
changeset
|
1878 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
|
1879 pctx = repo[b'.'] |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1880 compat.clean_update(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
|
1881 ui.status(_(b'stopped the interrupted evolve\n')) |
3824
a8f509981d30
evolve: factor out logic for --stop flag in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3822
diff
changeset
|
1882 |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1883 def abortevolve(ui, repo, evolvestate): |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1884 """ 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
|
1885 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1886 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
|
1887 repo = repo.unfiltered() |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1888 evolvedctx = [] |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1889 # 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
|
1890 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
|
1891 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
|
1892 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
|
1893 if new: |
a19703c6d2bb
evolve: check for None before adding in set of revisions to strip
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3754
diff
changeset
|
1894 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
|
1895 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
|
1896 if temp: |
2bc60fcac354
evolve: make `--abort` strip the temporary revs created during resolution
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3756
diff
changeset
|
1897 evolvedctx.append(repo[temp]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1898 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
|
1899 |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1900 # 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
|
1901 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
|
1902 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
|
1903 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
|
1904 % 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
|
1905 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
|
1906 cleanup = False |
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1907 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1908 # 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
|
1909 descendants = set() |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1910 if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1911 descendants = set(repo.changelog.descendants(evolvedrevs)) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1912 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
|
1913 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
|
1914 b"branch\n")) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1915 cleanup = False |
3832
fb821ed44f86
evolve: strip the extra obsmarkers if any on `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3831
diff
changeset
|
1916 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1917 # 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
|
1918 # 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
|
1919 if evolvestate[b'obsmarkers']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1920 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
|
1921 for m in evolvestate[b'obsmarkers']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1922 m = (m[0], m[1]) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1923 stripmarkers.add(m) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1924 indices = [] |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1925 allmarkers = obsutil.getmarkers(repo) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1926 for i, m in enumerate(allmarkers): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1927 marker = (m.prednode(), m.succnodes()[0]) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1928 if marker in stripmarkers: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1929 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
|
1930 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1931 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
|
1932 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
|
1933 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1934 if cleanup: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1935 if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1936 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
|
1937 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
|
1938 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1939 # updating the working directory |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1940 compat.clean_update(repo[startnode]) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1941 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1942 # Strip from the first evolved revision |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1943 if evolvedrevs: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1944 # no backup of evolved cset versions needed |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1945 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
|
1946 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
1947 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
|
1948 # 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
|
1949 bmchanges = evolvestate[b'bookmarkchanges'] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1950 if bmchanges: |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1951 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
|
1952 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1953 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
|
1954 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
|
1955 ui.status(_(b'working directory is now at %s\n') |
5793
ccc558c9c736
evolve: use nodemod.short() instead of nodemod.hex()[:12]
Anton Shestakov <av6@dwimlabs.net>
parents:
5792
diff
changeset
|
1956 % nodemod.short(startnode)) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1957 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
|
1958 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
|
1959 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
|
1960 |
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1961 def hgabortevolve(ui, repo): |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1962 """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
|
1963 with repo.wlock(), repo.lock(): |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1964 evolvestate = state.cmdstate(repo) |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1965 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
|
1966 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
|
1967 pctx = repo[b'.'] |
5615
947820d4b476
compat: add implementations of new merge.update() and merge.clean_update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5614
diff
changeset
|
1968 compat.clean_update(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
|
1969 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
|
1970 ui.status(_(b'working directory is now at %s\n') |
5792
5d00679d78aa
evolve: rely on ctx.__bytes__() for formatting instead of using ctx.hex()[:12]
Anton Shestakov <av6@dwimlabs.net>
parents:
5785
diff
changeset
|
1971 % pctx) |
3642
319b1f0f4de2
evolve: add a `--abort` flag for `hg evolve` command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3640
diff
changeset
|
1972 evolvestate.delete() |
4798
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1973 return 0 |
2e14a9386316
abort: added support for evolve to hg abort
Taapas Agrawal <taapas2897@gmail.com>
parents:
4797
diff
changeset
|
1974 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
|
1975 |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
1976 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
|
1977 """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
|
1978 |
5431
b34af5087714
compat: compatibility for mergestate being a separate module in 5.5
Anton Shestakov <av6@dwimlabs.net>
parents:
5297
diff
changeset
|
1979 ms = compat.mergestate.read(repo) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1980 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
|
1981 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
|
1982 or evolvestate[b'category'] == b'orphan'): |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1983 _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
|
1984 elif evolvestate[b'category'] == b'phasedivergent': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1985 _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
|
1986 elif evolvestate[b'category'] == b'contentdivergent': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1987 _continuecontentdivergent(ui, repo, evolvestate, None) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1988 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
|
1989 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
|
1990 b" supported\n") % evolvestate[b'category']) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1991 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
|
1992 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1993 # 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
|
1994 if evolvestate[b'command'] != b'evolve': |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1995 return |
4589
5ba885e2ef5e
evolve: reduce indentation with an early return statement
Martin von Zweigbergk <martinvonz@google.com>
parents:
4588
diff
changeset
|
1996 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1997 # Progress handling |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
1998 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
|
1999 count = len(evolvestate[b'revs']) |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
2000 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2001 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
|
2002 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
|
2003 total=count) |
4603
8cc329d705f9
evolve: add progress support for --continue
Martin von Zweigbergk <martinvonz@google.com>
parents:
4602
diff
changeset
|
2004 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
2005 headnode = 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
|
2006 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
|
2007 confirm = evolvestate[b'confirm'] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2008 unfi = 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
|
2009 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
|
2010 tr = repo.transaction(b"evolve") |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2011 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
|
2012 for rev in evolvestate[b'revs']: |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2013 # 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
|
2014 curctx = unfi[rev] |
4221
db70de7c1698
evolve: use stack template in --continue case also
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4219
diff
changeset
|
2015 |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2016 # 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
|
2017 revtopic = getattr(curctx, 'topic', lambda: b'')() |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2018 topicidx = getattr(curctx, 'topicidx', lambda: None)() |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2019 stacktmplt = False |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2020 if (activetopic and (activetopic == revtopic) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2021 and topicidx is not None): |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2022 stacktmplt = True |
4608
fe22c36b5563
evolve: use single transaction also when continuing
Martin von Zweigbergk <martinvonz@google.com>
parents:
4607
diff
changeset
|
2023 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2024 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
|
2025 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
|
2026 newnode = _solveone(ui, repo, curctx, evolvestate, False, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2027 confirm, progresscb, category, |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2028 stacktmplt=stacktmplt) |
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2029 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
|
2030 evolvestate[b'replacements'][curctx.node()] = newnode[1] |
5510
9fef6f8790a5
evolve: use evolvestate instead of populating a variable in functions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5477
diff
changeset
|
2031 evolvestate[b'lastsolved'] = newnode[1] |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
2032 headnode = newnode[1] |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2033 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
|
2034 evolvestate[b'skippedrevs'].append(curctx.node()) |
4797
8c780c3eb116
evolve: fixed lock acquire before checking state
Taapas Agrawal <taapas2897@gmail.com>
parents:
4774
diff
changeset
|
2035 seen += 1 |
5778
84affb254cdf
evolvecmd: don't update working copy when using in-memory merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
5777
diff
changeset
|
2036 return headnode |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2037 |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2038 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
|
2039 """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
|
2040 tr = repo.transaction(b'evolve') |
4594
fed1435757ba
evolve: use util.acceptintervention() for closing transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4593
diff
changeset
|
2041 with util.acceptintervention(tr): |
3822
cb060c408b41
evolve: move logic to continue interrupted content-div resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3821
diff
changeset
|
2042 repo = repo.unfiltered() |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2043 divergent = repo[evolvestate[b'divergent']] |
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2044 other = repo[evolvestate[b'other-divergent']] |
5552
4c328eb7196e
evolve: add some assertions
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5551
diff
changeset
|
2045 assert divergent != other |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2046 base = repo[evolvestate[b'base']] |
5550
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
2047 resolutionparent = repo[evolvestate.get(b'resolutionparent')] |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2048 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
|
2049 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
|
2050 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
|
2051 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
|
2052 operation=b'evolve') |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2053 evolvestate[b'old-divergent'] = divergent.node() |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2054 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
|
2055 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
|
2056 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
|
2057 evolvestate[b'divergent'] = newdiv |
5517
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
2058 divergent = repo[newdiv] |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2059 |
5572
d7d954b6d518
evolve: remove swapping nodes logic while resolving divergence
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5571
diff
changeset
|
2060 if evolvestate[b'relocate-other']: |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2061 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
|
2062 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
|
2063 ui.status(_(b'rebasing "other" content-divergent changeset %s on' |
5550
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
2064 b' %s\n' % (other, resolutionparent))) |
95d00d58885f
evolve: rely on resolutionparent when relocating divergent csets
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5541
diff
changeset
|
2065 newother = _relocatedivergent(repo, other, resolutionparent, |
5285
299d86c15b55
evolve: extract function for relocating divergent commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
5264
diff
changeset
|
2066 evolvestate) |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2067 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
|
2068 evolvestate[b'relocating-other'] = False |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2069 evolvestate[b'relocated-other'] = newother |
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2070 evolvestate[b'temprevs'].append(newother) |
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2071 evolvestate[b'other-divergent'] = newother |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2072 other = repo[newother] |
5557
ca45afafd94f
evolve: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5556
diff
changeset
|
2073 # continue the resolution by merging the content-divergent csets |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
2074 _mergecontentdivergents(repo, progresscb, divergent, other, |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2075 base, evolvestate) |
5016
64868b7dc112
evolve: add logic to cover --continue case when relocating "divergent"
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5014
diff
changeset
|
2076 |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
2077 if evolvestate[b'relocating-other']: |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2078 newother = _completerelocation(ui, repo, evolvestate) |
5516
2a04af930bad
evolve: update "old-other" in evolvestate for --stop functionality
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5515
diff
changeset
|
2079 evolvestate[b'old-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
|
2080 current = repo[evolvestate[b'current']] |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2081 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
|
2082 operation=b'evolve') |
5014
35870ce163ee
evolve: use more specific key name to store in evolvestate
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5012
diff
changeset
|
2083 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
|
2084 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
|
2085 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
|
2086 evolvestate[b'other-divergent'] = newother |
5517
a4c6c63e0ed5
evolve: refactor few lines for clear understanding
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5516
diff
changeset
|
2087 other = repo[newother] |
5557
ca45afafd94f
evolve: update some comments
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5556
diff
changeset
|
2088 # continue the resolution by merging the content-divergent csets |
5857
b0b1ab64f6d8
public-content-divergence: early set the public one to local side
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5820
diff
changeset
|
2089 _mergecontentdivergents(repo, progresscb, divergent, other, |
5561
d6b3f32f8261
evolve: add logic to decide local and other side before merge
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5560
diff
changeset
|
2090 base, evolvestate) |
3881
9cf45b94f977
evolve: continue conflicted relocation content-divergence
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3879
diff
changeset
|
2091 |
5017
b302066725c3
evolve: use meaningful variable names for a return value
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5016
diff
changeset
|
2092 res, newnode = _completecontentdivergent(ui, repo, progresscb, |
5515
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2093 divergent, other, |
159d6c0c7dbb
evolve: make consistent usage of variable throughout the func
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5514
diff
changeset
|
2094 base, 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
|
2095 origdivergent = evolvestate[b'orig-divergent'] |
5017
b302066725c3
evolve: use meaningful variable names for a return value
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5016
diff
changeset
|
2096 evolvestate[b'replacements'][origdivergent] = newnode |
b302066725c3
evolve: use meaningful variable names for a return value
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5016
diff
changeset
|
2097 ret = (res, newnode) |
4384
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2098 # 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
|
2099 publicnode = evolvestate.get(b'public-divergent') |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
2100 if publicnode: |
4384
8993fd4805d0
evolve: update the public divergence resolution logic to cover --continue case
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4383
diff
changeset
|
2101 if not res: |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2102 # 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
|
2103 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
|
2104 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
|
2105 # 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
|
2106 # 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
|
2107 pass |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2108 else: |
4415
29733c2b0fd3
evolve: rename npublicdiv to publicnode
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4414
diff
changeset
|
2109 prec = repo[publicnode] |
4414
29645d5ba3d9
evolve: in pubdiv resolution make sure that transaction get closed
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4413
diff
changeset
|
2110 bumped = repo[newnode] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
2111 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
|
2112 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
|
2113 |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2114 def _completephasedivergent(ui, repo, evolvestate): |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2115 """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
|
2116 |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2117 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
|
2118 phase-divergence""" |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2119 |
4593
f6b9c409c12e
evolve: use context manager for transactions
Martin von Zweigbergk <martinvonz@google.com>
parents:
4592
diff
changeset
|
2120 # 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
|
2121 with repo.transaction(b'evolve'): |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2122 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
|
2123 evolvestate[b'temprevs'].append(node) |
3633
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2124 # 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
|
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']] |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2127 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
|
2128 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
|
2129 |
ed3032ee53eb
evolve: handle interrupted phase-divergence resolution gracefully
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3632
diff
changeset
|
2130 # 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
|
2131 prec = repo[evolvestate[b'precursor']] |
4466
cc4506838589
evolve: remove tmpctx arg from _resolvephasedivergent()
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
4465
diff
changeset
|
2132 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
|
2133 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
|
2134 |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2135 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
|
2136 """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
|
2137 |
3630
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2138 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
|
2139 # 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
|
2140 # 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
|
2141 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
|
2142 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
|
2143 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
|
2144 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
|
2145 replacement = () |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2146 else: |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2147 replacement = (repo[node],) |
27947b17cfaf
evolve: orphans that evolve into nothing don't need successors (issue5967)
Anton Shestakov <av6@dwimlabs.net>
parents:
4641
diff
changeset
|
2148 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2149 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
|
2150 |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2151 # 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
|
2152 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
|
2153 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
|
2154 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
|
2155 # 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
|
2156 # 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
|
2157 # 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
|
2158 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
|
2159 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
|
2160 |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2161 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
|
2162 """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
|
2163 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
|
2164 """ |
2789c0ec2ad7
evolve: move logic to complete interrupted relocation to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3629
diff
changeset
|
2165 |
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 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
|
2167 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
|
2168 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
|
2169 extra = {} |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2170 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
|
2171 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
|
2172 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
|
2173 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
|
2174 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
|
2175 user = ctx.user() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2176 date = ctx.date() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2177 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
|
2178 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
|
2179 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
|
2180 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
|
2181 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
|
2182 |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2183 ctxparents = orig.parents() |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2184 if len(ctxparents) == 2: |
5019
967e9a87e82d
cleanup: replace .parents()[0] by .p1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5017
diff
changeset
|
2185 currentp1 = repo.dirstate.p1() |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2186 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
|
2187 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
|
2188 # 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
|
2189 # 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
|
2190 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
|
2191 # 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
|
2192 # 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
|
2193 # set dirstate parents to (succ of p1, p2) |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
2194 with repo.dirstate.parentchange(), compat.parentchange(repo): |
3629
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(currentp1, |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2196 ctxparents[1].node()) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2197 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
|
2198 # 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
|
2199 # 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
|
2200 # set dirstate parents to (succ of p2, p1) |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
2201 with repo.dirstate.parentchange(), compat.parentchange(repo): |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2202 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
|
2203 currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2204 |
5476
d542e9720b1e
orphan: fix buggy case of try resolving orphan merge two times
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
5474
diff
changeset
|
2205 elif p1obs and p2obs: |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2206 # 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
|
2207 # 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
|
2208 if evolvestate.get(b'orphanmerge'): |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
2209 with repo.dirstate.parentchange(), compat.parentchange(repo): |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2210 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
|
2211 currentp1) |
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2212 pass |
3978
fb8e44c70798
evolve: set the second parent if we get conflicts while evolving
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
3977
diff
changeset
|
2213 else: |
5096
6742ce189373
compat: add a context manager that calls _quick_access_changeid_invalidate()
Anton Shestakov <av6@dwimlabs.net>
parents:
5095
diff
changeset
|
2214 with repo.dirstate.parentchange(), compat.parentchange(repo): |
5019
967e9a87e82d
cleanup: replace .parents()[0] by .p1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
5017
diff
changeset
|
2215 repo.dirstate.setparents(repo.dirstate.p1(), nodemod.nullid) |
3629
f23946bf6625
evolve: move logic to complete interrupted orphan resolution to new fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3628
diff
changeset
|
2216 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4812
diff
changeset
|
2217 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
|
2218 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
|
2219 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
|
2220 return node |