author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Wed, 21 Nov 2012 11:14:20 +0100 | |
branch | stable |
changeset 617 | 469befc27b26 |
parent 616 | 279403a12565 |
child 618 | c39afce52e31 |
child 621 | e50a5d9a6cbf |
permissions | -rw-r--r-- |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1 |
# Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2 |
# Logilab SA <contact@logilab.fr> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
3 |
# Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
519
9825c7da5b54
ensure all file have a copyright notice
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
517
diff
changeset
|
4 |
# Patrick Mezard <patrick@mezard.eu> |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
5 |
# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
7 |
# GNU General Public License version 2 or any later version. |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
8 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
9 |
'''Extends Mercurial feature related to Changeset Evolution |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
10 |
|
540
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
11 |
This extension provides several commands to mutate history and deal with |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
12 |
issues it may raise. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
13 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
14 |
It also: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
15 |
|
540
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
16 |
- enables the "Changeset Obsolescence" feature of mercurial, |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
17 |
- alters core commands and extensions that rewrite history to use |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
18 |
this feature, |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
19 |
- improves some aspect of the early implementation in 2.3 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
20 |
''' |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
21 |
|
617
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
22 |
testedwith = '2.4' |
584
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
23 |
buglink = 'https://bitbucket.org/marmoute/mutable-history/issues' |
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
24 |
|
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
25 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
26 |
import random |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
27 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
28 |
from mercurial import util |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
29 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
30 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
31 |
from mercurial import obsolete |
591
012e48e80840
evolve: require Mercurial 2.4 to work
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
590
diff
changeset
|
32 |
getattr(obsolete, 'getrevs') # 2.4 specific |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
33 |
if not obsolete._enabled: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
34 |
obsolete._enabled = True |
591
012e48e80840
evolve: require Mercurial 2.4 to work
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
590
diff
changeset
|
35 |
except (ImportError, AttributeError): |
617
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
36 |
raise util.Abort('Evolve extension requires Mercurial 2.4.x') |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
37 |
try: |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
38 |
from mercurial import bookmarks |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
39 |
bookmarks.bmstore |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
40 |
raise util.Abort('This version of Evolve is too old for you mercurial version') |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
41 |
except AttributeError: |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
42 |
pass |
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
43 |
|
585
f013ca072bd9
evolve: detect and abort if 2.4 is detected
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
584
diff
changeset
|
44 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
45 |
|
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
46 |
from mercurial import bookmarks |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
47 |
from mercurial import cmdutil |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
48 |
from mercurial import commands |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
49 |
from mercurial import context |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
50 |
from mercurial import copies |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
51 |
from mercurial import discovery |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
52 |
from mercurial import error |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
53 |
from mercurial import extensions |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
54 |
from mercurial import hg |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
55 |
from mercurial import localrepo |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
56 |
from mercurial import lock as lockmod |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
57 |
from mercurial import merge |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
58 |
from mercurial import node |
113
3bdabdbb4140
adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
108
diff
changeset
|
59 |
from mercurial import phases |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
60 |
from mercurial import revset |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
61 |
from mercurial import scmutil |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
62 |
from mercurial import templatekw |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
63 |
from mercurial.i18n import _ |
455
f46a41006136
obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
446
diff
changeset
|
64 |
from mercurial.commands import walkopts, commitopts, commitopts2 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
65 |
from mercurial.node import nullid |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
66 |
|
539
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
67 |
import mercurial.hgweb.hgweb_mod |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
68 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
69 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
70 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
71 |
# This extension contains the following code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
72 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
73 |
# - Extension Helper code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
74 |
# - Obsolescence cache |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
75 |
# - ... |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
76 |
# - Older format compat |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
77 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
78 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
79 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
80 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
81 |
### Extension helper ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
82 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
83 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
84 |
class exthelper(object): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
85 |
"""Helper for modular extension setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
86 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
87 |
A single helper should be instanciated for each extension. Helper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
88 |
methods are then used as decorator for various purpose. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
89 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
90 |
All decorators return the original function and may be chained. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
91 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
92 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
93 |
def __init__(self): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
94 |
self._uicallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
95 |
self._extcallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
96 |
self._repocallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
97 |
self._revsetsymbols = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
98 |
self._templatekws = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
99 |
self._commandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
100 |
self._extcommandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
101 |
self._functionwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
102 |
self._duckpunchers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
103 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
104 |
def final_uisetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
105 |
"""Method to be used as the extension uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
106 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
107 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
108 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
109 |
- Changes to ui.__class__ . The ui object that will be used to run the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
110 |
command has not yet been created. Changes made here will affect ui |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
111 |
objects created after this, and in particular the ui that will be |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
112 |
passed to runcommand |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
113 |
- Command wraps (extensions.wrapcommand) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
114 |
- Changes that need to be visible to other extensions: because |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
115 |
initialization occurs in phases (all extensions run uisetup, then all |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
116 |
run extsetup), a change made here will be visible to other extensions |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
117 |
during extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
118 |
- Monkeypatch or wrap function (extensions.wrapfunction) of dispatch |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
119 |
module members |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
120 |
- Setup of pre-* and post-* hooks |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
121 |
- pushkey setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
122 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
123 |
for cont, funcname, func in self._duckpunchers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
124 |
setattr(cont, funcname, func) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
125 |
for command, wrapper in self._commandwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
126 |
extensions.wrapcommand(commands.table, command, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
127 |
for cont, funcname, wrapper in self._functionwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
128 |
extensions.wrapfunction(cont, funcname, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
129 |
for c in self._uicallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
130 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
131 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
132 |
def final_extsetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
133 |
"""Method to be used as a the extension extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
134 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
135 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
136 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
137 |
- Changes depending on the status of other extensions. (if |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
138 |
extensions.find('mq')) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
139 |
- Add a global option to all commands |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
140 |
- Register revset functions |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
141 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
142 |
knownexts = {} |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
143 |
for name, symbol in self._revsetsymbols: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
144 |
revset.symbols[name] = symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
145 |
for name, kw in self._templatekws: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
146 |
templatekw.keywords[name] = kw |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
147 |
for ext, command, wrapper in self._extcommandwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
148 |
if ext not in knownexts: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
149 |
e = extensions.find(ext) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
150 |
if e is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
151 |
raise util.Abort('extension %s not found' % ext) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
152 |
knownexts[ext] = e.cmdtable |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
153 |
extensions.wrapcommand(knownexts[ext], commands, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
154 |
for c in self._extcallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
155 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
156 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
157 |
def final_reposetup(self, ui, repo): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
158 |
"""Method to be used as a the extension reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
159 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
160 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
161 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
162 |
- All hooks but pre-* and post-* |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
163 |
- Modify configuration variables |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
164 |
- Changes to repo.__class__, repo.dirstate.__class__ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
165 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
166 |
for c in self._repocallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
167 |
c(ui, repo) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
168 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
169 |
def uisetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
170 |
"""Decorated function will be executed during uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
171 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
172 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
173 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
174 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
175 |
def setupbabar(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
176 |
print 'this is uisetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
177 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
178 |
self._uicallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
179 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
180 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
181 |
def extsetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
182 |
"""Decorated function will be executed during extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
183 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
184 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
185 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
186 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
187 |
def setupcelestine(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
188 |
print 'this is extsetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
189 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
190 |
self._uicallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
191 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
192 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
193 |
def reposetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
194 |
"""Decorated function will be executed during reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
195 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
196 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
197 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
198 |
@eh.reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
199 |
def setupzephir(ui, repo): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
200 |
print 'this is reposetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
201 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
202 |
self._repocallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
203 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
204 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
205 |
def revset(self, symbolname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
206 |
"""Decorated function is a revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
207 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
208 |
The name of the symbol must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
209 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
210 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
211 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
212 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
213 |
@eh.revset('hidden') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
214 |
def revsetbabar(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
215 |
args = revset.getargs(x, 0, 0, 'babar accept no argument') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
216 |
return [r for r in subset if 'babar' in repo[r].description()] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
217 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
218 |
def dec(symbol): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
219 |
self._revsetsymbols.append((symbolname, symbol)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
220 |
return symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
221 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
222 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
223 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
224 |
def templatekw(self, keywordname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
225 |
"""Decorated function is a revset keyword |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
226 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
227 |
The name of the keyword must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
228 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
229 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
230 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
231 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
232 |
@eh.templatekw('babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
233 |
def kwbabar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
234 |
return 'babar' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
235 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
236 |
def dec(keyword): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
237 |
self._templatekws.append((keywordname, keyword)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
238 |
return keyword |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
239 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
240 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
241 |
def wrapcommand(self, command, extension=None): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
242 |
"""Decorated function is a command wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
243 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
244 |
The name of the command must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
245 |
The wrapping is installed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
246 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
247 |
If the second option `extension` argument is provided, the wrapping |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
248 |
will be applied in the extension commandtable. This argument must be a |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
249 |
string that will be searched using `extension.find` if not found and |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
250 |
Abort error is raised. If the wrapping applies to an extension, it is |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
251 |
installed during `extsetup` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
252 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
253 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
254 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
255 |
@eh.wrapcommand('summary') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
256 |
def wrapsummary(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
257 |
ui.note('Barry!') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
258 |
return orig(ui, repo, *args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
259 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
260 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
261 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
262 |
if extension is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
263 |
self._commandwrappers.append((command, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
264 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
265 |
self._extcommandwrappers.append((extension, command, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
266 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
267 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
268 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
269 |
def wrapfunction(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
270 |
"""Decorated function is a function wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
271 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
272 |
This function takes two arguments, the container and the name of the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
273 |
function to wrap. The wrapping is performed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
274 |
(there is no extension support) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
275 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
276 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
277 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
278 |
@eh.function(discovery, 'checkheads') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
279 |
def wrapfunction(orig, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
280 |
ui.note('His head smashed in and his heart cut out') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
281 |
return orig(*args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
282 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
283 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
284 |
self._functionwrappers.append((container, funcname, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
285 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
286 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
287 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
288 |
def addattr(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
289 |
"""Decorated function is to be added to the container |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
290 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
291 |
This function takes two arguments, the container and the name of the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
292 |
function to wrap. The wrapping is performed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
293 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
294 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
295 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
296 |
@eh.function(context.changectx, 'babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
297 |
def babar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
298 |
return 'babar' in ctx.description |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
299 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
300 |
def dec(func): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
301 |
self._duckpunchers.append((container, funcname, func)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
302 |
return func |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
303 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
304 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
305 |
eh = exthelper() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
306 |
uisetup = eh.final_uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
307 |
extsetup = eh.final_extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
308 |
reposetup = eh.final_reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
309 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
310 |
##################################################################### |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
311 |
### Critical fix ### |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
312 |
##################################################################### |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
313 |
|
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
314 |
@eh.wrapfunction(mercurial.obsolete, '_readmarkers') |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
315 |
def safereadmarkers(orig, data): |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
316 |
"""safe maker wrapper to remove nullid succesors |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
317 |
|
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
318 |
Nullid successors was created by older version of evolve. |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
319 |
""" |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
320 |
for marker in orig(data): |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
321 |
if nullid in marker[1]: |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
322 |
marker = (marker[0], |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
323 |
tuple(s for s in marker[1] if s != nullid), |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
324 |
marker[2], |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
325 |
marker[3]) |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
326 |
yield marker |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
327 |
|
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
328 |
|
579
f6063ef211fd
evolve: drop code now in core
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
329 |
cachefuncs = obsolete.cachefuncs |
f6063ef211fd
evolve: drop code now in core
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
330 |
cachefor = obsolete.cachefor |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
331 |
getrevs = obsolete.getrevs |
579
f6063ef211fd
evolve: drop code now in core
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
332 |
clearobscaches = obsolete.clearobscaches |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
333 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
334 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
335 |
### Complete troubles computation logic ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
336 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
337 |
|
604
d43e80504e55
evolve: some comment update
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
594
diff
changeset
|
338 |
# there is one kind of trouble not handled by core right now: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
339 |
# - divergent: (two changeset try to succeed to the same precursors) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
340 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
341 |
# This section add support for those two addition trouble |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
342 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
343 |
# - Cache computation |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
344 |
# - revset and ctx method |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
345 |
# - push warning |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
346 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
347 |
### Cache computation |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
348 |
latediff = 1 # flag to prevent taking late comer fix into account |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
349 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
350 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
351 |
@cachefor('divergent') |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
352 |
def _computedivergentset(repo): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
353 |
"""the set of rev trying to obsolete public revision""" |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
354 |
divergent = set() |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
355 |
obsstore = repo.obsstore |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
356 |
newermap = {} |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
357 |
for ctx in repo.set('(not public()) - obsolete()'): |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
358 |
mark = obsstore.precursors.get(ctx.node(), ()) |
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
359 |
toprocess = set(mark) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
360 |
while toprocess: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
361 |
prec = toprocess.pop()[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
362 |
if prec not in newermap: |
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
363 |
successorssets(repo, prec, newermap) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
364 |
newer = [n for n in newermap[prec] if n] |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
365 |
if len(newer) > 1: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
366 |
divergent.add(ctx.rev()) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
367 |
break |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
368 |
toprocess.update(obsstore.precursors.get(prec, ())) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
369 |
return divergent |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
370 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
371 |
### changectx method |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
372 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
373 |
@eh.addattr(context.changectx, 'latecomer') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
374 |
def latecomer(ctx): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
375 |
"""is the changeset bumped (Try to succeed to public change)""" |
594 | 376 |
return ctx.bumped() |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
377 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
378 |
@eh.addattr(context.changectx, 'conflicting') |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
379 |
@eh.addattr(context.changectx, 'divergent') |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
380 |
def divergent(ctx): |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
381 |
"""is the changeset divergent (Try to succeed to public change)""" |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
382 |
if ctx.node() is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
383 |
return False |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
384 |
return ctx.rev() in getrevs(ctx._repo, 'divergent') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
385 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
386 |
### revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
387 |
|
594 | 388 |
eh.revset('latecomer')(revset.symbols['bumped']) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
389 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
390 |
@eh.revset('conflicting') |
576
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
391 |
@eh.revset('divergent') |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
392 |
def revsetdivergent(repo, subset, x): |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
393 |
"""``divergent()`` |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
394 |
Changesets marked as successors of a same changeset. |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
395 |
""" |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
396 |
args = revset.getargs(x, 0, 0, 'divergent takes no arguments') |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
397 |
conf = getrevs(repo, 'divergent') |
576
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
398 |
return [r for r in subset if r in conf] |
cf116ffc9cc5
evolve: new divergent revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
572
diff
changeset
|
399 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
400 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
401 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
402 |
### Discovery wrapping |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
403 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
404 |
@eh.wrapfunction(discovery, 'checkheads') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
405 |
def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
406 |
"""wrap mercurial.discovery.checkheads |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
407 |
|
594 | 408 |
* prevent divergent to be pushed |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
409 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
410 |
# do not push instability |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
411 |
for h in outgoing.missingheads: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
412 |
# Checking heads is enough, obsolete descendants are either |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
413 |
# obsolete or unstable. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
414 |
ctx = repo[h] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
415 |
if ctx.divergent(): |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
416 |
raise util.Abort(_("push includes a divergent changeset: %s!") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
417 |
% ctx) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
418 |
return orig(repo, remote, outgoing, *args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
419 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
420 |
##################################################################### |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
421 |
### Filter extinct changesets from common operations ### |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
422 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
423 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
424 |
@eh.wrapfunction(merge, 'update') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
425 |
def wrapmergeupdate(orig, repo, node, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
426 |
"""ensure we don't automatically update on hidden changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
427 |
if node is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
428 |
# tip of current branch |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
429 |
branch = repo[None].branch() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
430 |
node = repo.revs('last((.:: and branch(%s)) - hidden())', branch)[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
431 |
return orig(repo, node, *args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
432 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
433 |
@eh.wrapfunction(localrepo.localrepository, 'branchtip') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
434 |
def obsbranchtip(orig, repo, branch): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
435 |
"""ensure "stable" reference does not end on a hidden changeset""" |
539
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
436 |
if not getattr(repo, '_dofilterbranchtip', True): |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
437 |
return orig(repo, branch) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
438 |
result = () |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
439 |
heads = repo.branchmap().get(branch, ()) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
440 |
if heads: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
441 |
result = list(repo.set('last(heads(branch(%n) - hidden()))', heads[0])) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
442 |
if not result: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
443 |
raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
444 |
return result[0].node() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
445 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
446 |
|
539
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
447 |
@eh.wrapfunction(mercurial.hgweb.hgweb_mod.hgweb, '__init__') |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
448 |
@eh.wrapfunction(mercurial.hgweb.hgweb_mod.hgweb, 'refresh') |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
449 |
def nofilter(orig, hgweb, *args, **kwargs): |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
450 |
orig(hgweb, *args, **kwargs) |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
451 |
hgweb.repo._dofilterbranchtip = False |
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
452 |
|
9555231a66b2
hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
534
diff
changeset
|
453 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
454 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
455 |
### Additional Utilities ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
456 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
457 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
458 |
# This section contains a lot of small utility function and method |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
459 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
460 |
# - Function to create markers |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
461 |
# - useful alias pstatus and pdiff (should probably go in evolve) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
462 |
# - "troubles" method on changectx |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
463 |
# - function to travel throught the obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
464 |
# - function to find useful changeset to stabilize |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
465 |
|
579
f6063ef211fd
evolve: drop code now in core
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
466 |
createmarkers = obsolete.createmarkers |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
467 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
468 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
469 |
### Useful alias |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
470 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
471 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
472 |
def _installalias(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
473 |
if ui.config('alias', 'pstatus', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
474 |
ui.setconfig('alias', 'pstatus', 'status --rev .^') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
475 |
if ui.config('alias', 'pdiff', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
476 |
ui.setconfig('alias', 'pdiff', 'diff --rev .^') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
477 |
if ui.config('alias', 'olog', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
478 |
ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden") |
497
43e1b2cab789
evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
492
diff
changeset
|
479 |
if ui.config('alias', 'odiff', None) is None: |
43e1b2cab789
evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
492
diff
changeset
|
480 |
ui.setconfig('alias', 'odiff', "diff --rev 'limit(precursors(.),1)' --rev .") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
481 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
482 |
# - "troubles" method on changectx |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
483 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
484 |
@eh.addattr(context.changectx, 'troubles') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
485 |
def troubles(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
486 |
"""Return a tuple listing all the troubles that affect a changeset |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
487 |
|
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
488 |
Troubles may be "unstable", "bumped" or "divergent". |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
489 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
490 |
troubles = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
491 |
if ctx.unstable(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
492 |
troubles.append('unstable') |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
493 |
if ctx.bumped(): |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
494 |
troubles.append('bumped') |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
495 |
if ctx.divergent(): |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
496 |
troubles.append('divergent') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
497 |
return tuple(troubles) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
498 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
499 |
### Troubled revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
500 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
501 |
@eh.revset('troubled') |
594 | 502 |
def revsettroubled(repo, subset, x): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
503 |
"""``troubled()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
504 |
Changesets with troubles. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
505 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
506 |
_ = revset.getargs(x, 0, 0, 'troubled takes no arguments') |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
507 |
return repo.revs('%ld and (unstable() + bumped() + divergent())', |
511
ddeb71df916d
evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents:
510
diff
changeset
|
508 |
subset) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
509 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
510 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
511 |
### Obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
512 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
513 |
# XXX SOME MAJOR CLEAN UP TO DO HERE XXX |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
514 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
515 |
def _precursors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
516 |
"""Precursor of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
517 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
518 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
519 |
markerbysubj = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
520 |
for r in s: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
521 |
for p in markerbysubj.get(repo[r].node(), ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
522 |
pr = nm.get(p[0]) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
523 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
524 |
cs.add(pr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
525 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
526 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
527 |
def _allprecursors(repo, s): # XXX we need a better naming |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
528 |
"""transitive precursors of a subset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
529 |
toproceed = [repo[r].node() for r in s] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
530 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
531 |
allsubjects = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
532 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
533 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
534 |
for mark in allsubjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
535 |
np = mark[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
536 |
if np not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
537 |
seen.add(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
538 |
toproceed.append(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
539 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
540 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
541 |
for p in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
542 |
pr = nm.get(p) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
543 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
544 |
cs.add(pr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
545 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
546 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
547 |
def _successors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
548 |
"""Successors of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
549 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
550 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
551 |
markerbyobj = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
552 |
for r in s: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
553 |
for p in markerbyobj.get(repo[r].node(), ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
554 |
for sub in p[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
555 |
sr = nm.get(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
556 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
557 |
cs.add(sr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
558 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
559 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
560 |
def _allsuccessors(repo, s, haltonflags=0): # XXX we need a better naming |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
561 |
"""transitive successors of a subset |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
562 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
563 |
haltonflags allows to provide flags which prevent the evaluation of a |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
564 |
marker. """ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
565 |
toproceed = [repo[r].node() for r in s] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
566 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
567 |
allobjects = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
568 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
569 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
570 |
for mark in allobjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
571 |
if mark[2] & haltonflags: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
572 |
continue |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
573 |
for sub in mark[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
574 |
if sub == nullid: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
575 |
continue # should not be here! |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
576 |
if sub not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
577 |
seen.add(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
578 |
toproceed.append(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
579 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
580 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
581 |
for s in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
582 |
sr = nm.get(s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
583 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
584 |
cs.add(sr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
585 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
586 |
|
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
587 |
nodemod = node |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
588 |
def successorssets(repo, initialnode, cache=None): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
589 |
"""Return the newer version of an obsolete changeset""" |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
590 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
591 |
# prec -> markers mapping |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
592 |
markersfor = repo.obsstore.successors |
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
593 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
594 |
# Stack of node need to know the last successors set |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
595 |
toproceed = [initialnode] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
596 |
# set version of toproceed for fast loop detection |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
597 |
stackedset = set(toproceed) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
598 |
if cache is None: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
599 |
cache = {} |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
600 |
while toproceed: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
601 |
# work on the last node of the stack |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
602 |
node = toproceed[-1] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
603 |
if node in cache: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
604 |
# We already have a value for it. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
605 |
# Keep working on something else. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
606 |
stackedset.remove(toproceed.pop()) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
607 |
elif node not in markersfor: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
608 |
# The node is not obsolete. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
609 |
# This mean it is its own last successors. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
610 |
if node in repo: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
611 |
# We have a valid last successors. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
612 |
cache[node] = [(node,)] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
613 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
614 |
# final obsolete version is unknown locally. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
615 |
# Do not count that as a valid successors |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
616 |
cache[node] = [] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
617 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
618 |
# <lss> stand for Last Successors Sets |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
619 |
# it contains the list of all last successors for the current node. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
620 |
lss = [] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
621 |
for mark in markersfor[node]: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
622 |
# <mlss> stand for Marker Last Successors Sets |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
623 |
# it contains the list of last successors set introduced by |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
624 |
# this marker. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
625 |
mlss = [[]] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
626 |
# iterate over possible multiple successors |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
627 |
for suc in mark[1]: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
628 |
if suc not in cache: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
629 |
# We do not know the last successors of that yet. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
630 |
if suc in stackedset: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
631 |
# Loop detected! |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
632 |
# |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
633 |
# we won't be able to ever compute a proper last |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
634 |
# successors the naive and simple approve is to |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
635 |
# consider it killed |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
636 |
cache[suc] = [] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
637 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
638 |
# Add the successor to the stack and break the next |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
639 |
# iteration will work on this successors and the |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
640 |
# algorithm will eventually process the current |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
641 |
# node again. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
642 |
toproceed.append(suc) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
643 |
stackedset.add(suc) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
644 |
break |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
645 |
# if we did not break, we can extend the possible set of |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
646 |
# last successors. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
647 |
# |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
648 |
# I say "extends" because if the marker have multiple |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
649 |
# successors we have to generate |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
650 |
# |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
651 |
# if successors have multiple successors set (when ther are |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
652 |
# divergent themself), we do a cartesian product of |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
653 |
# possible successors set of already processed successors |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
654 |
# and newly obtains successors set. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
655 |
newmlss = [] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
656 |
for prefix in mlss: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
657 |
for suffix in cache[suc]: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
658 |
newss = list(prefix) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
659 |
for part in suffix: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
660 |
# do not duplicated entry in successors set. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
661 |
# first entry win. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
662 |
if part not in newss: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
663 |
newss.append(part) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
664 |
newmlss.append(newss) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
665 |
mlss = newmlss |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
666 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
667 |
# note: mlss is still empty if the marker was a bare killing |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
668 |
# of this changeset |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
669 |
# |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
670 |
# We extends the list of all possible successors sets with |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
671 |
# successors set continuted by this marker |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
672 |
lss.extend(mlss) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
673 |
# we use continue here to skip the break right bellow |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
674 |
continue |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
675 |
# propagate "nested for" break. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
676 |
# if the nested for exited on break, it did not ran the else |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
677 |
# clause and didn't "continue |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
678 |
break |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
679 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
680 |
# computation was succesful for *all* marker. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
681 |
# Add computed successors set to the cache |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
682 |
# (will be poped from to proceeed) on the new iteration |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
683 |
# |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
684 |
# We remove successors set that are subset of another one |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
685 |
# this fil |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
686 |
candsucset = sorted(((len(ss), set(ss), ss) for ss in lss), |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
687 |
reverse=True) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
688 |
finalsucset = [] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
689 |
for cl, cs, css in candsucset: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
690 |
if not css: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
691 |
# remove empty successors set |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
692 |
continue |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
693 |
for fs, fss in finalsucset: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
694 |
if cs.issubset(fs): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
695 |
break |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
696 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
697 |
finalsucset.append((cs, css)) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
698 |
finalsucset = [s[1] for s in finalsucset] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
699 |
finalsucset.reverse() |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
700 |
cache[node] = finalsucset |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
701 |
return cache[initialnode] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
702 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
703 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
704 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
705 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
706 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
707 |
### Extending revset and template ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
708 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
709 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
710 |
# this section add several useful revset symbol not yet in core. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
711 |
# they are subject to changes |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
712 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
713 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
714 |
### XXX I'm not sure this revset is useful |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
715 |
@eh.revset('suspended') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
716 |
def revsetsuspended(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
717 |
"""``suspended()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
718 |
Obsolete changesets with non-obsolete descendants. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
719 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
720 |
args = revset.getargs(x, 0, 0, 'suspended takes no arguments') |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
721 |
suspended = getrevs(repo, 'suspended') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
722 |
return [r for r in subset if r in suspended] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
723 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
724 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
725 |
@eh.revset('precursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
726 |
def revsetprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
727 |
"""``precursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
728 |
Immediate precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
729 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
730 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
731 |
cs = _precursors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
732 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
733 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
734 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
735 |
@eh.revset('allprecursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
736 |
def revsetallprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
737 |
"""``allprecursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
738 |
Transitive precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
739 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
740 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
741 |
cs = _allprecursors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
742 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
743 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
744 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
745 |
@eh.revset('successors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
746 |
def revsetsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
747 |
"""``successors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
748 |
Immediate successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
749 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
750 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
751 |
cs = _successors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
752 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
753 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
754 |
@eh.revset('allsuccessors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
755 |
def revsetallsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
756 |
"""``allsuccessors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
757 |
Transitive successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
758 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
759 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
760 |
cs = _allsuccessors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
761 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
762 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
763 |
### template keywords |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
764 |
# XXX it does not handle troubles well :-/ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
765 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
766 |
@eh.templatekw('obsolete') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
767 |
def obsoletekw(repo, ctx, templ, **args): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
768 |
""":obsolete: String. The obsolescence level of the node, could be |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
769 |
``stable``, ``unstable``, ``suspended`` or ``extinct``. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
770 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
771 |
rev = ctx.rev() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
772 |
if ctx.obsolete(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
773 |
if ctx.extinct(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
774 |
return 'extinct' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
775 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
776 |
return 'suspended' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
777 |
elif ctx.unstable(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
778 |
return 'unstable' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
779 |
return 'stable' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
780 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
781 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
782 |
### Various trouble warning ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
783 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
784 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
785 |
# This section take care of issue warning to the user when troubles appear |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
786 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
787 |
@eh.wrapcommand("update") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
788 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
789 |
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
790 |
"""Warn that the working directory parent is an obsolete changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
791 |
res = origfn(ui, repo, *args, **opts) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
792 |
if repo['.'].obsolete(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
793 |
ui.warn(_('Working directory parent is obsolete\n')) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
794 |
return res |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
795 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
796 |
# XXX this could wrap transaction code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
797 |
# XXX (but this is a bit a layer violation) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
798 |
@eh.wrapcommand("commit") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
799 |
@eh.wrapcommand("push") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
800 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
801 |
@eh.wrapcommand("graft") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
802 |
@eh.wrapcommand("phase") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
803 |
@eh.wrapcommand("unbundle") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
804 |
def warnobserrors(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
805 |
"""display warning is the command resulted in more instable changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
806 |
priorunstables = len(repo.revs('unstable()')) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
807 |
priorbumpeds = len(repo.revs('bumped()')) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
808 |
priordivergents = len(repo.revs('divergent()')) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
809 |
ret = orig(ui, repo, *args, **kwargs) |
552
f7e54d4a3b90
warning: work around phase limitation when computing warnings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
551
diff
changeset
|
810 |
# workaround phase stupidity |
f7e54d4a3b90
warning: work around phase limitation when computing warnings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
551
diff
changeset
|
811 |
phases._filterunknown(ui, repo.changelog, repo._phasecache.phaseroots) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
812 |
newunstables = len(repo.revs('unstable()')) - priorunstables |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
813 |
newbumpeds = len(repo.revs('bumped()')) - priorbumpeds |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
814 |
newdivergents = len(repo.revs('divergent()')) - priordivergents |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
815 |
if newunstables > 0: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
816 |
ui.warn(_('%i new unstable changesets\n') % newunstables) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
817 |
if newbumpeds > 0: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
818 |
ui.warn(_('%i new bumped changesets\n') % newbumpeds) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
819 |
if newdivergents > 0: |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
820 |
ui.warn(_('%i new divergent changesets\n') % newdivergents) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
821 |
return ret |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
822 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
823 |
@eh.reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
824 |
def _repostabilizesetup(ui, repo): |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
825 |
"""Add a hint for "hg evolve" when troubles make push fails |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
826 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
827 |
if not repo.local(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
828 |
return |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
829 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
830 |
opush = repo.push |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
831 |
|
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
832 |
class evolvingrepo(repo.__class__): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
833 |
def push(self, remote, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
834 |
"""wrapper around pull that pull obsolete relation""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
835 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
836 |
result = opush(remote, *args, **opts) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
837 |
except util.Abort, ex: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
838 |
hint = _("use 'hg evolve' to get a stable history " |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
839 |
"or --force to ignore warnings") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
840 |
if (len(ex.args) >= 1 |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
841 |
and ex.args[0].startswith('push includes ') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
842 |
and ex.hint is None): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
843 |
ex.hint = hint |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
844 |
raise |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
845 |
return result |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
846 |
repo.__class__ = evolvingrepo |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
847 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
848 |
@eh.wrapcommand("summary") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
849 |
def obssummary(orig, ui, repo, *args, **kwargs): |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
850 |
def write(fmt, count): |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
851 |
s = fmt % count |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
852 |
if count: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
853 |
ui.write(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
854 |
else: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
855 |
ui.note(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
856 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
857 |
ret = orig(ui, repo, *args, **kwargs) |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
858 |
nbunstable = len(getrevs(repo, 'unstable')) |
594 | 859 |
nbbumped = len(getrevs(repo, 'bumped')) |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
860 |
nbdivergent = len(getrevs(repo, 'unstable')) |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
861 |
write('unstable: %i changesets\n', nbunstable) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
862 |
write('bumped: %i changesets\n', nbbumped) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
863 |
write('divergent: %i changesets\n', nbdivergent) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
864 |
return ret |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
865 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
866 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
867 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
868 |
### Core Other extension compat ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
869 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
870 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
871 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
872 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
873 |
def _rebasewrapping(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
874 |
# warning about more obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
875 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
876 |
rebase = extensions.find('rebase') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
877 |
if rebase: |
572
dc107acd0bd2
adapt to core rebase support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
571
diff
changeset
|
878 |
extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
879 |
except KeyError: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
880 |
pass # rebase not found |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
881 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
882 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
883 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
884 |
### Old Evolve extension content ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
885 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
886 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
887 |
# XXX need clean up and proper sorting in other section |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
888 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
889 |
### util function |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
890 |
############################# |
303 | 891 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
892 |
def noderange(repo, revsets): |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
893 |
"""The same as revrange but return node""" |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
894 |
return map(repo.changelog.node, |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
895 |
scmutil.revrange(repo, revsets)) |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
896 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
897 |
### changeset rewriting logic |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
898 |
############################# |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
899 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
900 |
def rewrite(repo, old, updates, head, newbases, commitopts): |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
901 |
"""Return (nodeid, created) where nodeid is the identifier of the |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
902 |
changeset generated by the rewrite process, and created is True if |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
903 |
nodeid was actually created. If created is False, nodeid |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
904 |
references a changeset existing before the rewrite call. |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
905 |
""" |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
906 |
if len(old.parents()) > 1: #XXX remove this unecessary limitation. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
907 |
raise error.Abort(_('cannot amend merge changesets')) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
908 |
base = old.p1() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
909 |
updatebookmarks = _bookmarksupdater(repo, old.node()) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
910 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
911 |
wlock = repo.wlock() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
912 |
try: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
913 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
914 |
# commit a new version of the old changeset, including the update |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
915 |
# collect all files which might be affected |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
916 |
files = set(old.files()) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
917 |
for u in updates: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
918 |
files.update(u.files()) |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
919 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
920 |
# Recompute copies (avoid recording a -> b -> a) |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
921 |
copied = copies.pathcopies(base, head) |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
922 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
923 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
924 |
# prune files which were reverted by the updates |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
925 |
def samefile(f): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
926 |
if f in head.manifest(): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
927 |
a = head.filectx(f) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
928 |
if f in base.manifest(): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
929 |
b = base.filectx(f) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
930 |
return (a.data() == b.data() |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
931 |
and a.flags() == b.flags()) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
932 |
else: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
933 |
return False |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
934 |
else: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
935 |
return f not in base.manifest() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
936 |
files = [f for f in files if not samefile(f)] |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
937 |
# commit version of these files as defined by head |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
938 |
headmf = head.manifest() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
939 |
def filectxfn(repo, ctx, path): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
940 |
if path in headmf: |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
941 |
fctx = head[path] |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
942 |
flags = fctx.flags() |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
943 |
mctx = context.memfilectx(fctx.path(), fctx.data(), |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
944 |
islink='l' in flags, |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
945 |
isexec='x' in flags, |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
946 |
copied=copied.get(path)) |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
947 |
return mctx |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
948 |
raise IOError() |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
949 |
if commitopts.get('message') and commitopts.get('logfile'): |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
950 |
raise util.Abort(_('options --message and --logfile are mutually' |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
951 |
' exclusive')) |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
952 |
if commitopts.get('logfile'): |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
953 |
message= open(commitopts['logfile']).read() |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
954 |
elif commitopts.get('message'): |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
955 |
message = commitopts['message'] |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
956 |
else: |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
957 |
message = old.description() |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
958 |
|
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
959 |
user = commitopts.get('user') or old.user() |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
960 |
date = commitopts.get('date') or None # old.date() |
263
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
961 |
extra = dict(commitopts.get('extra', {})) |
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
962 |
extra['branch'] = head.branch() |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
963 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
964 |
new = context.memctx(repo, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
965 |
parents=newbases, |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
966 |
text=message, |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
967 |
files=files, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
968 |
filectxfn=filectxfn, |
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
969 |
user=user, |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
970 |
date=date, |
263
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
971 |
extra=extra) |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
972 |
|
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
973 |
if commitopts.get('edit'): |
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
974 |
new._text = cmdutil.commitforceeditor(repo, new, []) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
975 |
revcount = len(repo) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
976 |
newid = repo.commitctx(new) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
977 |
new = repo[newid] |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
978 |
created = len(repo) != revcount |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
979 |
if created: |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
980 |
updatebookmarks(newid) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
981 |
# add evolution metadata |
443
3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
420
diff
changeset
|
982 |
markers = [(u, (new,)) for u in updates] |
3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
420
diff
changeset
|
983 |
markers.append((old, (new,))) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
984 |
createmarkers(repo, markers) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
985 |
else: |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
986 |
# newid is an existing revision. It could make sense to |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
987 |
# replace revisions with existing ones but probably not by |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
988 |
# default. |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
989 |
pass |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
990 |
finally: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
991 |
wlock.release() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
992 |
|
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
993 |
return newid, created |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
994 |
|
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
995 |
class MergeFailure(util.Abort): |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
996 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
997 |
|
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
998 |
def relocate(repo, orig, dest): |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
999 |
"""rewrite <rev> on dest""" |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1000 |
try: |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1001 |
rebase = extensions.find('rebase') |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1002 |
# dummy state to trick rebase node |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1003 |
assert orig.p2().rev() == node.nullrev, 'no support yet' |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1004 |
destbookmarks = repo.nodebookmarks(dest.node()) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1005 |
cmdutil.duplicatecopies(repo, orig.node(), dest.node()) |
258
8337bb3bb958
Fix amend and relocate who picked phases data after extinct wher made secret
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
255
diff
changeset
|
1006 |
nodesrc = orig.node() |
8337bb3bb958
Fix amend and relocate who picked phases data after extinct wher made secret
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
255
diff
changeset
|
1007 |
destphase = repo[nodesrc].phase() |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
1008 |
try: |
550
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1009 |
if rebase.rebasenode.func_code.co_argcount == 5: |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1010 |
# rebasenode collapse argument was introduced by |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1011 |
# d1afbf03e69a (2.3) |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1012 |
r = rebase.rebasenode(repo, orig.node(), dest.node(), |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1013 |
{node.nullrev: node.nullrev}, False) |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1014 |
else: |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1015 |
r = rebase.rebasenode(repo, orig.node(), dest.node(), |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1016 |
{node.nullrev: node.nullrev}) |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1017 |
if r[-1]: #some conflict |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1018 |
raise util.Abort( |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
1019 |
'unresolved merge conflicts (see hg help resolve)') |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
1020 |
nodenew = rebase.concludenode(repo, orig.node(), dest.node(), |
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
1021 |
node.nullid) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1022 |
except util.Abort, exc: |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1023 |
class LocalMergeFailure(MergeFailure, exc.__class__): |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1024 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1025 |
exc.__class__ = LocalMergeFailure |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
1026 |
raise |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1027 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1028 |
if nodenew is not None: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1029 |
phases.retractboundary(repo, destphase, [nodenew]) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1030 |
createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1031 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1032 |
repo._bookmarks[book] = nodenew |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1033 |
else: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1034 |
createmarkers(repo, [(repo[nodesrc], ())]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1035 |
# Behave like rebase, move bookmarks to dest |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1036 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
1037 |
repo._bookmarks[book] = dest.node() |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1038 |
for book in destbookmarks: # restore bookmark that rebase move |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1039 |
repo._bookmarks[book] = dest.node() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1040 |
if oldbookmarks or destbookmarks: |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1041 |
bookmarks.write(repo) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1042 |
return nodenew |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1043 |
except util.Abort: |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1044 |
# Invalidate the previous setparents |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1045 |
repo.dirstate.invalidate() |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1046 |
raise |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1047 |
|
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1048 |
def _bookmarksupdater(repo, oldid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1049 |
"""Return a callable update(newid) updating the current bookmark |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1050 |
and bookmarks bound to oldid to newid. |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1051 |
""" |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1052 |
bm = bookmarks.readcurrent(repo) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1053 |
def updatebookmarks(newid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1054 |
dirty = False |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1055 |
if bm: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1056 |
repo._bookmarks[bm] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1057 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1058 |
oldbookmarks = repo.nodebookmarks(oldid) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1059 |
if oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1060 |
for b in oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1061 |
repo._bookmarks[b] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1062 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1063 |
if dirty: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1064 |
bookmarks.write(repo) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1065 |
return updatebookmarks |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1066 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1067 |
### new command |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1068 |
############################# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1069 |
cmdtable = {} |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1070 |
command = cmdutil.command(cmdtable) |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1071 |
|
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1072 |
@command('^evolve|stabilize|evolve|solve', |
303 | 1073 |
[('n', 'dry-run', False, 'do not perform actions, print what to be done'), |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1074 |
('A', 'any', False, 'evolve any troubled changeset'), |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1075 |
('c', 'continue', False, 'continue an interrupted evolution'), ], |
303 | 1076 |
_('[OPTIONS]...')) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1077 |
def evolve(ui, repo, **opts): |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1078 |
"""Solve trouble in your repository |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1079 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1080 |
- rebase unstable changeset to make it stable again, |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1081 |
- create proper diff from bumped changeset, |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1082 |
- merge divergent changeset. |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1083 |
|
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1084 |
By default, take the first troubles changeset that looks relevant. |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1085 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1086 |
(The logic is still a bit fuzzy) |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1087 |
|
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1088 |
- For unstable, that mean the first which could be rebased as child of the |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1089 |
working directory parent revision or one of its descendants and rebase |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1090 |
it. |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1091 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1092 |
- For divergent this mean "." if applicable. |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1093 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1094 |
With --any, evolve pick any troubled changeset to solve |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1095 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1096 |
The working directory is updated to the newly created revision. |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1097 |
""" |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1098 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1099 |
contopt = opts['continue'] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1100 |
anyopt = opts['any'] |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1101 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1102 |
if contopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1103 |
if anyopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1104 |
raise util.Abort('can not specify both "--any" and "--continue"') |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1105 |
graftcmd = commands.table['graft'][0] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1106 |
return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1107 |
|
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1108 |
tr = _picknexttroubled(ui, repo, anyopt) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1109 |
if tr is None: |
511
ddeb71df916d
evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents:
510
diff
changeset
|
1110 |
troubled = repo.revs('troubled()') |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1111 |
if troubled: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1112 |
ui.write_err(_('nothing to evolve here\n')) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1113 |
ui.status(_('(%i troubled changesets, do you want --any ?)\n') |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1114 |
% len(troubled)) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1115 |
return 2 |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1116 |
else: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1117 |
ui.write_err(_('no troubled changeset\n')) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1118 |
return 1 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1119 |
cmdutil.bailifchanged(repo) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1120 |
troubles = tr.troubles() |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1121 |
if 'unstable' in troubles: |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1122 |
return _solveunstable(ui, repo, tr, opts['dry_run']) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1123 |
elif 'bumped' in troubles: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1124 |
return _solvebumped(ui, repo, tr, opts['dry_run']) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1125 |
elif 'divergent' in troubles: |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1126 |
return _solvedivergent(ui, repo, tr, opts['dry_run']) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1127 |
else: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1128 |
assert False # WHAT? unknown troubles |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1129 |
|
512
8b25e9cf76fd
evolve: avoid 'any' argument name in _picknexttroubled()
Patrick Mezard <patrick@mezard.eu>
parents:
511
diff
changeset
|
1130 |
def _picknexttroubled(ui, repo, pickany=False): |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1131 |
"""Pick a the next trouble changeset to solve""" |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1132 |
tr = _stabilizableunstable(repo, repo['.']) |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1133 |
if tr is None: |
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1134 |
wdp = repo['.'] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1135 |
if 'divergent' in wdp.troubles(): |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1136 |
tr = wdp |
512
8b25e9cf76fd
evolve: avoid 'any' argument name in _picknexttroubled()
Patrick Mezard <patrick@mezard.eu>
parents:
511
diff
changeset
|
1137 |
if tr is None and pickany: |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1138 |
troubled = list(repo.set('unstable()')) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1139 |
if not troubled: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1140 |
troubled = list(repo.set('bumped()')) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1141 |
if not troubled: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1142 |
troubled = list(repo.set('divergent()')) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1143 |
if troubled: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1144 |
tr = troubled[0] |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1145 |
|
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1146 |
return tr |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1147 |
|
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1148 |
def _stabilizableunstable(repo, pctx): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1149 |
"""Return a changectx for an unstable changeset which can be |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1150 |
stabilized on top of pctx or one of its descendants. None if none |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1151 |
can be found. |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1152 |
""" |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1153 |
def selfanddescendants(repo, pctx): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1154 |
yield pctx |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1155 |
for ctx in pctx.descendants(): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1156 |
yield ctx |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1157 |
|
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1158 |
# Look for an unstable which can be stabilized as a child of |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1159 |
# node. The unstable must be a child of one of node predecessors. |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1160 |
for ctx in selfanddescendants(repo, pctx): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1161 |
unstables = list(repo.set('unstable() and children(allprecursors(%d))', |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1162 |
ctx.rev())) |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1163 |
if unstables: |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1164 |
return unstables[0] |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1165 |
return None |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1166 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1167 |
def _solveunstable(ui, repo, orig, dryrun=False): |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1168 |
"""Stabilize a unstable changeset""" |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1169 |
obs = orig.parents()[0] |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1170 |
if not obs.obsolete(): |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1171 |
obs = orig.parents()[1] |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1172 |
assert obs.obsolete() |
588
89c8550019d0
mercurial: replace all `newerversion` call by `successorsset` call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
587
diff
changeset
|
1173 |
newer = successorssets(repo, obs.node()) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1174 |
# search of a parent which is not killed |
588
89c8550019d0
mercurial: replace all `newerversion` call by `successorsset` call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
587
diff
changeset
|
1175 |
while not newer or newer == [()]: |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1176 |
ui.debug("stabilize target %s is plain dead," |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1177 |
" trying to stabilize on its parent") |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1178 |
obs = obs.parents()[0] |
588
89c8550019d0
mercurial: replace all `newerversion` call by `successorsset` call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
587
diff
changeset
|
1179 |
newer = successorssets(repo, obs.node()) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1180 |
if len(newer) > 1: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1181 |
ui.write_err(_("conflict rewriting. can't choose destination\n")) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1182 |
return 2 |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1183 |
targets = newer[0] |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1184 |
assert targets |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1185 |
if len(targets) > 1: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1186 |
ui.write_err(_("does not handle splitted parent yet\n")) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1187 |
return 2 |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1188 |
target = targets[0] |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1189 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1190 |
target = repo[target] |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1191 |
repo.ui.status(_('move:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1192 |
if not ui.quiet: |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1193 |
displayer.show(orig) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1194 |
repo.ui.status(_('atop:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1195 |
if not ui.quiet: |
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1196 |
displayer.show(target) |
546
415540dee2bd
fix missing --dest evolve output in dryrun
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
540
diff
changeset
|
1197 |
todo = 'hg rebase -r %s -d %s\n' % (orig, target) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1198 |
if dryrun: |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1199 |
repo.ui.write(todo) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1200 |
else: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1201 |
repo.ui.note(todo) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1202 |
lock = repo.lock() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1203 |
try: |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1204 |
relocate(repo, orig, target) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1205 |
except MergeFailure: |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1206 |
repo.opener.write('graftstate', orig.hex() + '\n') |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1207 |
repo.ui.write_err(_('evolve failed!\n')) |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1208 |
repo.ui.write_err(_('fix conflict and run "hg evolve --continue"\n')) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1209 |
raise |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1210 |
finally: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1211 |
lock.release() |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1212 |
|
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1213 |
def _solvebumped(ui, repo, bumped, dryrun=False): |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1214 |
"""Stabilize a bumped changeset""" |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1215 |
# For now we deny bumped merge |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1216 |
if len(bumped.parents()) > 1: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1217 |
raise util.Abort('late comer stabilization is confused by bumped' |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1218 |
' %s being a merge' % bumped) |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1219 |
prec = repo.set('last(allprecursors(%d) and public())', bumped).next() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1220 |
# For now we deny target merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1221 |
if len(prec.parents()) > 1: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1222 |
raise util.Abort('late comer evolution is confused by precursors' |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1223 |
' %s being a merge' % prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1224 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1225 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1226 |
repo.ui.status(_('recreate:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1227 |
if not ui.quiet: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1228 |
displayer.show(bumped) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1229 |
repo.ui.status(_('atop:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1230 |
if not ui.quiet: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1231 |
displayer.show(prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1232 |
if dryrun: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1233 |
todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1234 |
repo.ui.write(todo) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1235 |
repo.ui.write('hg update %s;\n' % prec) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1236 |
repo.ui.write('hg revert --all --rev %s;\n' % bumped) |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1237 |
repo.ui.write('hg commit --msg "bumped update to %s"') |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1238 |
return 0 |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1239 |
wlock = repo.wlock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1240 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1241 |
newid = tmpctx = None |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1242 |
tmpctx = bumped |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1243 |
lock = repo.lock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1244 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1245 |
bmupdate = _bookmarksupdater(repo, bumped.node()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1246 |
# Basic check for common parent. Far too complicated and fragile |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1247 |
tr = repo.transaction('bumped-stabilize') |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1248 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1249 |
if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1250 |
# Need to rebase the changeset at the right place |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1251 |
repo.ui.status(_('rebasing to destination parent: %s\n') % prec.p1()) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1252 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1253 |
tmpid = relocate(repo, bumped, prec.p1()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1254 |
if tmpid is not None: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1255 |
tmpctx = repo[tmpid] |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1256 |
createmarkers(repo, [(bumped, (tmpctx,))]) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1257 |
except MergeFailure: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1258 |
repo.opener.write('graftstate', bumped.hex() + '\n') |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1259 |
repo.ui.write_err(_('evolution failed!\n')) |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1260 |
repo.ui.write_err(_('fix conflict and run "hg evolve --continue"\n')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1261 |
raise |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1262 |
# Create the new commit context |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1263 |
repo.ui.status(_('computing new diff\n')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1264 |
files = set() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1265 |
copied = copies.pathcopies(prec, bumped) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1266 |
precmanifest = prec.manifest() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1267 |
for key, val in bumped.manifest().iteritems(): |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1268 |
if precmanifest.pop(key, None) != val: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1269 |
files.add(key) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1270 |
files.update(precmanifest) # add missing files |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1271 |
# commit it |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1272 |
if files: # something to commit! |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1273 |
def filectxfn(repo, ctx, path): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1274 |
if path in bumped: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1275 |
fctx = bumped[path] |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1276 |
flags = fctx.flags() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1277 |
mctx = context.memfilectx(fctx.path(), fctx.data(), |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1278 |
islink='l' in flags, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1279 |
isexec='x' in flags, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1280 |
copied=copied.get(path)) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1281 |
return mctx |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1282 |
raise IOError() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1283 |
text = 'bumped update to %s:\n\n' % prec |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1284 |
text += bumped.description() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1285 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1286 |
new = context.memctx(repo, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1287 |
parents=[prec.node(), node.nullid], |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1288 |
text=text, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1289 |
files=files, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1290 |
filectxfn=filectxfn, |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1291 |
user=bumped.user(), |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1292 |
date=bumped.date(), |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1293 |
extra=bumped.extra()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1294 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1295 |
newid = repo.commitctx(new) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1296 |
if newid is None: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1297 |
createmarkers(repo, [(tmpctx, ())]) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1298 |
newid = prec.node() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1299 |
else: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1300 |
phases.retractboundary(repo, bumped.phase(), [newid]) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1301 |
createmarkers(repo, [(tmpctx, (repo[newid],))], |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1302 |
flag=latediff) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1303 |
bmupdate(newid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1304 |
tr.close() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1305 |
repo.ui.status(_('commited as %s\n') % node.short(newid)) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1306 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1307 |
tr.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1308 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1309 |
lock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1310 |
# reroute the working copy parent to the new changeset |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1311 |
repo.dirstate.setparents(newid, node.nullid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1312 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1313 |
wlock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1314 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1315 |
def _solvedivergent(ui, repo, divergent, dryrun=False): |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1316 |
base, others = divergentdata(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1317 |
if len(others) > 1: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1318 |
raise util.Abort("We do not handle split yet") |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1319 |
other = others[0] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1320 |
if divergent.phase() <= phases.public: |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1321 |
raise util.Abort("We can't resolve this conflict from the public side") |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1322 |
if len(other.parents()) > 1: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1323 |
raise util.Abort("divergent changeset can't be a merge (yet)") |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1324 |
if other.p1() not in divergent.parents(): |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1325 |
raise util.Abort("parents are not common (not handled yet)") |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1326 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1327 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1328 |
ui.status(_('merge:')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1329 |
if not ui.quiet: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1330 |
displayer.show(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1331 |
ui.status(_('with: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1332 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1333 |
displayer.show(other) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1334 |
ui.status(_('base: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1335 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1336 |
displayer.show(base) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1337 |
if dryrun: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1338 |
ui.write('hg update -c %s &&\n' % divergent) |
533
87c41ef95ebf
test conflicting conflicting (sic) resolution
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
523
diff
changeset
|
1339 |
ui.write('hg merge %s &&\n' % other) |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1340 |
ui.write('hg commit -m "auto merge resolving conflict between ' |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1341 |
'%s and %s"&&\n' % (divergent, other)) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1342 |
ui.write('hg up -C %s &&\n' % base) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1343 |
ui.write('hg revert --all --rev tip &&\n') |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1344 |
ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1345 |
% divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1346 |
return |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1347 |
wlock = lock = None |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1348 |
try: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1349 |
wlock = repo.wlock() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1350 |
lock = repo.lock() |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1351 |
if divergent not in repo[None].parents(): |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1352 |
repo.ui.status(_('updating to "local" conflict\n')) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1353 |
hg.update(repo, divergent.rev()) |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1354 |
repo.ui.note(_('merging divergent changeset\n')) |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1355 |
stats = merge.update(repo, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1356 |
other.node(), |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1357 |
branchmerge=True, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1358 |
force=False, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1359 |
partial=None, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1360 |
ancestor=base.node(), |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1361 |
mergeancestor=True) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1362 |
hg._showstats(repo, stats) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1363 |
if stats[3]: |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1364 |
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1365 |
"or 'hg update -C .' to abandon\n")) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1366 |
if stats[3] > 0: |
534
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1367 |
raise util.Abort('Merge conflict between several amendments, and this is not yet automated', |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1368 |
hint="""/!\ You can try: |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1369 |
/!\ * manual merge + resolve => new cset X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1370 |
/!\ * hg up to the parent of the amended changeset (which are named W and Z) |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1371 |
/!\ * hg revert --all -r X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1372 |
/!\ * hg ci -m "same message as the amended changeset" => new cset Y |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1373 |
/!\ * hg kill -n Y W Z |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1374 |
""") |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1375 |
tr = repo.transaction('stabilize-divergent') |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1376 |
try: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1377 |
repo.dirstate.setparents(divergent.node(), node.nullid) |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1378 |
oldlen = len(repo) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1379 |
amend(ui, repo) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1380 |
if oldlen == len(repo): |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1381 |
new = divergent |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1382 |
# no changes |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1383 |
else: |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1384 |
new = repo['.'] |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1385 |
createmarkers(repo, [(other, (new,))]) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1386 |
phases.retractboundary(repo, other.phase(), [new.node()]) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1387 |
tr.close() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1388 |
finally: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1389 |
tr.release() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1390 |
finally: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1391 |
lockmod.release(lock, wlock) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1392 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1393 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1394 |
def divergentdata(ctx): |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1395 |
"""return base, other part of a conflict |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1396 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1397 |
This only return the first one. |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1398 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1399 |
XXX this woobly function won't survive XXX |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1400 |
""" |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1401 |
for base in ctx._repo.set('reverse(precursors(%d))', ctx): |
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1402 |
newer = successorssets(ctx._repo, base.node()) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1403 |
# drop filter and solution including the original ctx |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1404 |
newer = [n for n in newer if n and ctx.node() not in n] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1405 |
if newer: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1406 |
return base, tuple(ctx._repo[o] for o in newer[0]) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1407 |
raise KeyError('Base seem unknown. This case is not handled yet.') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1408 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1409 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1410 |
|
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1411 |
shorttemplate = '[{rev}] {desc|firstline}\n' |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1412 |
|
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1413 |
@command('^gdown', |
303 | 1414 |
[], |
1415 |
'') |
|
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1416 |
def cmdgdown(ui, repo): |
303 | 1417 |
"""update to parent an display summary lines""" |
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1418 |
wkctx = repo[None] |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1419 |
wparents = wkctx.parents() |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1420 |
if len(wparents) != 1: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1421 |
raise util.Abort('merge in progress') |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1422 |
|
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1423 |
parents = wparents[0].parents() |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1424 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1425 |
if len(parents) == 1: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1426 |
p = parents[0] |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1427 |
hg.update(repo, p.rev()) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1428 |
displayer.show(p) |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1429 |
return 0 |
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1430 |
else: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1431 |
for p in parents: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1432 |
displayer.show(p) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1433 |
ui.warn(_('multiple parents, explicitly update to one\n')) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1434 |
return 1 |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1435 |
|
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1436 |
@command('^gup', |
303 | 1437 |
[], |
1438 |
'') |
|
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1439 |
def cmdup(ui, repo): |
303 | 1440 |
"""update to child an display summary lines""" |
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1441 |
wkctx = repo[None] |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1442 |
wparents = wkctx.parents() |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1443 |
if len(wparents) != 1: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1444 |
raise util.Abort('merge in progress') |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1445 |
|
127
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1446 |
children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1447 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1448 |
if not children: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1449 |
ui.warn(_('No non-obsolete children\n')) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1450 |
return 1 |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1451 |
if len(children) == 1: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1452 |
c = children[0] |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1453 |
hg.update(repo, c.rev()) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1454 |
displayer.show(c) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1455 |
return 0 |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1456 |
else: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1457 |
for c in children: |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1458 |
displayer.show(c) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1459 |
ui.warn(_('Multiple non-obsolete children, explicitly update to one\n')) |
7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
119
diff
changeset
|
1460 |
return 1 |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1461 |
|
365
9f6a77ec66cb
evolve: switch the official name for "kill" to prune
Pierre-Yves.David@ens-lyon.org
parents:
362
diff
changeset
|
1462 |
@command('^prune|obsolete|kill', |
303 | 1463 |
[('n', 'new', [], _("successor changeset"))], |
1464 |
_('[OPTION] REV...')) |
|
130
b70fadbccc2a
evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
127
diff
changeset
|
1465 |
def kill(ui, repo, *revs, **opts): |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1466 |
"""mark a changeset as obsolete |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1467 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1468 |
This update the parent directory to a not-killed parent if the current |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1469 |
working directory parent are killed. |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1470 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1471 |
XXX bookmark support |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1472 |
XXX handle merge |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1473 |
XXX check immutable first |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1474 |
""" |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1475 |
wlock = repo.wlock() |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1476 |
try: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1477 |
lock = repo.lock() |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1478 |
try: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1479 |
new = set(noderange(repo, opts['new'])) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1480 |
targetnodes = set(noderange(repo, revs)) |
562
b1bdcb4506de
hg prune: prevent empty call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
561
diff
changeset
|
1481 |
if not targetnodes: |
b1bdcb4506de
hg prune: prevent empty call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
561
diff
changeset
|
1482 |
raise util.Abort('nothing to prune') |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1483 |
if new: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1484 |
sucs = tuple(repo[n] for n in new) |
130
b70fadbccc2a
evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
127
diff
changeset
|
1485 |
else: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1486 |
sucs = () |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1487 |
markers = [] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1488 |
for n in targetnodes: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1489 |
markers.append((repo[n], sucs)) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1490 |
createmarkers(repo, markers) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1491 |
|
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1492 |
# update to an unkilled parent |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1493 |
wdp = repo['.'] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1494 |
newnode = wdp |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1495 |
while newnode.obsolete(): |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1496 |
newnode = newnode.parents()[0] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1497 |
if newnode.node() != wdp.node(): |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1498 |
commands.update(ui, repo, newnode.rev()) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1499 |
ui.status(_('working directory now at %s\n') % newnode) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1500 |
finally: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1501 |
lock.release() |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1502 |
finally: |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1503 |
wlock.release() |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1504 |
|
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1505 |
@command('^amend|refresh', |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1506 |
[('A', 'addremove', None, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1507 |
_('mark new/missing files as added/removed before committing')), |
303 | 1508 |
('n', 'note', '', _('use text as commit message for this update')), |
611
bd0f49f2ec83
deprecate "amend --change" option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
593
diff
changeset
|
1509 |
('c', 'change', '', _('specifies the changesets to amend (DEPRECATED)'), _('REV')), |
303 | 1510 |
('e', 'edit', False, _('invoke editor on commit messages')), |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1511 |
] + walkopts + commitopts + commitopts2, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1512 |
_('[OPTION]... [FILE]...')) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1513 |
def amend(ui, repo, *pats, **opts): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1514 |
"""combine a changeset with updates and replace it with a new one |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1515 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1516 |
Commits a new changeset incorporating both the changes to the given files |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1517 |
and all the changes from the current parent changeset into the repository. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1518 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1519 |
See :hg:`commit` for details about committing changes. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1520 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1521 |
If you don't specify -m, the parent's message will be reused. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1522 |
|
303 | 1523 |
If you specify --change, amend additionally considers all |
1524 |
changesets between the indicated changeset and the working copy |
|
1525 |
parent as updates to be subsumed. |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1526 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1527 |
Behind the scenes, Mercurial first commits the update as a regular child |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1528 |
of the current parent. Then it creates a new commit on the parent's parents |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1529 |
with the updated contents. Then it changes the working copy parent to this |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1530 |
new combined changeset. Finally, the old changeset and its update are hidden |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1531 |
from :hg:`log` (unless you use --hidden with log). |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1532 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1533 |
Returns 0 on success, 1 if nothing changed. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1534 |
""" |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1535 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1536 |
# determine updates to subsume |
295
a5894bb97909
evolve: remove --change . == --change .^ crazyness
Patrick Mezard <patrick@mezard.eu>
parents:
294
diff
changeset
|
1537 |
old = scmutil.revsingle(repo, opts.get('change') or '.') |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1538 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1539 |
lock = repo.lock() |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1540 |
try: |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1541 |
wlock = repo.wlock() |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1542 |
try: |
475
9f69a5e41ab0
[evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
418
diff
changeset
|
1543 |
if old.phase() == phases.public: |
9f69a5e41ab0
[evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
418
diff
changeset
|
1544 |
raise util.Abort(_("can not rewrite immutable changeset %s") |
9f69a5e41ab0
[evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
418
diff
changeset
|
1545 |
% old) |
476
f17a0f801e0b
[evolve] amend: display proper error message while trying to amend non ancestor
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
475
diff
changeset
|
1546 |
if not repo.revs('%d and (::.)', old): |
f17a0f801e0b
[evolve] amend: display proper error message while trying to amend non ancestor
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
475
diff
changeset
|
1547 |
raise error.Abort(_('cannot amend non ancestor changeset')) |
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1548 |
tr = repo.transaction('amend') |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1549 |
try: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1550 |
oldphase = old.phase() |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1551 |
# commit current changes as update |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1552 |
# code copied from commands.commit to avoid noisy messages |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1553 |
ciopts = dict(opts) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1554 |
ciopts.pop('message', None) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1555 |
ciopts.pop('logfile', None) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1556 |
ciopts['message'] = opts.get('note') or ('amends %s' % old.hex()) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1557 |
e = cmdutil.commiteditor |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1558 |
def commitfunc(ui, repo, message, match, opts): |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1559 |
return repo.commit(message, opts.get('user'), opts.get('date'), |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1560 |
match, editor=e) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1561 |
revcount = len(repo) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1562 |
tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1563 |
if len(repo) == revcount: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1564 |
# No revision created |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1565 |
tempid = None |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1566 |
|
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1567 |
# find all changesets to be considered updates |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1568 |
head = repo['.'] |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1569 |
updatenodes = set(repo.changelog.nodesbetween( |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1570 |
roots=[old.node()], heads=[head.node()])[0]) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1571 |
updatenodes.remove(old.node()) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1572 |
okoptions = ['message', 'logfile', 'edit', 'user'] |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1573 |
if not updatenodes: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1574 |
for o in okoptions: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1575 |
if opts.get(o): |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1576 |
break |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1577 |
else: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1578 |
raise error.Abort(_('no updates found')) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1579 |
updates = [repo[n] for n in updatenodes] |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1580 |
|
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1581 |
# perform amend |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1582 |
if opts.get('edit'): |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1583 |
opts['force_editor'] = True |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1584 |
newid, created = rewrite(repo, old, updates, head, |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1585 |
[old.p1().node(), old.p2().node()], opts) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1586 |
if created: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1587 |
# reroute the working copy parent to the new changeset |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1588 |
phases.retractboundary(repo, oldphase, [newid]) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1589 |
repo.dirstate.setparents(newid, node.nullid) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1590 |
else: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1591 |
# rewrite() recreated an existing revision, discard |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1592 |
# the intermediate revision if any. No need to update |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1593 |
# phases or parents. |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1594 |
if tempid is not None: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1595 |
createmarkers(repo, [(repo[tempid], ())]) |
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1596 |
# XXX: need another message in collapse case. |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1597 |
tr.close() |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1598 |
raise error.Abort(_('no updates found')) |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1599 |
tr.close() |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1600 |
finally: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
1601 |
tr.release() |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1602 |
finally: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1603 |
wlock.release() |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1604 |
finally: |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1605 |
lock.release() |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1606 |
|
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1607 |
def _commitfiltered(repo, ctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1608 |
"""Recommit ctx with changed files not in match. Return the new |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1609 |
node identifier, or None if nothing changed. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1610 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1611 |
base = ctx.p1() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1612 |
m, a, r = repo.status(base, ctx)[:3] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1613 |
allfiles = set(m + a + r) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1614 |
files = set(f for f in allfiles if not match(f)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1615 |
if files == allfiles: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1616 |
return None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1617 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1618 |
# Filter copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1619 |
copied = copies.pathcopies(base, ctx) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1620 |
copied = dict((src, dst) for src, dst in copied.iteritems() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1621 |
if dst in files) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1622 |
def filectxfn(repo, memctx, path): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1623 |
if path not in ctx: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1624 |
raise IOError() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1625 |
fctx = ctx[path] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1626 |
flags = fctx.flags() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1627 |
mctx = context.memfilectx(fctx.path(), fctx.data(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1628 |
islink='l' in flags, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1629 |
isexec='x' in flags, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1630 |
copied=copied.get(path)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1631 |
return mctx |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1632 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1633 |
new = context.memctx(repo, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1634 |
parents=[base.node(), node.nullid], |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1635 |
text=ctx.description(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1636 |
files=files, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1637 |
filectxfn=filectxfn, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1638 |
user=ctx.user(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1639 |
date=ctx.date(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1640 |
extra=ctx.extra()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1641 |
# commitctx always create a new revision, no need to check |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1642 |
newid = repo.commitctx(new) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1643 |
return newid |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1644 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1645 |
def _uncommitdirstate(repo, oldctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1646 |
"""Fix the dirstate after switching the working directory from |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1647 |
oldctx to a copy of oldctx not containing changed files matched by |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1648 |
match. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1649 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1650 |
ctx = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1651 |
ds = repo.dirstate |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1652 |
copies = dict(ds.copies()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1653 |
m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1654 |
for f in m: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1655 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1656 |
# modified + removed -> removed |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1657 |
continue |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1658 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1659 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1660 |
for f in a: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1661 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1662 |
# added + removed -> unknown |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1663 |
ds.drop(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1664 |
elif ds[f] != 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1665 |
ds.add(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1666 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1667 |
for f in r: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1668 |
if ds[f] == 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1669 |
# removed + added -> normal |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1670 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1671 |
elif ds[f] != 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1672 |
ds.remove(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1673 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1674 |
# Merge old parent and old working dir copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1675 |
oldcopies = {} |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1676 |
for f in (m + a): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1677 |
src = oldctx[f].renamed() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1678 |
if src: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1679 |
oldcopies[f] = src[0] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1680 |
oldcopies.update(copies) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1681 |
copies = dict((dst, oldcopies.get(src, src)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1682 |
for dst, src in oldcopies.iteritems()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1683 |
# Adjust the dirstate copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1684 |
for dst, src in copies.iteritems(): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1685 |
if (src not in ctx or dst in ctx or ds[dst] != 'a'): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1686 |
src = None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1687 |
ds.copy(src, dst) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1688 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1689 |
@command('^uncommit', |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1690 |
[('a', 'all', None, _('uncommit all changes when no arguments given')), |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1691 |
] + commands.walkopts, |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1692 |
_('[OPTION]... [NAME]')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1693 |
def uncommit(ui, repo, *pats, **opts): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1694 |
"""move changes from parent revision to working directory |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1695 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1696 |
Changes to selected files in parent revision appear again as |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1697 |
uncommitted changed in the working directory. A new revision |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1698 |
without selected changes is created, becomes the new parent and |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1699 |
obsoletes the previous one. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1700 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1701 |
The --include option specify pattern to uncommit |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1702 |
The --exclude option specify pattern to keep in the commit |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1703 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1704 |
Return 0 if changed files are uncommitted. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1705 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1706 |
lock = repo.lock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1707 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1708 |
wlock = repo.wlock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1709 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1710 |
wctx = repo[None] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1711 |
if len(wctx.parents()) <= 0: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1712 |
raise util.Abort(_("cannot uncommit null changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1713 |
if len(wctx.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1714 |
raise util.Abort(_("cannot uncommit while merging")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1715 |
old = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1716 |
if old.phase() == phases.public: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1717 |
raise util.Abort(_("cannot rewrite immutable changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1718 |
if len(old.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1719 |
raise util.Abort(_("cannot uncommit merge changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1720 |
oldphase = old.phase() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1721 |
updatebookmarks = _bookmarksupdater(repo, old.node()) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1722 |
# Recommit the filtered changeset |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1723 |
newid = None |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1724 |
if (pats or opts.get('include') or opts.get('exclude') |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1725 |
or opts.get('all')): |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1726 |
match = scmutil.match(old, pats, opts) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1727 |
newid = _commitfiltered(repo, old, match) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1728 |
if newid is None: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1729 |
raise util.Abort(_('nothing to uncommit')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1730 |
# Move local changes on filtered changeset |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1731 |
createmarkers(repo, [(old, (repo[newid],))]) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1732 |
phases.retractboundary(repo, oldphase, [newid]) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1733 |
repo.dirstate.setparents(newid, node.nullid) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1734 |
_uncommitdirstate(repo, old, match) |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1735 |
updatebookmarks(newid) |
318
da7509e7b50c
evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
315
diff
changeset
|
1736 |
if not repo[newid].files(): |
da7509e7b50c
evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
315
diff
changeset
|
1737 |
ui.warn(_("new changeset is empty\n")) |
da7509e7b50c
evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
315
diff
changeset
|
1738 |
ui.status(_('(use "hg kill ." to remove it)\n')) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1739 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1740 |
wlock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1741 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1742 |
lock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1743 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1744 |
@eh.wrapcommand('commit') |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1745 |
def commitwrapper(orig, ui, repo, *arg, **kwargs): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1746 |
if kwargs.get('amend', False): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1747 |
lock = None |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1748 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1749 |
lock = repo.lock() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1750 |
try: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1751 |
obsoleted = kwargs.get('obsolete', []) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1752 |
if obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1753 |
obsoleted = repo.set('%lr', obsoleted) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1754 |
result = orig(ui, repo, *arg, **kwargs) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1755 |
if not result: # commit successed |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1756 |
new = repo['-1'] |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1757 |
oldbookmarks = [] |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1758 |
markers = [] |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1759 |
for old in obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1760 |
oldbookmarks.extend(repo.nodebookmarks(old.node())) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1761 |
markers.append((old, (new,))) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1762 |
if markers: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1763 |
createmarkers(repo, markers) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1764 |
for book in oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1765 |
repo._bookmarks[book] = new.node() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1766 |
if oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1767 |
bookmarks.write(repo) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1768 |
return result |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1769 |
finally: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1770 |
if lock is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1771 |
lock.release() |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1772 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1773 |
@command('^touch', |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1774 |
[('r', 'rev', [], 'revision to update'),], |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1775 |
# allow to choose the seed ? |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1776 |
_('[-r] revs')) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1777 |
def touch(ui, repo, *revs, **opts): |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1778 |
"""Create successors with exact same property but hash |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1779 |
|
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1780 |
This is used to "resurrect" changesets |
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1781 |
""" |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1782 |
revs = list(revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1783 |
revs.extend(opts['rev']) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1784 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1785 |
revs = ['.'] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1786 |
revs = scmutil.revrange(repo, revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1787 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1788 |
ui.write_err('no revision to touch\n') |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1789 |
return 1 |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1790 |
if repo.revs('public() and %ld', revs): |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1791 |
raise util.Abort("can't touch public revision") |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1792 |
wlock = lock = None |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1793 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1794 |
wlock = repo.wlock() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1795 |
lock = repo.lock() |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1796 |
tr = repo.transaction('touch') |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1797 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1798 |
for r in revs: |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1799 |
ctx = repo[r] |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1800 |
extra = ctx.extra().copy() |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1801 |
extra['__touch-noise__'] = random.randint(0, 0xffffffff) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1802 |
new, _ = rewrite(repo, ctx, [], ctx, |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1803 |
[ctx.p1().node(), ctx.p2().node()], |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1804 |
commitopts={'extra': extra}) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1805 |
createmarkers(repo, [(ctx, (repo[new],))]) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1806 |
phases.retractboundary(repo, ctx.phase(), [new]) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1807 |
if ctx in repo[None].parents(): |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1808 |
repo.dirstate.setparents(new, node.nullid) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1809 |
tr.close() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1810 |
finally: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1811 |
tr.release() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1812 |
finally: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
1813 |
lockmod.release(lock, wlock) |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1814 |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1815 |
@command('^fold', |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1816 |
[('r', 'rev', [], 'revisions to fold'),], |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1817 |
# allow to choose the seed ? |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1818 |
_('[-r] revs')) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1819 |
def fold(ui, repo, *revs, **opts): |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1820 |
"""Fold multiple revisions into a single one""" |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1821 |
revs = list(revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1822 |
revs.extend(opts['rev']) |
561
897f6da2314e
fold: handle the lack of revision to fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
554
diff
changeset
|
1823 |
if revs: |
897f6da2314e
fold: handle the lack of revision to fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
554
diff
changeset
|
1824 |
revs = scmutil.revrange(repo, revs) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1825 |
if not revs: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1826 |
ui.write_err('no revision to fold\n') |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1827 |
return 1 |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1828 |
roots = repo.revs('roots(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1829 |
if len(roots) > 1: |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1830 |
raise util.Abort("set has multiple roots") |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1831 |
root = repo[roots[0]] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1832 |
if root.phase() <= phases.public: |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1833 |
raise util.Abort("can't fold public revisions") |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1834 |
heads = repo.revs('heads(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1835 |
if len(heads) > 1: |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1836 |
raise util.Abort("set has multiple heads") |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1837 |
head = repo[heads[0]] |
515 | 1838 |
wlock = lock = None |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1839 |
try: |
515 | 1840 |
wlock = repo.wlock() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1841 |
lock = repo.lock() |
515 | 1842 |
tr = repo.transaction('touch') |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1843 |
try: |
515 | 1844 |
allctx = [repo[r] for r in revs] |
1845 |
targetphase = max(c.phase() for c in allctx) |
|
1846 |
msg = '\n\n***\n\n'.join(c.description() for c in allctx) |
|
1847 |
newid, _ = rewrite(repo, root, allctx, head, |
|
1848 |
[root.p1().node(), root.p2().node()], |
|
1849 |
commitopts={'message': msg}) |
|
1850 |
phases.retractboundary(repo, targetphase, [newid]) |
|
1851 |
createmarkers(repo, [(ctx, (repo[newid],)) |
|
1852 |
for ctx in allctx]) |
|
1853 |
tr.close() |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1854 |
finally: |
515 | 1855 |
tr.release() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1856 |
ui.status('%i changesets folded\n' % len(revs)) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1857 |
if repo.revs('. and %ld', revs): |
549
b047e9417d96
Properly update after fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
548
diff
changeset
|
1858 |
hg.update(repo, newid) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1859 |
finally: |
515 | 1860 |
lockmod.release(lock, wlock) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
1861 |
|
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1862 |
if 'debugsuccessorssets' not in commands.table: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1863 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1864 |
@command('debugsuccessorssets', |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1865 |
[], |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1866 |
_('[REV]')) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1867 |
def debugsuccessorssets(ui, repo, *revs): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1868 |
"""show set of successors for revision |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1869 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1870 |
Successors set of changeset A are a consistent group of revision that |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1871 |
succeed to A. Successors set contains non-obsolete changeset only. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1872 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1873 |
In most case a changeset A have zero (changeset pruned) or a single |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1874 |
successors set that contains a single successors (changeset A replacement |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1875 |
by A') |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1876 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1877 |
But splitted changeset will result with successors set containing more than |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1878 |
a single element. Divergent rewritting will result in multiple successor |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1879 |
set. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1880 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1881 |
result is displayed as follows:: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1882 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1883 |
<rev1> |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1884 |
<successors-1A> |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1885 |
<rev2> |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1886 |
<successors-2A> |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1887 |
<successors-2B1> <successors-2B1> <successors-2B1> |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1888 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1889 |
here rev2 have two possible successors sets. One hold three elements. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1890 |
|
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1891 |
add --debug if you want full size node id. |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1892 |
""" |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1893 |
cache = {} |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1894 |
s = str |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1895 |
if ui.debug: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1896 |
def s(ctx): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1897 |
return ctx.hex() |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1898 |
for rev in scmutil.revrange(repo, revs): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1899 |
ctx = repo[rev] |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1900 |
if ui.debug(): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1901 |
ui.write('%s\n'% ctx.hex()) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1902 |
s = node.hex |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1903 |
else: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1904 |
ui.write('%s\n'% ctx) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1905 |
s = node.short |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1906 |
for ss in successorssets(repo, ctx.node(), cache): |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1907 |
if ss: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1908 |
ui.write(' ') |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1909 |
ui.write(s(ss[0])) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1910 |
for n in ss[1:]: |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1911 |
ui.write(' ') |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1912 |
ui.write(s(n)) |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1913 |
ui.write('\n') |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1914 |
pass |
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
1915 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
1916 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1917 |
@eh.wrapcommand('graft') |
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
1918 |
def graftwrapper(orig, ui, repo, *revs, **kwargs): |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1919 |
kwargs = dict(kwargs) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1920 |
revs = list(revs) + kwargs.get('rev', []) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1921 |
kwargs['rev'] = [] |
417
a1fb18ad29a1
evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents:
416
diff
changeset
|
1922 |
obsoleted = kwargs.setdefault('obsolete', []) |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1923 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1924 |
lock = repo.lock() |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1925 |
try: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1926 |
if kwargs.get('old_obsolete'): |
418
18a0d96ed559
evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents:
417
diff
changeset
|
1927 |
if kwargs.get('continue'): |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1928 |
obsoleted.extend(repo.opener.read('graftstate').splitlines()) |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1929 |
else: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1930 |
obsoleted.extend(revs) |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1931 |
# convert obsolete target into revs to avoid alias joke |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1932 |
obsoleted[:] = [str(i) for i in repo.revs('%lr', obsoleted)] |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1933 |
if obsoleted and len(revs) > 1: |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1934 |
|
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1935 |
raise error.Abort(_('Can not graft multiple revision while ' |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1936 |
'obsoleting (for now).')) |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1937 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1938 |
return commitwrapper(orig, ui, repo,*revs, **kwargs) |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1939 |
finally: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1940 |
lock.release() |
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
1941 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1942 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1943 |
def oldevolveextsetup(ui): |
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1944 |
try: |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1945 |
rebase = extensions.find('rebase') |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1946 |
except KeyError: |
416
22f348c25d25
obsolete/evolve: fix grammar in prerequisite messages
Patrick Mezard <patrick@mezard.eu>
parents:
414
diff
changeset
|
1947 |
raise error.Abort(_('evolution extension requires rebase extension.')) |
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1948 |
|
507
4b1797518abe
evolve: add touch and fold to command that may create troubles
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
497
diff
changeset
|
1949 |
for cmd in ['amend', 'kill', 'uncommit', 'touch', 'fold']: |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1950 |
entry = extensions.wrapcommand(cmdtable, cmd, |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1951 |
warnobserrors) |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1952 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1953 |
entry = cmdutil.findcmd('commit', commands.table)[1] |
303 | 1954 |
entry[1].append(('o', 'obsolete', [], |
1955 |
_("make commit obsolete this revision"))) |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1956 |
entry = cmdutil.findcmd('graft', commands.table)[1] |
303 | 1957 |
entry[1].append(('o', 'obsolete', [], |
1958 |
_("make graft obsoletes this revision"))) |
|
1959 |
entry[1].append(('O', 'old-obsolete', False, |
|
1960 |
_("make graft obsoletes its source"))) |
|
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1961 |