author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Thu, 23 Aug 2012 18:21:18 +0200 | |
changeset 490 | 8096833e9226 |
parent 485 | 41bf6c27a122 |
child 491 | 6989d8fe4ed2 |
permissions | -rw-r--r-- |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1 |
# states.py - introduce the state concept for mercurial changeset |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2 |
# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
3 |
# Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
4 |
# Logilab SA <contact@logilab.fr> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
5 |
# Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
6 |
# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
7 |
# 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
|
8 |
# 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
|
9 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
219
diff
changeset
|
10 |
'''a set of commands to handle changeset mutation''' |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
11 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
12 |
import random |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
13 |
|
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
14 |
from mercurial import bookmarks |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
15 |
from mercurial import cmdutil |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
16 |
from mercurial import commands |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
17 |
from mercurial import context |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
18 |
from mercurial import copies |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
19 |
from mercurial import error |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
20 |
from mercurial import extensions |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
21 |
from mercurial import merge |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
22 |
from mercurial import node |
113
3bdabdbb4140
adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
108
diff
changeset
|
23 |
from mercurial import phases |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
24 |
from mercurial import scmutil |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
25 |
from mercurial import util |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
26 |
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
|
27 |
from mercurial.commands import walkopts, commitopts, commitopts2 |
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
|
28 |
from mercurial import hg |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
29 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
30 |
### util function |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
31 |
############################# |
303 | 32 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
33 |
def noderange(repo, revsets): |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
34 |
"""The same as revrange but return node""" |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
35 |
return map(repo.changelog.node, |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
36 |
scmutil.revrange(repo, revsets)) |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
37 |
|
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
38 |
### changeset rewriting logic |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
39 |
############################# |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
40 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
41 |
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
|
42 |
"""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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
""" |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
base = old.p1() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
50 |
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
|
51 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
52 |
wlock = repo.wlock() |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
53 |
try: |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
54 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
55 |
# 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
|
56 |
# 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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
61 |
# 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
|
62 |
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
|
63 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
64 |
|
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
65 |
# 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
|
66 |
def samefile(f): |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
else: |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
74 |
return False |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
75 |
else: |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
76 |
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
|
77 |
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
|
78 |
# 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
|
79 |
headmf = head.manifest() |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
return mctx |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
89 |
raise IOError() |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
' exclusive')) |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
93 |
if commitopts.get('logfile'): |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
94 |
message= open(commitopts['logfile']).read() |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
95 |
elif commitopts.get('message'): |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
96 |
message = commitopts['message'] |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
97 |
else: |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
98 |
message = old.description() |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
99 |
|
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
100 |
user = commitopts.get('user') or old.user() |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
101 |
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
|
102 |
extra = dict(commitopts.get('extra', {})) |
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
103 |
extra['branch'] = head.branch() |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
104 |
|
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
105 |
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
|
106 |
parents=newbases, |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
107 |
text=message, |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
108 |
files=files, |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
109 |
filectxfn=filectxfn, |
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
110 |
user=user, |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
111 |
date=date, |
263
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
112 |
extra=extra) |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
113 |
|
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
114 |
if commitopts.get('edit'): |
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
115 |
new._text = cmdutil.commitforceeditor(repo, new, []) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
new = repo[newid] |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
119 |
created = len(repo) != revcount |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
120 |
if created: |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
121 |
updatebookmarks(newid) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
122 |
# add evolution metadata |
443
3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
420
diff
changeset
|
123 |
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
|
124 |
markers.append((old, (new,))) |
3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
420
diff
changeset
|
125 |
obsolete = extensions.find('obsolete') |
3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
420
diff
changeset
|
126 |
obsolete.createmarkers(repo, markers) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
127 |
else: |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
128 |
# 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
|
129 |
# 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
|
130 |
# default. |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
131 |
pass |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
132 |
finally: |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
133 |
wlock.release() |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
134 |
|
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
135 |
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
|
136 |
|
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
137 |
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
|
138 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
139 |
|
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
140 |
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
|
141 |
"""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
|
142 |
try: |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
143 |
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
|
144 |
# 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
|
145 |
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
|
146 |
destbookmarks = repo.nodebookmarks(dest.node()) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
destphase = repo[nodesrc].phase() |
255
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
150 |
if rebase.rebasenode.func_code.co_argcount == 5: |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
151 |
# rebasenode collapse argument was introduced by |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
152 |
# d1afbf03e69a (2.3) |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
153 |
rebase.rebasenode(repo, orig.node(), dest.node(), |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
154 |
{node.nullrev: node.nullrev}, False) |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
155 |
else: |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
156 |
rebase.rebasenode(repo, orig.node(), dest.node(), |
9852b3ef7234
evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
232
diff
changeset
|
157 |
{node.nullrev: node.nullrev}) |
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
|
158 |
try: |
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
159 |
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
|
160 |
node.nullid) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
164 |
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
|
165 |
raise |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
166 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
167 |
obsolete = extensions.find('obsolete') |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
168 |
if nodenew is not None: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
169 |
phases.retractboundary(repo, destphase, [nodenew]) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
170 |
obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
171 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
172 |
repo._bookmarks[book] = nodenew |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
173 |
else: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
174 |
obsolete.createmarkers(repo, [(repo[nodesrc], ())]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
175 |
# Behave like rebase, move bookmarks to dest |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
176 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
177 |
repo._bookmarks[book] = dest.node() |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
178 |
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
|
179 |
repo._bookmarks[book] = dest.node() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
180 |
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
|
181 |
bookmarks.write(repo) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
182 |
return nodenew |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
183 |
except util.Abort: |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
184 |
# 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
|
185 |
repo.dirstate.invalidate() |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
186 |
raise |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
187 |
|
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
|
188 |
def _stabilizableunstable(repo, pctx): |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
189 |
"""Return a changectx for an unstable changeset which can be |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
190 |
stabilized on top of pctx or one of its descendants. None if none |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
191 |
can be found. |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
192 |
""" |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
193 |
def selfanddescendants(repo, pctx): |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
194 |
yield pctx |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
195 |
for ctx in pctx.descendants(): |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
196 |
yield ctx |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
197 |
|
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
198 |
# Look for an unstable which can be stabilized as a child of |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
199 |
# node. The unstable must be a child of one of node predecessors. |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
200 |
for ctx in selfanddescendants(repo, pctx): |
446
9d47474d2582
obsolete: remove legacy revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
444
diff
changeset
|
201 |
unstables = list(repo.set('unstable() and children(allprecursors(%d))', |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
202 |
ctx.rev())) |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
203 |
if unstables: |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
204 |
return unstables[0] |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
205 |
return None |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
206 |
|
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
207 |
def _bookmarksupdater(repo, oldid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
208 |
"""Return a callable update(newid) updating the current bookmark |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
209 |
and bookmarks bound to oldid to newid. |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
210 |
""" |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
211 |
bm = bookmarks.readcurrent(repo) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
212 |
def updatebookmarks(newid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
213 |
dirty = False |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
214 |
if bm: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
215 |
repo._bookmarks[bm] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
216 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
217 |
oldbookmarks = repo.nodebookmarks(oldid) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
218 |
if oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
219 |
for b in oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
220 |
repo._bookmarks[b] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
221 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
222 |
if dirty: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
223 |
bookmarks.write(repo) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
224 |
return updatebookmarks |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
225 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
226 |
### new command |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
227 |
############################# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
228 |
cmdtable = {} |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
229 |
command = cmdutil.command(cmdtable) |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
230 |
|
362
88cee22c89f1
evolve: add the solve alias to obsolete
Pierre-Yves.David@ens-lyon.org
parents:
356
diff
changeset
|
231 |
@command('^stabilize|evolve|solve', |
303 | 232 |
[('n', 'dry-run', False, 'do not perform actions, print what to be done'), |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
233 |
('A', 'any', False, 'stabilize any unstable changeset'), |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
234 |
('c', 'continue', False, 'continue an interrupted stabilized'), ], |
303 | 235 |
_('[OPTIONS]...')) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
236 |
def stabilize(ui, repo, **opts): |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
237 |
"""rebase an unstable changeset to make it stable again |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
238 |
|
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
239 |
By default, take the first unstable changeset which could be |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
240 |
rebased as child of the working directory parent revision or one |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
241 |
of its descendants and rebase it. |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
242 |
|
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
243 |
With --any, stabilize any unstable changeset. |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
244 |
|
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
245 |
The working directory is updated to the rebased revision. |
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
246 |
""" |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
247 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
248 |
contopt = opts['continue'] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
249 |
anyopt = opts['any'] |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
250 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
251 |
if contopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
252 |
if anyopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
253 |
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
|
254 |
graftcmd = commands.table['graft'][0] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
255 |
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
|
256 |
|
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
|
257 |
troubled = list(repo.revs('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
|
258 |
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
|
259 |
if tr is None: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
260 |
if troubled: |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
261 |
ui.write_err(_('nothing to stabilize 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
|
262 |
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
|
263 |
% len(troubled)) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
return 1 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
if 'unstable' in troubles: |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
271 |
return _solveunstable(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
|
272 |
elif 'latecomer' in troubles: |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
273 |
return _solvelatecomer(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
|
274 |
elif 'conflicting' in troubles: |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
275 |
return _solveconflicting(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
|
276 |
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
|
277 |
assert False # WHAT? unknown troubles |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
278 |
|
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
|
279 |
def _picknexttroubled(ui, repo, any=False): |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
280 |
"""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
|
281 |
tr = _stabilizableunstable(repo, repo['.']) |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
282 |
if tr is None: |
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
283 |
wdp = repo['.'] |
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
284 |
if 'conflicting' in wdp.troubles(): |
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
285 |
tr = wdp |
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
|
286 |
if tr is None and any: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
287 |
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
|
288 |
if not 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
|
289 |
troubled = list(repo.set('latecomer()')) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
290 |
if not 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
|
291 |
troubled = list(repo.set('conflicting()')) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
292 |
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
|
293 |
tr = troubled[0] |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
294 |
|
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
|
295 |
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
|
296 |
|
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
297 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
298 |
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
|
299 |
"""Stabilize a unstable changeset""" |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
300 |
obsolete = extensions.find('obsolete') |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
301 |
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
|
302 |
if not obs.obsolete(): |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
303 |
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
|
304 |
assert obs.obsolete() |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
305 |
newer = obsolete.newerversion(repo, obs.node()) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
306 |
# search of a parent which is not killed |
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
307 |
while newer == [()]: |
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
308 |
ui.debug("stabilize target %s is plain dead," |
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
309 |
" trying to stabilize on it's parent") |
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
310 |
obs = obs.parents()[0] |
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
311 |
newer = obsolete.newerversion(repo, obs.node()) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
312 |
if len(newer) > 1: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
313 |
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
|
314 |
return 2 |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
315 |
targets = newer[0] |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
316 |
assert targets |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
317 |
if len(targets) > 1: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
318 |
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
|
319 |
return 2 |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
320 |
target = targets[0] |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
321 |
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
|
322 |
target = repo[target] |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
323 |
repo.ui.status(_('move:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
324 |
if not ui.quiet: |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
325 |
displayer.show(orig) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
326 |
repo.ui.status(_('atop:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
327 |
if not ui.quiet: |
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
328 |
displayer.show(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
|
329 |
todo = 'hg rebase -Dr %s -d %s\n' % (orig, target) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
330 |
if dryrun: |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
331 |
repo.ui.write(todo) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
332 |
else: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
333 |
repo.ui.note(todo) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
334 |
lock = repo.lock() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
335 |
try: |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
336 |
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
|
337 |
except MergeFailure: |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
338 |
repo.opener.write('graftstate', orig.hex() + '\n') |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
339 |
repo.ui.write_err(_('stabilize failed!\n')) |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
340 |
repo.ui.write_err(_('fix conflict and run "hg stabilize --continue"\n')) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
341 |
raise |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
342 |
finally: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
343 |
lock.release() |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
344 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
345 |
def _solvelatecomer(ui, repo, latecomer, dryrun=False): |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
346 |
"""Stabilize a latecomer changeset""" |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
347 |
# For now we deny latecomer merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
348 |
if len(latecomer.parents()) > 1: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
349 |
raise util.Abort('late comer stabilization is confused by latecomer' |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
350 |
' %s being a merge' % latecomer) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
351 |
prec = repo.set('last(allprecursors(%d) and public())', latecomer).next() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
352 |
# For now we deny target merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
353 |
if len(prec.parents()) > 1: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
354 |
raise util.Abort('late comer stabilization is confused by precursors' |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
355 |
' %s being a merge' % prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
356 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
357 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
358 |
repo.ui.status(_('recreate:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
359 |
if not ui.quiet: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
360 |
displayer.show(latecomer) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
361 |
repo.ui.status(_('atop:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
362 |
if not ui.quiet: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
363 |
displayer.show(prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
364 |
obsolete = extensions.find('obsolete') |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
365 |
if dryrun: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
366 |
todo = 'hg rebase --rev %s --detach %s;\n' % (latecomer, prec.p1()) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
367 |
repo.ui.write(todo) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
368 |
repo.ui.write('hg update %s;\n' % prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
369 |
repo.ui.write('hg revert --all --rev %s;\n' % latecomer) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
370 |
repo.ui.write('hg commit --msg "latecomer update to %s"') |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
371 |
return 0 |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
372 |
wlock = repo.wlock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
373 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
374 |
newid = tmpctx = None |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
375 |
tmpctx = latecomer |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
376 |
lock = repo.lock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
377 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
378 |
bmupdate = _bookmarksupdater(repo, latecomer.node()) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
379 |
# Basic check for common parent. Far too complicated and fragile |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
380 |
tr = repo.transaction('latecomer-stabilize') |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
381 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
382 |
if not list(repo.set('parents(%d) and parents(%d)', latecomer, prec)): |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
383 |
# 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
|
384 |
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
|
385 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
386 |
tmpid = relocate(repo, latecomer, prec.p1()) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
387 |
if tmpid is not None: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
388 |
tmpctx = repo[tmpid] |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
389 |
obsolete.createmarkers(repo, [(latecomer, (tmpctx,))]) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
390 |
except MergeFailure: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
391 |
repo.opener.write('graftstate', latecomer.hex() + '\n') |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
392 |
repo.ui.write_err(_('stabilize failed!\n')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
393 |
repo.ui.write_err(_('fix conflict and run "hg stabilize --continue"\n')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
394 |
raise |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
395 |
# Create the new commit context |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
396 |
repo.ui.status(_('computing new diff\n')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
397 |
files = set() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
398 |
copied = copies.pathcopies(prec, latecomer) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
399 |
precmanifest = prec.manifest() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
400 |
for key, val in latecomer.manifest().iteritems(): |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
401 |
if precmanifest.pop(key, None) != val: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
402 |
files.add(key) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
403 |
files.update(precmanifest) # add missing files |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
404 |
# commit it |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
405 |
if files: # something to commit! |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
406 |
def filectxfn(repo, ctx, path): |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
407 |
if path in latecomer: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
408 |
fctx = latecomer[path] |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
409 |
flags = fctx.flags() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
410 |
mctx = context.memfilectx(fctx.path(), fctx.data(), |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
411 |
islink='l' in flags, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
412 |
isexec='x' in flags, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
413 |
copied=copied.get(path)) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
414 |
return mctx |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
415 |
raise IOError() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
416 |
text = 'latecomer update to %s:\n\n' % prec |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
417 |
text += latecomer.description() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
418 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
419 |
new = context.memctx(repo, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
420 |
parents=[prec.node(), node.nullid], |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
421 |
text=text, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
422 |
files=files, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
423 |
filectxfn=filectxfn, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
424 |
user=latecomer.user(), |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
425 |
date=latecomer.date(), |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
426 |
extra=latecomer.extra()) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
427 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
428 |
newid = repo.commitctx(new) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
429 |
if newid is None: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
430 |
obsolete.createmarkers(repo, [(tmpctx, ())]) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
431 |
newid = prec.node() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
432 |
else: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
433 |
phases.retractboundary(repo, latecomer.phase(), [newid]) |
470
a2dfe82f27a0
obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
469
diff
changeset
|
434 |
obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], |
a2dfe82f27a0
obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
469
diff
changeset
|
435 |
flag=obsolete.latediff) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
436 |
bmupdate(newid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
437 |
tr.close() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
438 |
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
|
439 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
440 |
tr.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
441 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
442 |
lock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
443 |
# 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
|
444 |
repo.dirstate.setparents(newid, node.nullid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
445 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
446 |
wlock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
447 |
|
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
448 |
def _solveconflicting(ui, repo, conflicting, dryrun=False): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
449 |
obsolete = extensions.find('obsolete') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
450 |
base, others = conflictingdata(conflicting) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
451 |
if len(others) > 1: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
452 |
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
|
453 |
other = others[0] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
454 |
if conflicting.phase() <= phases.public: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
455 |
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
|
456 |
if len(other.parents()) > 1: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
457 |
raise util.Abort("conflicting changeset can't be a merge (yet)") |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
458 |
if other.p1() not in conflicting.parents(): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
459 |
raise util.Abort("parent are not common (not handled yet)") |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
460 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
461 |
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
|
462 |
ui.status(_('merge:')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
463 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
464 |
displayer.show(conflicting) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
465 |
ui.status(_('with: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
466 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
467 |
displayer.show(other) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
468 |
ui.status(_('base: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
469 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
470 |
displayer.show(base) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
471 |
if dryrun: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
472 |
ui.write('hg update -c %s &&\n' % conflicting) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
473 |
ui.write('hg merge %s && \n' % other) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
474 |
ui.write('hg commit -m "auto merge resolving conflict between %s and %s"&&\n' |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
475 |
% (conflicting, other)) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
476 |
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
|
477 |
ui.write('hg revert --all --rev tip &&\n') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
478 |
ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' % conflicting) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
479 |
return |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
480 |
#oldphase = max(conflicting.phase(), other.phase()) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
481 |
wlock = repo.wlock() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
482 |
try: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
483 |
lock = repo.lock() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
484 |
try: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
485 |
if conflicting not in repo[None].parents(): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
486 |
repo.ui.status(_('updating to "local" conflict\n')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
487 |
hg.update(repo, conflicting.rev()) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
488 |
repo.ui.note(_('merging conflicting changeset\n')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
489 |
stats = merge.update(repo, |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
490 |
other.node(), |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
491 |
branchmerge=True, |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
492 |
force=False, |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
493 |
partial=None, |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
494 |
ancestor=base.node(), |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
495 |
mergeancestor=True) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
496 |
hg._showstats(repo, stats) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
497 |
if stats[3]: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
498 |
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
499 |
"or 'hg update -C .' to abandon\n")) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
500 |
#repo.dirstate.write() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
501 |
if stats[3] > 0: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
502 |
raise util.Abort('GASP! Merge Conflict! You are on you own chap!') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
503 |
tr = repo.transaction('stabilize-conflicting') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
504 |
try: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
505 |
repo.dirstate.setparents(conflicting.node(), node.nullid) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
506 |
oldlen = len(repo) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
507 |
amend(ui, repo) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
508 |
if oldlen == len(repo): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
509 |
new = conflicting |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
510 |
# no changes |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
511 |
else: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
512 |
new = repo['.'] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
513 |
obsolete.createmarkers(repo, [(other, (new,))]) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
514 |
phases.retractboundary(repo, other.phase(), [new.node()]) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
515 |
tr.close() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
516 |
finally: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
517 |
tr.release() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
518 |
finally: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
519 |
lock.release() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
520 |
finally: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
521 |
wlock.release() |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
522 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
523 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
524 |
def conflictingdata(ctx): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
525 |
"""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
|
526 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
527 |
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
|
528 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
529 |
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
|
530 |
""" |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
531 |
obsolete = extensions.find('obsolete') |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
532 |
for base in ctx._repo.set('reverse(precursors(%d))', ctx): |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
533 |
newer = obsolete.newerversion(ctx._repo, base.node()) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
534 |
# 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
|
535 |
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
|
536 |
if newer: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
537 |
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
|
538 |
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
|
539 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
540 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
541 |
|
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
|
542 |
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
|
543 |
|
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
|
544 |
@command('^gdown', |
303 | 545 |
[], |
546 |
'') |
|
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
|
547 |
def cmdgdown(ui, repo): |
303 | 548 |
"""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
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
|
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
|
554 |
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
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
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
|
564 |
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
|
565 |
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
|
566 |
|
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
|
567 |
@command('^gup', |
303 | 568 |
[], |
569 |
'') |
|
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
|
570 |
def cmdup(ui, repo): |
303 | 571 |
"""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
|
572 |
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
|
573 |
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
|
574 |
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
|
575 |
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
|
576 |
|
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
|
577 |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
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
|
589 |
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
|
590 |
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
|
591 |
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
|
592 |
|
365
9f6a77ec66cb
evolve: switch the official name for "kill" to prune
Pierre-Yves.David@ens-lyon.org
parents:
362
diff
changeset
|
593 |
@command('^prune|obsolete|kill', |
303 | 594 |
[('n', 'new', [], _("successor changeset"))], |
595 |
_('[OPTION] REV...')) |
|
130
b70fadbccc2a
evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
127
diff
changeset
|
596 |
def kill(ui, repo, *revs, **opts): |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
597 |
"""mark a changeset as obsolete |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
598 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
599 |
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
|
600 |
working directory parent are killed. |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
601 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
602 |
XXX bookmark support |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
603 |
XXX handle merge |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
604 |
XXX check immutable first |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
605 |
""" |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
606 |
wlock = repo.wlock() |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
607 |
try: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
608 |
lock = repo.lock() |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
609 |
try: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
610 |
new = set(noderange(repo, opts['new'])) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
611 |
targetnodes = set(noderange(repo, revs)) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
612 |
if new: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
613 |
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
|
614 |
else: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
615 |
sucs = () |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
616 |
markers = [] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
617 |
for n in targetnodes: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
618 |
markers.append((repo[n], sucs)) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
619 |
obsolete = extensions.find('obsolete') |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
620 |
obsolete.createmarkers(repo, markers) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
621 |
|
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
622 |
# update to an unkilled parent |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
623 |
wdp = repo['.'] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
624 |
newnode = wdp |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
625 |
while newnode.obsolete(): |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
626 |
newnode = newnode.parents()[0] |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
627 |
if newnode.node() != wdp.node(): |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
628 |
commands.update(ui, repo, newnode.rev()) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
629 |
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
|
630 |
finally: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
631 |
lock.release() |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
632 |
finally: |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
633 |
wlock.release() |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
634 |
|
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
635 |
@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
|
636 |
[('A', 'addremove', None, |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
637 |
_('mark new/missing files as added/removed before committing')), |
303 | 638 |
('n', 'note', '', _('use text as commit message for this update')), |
639 |
('c', 'change', '', _('specifies the changesets to amend'), _('REV')), |
|
640 |
('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
|
641 |
] + walkopts + commitopts + commitopts2, |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
642 |
_('[OPTION]... [FILE]...')) |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
643 |
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
|
644 |
"""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
|
645 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
646 |
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
|
647 |
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
|
648 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
649 |
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
|
650 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
651 |
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
|
652 |
|
303 | 653 |
If you specify --change, amend additionally considers all |
654 |
changesets between the indicated changeset and the working copy |
|
655 |
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
|
656 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
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
|
660 |
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
|
661 |
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
|
662 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
663 |
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
|
664 |
""" |
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
665 |
|
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
666 |
# determine updates to subsume |
295
a5894bb97909
evolve: remove --change . == --change .^ crazyness
Patrick Mezard <patrick@mezard.eu>
parents:
294
diff
changeset
|
667 |
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
|
668 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
669 |
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
|
670 |
try: |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
671 |
wlock = repo.wlock() |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
672 |
try: |
475
9f69a5e41ab0
[evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
418
diff
changeset
|
673 |
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
|
674 |
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
|
675 |
% 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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
try: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
680 |
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
|
681 |
# 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
|
682 |
# 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
|
683 |
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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
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
|
689 |
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
|
690 |
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
|
691 |
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
|
692 |
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
|
693 |
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
|
694 |
# 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
|
695 |
tempid = None |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
696 |
|
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
697 |
# 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
|
698 |
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
|
699 |
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
|
700 |
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
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
break |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
707 |
else: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
708 |
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
|
709 |
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
|
710 |
|
410
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
711 |
# 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
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
[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
|
716 |
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
|
717 |
# 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
|
718 |
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
|
719 |
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
|
720 |
else: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
721 |
# 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
|
722 |
# 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
|
723 |
# 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
|
724 |
if tempid is not None: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
725 |
obsolete = extensions.find('obsolete') |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
726 |
obsolete.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
|
727 |
# 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
|
728 |
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
|
729 |
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
|
730 |
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
|
731 |
finally: |
598ff1df3b92
amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
365
diff
changeset
|
732 |
tr.release() |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
733 |
finally: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
734 |
wlock.release() |
82
8108d566a8b5
[evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
735 |
finally: |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
736 |
lock.release() |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
737 |
|
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
738 |
def _commitfiltered(repo, ctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
739 |
"""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
|
740 |
node identifier, or None if nothing changed. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
741 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
742 |
base = ctx.p1() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
743 |
m, a, r = repo.status(base, ctx)[:3] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
744 |
allfiles = set(m + a + r) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
745 |
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
|
746 |
if files == allfiles: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
747 |
return None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
748 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
749 |
# Filter copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
750 |
copied = copies.pathcopies(base, ctx) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
751 |
copied = dict((src, dst) for src, dst in copied.iteritems() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
752 |
if dst in files) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
753 |
def filectxfn(repo, memctx, path): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
754 |
if path not in ctx: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
755 |
raise IOError() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
756 |
fctx = ctx[path] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
757 |
flags = fctx.flags() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
758 |
mctx = context.memfilectx(fctx.path(), fctx.data(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
759 |
islink='l' in flags, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
760 |
isexec='x' in flags, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
761 |
copied=copied.get(path)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
762 |
return mctx |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
763 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
764 |
new = context.memctx(repo, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
765 |
parents=[base.node(), node.nullid], |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
766 |
text=ctx.description(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
767 |
files=files, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
768 |
filectxfn=filectxfn, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
769 |
user=ctx.user(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
770 |
date=ctx.date(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
771 |
extra=ctx.extra()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
772 |
# commitctx always create a new revision, no need to check |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
773 |
newid = repo.commitctx(new) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
774 |
return newid |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
775 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
776 |
def _uncommitdirstate(repo, oldctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
777 |
"""Fix the dirstate after switching the working directory from |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
778 |
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
|
779 |
match. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
780 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
781 |
ctx = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
782 |
ds = repo.dirstate |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
783 |
copies = dict(ds.copies()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
784 |
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
|
785 |
for f in m: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
786 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
787 |
# modified + removed -> removed |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
788 |
continue |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
789 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
790 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
791 |
for f in a: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
792 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
793 |
# added + removed -> unknown |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
794 |
ds.drop(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
795 |
elif ds[f] != 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
796 |
ds.add(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
797 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
798 |
for f in r: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
799 |
if ds[f] == 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
800 |
# removed + added -> normal |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
801 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
802 |
elif ds[f] != 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
803 |
ds.remove(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
804 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
805 |
# Merge old parent and old working dir copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
806 |
oldcopies = {} |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
807 |
for f in (m + a): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
808 |
src = oldctx[f].renamed() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
809 |
if src: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
810 |
oldcopies[f] = src[0] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
811 |
oldcopies.update(copies) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
812 |
copies = dict((dst, oldcopies.get(src, src)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
813 |
for dst, src in oldcopies.iteritems()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
814 |
# Adjust the dirstate copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
815 |
for dst, src in copies.iteritems(): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
816 |
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
|
817 |
src = None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
818 |
ds.copy(src, dst) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
819 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
820 |
@command('^uncommit', |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
821 |
[('a', 'all', None, _('uncommit all changes when no arguments given')), |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
822 |
] + commands.walkopts, |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
823 |
_('[OPTION]... [NAME]')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
824 |
def uncommit(ui, repo, *pats, **opts): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
825 |
"""move changes from parent revision to working directory |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
826 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
827 |
Changes to selected files in parent revision appear again as |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
828 |
uncommitted changed in the working directory. A new revision |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
829 |
without selected changes is created, becomes the new parent and |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
830 |
obsoletes the previous one. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
831 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
832 |
The --include option specify pattern to uncommit |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
833 |
The --exclude option specify pattern to keep in the commit |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
834 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
835 |
Return 0 if changed files are uncommitted. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
836 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
837 |
lock = repo.lock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
838 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
839 |
wlock = repo.wlock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
840 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
841 |
wctx = repo[None] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
842 |
if len(wctx.parents()) <= 0: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
843 |
raise util.Abort(_("cannot uncommit null changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
844 |
if len(wctx.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
845 |
raise util.Abort(_("cannot uncommit while merging")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
846 |
old = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
847 |
if old.phase() == phases.public: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
848 |
raise util.Abort(_("cannot rewrite immutable changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
849 |
if len(old.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
850 |
raise util.Abort(_("cannot uncommit merge changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
851 |
oldphase = old.phase() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
852 |
updatebookmarks = _bookmarksupdater(repo, old.node()) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
853 |
# Recommit the filtered changeset |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
854 |
newid = None |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
855 |
if (pats or opts.get('include') or opts.get('exclude') |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
856 |
or opts.get('all')): |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
857 |
match = scmutil.match(old, pats, opts) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
858 |
newid = _commitfiltered(repo, old, match) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
859 |
if newid is None: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
860 |
raise util.Abort(_('nothing to uncommit')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
861 |
# Move local changes on filtered changeset |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
862 |
obsolete = extensions.find('obsolete') |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
863 |
obsolete.createmarkers(repo, [(old, (repo[newid],))]) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
864 |
phases.retractboundary(repo, oldphase, [newid]) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
865 |
repo.dirstate.setparents(newid, node.nullid) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
866 |
_uncommitdirstate(repo, old, match) |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
867 |
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
|
868 |
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
|
869 |
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
|
870 |
ui.status(_('(use "hg kill ." to remove it)\n')) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
871 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
872 |
wlock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
873 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
874 |
lock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
875 |
|
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
876 |
def commitwrapper(orig, ui, repo, *arg, **kwargs): |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
877 |
lock = repo.lock() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
878 |
try: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
879 |
obsoleted = kwargs.get('obsolete', []) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
880 |
if obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
881 |
obsoleted = repo.set('%lr', obsoleted) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
882 |
result = orig(ui, repo, *arg, **kwargs) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
883 |
if not result: # commit successed |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
884 |
new = repo['-1'] |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
885 |
oldbookmarks = [] |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
886 |
obsolete = extensions.find('obsolete') |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
887 |
markers = [] |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
888 |
for old in obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
889 |
oldbookmarks.extend(repo.nodebookmarks(old.node())) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
890 |
markers.append((old, (new,))) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
891 |
if markers: |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
892 |
obsolete.createmarkers(repo, markers) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
893 |
for book in oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
894 |
repo._bookmarks[book] = new.node() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
895 |
if oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
896 |
bookmarks.write(repo) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
897 |
return result |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
898 |
finally: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
899 |
lock.release() |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
900 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
901 |
@command('^touch', |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
902 |
[('r', 'rev', [], 'revision to update'),], |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
903 |
# allow to choose the seed ? |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
904 |
_('[-r] revs')) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
905 |
def touch(ui, repo, *revs, **opts): |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
906 |
"""Create successors with exact same property but hash |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
907 |
|
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
908 |
This is used to "resurect" changeset""" |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
909 |
revs = list(revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
910 |
revs.extend(opts['rev']) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
911 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
912 |
revs = ['.'] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
913 |
revs = scmutil.revrange(repo, revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
914 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
915 |
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
|
916 |
return 1 |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
917 |
if repo.revs('public() and %ld', revs): |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
918 |
raise util.Abort("can't touch public revision") |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
919 |
obsolete = extensions.find('obsolete') |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
920 |
wlock = repo.wlock() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
921 |
try: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
922 |
lock = repo.lock() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
923 |
try: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
924 |
tr = repo.transaction('touch') |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
925 |
try: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
926 |
for r in revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
927 |
ctx = repo[r] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
928 |
extra = ctx.extra().copy() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
929 |
extra['__touch-noise__'] = random.randint(0, 0xffffffff) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
930 |
new, _ = rewrite(repo, ctx, [], ctx, |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
931 |
[ctx.p1().node(), ctx.p2().node()], |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
932 |
commitopts={'extra': extra}) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
933 |
obsolete.createmarkers(repo, [(ctx, (repo[new],))]) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
934 |
phases.retractboundary(repo, ctx.phase(), [new]) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
935 |
if ctx in repo[None].parents(): |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
936 |
repo.dirstate.setparents(new, node.nullid) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
937 |
tr.close() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
938 |
finally: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
939 |
tr.release() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
940 |
finally: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
941 |
lock.release() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
942 |
finally: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
943 |
wlock.release() |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
944 |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
945 |
@command('^fold', |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
946 |
[('r', 'rev', [], 'revision to fold'),], |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
947 |
# allow to choose the seed ? |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
948 |
_('[-r] revs')) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
949 |
def fold(ui, repo, *revs, **opts): |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
950 |
"""Fold multiple revision into a single one""" |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
951 |
revs = list(revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
952 |
revs.extend(opts['rev']) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
953 |
if not revs: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
954 |
revs = ['.'] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
955 |
revs = scmutil.revrange(repo, revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
956 |
if not revs: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
957 |
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
|
958 |
return 1 |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
959 |
roots = repo.revs('roots(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
960 |
if len(roots) > 1: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
961 |
raise util.Abort("set have multiple roots") |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
962 |
root = repo[roots[0]] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
963 |
if root.phase() <= phases.public: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
964 |
raise util.Abort("can't touch public revision") |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
965 |
heads = repo.revs('heads(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
966 |
if len(heads) > 1: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
967 |
raise util.Abort("set have multiple heads") |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
968 |
head = repo[heads[0]] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
969 |
obsolete = extensions.find('obsolete') |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
970 |
wlock = repo.wlock() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
971 |
try: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
972 |
lock = repo.lock() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
973 |
try: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
974 |
tr = repo.transaction('touch') |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
975 |
try: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
976 |
allctx = [repo[r] for r in revs] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
977 |
targetphase = max(c.phase() for c in allctx) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
978 |
msg = '\n\n***\n\n'.join(c.description() for c in allctx) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
979 |
newid, _ = rewrite(repo, root, allctx, head, |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
980 |
[root.p1().node(), root.p2().node()], |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
981 |
commitopts={'message': msg}) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
982 |
phases.retractboundary(repo, targetphase, [newid]) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
983 |
obsolete.createmarkers(repo, [(ctx, (repo[newid],)) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
984 |
for ctx in allctx]) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
985 |
tr.close() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
986 |
finally: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
987 |
tr.release() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
988 |
finally: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
989 |
lock.release() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
990 |
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
|
991 |
if repo.revs('. and %ld', revs): |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
992 |
repo.dirstate.setparents(newid, node.nullid) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
993 |
finally: |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
994 |
wlock.release() |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
995 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
996 |
|
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
997 |
def graftwrapper(orig, ui, repo, *revs, **kwargs): |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
998 |
kwargs = dict(kwargs) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
999 |
revs = list(revs) + kwargs.get('rev', []) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1000 |
kwargs['rev'] = [] |
417
a1fb18ad29a1
evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents:
416
diff
changeset
|
1001 |
obsoleted = kwargs.setdefault('obsolete', []) |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
1002 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1003 |
lock = repo.lock() |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1004 |
try: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1005 |
if kwargs.get('old_obsolete'): |
418
18a0d96ed559
evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents:
417
diff
changeset
|
1006 |
if kwargs.get('continue'): |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1007 |
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
|
1008 |
else: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1009 |
obsoleted.extend(revs) |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1010 |
# 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
|
1011 |
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
|
1012 |
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
|
1013 |
|
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1014 |
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
|
1015 |
'obsoleting (for now).')) |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
1016 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1017 |
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
|
1018 |
finally: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
1019 |
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
|
1020 |
|
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1021 |
def extsetup(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
|
1022 |
try: |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1023 |
obsolete = extensions.find('obsolete') |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1024 |
except KeyError: |
416
22f348c25d25
obsolete/evolve: fix grammar in prerequisite messages
Patrick Mezard <patrick@mezard.eu>
parents:
414
diff
changeset
|
1025 |
raise error.Abort(_('evolution extension requires obsolete 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
|
1026 |
try: |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1027 |
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
|
1028 |
except KeyError: |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
1029 |
rebase = None |
416
22f348c25d25
obsolete/evolve: fix grammar in prerequisite messages
Patrick Mezard <patrick@mezard.eu>
parents:
414
diff
changeset
|
1030 |
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
|
1031 |
|
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1032 |
for cmd in ['amend', 'kill', 'uncommit']: |
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1033 |
entry = extensions.wrapcommand(cmdtable, cmd, |
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1034 |
obsolete.warnobserrors) |
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
1035 |
|
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1036 |
entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper) |
303 | 1037 |
entry[1].append(('o', 'obsolete', [], |
1038 |
_("make commit obsolete this revision"))) |
|
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
1039 |
entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper) |
303 | 1040 |
entry[1].append(('o', 'obsolete', [], |
1041 |
_("make graft obsoletes this revision"))) |
|
1042 |
entry[1].append(('O', 'old-obsolete', False, |
|
1043 |
_("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
|
1044 |