author | Augie Fackler <raf@durin42.com> |
Wed, 27 Jun 2012 17:52:54 -0500 | |
changeset 17064 | 168cc52ad7c2 |
child 17066 | baf8887d40e2 |
permissions | -rw-r--r-- |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1 |
# histedit.py - interactive history editing for mercurial |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2 |
# |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 Augie Fackler <raf@durin42.com> |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
4 |
# |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
7 |
"""Interactive history editing. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
8 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
9 |
Inspired by git rebase --interactive. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
10 |
""" |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
11 |
from inspect import getargspec |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
12 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
13 |
import cPickle as pickle |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
14 |
except ImportError: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
15 |
import pickle |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
16 |
import tempfile |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
17 |
import os |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
18 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
19 |
from mercurial import bookmarks |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
20 |
from mercurial import cmdutil |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
21 |
from mercurial import discovery |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
22 |
from mercurial import error |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
23 |
from mercurial import hg |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
24 |
from mercurial import node |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
25 |
from mercurial import patch |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
26 |
from mercurial import repair |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
27 |
from mercurial import scmutil |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
28 |
from mercurial import url |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
29 |
from mercurial import util |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
30 |
from mercurial.i18n import _ |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
31 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
32 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
33 |
editcomment = """ |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
34 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
35 |
# Edit history between %s and %s |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
36 |
# |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
37 |
# Commands: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
38 |
# p, pick = use commit |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
39 |
# e, edit = use commit, but stop for amending |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
40 |
# f, fold = use commit, but fold into previous commit (combines N and N-1) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
41 |
# d, drop = remove commit from history |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
42 |
# m, mess = edit message without changing commit content |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
43 |
# |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
44 |
""" |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
45 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
46 |
def between(repo, old, new, keep): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
47 |
revs = [old, ] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
48 |
current = old |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
49 |
while current != new: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
50 |
ctx = repo[current] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
51 |
if not keep and len(ctx.children()) > 1: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
52 |
raise util.Abort(_('cannot edit history that would orphan nodes')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
53 |
if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
54 |
raise util.Abort(_("can't edit history with merges")) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
55 |
if not ctx.children(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
56 |
current = new |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
57 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
58 |
current = ctx.children()[0].node() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
59 |
revs.append(current) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
60 |
if len(repo[current].children()) and not keep: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
61 |
raise util.Abort(_('cannot edit history that would orphan nodes')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
62 |
return revs |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
63 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
64 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
65 |
def pick(ui, repo, ctx, ha, opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
66 |
oldctx = repo[ha] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
67 |
if oldctx.parents()[0] == ctx: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
68 |
ui.debug('node %s unchanged\n' % ha) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
69 |
return oldctx, [], [], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
70 |
hg.update(repo, ctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
71 |
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
72 |
fp = os.fdopen(fd, 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
73 |
diffopts = patch.diffopts(ui, opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
74 |
diffopts.git = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
75 |
diffopts.ignorews = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
76 |
diffopts.ignorewsamount = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
77 |
diffopts.ignoreblanklines = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
78 |
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
79 |
for chunk in gen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
80 |
fp.write(chunk) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
81 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
82 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
83 |
files = set() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
84 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
85 |
patch.patch(ui, repo, patchfile, files=files, eolmode=None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
86 |
if not files: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
87 |
ui.warn(_('%s: empty changeset') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
88 |
% node.hex(ha)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
89 |
return ctx, [], [], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
90 |
finally: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
91 |
os.unlink(patchfile) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
92 |
except Exception, inst: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
93 |
raise util.Abort(_('Fix up the change and run ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
94 |
'hg histedit --continue')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
95 |
n = repo.commit(text=oldctx.description(), user=oldctx.user(), date=oldctx.date(), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
96 |
extra=oldctx.extra()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
97 |
return repo[n], [n, ], [oldctx.node(), ], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
98 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
99 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
100 |
def edit(ui, repo, ctx, ha, opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
101 |
oldctx = repo[ha] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
102 |
hg.update(repo, ctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
103 |
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
104 |
fp = os.fdopen(fd, 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
105 |
diffopts = patch.diffopts(ui, opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
106 |
diffopts.git = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
107 |
diffopts.ignorews = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
108 |
diffopts.ignorewsamount = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
109 |
diffopts.ignoreblanklines = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
110 |
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
111 |
for chunk in gen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
112 |
fp.write(chunk) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
113 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
114 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
115 |
files = set() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
116 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
117 |
patch.patch(ui, repo, patchfile, files=files, eolmode=None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
118 |
finally: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
119 |
os.unlink(patchfile) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
120 |
except Exception, inst: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
121 |
pass |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
122 |
raise util.Abort(_('Make changes as needed, you may commit or record as ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
123 |
'needed now.\nWhen you are finished, run hg' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
124 |
' histedit --continue to resume.')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
125 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
126 |
def fold(ui, repo, ctx, ha, opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
127 |
oldctx = repo[ha] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
128 |
hg.update(repo, ctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
129 |
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
130 |
fp = os.fdopen(fd, 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
131 |
diffopts = patch.diffopts(ui, opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
132 |
diffopts.git = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
133 |
diffopts.ignorews = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
134 |
diffopts.ignorewsamount = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
135 |
diffopts.ignoreblanklines = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
136 |
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
137 |
for chunk in gen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
138 |
fp.write(chunk) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
139 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
140 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
141 |
files = set() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
142 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
143 |
patch.patch(ui, repo, patchfile, files=files, eolmode=None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
144 |
if not files: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
145 |
ui.warn(_('%s: empty changeset') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
146 |
% node.hex(ha)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
147 |
return ctx, [], [], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
148 |
finally: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
149 |
os.unlink(patchfile) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
150 |
except Exception, inst: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
151 |
raise util.Abort(_('Fix up the change and run ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
152 |
'hg histedit --continue')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
153 |
n = repo.commit(text='fold-temp-revision %s' % ha, user=oldctx.user(), date=oldctx.date(), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
154 |
extra=oldctx.extra()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
155 |
return finishfold(ui, repo, ctx, oldctx, n, opts, []) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
156 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
157 |
def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
158 |
parent = ctx.parents()[0].node() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
159 |
hg.update(repo, parent) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
160 |
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
161 |
fp = os.fdopen(fd, 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
162 |
diffopts = patch.diffopts(ui, opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
163 |
diffopts.git = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
164 |
diffopts.ignorews = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
165 |
diffopts.ignorewsamount = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
166 |
diffopts.ignoreblanklines = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
167 |
gen = patch.diff(repo, parent, newnode, opts=diffopts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
168 |
for chunk in gen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
169 |
fp.write(chunk) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
170 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
171 |
files = set() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
172 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
173 |
patch.patch(ui, repo, patchfile, files=files, eolmode=None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
174 |
finally: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
175 |
os.unlink(patchfile) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
176 |
newmessage = '\n***\n'.join( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
177 |
[ctx.description(), ] + |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
178 |
[repo[r].description() for r in internalchanges] + |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
179 |
[oldctx.description(), ]) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
180 |
# If the changesets are from the same author, keep it. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
181 |
if ctx.user() == oldctx.user(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
182 |
username = ctx.user() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
183 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
184 |
username = ui.username() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
185 |
newmessage = ui.edit(newmessage, username) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
186 |
n = repo.commit(text=newmessage, user=username, date=max(ctx.date(), oldctx.date()), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
187 |
extra=oldctx.extra()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
188 |
return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
189 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
190 |
def drop(ui, repo, ctx, ha, opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
191 |
return ctx, [], [repo[ha].node(), ], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
192 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
193 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
194 |
def message(ui, repo, ctx, ha, opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
195 |
oldctx = repo[ha] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
196 |
hg.update(repo, ctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
197 |
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
198 |
fp = os.fdopen(fd, 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
199 |
diffopts = patch.diffopts(ui, opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
200 |
diffopts.git = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
201 |
diffopts.ignorews = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
202 |
diffopts.ignorewsamount = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
203 |
diffopts.ignoreblanklines = False |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
204 |
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
205 |
for chunk in gen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
206 |
fp.write(chunk) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
207 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
208 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
209 |
files = set() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
210 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
211 |
patch.patch(ui, repo, patchfile, files=files, eolmode=None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
212 |
finally: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
213 |
os.unlink(patchfile) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
214 |
except Exception, inst: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
215 |
raise util.Abort(_('Fix up the change and run ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
216 |
'hg histedit --continue')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
217 |
message = oldctx.description() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
218 |
message = ui.edit(message, ui.username()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
219 |
new = repo.commit(text=message, user=oldctx.user(), date=oldctx.date(), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
220 |
extra=oldctx.extra()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
221 |
newctx = repo[new] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
222 |
if oldctx.node() != newctx.node(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
223 |
return newctx, [new], [oldctx.node()], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
224 |
# We didn't make an edit, so just indicate no replaced nodes |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
225 |
return newctx, [new], [], [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
226 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
227 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
228 |
def makedesc(c): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
229 |
summary = '' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
230 |
if c.description(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
231 |
summary = c.description().splitlines()[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
232 |
line = 'pick %s %d %s' % (c.hex()[:12], c.rev(), summary) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
233 |
return line[:80] # trim to 80 chars so it's not stupidly wide in my editor |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
234 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
235 |
actiontable = {'p': pick, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
236 |
'pick': pick, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
237 |
'e': edit, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
238 |
'edit': edit, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
239 |
'f': fold, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
240 |
'fold': fold, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
241 |
'd': drop, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
242 |
'drop': drop, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
243 |
'm': message, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
244 |
'mess': message, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
245 |
} |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
246 |
def histedit(ui, repo, *parent, **opts): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
247 |
"""hg histedit <parent> |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
248 |
""" |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
249 |
# TODO only abort if we try and histedit mq patches, not just |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
250 |
# blanket if mq patches are applied somewhere |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
251 |
mq = getattr(repo, 'mq', None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
252 |
if mq and mq.applied: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
253 |
raise util.Abort(_('source has mq patches applied')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
254 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
255 |
parent = list(parent) + opts.get('rev', []) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
256 |
if opts.get('outgoing'): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
257 |
if len(parent) > 1: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
258 |
raise util.Abort(_('only one repo argument allowed with --outgoing')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
259 |
elif parent: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
260 |
parent = parent[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
261 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
262 |
dest = ui.expandpath(parent or 'default-push', parent or 'default') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
263 |
dest, revs = hg.parseurl(dest, None)[:2] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
264 |
ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
265 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
266 |
revs, checkout = hg.addbranchrevs(repo, repo, revs, None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
267 |
other = hg.repository(hg.remoteui(repo, opts), dest) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
268 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
269 |
if revs: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
270 |
revs = [repo.lookup(rev) for rev in revs] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
271 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
272 |
parent = discovery.findcommonoutgoing( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
273 |
repo, other, [], force=opts.get('force')).missing[0:1] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
274 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
275 |
if opts.get('force'): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
276 |
raise util.Abort(_('--force only allowed with --outgoing')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
277 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
278 |
if opts.get('continue', False): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
279 |
if len(parent) != 0: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
280 |
raise util.Abort(_('no arguments allowed with --continue')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
281 |
(parentctxnode, created, replaced, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
282 |
tmpnodes, existing, rules, keep, tip, replacemap ) = readstate(repo) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
283 |
currentparent, wantnull = repo.dirstate.parents() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
284 |
parentctx = repo[parentctxnode] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
285 |
# discover any nodes the user has added in the interim |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
286 |
newchildren = [c for c in parentctx.children() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
287 |
if c.node() not in existing] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
288 |
action, currentnode = rules.pop(0) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
289 |
while newchildren: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
290 |
if action in ['f', 'fold', ]: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
291 |
tmpnodes.extend([n.node() for n in newchildren]) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
292 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
293 |
created.extend([n.node() for n in newchildren]) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
294 |
newchildren = filter(lambda x: x.node() not in existing, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
295 |
reduce(lambda x, y: x + y, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
296 |
map(lambda r: r.children(), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
297 |
newchildren))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
298 |
m, a, r, d = repo.status()[:4] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
299 |
oldctx = repo[currentnode] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
300 |
message = oldctx.description() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
301 |
if action in ('e', 'edit', 'm', 'mess'): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
302 |
message = ui.edit(message, ui.username()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
303 |
elif action in ('f', 'fold', ): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
304 |
message = 'fold-temp-revision %s' % currentnode |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
305 |
new = None |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
306 |
if m or a or r or d: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
307 |
new = repo.commit(text=message, user=oldctx.user(), date=oldctx.date(), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
308 |
extra=oldctx.extra()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
309 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
310 |
if action in ('f', 'fold'): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
311 |
if new: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
312 |
tmpnodes.append(new) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
313 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
314 |
new = newchildren[-1] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
315 |
(parentctx, created_, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
316 |
replaced_, tmpnodes_, ) = finishfold(ui, repo, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
317 |
parentctx, oldctx, new, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
318 |
opts, newchildren) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
319 |
replaced.extend(replaced_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
320 |
created.extend(created_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
321 |
tmpnodes.extend(tmpnodes_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
322 |
elif action not in ('d', 'drop'): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
323 |
if new != oldctx.node(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
324 |
replaced.append(oldctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
325 |
if new: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
326 |
if new != oldctx.node(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
327 |
created.append(new) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
328 |
parentctx = repo[new] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
329 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
330 |
elif opts.get('abort', False): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
331 |
if len(parent) != 0: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
332 |
raise util.Abort(_('no arguments allowed with --abort')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
333 |
(parentctxnode, created, replaced, tmpnodes, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
334 |
existing, rules, keep, tip, replacemap) = readstate(repo) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
335 |
ui.debug('restore wc to old tip %s\n' % node.hex(tip)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
336 |
hg.clean(repo, tip) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
337 |
ui.debug('should strip created nodes %s\n' % |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
338 |
', '.join([node.hex(n)[:12] for n in created])) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
339 |
ui.debug('should strip temp nodes %s\n' % |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
340 |
', '.join([node.hex(n)[:12] for n in tmpnodes])) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
341 |
for nodes in (created, tmpnodes, ): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
342 |
for n in reversed(nodes): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
343 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
344 |
repair.strip(ui, repo, n) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
345 |
except error.LookupError: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
346 |
pass |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
347 |
os.unlink(os.path.join(repo.path, 'histedit-state')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
348 |
return |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
349 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
350 |
cmdutil.bailifchanged(repo) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
351 |
if os.path.exists(os.path.join(repo.path, 'histedit-state')): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
352 |
raise util.Abort(_('history edit already in progress, try ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
353 |
'--continue or --abort')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
354 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
355 |
tip, empty = repo.dirstate.parents() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
356 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
357 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
358 |
if len(parent) != 1: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
359 |
raise util.Abort(_('histedit requires exactly one parent revision')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
360 |
parent = scmutil.revsingle(repo, parent[0]).node() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
361 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
362 |
keep = opts.get('keep', False) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
363 |
revs = between(repo, parent, tip, keep) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
364 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
365 |
ctxs = [repo[r] for r in revs] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
366 |
existing = [r.node() for r in ctxs] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
367 |
rules = opts.get('commands', '') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
368 |
if not rules: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
369 |
rules = '\n'.join([makedesc(c) for c in ctxs]) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
370 |
rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12], ) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
371 |
rules = ui.edit(rules, ui.username()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
372 |
# Save edit rules in .hg/histedit-last-edit.txt in case |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
373 |
# the user needs to ask for help after something |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
374 |
# surprising happens. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
375 |
f = open(repo.join('histedit-last-edit.txt'), 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
376 |
f.write(rules) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
377 |
f.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
378 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
379 |
f = open(rules) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
380 |
rules = f.read() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
381 |
f.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
382 |
rules = [l for l in (r.strip() for r in rules.splitlines()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
383 |
if l and not l[0] == '#'] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
384 |
rules = verifyrules(rules, repo, ctxs) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
385 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
386 |
parentctx = repo[parent].parents()[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
387 |
keep = opts.get('keep', False) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
388 |
replaced = [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
389 |
replacemap = {} |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
390 |
tmpnodes = [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
391 |
created = [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
392 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
393 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
394 |
while rules: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
395 |
writestate(repo, parentctx.node(), created, replaced, tmpnodes, existing, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
396 |
rules, keep, tip, replacemap) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
397 |
action, ha = rules.pop(0) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
398 |
(parentctx, created_, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
399 |
replaced_, tmpnodes_, ) = actiontable[action](ui, repo, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
400 |
parentctx, ha, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
401 |
opts) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
402 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
403 |
hexshort = lambda x: node.hex(x)[:12] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
404 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
405 |
if replaced_: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
406 |
clen, rlen = len(created_), len(replaced_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
407 |
if clen == rlen == 1: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
408 |
ui.debug('histedit: exact replacement of %s with %s\n' % ( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
409 |
hexshort(replaced_[0]), hexshort(created_[0]))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
410 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
411 |
replacemap[replaced_[0]] = created_[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
412 |
elif clen > rlen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
413 |
assert rlen == 1, ('unexpected replacement of ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
414 |
'%d changes with %d changes' % (rlen, clen)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
415 |
# made more changesets than we're replacing |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
416 |
# TODO synthesize patch names for created patches |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
417 |
replacemap[replaced_[0]] = created_[-1] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
418 |
ui.debug('histedit: created many, assuming %s replaced by %s' % ( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
419 |
hexshort(replaced_[0]), hexshort(created_[-1]))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
420 |
elif rlen > clen: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
421 |
if not created_: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
422 |
# This must be a drop. Try and put our metadata on |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
423 |
# the parent change. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
424 |
assert rlen == 1 |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
425 |
r = replaced_[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
426 |
ui.debug('histedit: %s seems replaced with nothing, ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
427 |
'finding a parent\n' % (hexshort(r))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
428 |
pctx = repo[r].parents()[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
429 |
if pctx.node() in replacemap: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
430 |
ui.debug('histedit: parent is already replaced\n') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
431 |
replacemap[r] = replacemap[pctx.node()] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
432 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
433 |
replacemap[r] = pctx.node() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
434 |
ui.debug('histedit: %s best replaced by %s\n' % ( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
435 |
hexshort(r), hexshort(replacemap[r]))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
436 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
437 |
assert len(created_) == 1 |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
438 |
for r in replaced_: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
439 |
ui.debug('histedit: %s replaced by %s\n' % ( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
440 |
hexshort(r), hexshort(created_[0]))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
441 |
replacemap[r] = created_[0] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
442 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
443 |
assert False, ( |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
444 |
'Unhandled case in replacement mapping! ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
445 |
'replacing %d changes with %d changes' % (rlen, clen)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
446 |
created.extend(created_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
447 |
replaced.extend(replaced_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
448 |
tmpnodes.extend(tmpnodes_) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
449 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
450 |
hg.update(repo, parentctx.node()) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
451 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
452 |
if not keep: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
453 |
if replacemap: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
454 |
ui.note('histedit: Should update metadata for the following ' |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
455 |
'changes:\n') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
456 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
457 |
def copybms(old, new): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
458 |
if old in tmpnodes or old in created: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
459 |
# can't have any metadata we'd want to update |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
460 |
return |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
461 |
while new in replacemap: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
462 |
new = replacemap[new] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
463 |
ui.note('histedit: %s to %s\n' % (hexshort(old), hexshort(new))) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
464 |
octx = repo[old] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
465 |
marks = octx.bookmarks() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
466 |
if marks: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
467 |
ui.note('histedit: moving bookmarks %s\n' % |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
468 |
', '.join(marks)) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
469 |
for mark in marks: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
470 |
repo._bookmarks[mark] = new |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
471 |
bookmarks.write(repo) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
472 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
473 |
# We assume that bookmarks on the tip should remain |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
474 |
# tipmost, but bookmarks on non-tip changesets should go |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
475 |
# to their most reasonable successor. As a result, find |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
476 |
# the old tip and new tip and copy those bookmarks first, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
477 |
# then do the rest of the bookmark copies. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
478 |
oldtip = sorted(replacemap.keys(), key=repo.changelog.rev)[-1] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
479 |
newtip = sorted(replacemap.values(), key=repo.changelog.rev)[-1] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
480 |
copybms(oldtip, newtip) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
481 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
482 |
for old, new in replacemap.iteritems(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
483 |
copybms(old, new) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
484 |
# TODO update mq state |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
485 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
486 |
ui.debug('should strip replaced nodes %s\n' % |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
487 |
', '.join([node.hex(n)[:12] for n in replaced])) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
488 |
for n in sorted(replaced, key=lambda x: repo[x].rev()): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
489 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
490 |
repair.strip(ui, repo, n) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
491 |
except error.LookupError: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
492 |
pass |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
493 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
494 |
ui.debug('should strip temp nodes %s\n' % |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
495 |
', '.join([node.hex(n)[:12] for n in tmpnodes])) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
496 |
for n in reversed(tmpnodes): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
497 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
498 |
repair.strip(ui, repo, n) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
499 |
except error.LookupError: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
500 |
pass |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
501 |
os.unlink(os.path.join(repo.path, 'histedit-state')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
502 |
if os.path.exists(repo.sjoin('undo')): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
503 |
os.unlink(repo.sjoin('undo')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
504 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
505 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
506 |
def writestate(repo, parentctxnode, created, replaced, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
507 |
tmpnodes, existing, rules, keep, oldtip, replacemap): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
508 |
fp = open(os.path.join(repo.path, 'histedit-state'), 'w') |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
509 |
pickle.dump((parentctxnode, created, replaced, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
510 |
tmpnodes, existing, rules, keep, oldtip, replacemap), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
511 |
fp) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
512 |
fp.close() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
513 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
514 |
def readstate(repo): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
515 |
"""Returns a tuple of (parentnode, created, replaced, tmp, existing, rules, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
516 |
keep, oldtip, replacemap ). |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
517 |
""" |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
518 |
fp = open(os.path.join(repo.path, 'histedit-state')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
519 |
return pickle.load(fp) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
520 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
521 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
522 |
def verifyrules(rules, repo, ctxs): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
523 |
"""Verify that there exists exactly one edit rule per given changeset. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
524 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
525 |
Will abort if there are to many or too few rules, a malformed rule, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
526 |
or a rule on a changeset outside of the user-given range. |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
527 |
""" |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
528 |
parsed = [] |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
529 |
first = True |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
530 |
if len(rules) != len(ctxs): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
531 |
raise util.Abort(_('must specify a rule for each changeset once')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
532 |
for r in rules: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
533 |
if ' ' not in r: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
534 |
raise util.Abort(_('malformed line "%s"') % r) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
535 |
action, rest = r.split(' ', 1) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
536 |
if ' ' in rest.strip(): |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
537 |
ha, rest = rest.split(' ', 1) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
538 |
else: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
539 |
ha = r.strip() |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
540 |
try: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
541 |
if repo[ha] not in ctxs: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
542 |
raise util.Abort(_('may not use changesets other than the ones listed')) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
543 |
except error.RepoError: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
544 |
raise util.Abort(_('unknown changeset %s listed') % ha) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
545 |
if action not in actiontable: |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
546 |
raise util.Abort(_('unknown action "%s"') % action) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
547 |
parsed.append([action, ha]) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
548 |
return parsed |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
549 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
550 |
|
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
551 |
cmdtable = { |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
552 |
"histedit": |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
553 |
(histedit, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
554 |
[('', 'commands', '', _('Read history edits from the specified file.')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
555 |
('c', 'continue', False, _('continue an edit already in progress')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
556 |
('k', 'keep', False, _("don't strip old nodes after edit is complete")), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
557 |
('', 'abort', False, _('abort an edit in progress')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
558 |
('o', 'outgoing', False, _('changesets not found in destination')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
559 |
('f', 'force', False, _('force outgoing even for unrelated repositories')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
560 |
('r', 'rev', [], _('first revision to be edited')), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
561 |
], |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
562 |
__doc__, |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
563 |
), |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
564 |
} |