##// END OF EJS Templates
histedit: new extension for interactive history editing
Augie Fackler -
r17064:168cc52a default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (564 lines changed) Show them Hide them
@@ -0,0 +1,564 b''
1 # histedit.py - interactive history editing for mercurial
2 #
3 # Copyright 2009 Augie Fackler <raf@durin42.com>
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7 """Interactive history editing.
8
9 Inspired by git rebase --interactive.
10 """
11 from inspect import getargspec
12 try:
13 import cPickle as pickle
14 except ImportError:
15 import pickle
16 import tempfile
17 import os
18
19 from mercurial import bookmarks
20 from mercurial import cmdutil
21 from mercurial import discovery
22 from mercurial import error
23 from mercurial import hg
24 from mercurial import node
25 from mercurial import patch
26 from mercurial import repair
27 from mercurial import scmutil
28 from mercurial import url
29 from mercurial import util
30 from mercurial.i18n import _
31
32
33 editcomment = """
34
35 # Edit history between %s and %s
36 #
37 # Commands:
38 # p, pick = use commit
39 # e, edit = use commit, but stop for amending
40 # f, fold = use commit, but fold into previous commit (combines N and N-1)
41 # d, drop = remove commit from history
42 # m, mess = edit message without changing commit content
43 #
44 """
45
46 def between(repo, old, new, keep):
47 revs = [old, ]
48 current = old
49 while current != new:
50 ctx = repo[current]
51 if not keep and len(ctx.children()) > 1:
52 raise util.Abort(_('cannot edit history that would orphan nodes'))
53 if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid:
54 raise util.Abort(_("can't edit history with merges"))
55 if not ctx.children():
56 current = new
57 else:
58 current = ctx.children()[0].node()
59 revs.append(current)
60 if len(repo[current].children()) and not keep:
61 raise util.Abort(_('cannot edit history that would orphan nodes'))
62 return revs
63
64
65 def pick(ui, repo, ctx, ha, opts):
66 oldctx = repo[ha]
67 if oldctx.parents()[0] == ctx:
68 ui.debug('node %s unchanged\n' % ha)
69 return oldctx, [], [], []
70 hg.update(repo, ctx.node())
71 fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
72 fp = os.fdopen(fd, 'w')
73 diffopts = patch.diffopts(ui, opts)
74 diffopts.git = True
75 diffopts.ignorews = False
76 diffopts.ignorewsamount = False
77 diffopts.ignoreblanklines = False
78 gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
79 for chunk in gen:
80 fp.write(chunk)
81 fp.close()
82 try:
83 files = set()
84 try:
85 patch.patch(ui, repo, patchfile, files=files, eolmode=None)
86 if not files:
87 ui.warn(_('%s: empty changeset')
88 % node.hex(ha))
89 return ctx, [], [], []
90 finally:
91 os.unlink(patchfile)
92 except Exception, inst:
93 raise util.Abort(_('Fix up the change and run '
94 'hg histedit --continue'))
95 n = repo.commit(text=oldctx.description(), user=oldctx.user(), date=oldctx.date(),
96 extra=oldctx.extra())
97 return repo[n], [n, ], [oldctx.node(), ], []
98
99
100 def edit(ui, repo, ctx, ha, opts):
101 oldctx = repo[ha]
102 hg.update(repo, ctx.node())
103 fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
104 fp = os.fdopen(fd, 'w')
105 diffopts = patch.diffopts(ui, opts)
106 diffopts.git = True
107 diffopts.ignorews = False
108 diffopts.ignorewsamount = False
109 diffopts.ignoreblanklines = False
110 gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
111 for chunk in gen:
112 fp.write(chunk)
113 fp.close()
114 try:
115 files = set()
116 try:
117 patch.patch(ui, repo, patchfile, files=files, eolmode=None)
118 finally:
119 os.unlink(patchfile)
120 except Exception, inst:
121 pass
122 raise util.Abort(_('Make changes as needed, you may commit or record as '
123 'needed now.\nWhen you are finished, run hg'
124 ' histedit --continue to resume.'))
125
126 def fold(ui, repo, ctx, ha, opts):
127 oldctx = repo[ha]
128 hg.update(repo, ctx.node())
129 fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
130 fp = os.fdopen(fd, 'w')
131 diffopts = patch.diffopts(ui, opts)
132 diffopts.git = True
133 diffopts.ignorews = False
134 diffopts.ignorewsamount = False
135 diffopts.ignoreblanklines = False
136 gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
137 for chunk in gen:
138 fp.write(chunk)
139 fp.close()
140 try:
141 files = set()
142 try:
143 patch.patch(ui, repo, patchfile, files=files, eolmode=None)
144 if not files:
145 ui.warn(_('%s: empty changeset')
146 % node.hex(ha))
147 return ctx, [], [], []
148 finally:
149 os.unlink(patchfile)
150 except Exception, inst:
151 raise util.Abort(_('Fix up the change and run '
152 'hg histedit --continue'))
153 n = repo.commit(text='fold-temp-revision %s' % ha, user=oldctx.user(), date=oldctx.date(),
154 extra=oldctx.extra())
155 return finishfold(ui, repo, ctx, oldctx, n, opts, [])
156
157 def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
158 parent = ctx.parents()[0].node()
159 hg.update(repo, parent)
160 fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
161 fp = os.fdopen(fd, 'w')
162 diffopts = patch.diffopts(ui, opts)
163 diffopts.git = True
164 diffopts.ignorews = False
165 diffopts.ignorewsamount = False
166 diffopts.ignoreblanklines = False
167 gen = patch.diff(repo, parent, newnode, opts=diffopts)
168 for chunk in gen:
169 fp.write(chunk)
170 fp.close()
171 files = set()
172 try:
173 patch.patch(ui, repo, patchfile, files=files, eolmode=None)
174 finally:
175 os.unlink(patchfile)
176 newmessage = '\n***\n'.join(
177 [ctx.description(), ] +
178 [repo[r].description() for r in internalchanges] +
179 [oldctx.description(), ])
180 # If the changesets are from the same author, keep it.
181 if ctx.user() == oldctx.user():
182 username = ctx.user()
183 else:
184 username = ui.username()
185 newmessage = ui.edit(newmessage, username)
186 n = repo.commit(text=newmessage, user=username, date=max(ctx.date(), oldctx.date()),
187 extra=oldctx.extra())
188 return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ]
189
190 def drop(ui, repo, ctx, ha, opts):
191 return ctx, [], [repo[ha].node(), ], []
192
193
194 def message(ui, repo, ctx, ha, opts):
195 oldctx = repo[ha]
196 hg.update(repo, ctx.node())
197 fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
198 fp = os.fdopen(fd, 'w')
199 diffopts = patch.diffopts(ui, opts)
200 diffopts.git = True
201 diffopts.ignorews = False
202 diffopts.ignorewsamount = False
203 diffopts.ignoreblanklines = False
204 gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
205 for chunk in gen:
206 fp.write(chunk)
207 fp.close()
208 try:
209 files = set()
210 try:
211 patch.patch(ui, repo, patchfile, files=files, eolmode=None)
212 finally:
213 os.unlink(patchfile)
214 except Exception, inst:
215 raise util.Abort(_('Fix up the change and run '
216 'hg histedit --continue'))
217 message = oldctx.description()
218 message = ui.edit(message, ui.username())
219 new = repo.commit(text=message, user=oldctx.user(), date=oldctx.date(),
220 extra=oldctx.extra())
221 newctx = repo[new]
222 if oldctx.node() != newctx.node():
223 return newctx, [new], [oldctx.node()], []
224 # We didn't make an edit, so just indicate no replaced nodes
225 return newctx, [new], [], []
226
227
228 def makedesc(c):
229 summary = ''
230 if c.description():
231 summary = c.description().splitlines()[0]
232 line = 'pick %s %d %s' % (c.hex()[:12], c.rev(), summary)
233 return line[:80] # trim to 80 chars so it's not stupidly wide in my editor
234
235 actiontable = {'p': pick,
236 'pick': pick,
237 'e': edit,
238 'edit': edit,
239 'f': fold,
240 'fold': fold,
241 'd': drop,
242 'drop': drop,
243 'm': message,
244 'mess': message,
245 }
246 def histedit(ui, repo, *parent, **opts):
247 """hg histedit <parent>
248 """
249 # TODO only abort if we try and histedit mq patches, not just
250 # blanket if mq patches are applied somewhere
251 mq = getattr(repo, 'mq', None)
252 if mq and mq.applied:
253 raise util.Abort(_('source has mq patches applied'))
254
255 parent = list(parent) + opts.get('rev', [])
256 if opts.get('outgoing'):
257 if len(parent) > 1:
258 raise util.Abort(_('only one repo argument allowed with --outgoing'))
259 elif parent:
260 parent = parent[0]
261
262 dest = ui.expandpath(parent or 'default-push', parent or 'default')
263 dest, revs = hg.parseurl(dest, None)[:2]
264 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
265
266 revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
267 other = hg.repository(hg.remoteui(repo, opts), dest)
268
269 if revs:
270 revs = [repo.lookup(rev) for rev in revs]
271
272 parent = discovery.findcommonoutgoing(
273 repo, other, [], force=opts.get('force')).missing[0:1]
274 else:
275 if opts.get('force'):
276 raise util.Abort(_('--force only allowed with --outgoing'))
277
278 if opts.get('continue', False):
279 if len(parent) != 0:
280 raise util.Abort(_('no arguments allowed with --continue'))
281 (parentctxnode, created, replaced,
282 tmpnodes, existing, rules, keep, tip, replacemap ) = readstate(repo)
283 currentparent, wantnull = repo.dirstate.parents()
284 parentctx = repo[parentctxnode]
285 # discover any nodes the user has added in the interim
286 newchildren = [c for c in parentctx.children()
287 if c.node() not in existing]
288 action, currentnode = rules.pop(0)
289 while newchildren:
290 if action in ['f', 'fold', ]:
291 tmpnodes.extend([n.node() for n in newchildren])
292 else:
293 created.extend([n.node() for n in newchildren])
294 newchildren = filter(lambda x: x.node() not in existing,
295 reduce(lambda x, y: x + y,
296 map(lambda r: r.children(),
297 newchildren)))
298 m, a, r, d = repo.status()[:4]
299 oldctx = repo[currentnode]
300 message = oldctx.description()
301 if action in ('e', 'edit', 'm', 'mess'):
302 message = ui.edit(message, ui.username())
303 elif action in ('f', 'fold', ):
304 message = 'fold-temp-revision %s' % currentnode
305 new = None
306 if m or a or r or d:
307 new = repo.commit(text=message, user=oldctx.user(), date=oldctx.date(),
308 extra=oldctx.extra())
309
310 if action in ('f', 'fold'):
311 if new:
312 tmpnodes.append(new)
313 else:
314 new = newchildren[-1]
315 (parentctx, created_,
316 replaced_, tmpnodes_, ) = finishfold(ui, repo,
317 parentctx, oldctx, new,
318 opts, newchildren)
319 replaced.extend(replaced_)
320 created.extend(created_)
321 tmpnodes.extend(tmpnodes_)
322 elif action not in ('d', 'drop'):
323 if new != oldctx.node():
324 replaced.append(oldctx.node())
325 if new:
326 if new != oldctx.node():
327 created.append(new)
328 parentctx = repo[new]
329
330 elif opts.get('abort', False):
331 if len(parent) != 0:
332 raise util.Abort(_('no arguments allowed with --abort'))
333 (parentctxnode, created, replaced, tmpnodes,
334 existing, rules, keep, tip, replacemap) = readstate(repo)
335 ui.debug('restore wc to old tip %s\n' % node.hex(tip))
336 hg.clean(repo, tip)
337 ui.debug('should strip created nodes %s\n' %
338 ', '.join([node.hex(n)[:12] for n in created]))
339 ui.debug('should strip temp nodes %s\n' %
340 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
341 for nodes in (created, tmpnodes, ):
342 for n in reversed(nodes):
343 try:
344 repair.strip(ui, repo, n)
345 except error.LookupError:
346 pass
347 os.unlink(os.path.join(repo.path, 'histedit-state'))
348 return
349 else:
350 cmdutil.bailifchanged(repo)
351 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
352 raise util.Abort(_('history edit already in progress, try '
353 '--continue or --abort'))
354
355 tip, empty = repo.dirstate.parents()
356
357
358 if len(parent) != 1:
359 raise util.Abort(_('histedit requires exactly one parent revision'))
360 parent = scmutil.revsingle(repo, parent[0]).node()
361
362 keep = opts.get('keep', False)
363 revs = between(repo, parent, tip, keep)
364
365 ctxs = [repo[r] for r in revs]
366 existing = [r.node() for r in ctxs]
367 rules = opts.get('commands', '')
368 if not rules:
369 rules = '\n'.join([makedesc(c) for c in ctxs])
370 rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12], )
371 rules = ui.edit(rules, ui.username())
372 # Save edit rules in .hg/histedit-last-edit.txt in case
373 # the user needs to ask for help after something
374 # surprising happens.
375 f = open(repo.join('histedit-last-edit.txt'), 'w')
376 f.write(rules)
377 f.close()
378 else:
379 f = open(rules)
380 rules = f.read()
381 f.close()
382 rules = [l for l in (r.strip() for r in rules.splitlines())
383 if l and not l[0] == '#']
384 rules = verifyrules(rules, repo, ctxs)
385
386 parentctx = repo[parent].parents()[0]
387 keep = opts.get('keep', False)
388 replaced = []
389 replacemap = {}
390 tmpnodes = []
391 created = []
392
393
394 while rules:
395 writestate(repo, parentctx.node(), created, replaced, tmpnodes, existing,
396 rules, keep, tip, replacemap)
397 action, ha = rules.pop(0)
398 (parentctx, created_,
399 replaced_, tmpnodes_, ) = actiontable[action](ui, repo,
400 parentctx, ha,
401 opts)
402
403 hexshort = lambda x: node.hex(x)[:12]
404
405 if replaced_:
406 clen, rlen = len(created_), len(replaced_)
407 if clen == rlen == 1:
408 ui.debug('histedit: exact replacement of %s with %s\n' % (
409 hexshort(replaced_[0]), hexshort(created_[0])))
410
411 replacemap[replaced_[0]] = created_[0]
412 elif clen > rlen:
413 assert rlen == 1, ('unexpected replacement of '
414 '%d changes with %d changes' % (rlen, clen))
415 # made more changesets than we're replacing
416 # TODO synthesize patch names for created patches
417 replacemap[replaced_[0]] = created_[-1]
418 ui.debug('histedit: created many, assuming %s replaced by %s' % (
419 hexshort(replaced_[0]), hexshort(created_[-1])))
420 elif rlen > clen:
421 if not created_:
422 # This must be a drop. Try and put our metadata on
423 # the parent change.
424 assert rlen == 1
425 r = replaced_[0]
426 ui.debug('histedit: %s seems replaced with nothing, '
427 'finding a parent\n' % (hexshort(r)))
428 pctx = repo[r].parents()[0]
429 if pctx.node() in replacemap:
430 ui.debug('histedit: parent is already replaced\n')
431 replacemap[r] = replacemap[pctx.node()]
432 else:
433 replacemap[r] = pctx.node()
434 ui.debug('histedit: %s best replaced by %s\n' % (
435 hexshort(r), hexshort(replacemap[r])))
436 else:
437 assert len(created_) == 1
438 for r in replaced_:
439 ui.debug('histedit: %s replaced by %s\n' % (
440 hexshort(r), hexshort(created_[0])))
441 replacemap[r] = created_[0]
442 else:
443 assert False, (
444 'Unhandled case in replacement mapping! '
445 'replacing %d changes with %d changes' % (rlen, clen))
446 created.extend(created_)
447 replaced.extend(replaced_)
448 tmpnodes.extend(tmpnodes_)
449
450 hg.update(repo, parentctx.node())
451
452 if not keep:
453 if replacemap:
454 ui.note('histedit: Should update metadata for the following '
455 'changes:\n')
456
457 def copybms(old, new):
458 if old in tmpnodes or old in created:
459 # can't have any metadata we'd want to update
460 return
461 while new in replacemap:
462 new = replacemap[new]
463 ui.note('histedit: %s to %s\n' % (hexshort(old), hexshort(new)))
464 octx = repo[old]
465 marks = octx.bookmarks()
466 if marks:
467 ui.note('histedit: moving bookmarks %s\n' %
468 ', '.join(marks))
469 for mark in marks:
470 repo._bookmarks[mark] = new
471 bookmarks.write(repo)
472
473 # We assume that bookmarks on the tip should remain
474 # tipmost, but bookmarks on non-tip changesets should go
475 # to their most reasonable successor. As a result, find
476 # the old tip and new tip and copy those bookmarks first,
477 # then do the rest of the bookmark copies.
478 oldtip = sorted(replacemap.keys(), key=repo.changelog.rev)[-1]
479 newtip = sorted(replacemap.values(), key=repo.changelog.rev)[-1]
480 copybms(oldtip, newtip)
481
482 for old, new in replacemap.iteritems():
483 copybms(old, new)
484 # TODO update mq state
485
486 ui.debug('should strip replaced nodes %s\n' %
487 ', '.join([node.hex(n)[:12] for n in replaced]))
488 for n in sorted(replaced, key=lambda x: repo[x].rev()):
489 try:
490 repair.strip(ui, repo, n)
491 except error.LookupError:
492 pass
493
494 ui.debug('should strip temp nodes %s\n' %
495 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
496 for n in reversed(tmpnodes):
497 try:
498 repair.strip(ui, repo, n)
499 except error.LookupError:
500 pass
501 os.unlink(os.path.join(repo.path, 'histedit-state'))
502 if os.path.exists(repo.sjoin('undo')):
503 os.unlink(repo.sjoin('undo'))
504
505
506 def writestate(repo, parentctxnode, created, replaced,
507 tmpnodes, existing, rules, keep, oldtip, replacemap):
508 fp = open(os.path.join(repo.path, 'histedit-state'), 'w')
509 pickle.dump((parentctxnode, created, replaced,
510 tmpnodes, existing, rules, keep, oldtip, replacemap),
511 fp)
512 fp.close()
513
514 def readstate(repo):
515 """Returns a tuple of (parentnode, created, replaced, tmp, existing, rules,
516 keep, oldtip, replacemap ).
517 """
518 fp = open(os.path.join(repo.path, 'histedit-state'))
519 return pickle.load(fp)
520
521
522 def verifyrules(rules, repo, ctxs):
523 """Verify that there exists exactly one edit rule per given changeset.
524
525 Will abort if there are to many or too few rules, a malformed rule,
526 or a rule on a changeset outside of the user-given range.
527 """
528 parsed = []
529 first = True
530 if len(rules) != len(ctxs):
531 raise util.Abort(_('must specify a rule for each changeset once'))
532 for r in rules:
533 if ' ' not in r:
534 raise util.Abort(_('malformed line "%s"') % r)
535 action, rest = r.split(' ', 1)
536 if ' ' in rest.strip():
537 ha, rest = rest.split(' ', 1)
538 else:
539 ha = r.strip()
540 try:
541 if repo[ha] not in ctxs:
542 raise util.Abort(_('may not use changesets other than the ones listed'))
543 except error.RepoError:
544 raise util.Abort(_('unknown changeset %s listed') % ha)
545 if action not in actiontable:
546 raise util.Abort(_('unknown action "%s"') % action)
547 parsed.append([action, ha])
548 return parsed
549
550
551 cmdtable = {
552 "histedit":
553 (histedit,
554 [('', 'commands', '', _('Read history edits from the specified file.')),
555 ('c', 'continue', False, _('continue an edit already in progress')),
556 ('k', 'keep', False, _("don't strip old nodes after edit is complete")),
557 ('', 'abort', False, _('abort an edit in progress')),
558 ('o', 'outgoing', False, _('changesets not found in destination')),
559 ('f', 'force', False, _('force outgoing even for unrelated repositories')),
560 ('r', 'rev', [], _('first revision to be edited')),
561 ],
562 __doc__,
563 ),
564 }
@@ -0,0 +1,8 b''
1 #!/bin/sh
2
3 fixbundle() {
4 grep -v 'saving bundle' | grep -v 'saved backup' | \
5 grep -v added | grep -v adding | \
6 grep -v "unable to find 'e' for patching" | \
7 grep -v "e: No such file or directory"
8 }
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,190 b''
1 $ . "$TESTDIR/histedit-helpers.sh"
2
3 $ cat >> $HGRCPATH <<EOF
4 > [extensions]
5 > graphlog=
6 > histedit=
7 > EOF
8
9 $ hg init r
10 $ cd r
11 See if bookmarks are in core. If not, then we don't support bookmark
12 motion on this version of hg.
13 $ hg bookmarks || exit 80
14 no bookmarks set
15 $ for x in a b c d e f ; do
16 > echo $x > $x
17 > hg add $x
18 > hg ci -m $x
19 > done
20
21 $ hg book -r 1 will-move-backwards
22 $ hg book -r 2 two
23 $ hg book -r 2 also-two
24 $ hg book -r 3 three
25 $ hg book -r 4 four
26 $ hg book -r tip five
27 $ hg log --graph
28 @ changeset: 5:652413bf663e
29 | bookmark: five
30 | tag: tip
31 | user: test
32 | date: Thu Jan 01 00:00:00 1970 +0000
33 | summary: f
34 |
35 o changeset: 4:e860deea161a
36 | bookmark: four
37 | user: test
38 | date: Thu Jan 01 00:00:00 1970 +0000
39 | summary: e
40 |
41 o changeset: 3:055a42cdd887
42 | bookmark: three
43 | user: test
44 | date: Thu Jan 01 00:00:00 1970 +0000
45 | summary: d
46 |
47 o changeset: 2:177f92b77385
48 | bookmark: also-two
49 | bookmark: two
50 | user: test
51 | date: Thu Jan 01 00:00:00 1970 +0000
52 | summary: c
53 |
54 o changeset: 1:d2ae7f538514
55 | bookmark: will-move-backwards
56 | user: test
57 | date: Thu Jan 01 00:00:00 1970 +0000
58 | summary: b
59 |
60 o changeset: 0:cb9a9f314b8b
61 user: test
62 date: Thu Jan 01 00:00:00 1970 +0000
63 summary: a
64
65 $ HGEDITOR=cat hg histedit 1
66 pick d2ae7f538514 1 b
67 pick 177f92b77385 2 c
68 pick 055a42cdd887 3 d
69 pick e860deea161a 4 e
70 pick 652413bf663e 5 f
71
72 # Edit history between d2ae7f538514 and 652413bf663e
73 #
74 # Commands:
75 # p, pick = use commit
76 # e, edit = use commit, but stop for amending
77 # f, fold = use commit, but fold into previous commit (combines N and N-1)
78 # d, drop = remove commit from history
79 # m, mess = edit message without changing commit content
80 #
81 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 $ cat >> commands.txt <<EOF
83 > pick 177f92b77385 2 c
84 > drop d2ae7f538514 1 b
85 > pick 055a42cdd887 3 d
86 > fold e860deea161a 4 e
87 > pick 652413bf663e 5 f
88 > EOF
89 $ hg histedit 1 --commands commands.txt --verbose | grep histedit
90 histedit: Should update metadata for the following changes:
91 histedit: 055a42cdd887 to ae467701c500
92 histedit: moving bookmarks three
93 histedit: 652413bf663e to 0efacef7cb48
94 histedit: moving bookmarks five
95 histedit: d2ae7f538514 to cb9a9f314b8b
96 histedit: moving bookmarks will-move-backwards
97 histedit: e860deea161a to ae467701c500
98 histedit: moving bookmarks four
99 histedit: 177f92b77385 to d36c0562f908
100 histedit: moving bookmarks also-two, two
101 saved backup bundle to $TESTTMP/r/.hg/strip-backup/d2ae7f538514-backup.hg
102 saved backup bundle to $TESTTMP/r/.hg/strip-backup/34a9919932c1-backup.hg
103 $ hg log --graph
104 @ changeset: 3:0efacef7cb48
105 | bookmark: five
106 | tag: tip
107 | user: test
108 | date: Thu Jan 01 00:00:00 1970 +0000
109 | summary: f
110 |
111 o changeset: 2:ae467701c500
112 | bookmark: four
113 | bookmark: three
114 | user: test
115 | date: Thu Jan 01 00:00:00 1970 +0000
116 | summary: d
117 |
118 o changeset: 1:d36c0562f908
119 | bookmark: also-two
120 | bookmark: two
121 | user: test
122 | date: Thu Jan 01 00:00:00 1970 +0000
123 | summary: c
124 |
125 o changeset: 0:cb9a9f314b8b
126 bookmark: will-move-backwards
127 user: test
128 date: Thu Jan 01 00:00:00 1970 +0000
129 summary: a
130
131 $ HGEDITOR=cat hg histedit 1
132 pick d36c0562f908 1 c
133 pick ae467701c500 2 d
134 pick 0efacef7cb48 3 f
135
136 # Edit history between d36c0562f908 and 0efacef7cb48
137 #
138 # Commands:
139 # p, pick = use commit
140 # e, edit = use commit, but stop for amending
141 # f, fold = use commit, but fold into previous commit (combines N and N-1)
142 # d, drop = remove commit from history
143 # m, mess = edit message without changing commit content
144 #
145 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
146 $ cat > commands.txt << EOF
147 > pick d36c0562f908 1 c
148 > pick 0efacef7cb48 3 f
149 > pick ae467701c500 2 d
150 > EOF
151 $ hg histedit 1 --commands commands.txt --verbose | grep histedit
152 histedit: Should update metadata for the following changes:
153 histedit: 0efacef7cb48 to 1be9c35b4cb2
154 histedit: moving bookmarks five
155 histedit: ae467701c500 to 1be9c35b4cb2
156 histedit: moving bookmarks four, three
157 histedit: 0efacef7cb48 to 7c044e3e33a9
158 saved backup bundle to $TESTTMP/r/.hg/strip-backup/ae467701c500-backup.hg
159
160 We expect 'five' to stay at tip, since the tipmost bookmark is most
161 likely the useful signal.
162
163 $ hg log --graph
164 @ changeset: 3:1be9c35b4cb2
165 | bookmark: five
166 | bookmark: four
167 | bookmark: three
168 | tag: tip
169 | user: test
170 | date: Thu Jan 01 00:00:00 1970 +0000
171 | summary: d
172 |
173 o changeset: 2:7c044e3e33a9
174 | user: test
175 | date: Thu Jan 01 00:00:00 1970 +0000
176 | summary: f
177 |
178 o changeset: 1:d36c0562f908
179 | bookmark: also-two
180 | bookmark: two
181 | user: test
182 | date: Thu Jan 01 00:00:00 1970 +0000
183 | summary: c
184 |
185 o changeset: 0:cb9a9f314b8b
186 bookmark: will-move-backwards
187 user: test
188 date: Thu Jan 01 00:00:00 1970 +0000
189 summary: a
190
@@ -0,0 +1,97 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick 177f92b77385 c
14 pick e860deea161a e
15 pick 652413bf663e f
16 pick 055a42cdd887 d
17 EOF
18 initrepo ()
19 {
20 hg init r
21 cd r
22 for x in a b c d e f ; do
23 echo $x > $x
24 hg add $x
25 hg ci -m $x
26 done
27 }
28
29 initrepo
30
31 echo % log before edit
32 hg log --graph
33
34 echo % show the edit commands offered
35 HGEDITOR=cat hg histedit 177f92b77385
36
37 echo % edit the history
38 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
39
40 echo % rules should end up in .hg/histedit-last-edit.txt:
41 cat .hg/histedit-last-edit.txt
42 echo '**** end of rules file ****'
43
44 echo % log after edit
45 hg log --graph
46
47 echo % put things back
48
49 cat > $EDITED <<EOF
50 pick 177f92b77385 c
51 pick 853c68da763f d
52 pick b069cc29fb22 e
53 pick 26f6a030ae82 f
54 EOF
55 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
56
57 hg log --graph
58
59
60 echo % slightly different this time
61
62 cat > $EDITED <<EOF
63 pick 055a42cdd887 d
64 pick 652413bf663e f
65 pick e860deea161a e
66 pick 177f92b77385 c
67 EOF
68 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
69 hg log --graph
70
71
72 echo % keep prevents stripping dead revs
73 cat > $EDITED <<EOF
74 pick bfe4a5a76b37 d
75 pick c4f52e213402 f
76 pick 99a62755c625 c
77 pick 7c6fdd608667 e
78 EOF
79 HGEDITOR="cat $EDITED > " hg histedit bfe4a5a76b37 --keep 2>&1 | fixbundle
80 hg log --graph
81
82 echo '% try with --rev'
83 cat > $EDITED <<EOF
84 pick 7c6fdd608667 e
85 pick 99a62755c625 c
86 EOF
87 hg histedit --commands "$EDITED" --rev -2 2>&1 | fixbundle
88 hg log --graph
89
90 echo % should also work if a commit message is missing
91 BUNDLE="$TESTDIR/missing-comment.hg"
92 hg init missing
93 cd missing
94 hg unbundle $BUNDLE
95 hg co tip
96 hg log --graph
97 hg histedit 0
@@ -0,0 +1,277 b''
1 % log before edit
2 @ changeset: 5:652413bf663e
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: f
7 |
8 o changeset: 4:e860deea161a
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: e
12 |
13 o changeset: 3:055a42cdd887
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: d
17 |
18 o changeset: 2:177f92b77385
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: c
22 |
23 o changeset: 1:d2ae7f538514
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: b
27 |
28 o changeset: 0:cb9a9f314b8b
29 user: test
30 date: Thu Jan 01 00:00:00 1970 +0000
31 summary: a
32
33 % show the edit commands offered
34 pick 177f92b77385 2 c
35 pick 055a42cdd887 3 d
36 pick e860deea161a 4 e
37 pick 652413bf663e 5 f
38
39 # Edit history between 177f92b77385 and 652413bf663e
40 #
41 # Commands:
42 # p, pick = use commit
43 # e, edit = use commit, but stop for amending
44 # f, fold = use commit, but fold into previous commit (combines N and N-1)
45 # d, drop = remove commit from history
46 # m, mess = edit message without changing commit content
47 #
48 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 % edit the history
50 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
51 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
53 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
54 % rules should end up in .hg/histedit-last-edit.txt:
55 pick 177f92b77385 c
56 pick e860deea161a e
57 pick 652413bf663e f
58 pick 055a42cdd887 d
59 **** end of rules file ****
60 % log after edit
61 @ changeset: 5:853c68da763f
62 | tag: tip
63 | user: test
64 | date: Thu Jan 01 00:00:00 1970 +0000
65 | summary: d
66 |
67 o changeset: 4:26f6a030ae82
68 | user: test
69 | date: Thu Jan 01 00:00:00 1970 +0000
70 | summary: f
71 |
72 o changeset: 3:b069cc29fb22
73 | user: test
74 | date: Thu Jan 01 00:00:00 1970 +0000
75 | summary: e
76 |
77 o changeset: 2:177f92b77385
78 | user: test
79 | date: Thu Jan 01 00:00:00 1970 +0000
80 | summary: c
81 |
82 o changeset: 1:d2ae7f538514
83 | user: test
84 | date: Thu Jan 01 00:00:00 1970 +0000
85 | summary: b
86 |
87 o changeset: 0:cb9a9f314b8b
88 user: test
89 date: Thu Jan 01 00:00:00 1970 +0000
90 summary: a
91
92 % put things back
93 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
94 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
95 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
96 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 @ changeset: 5:652413bf663e
98 | tag: tip
99 | user: test
100 | date: Thu Jan 01 00:00:00 1970 +0000
101 | summary: f
102 |
103 o changeset: 4:e860deea161a
104 | user: test
105 | date: Thu Jan 01 00:00:00 1970 +0000
106 | summary: e
107 |
108 o changeset: 3:055a42cdd887
109 | user: test
110 | date: Thu Jan 01 00:00:00 1970 +0000
111 | summary: d
112 |
113 o changeset: 2:177f92b77385
114 | user: test
115 | date: Thu Jan 01 00:00:00 1970 +0000
116 | summary: c
117 |
118 o changeset: 1:d2ae7f538514
119 | user: test
120 | date: Thu Jan 01 00:00:00 1970 +0000
121 | summary: b
122 |
123 o changeset: 0:cb9a9f314b8b
124 user: test
125 date: Thu Jan 01 00:00:00 1970 +0000
126 summary: a
127
128 % slightly different this time
129 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
130 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
131 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
133 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
134 @ changeset: 5:99a62755c625
135 | tag: tip
136 | user: test
137 | date: Thu Jan 01 00:00:00 1970 +0000
138 | summary: c
139 |
140 o changeset: 4:7c6fdd608667
141 | user: test
142 | date: Thu Jan 01 00:00:00 1970 +0000
143 | summary: e
144 |
145 o changeset: 3:c4f52e213402
146 | user: test
147 | date: Thu Jan 01 00:00:00 1970 +0000
148 | summary: f
149 |
150 o changeset: 2:bfe4a5a76b37
151 | user: test
152 | date: Thu Jan 01 00:00:00 1970 +0000
153 | summary: d
154 |
155 o changeset: 1:d2ae7f538514
156 | user: test
157 | date: Thu Jan 01 00:00:00 1970 +0000
158 | summary: b
159 |
160 o changeset: 0:cb9a9f314b8b
161 user: test
162 date: Thu Jan 01 00:00:00 1970 +0000
163 summary: a
164
165 % keep prevents stripping dead revs
166 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
167 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
168 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 @ changeset: 7:99e266581538
170 | tag: tip
171 | user: test
172 | date: Thu Jan 01 00:00:00 1970 +0000
173 | summary: e
174 |
175 o changeset: 6:5ad36efb0653
176 | parent: 3:c4f52e213402
177 | user: test
178 | date: Thu Jan 01 00:00:00 1970 +0000
179 | summary: c
180 |
181 | o changeset: 5:99a62755c625
182 | | user: test
183 | | date: Thu Jan 01 00:00:00 1970 +0000
184 | | summary: c
185 | |
186 | o changeset: 4:7c6fdd608667
187 |/ user: test
188 | date: Thu Jan 01 00:00:00 1970 +0000
189 | summary: e
190 |
191 o changeset: 3:c4f52e213402
192 | user: test
193 | date: Thu Jan 01 00:00:00 1970 +0000
194 | summary: f
195 |
196 o changeset: 2:bfe4a5a76b37
197 | user: test
198 | date: Thu Jan 01 00:00:00 1970 +0000
199 | summary: d
200 |
201 o changeset: 1:d2ae7f538514
202 | user: test
203 | date: Thu Jan 01 00:00:00 1970 +0000
204 | summary: b
205 |
206 o changeset: 0:cb9a9f314b8b
207 user: test
208 date: Thu Jan 01 00:00:00 1970 +0000
209 summary: a
210
211 % try with --rev
212 abort: may not use changesets other than the ones listed
213 @ changeset: 7:99e266581538
214 | tag: tip
215 | user: test
216 | date: Thu Jan 01 00:00:00 1970 +0000
217 | summary: e
218 |
219 o changeset: 6:5ad36efb0653
220 | parent: 3:c4f52e213402
221 | user: test
222 | date: Thu Jan 01 00:00:00 1970 +0000
223 | summary: c
224 |
225 | o changeset: 5:99a62755c625
226 | | user: test
227 | | date: Thu Jan 01 00:00:00 1970 +0000
228 | | summary: c
229 | |
230 | o changeset: 4:7c6fdd608667
231 |/ user: test
232 | date: Thu Jan 01 00:00:00 1970 +0000
233 | summary: e
234 |
235 o changeset: 3:c4f52e213402
236 | user: test
237 | date: Thu Jan 01 00:00:00 1970 +0000
238 | summary: f
239 |
240 o changeset: 2:bfe4a5a76b37
241 | user: test
242 | date: Thu Jan 01 00:00:00 1970 +0000
243 | summary: d
244 |
245 o changeset: 1:d2ae7f538514
246 | user: test
247 | date: Thu Jan 01 00:00:00 1970 +0000
248 | summary: b
249 |
250 o changeset: 0:cb9a9f314b8b
251 user: test
252 date: Thu Jan 01 00:00:00 1970 +0000
253 summary: a
254
255 % should also work if a commit message is missing
256 adding changesets
257 adding manifests
258 adding file changes
259 added 3 changesets with 3 changes to 1 files
260 (run 'hg update' to get a working copy)
261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
262 @ changeset: 2:bd22688093b3
263 | tag: tip
264 | user: Robert Altman <robert.altman@telventDTN.com>
265 | date: Mon Nov 28 16:40:04 2011 +0000
266 | summary: Update file.
267 |
268 o changeset: 1:3b3e956f9171
269 | user: Robert Altman <robert.altman@telventDTN.com>
270 | date: Mon Nov 28 16:37:57 2011 +0000
271 |
272 o changeset: 0:141947992243
273 user: Robert Altman <robert.altman@telventDTN.com>
274 date: Mon Nov 28 16:35:28 2011 +0000
275 summary: Checked in text file
276
277 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -0,0 +1,43 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 drop 177f92b77385 c
14 pick e860deea161a e
15 pick 652413bf663e f
16 pick 055a42cdd887 d
17 EOF
18 initrepo ()
19 {
20 hg init r
21 cd r
22 for x in a b c d e f ; do
23 echo $x > $x
24 hg add $x
25 hg ci -m $x
26 done
27 }
28
29 initrepo
30
31 echo % log before edit
32 hg log --graph
33
34 echo % edit the history
35 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
36
37 echo % log after edit
38 hg log --graph
39
40 echo % manifest after edit
41 hg manifest
42
43 echo % EOF
@@ -0,0 +1,71 b''
1 % log before edit
2 @ changeset: 5:652413bf663e
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: f
7 |
8 o changeset: 4:e860deea161a
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: e
12 |
13 o changeset: 3:055a42cdd887
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: d
17 |
18 o changeset: 2:177f92b77385
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: c
22 |
23 o changeset: 1:d2ae7f538514
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: b
27 |
28 o changeset: 0:cb9a9f314b8b
29 user: test
30 date: Thu Jan 01 00:00:00 1970 +0000
31 summary: a
32
33 % edit the history
34 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
35 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 % log after edit
39 @ changeset: 4:708943196e52
40 | tag: tip
41 | user: test
42 | date: Thu Jan 01 00:00:00 1970 +0000
43 | summary: d
44 |
45 o changeset: 3:75cbdffecadb
46 | user: test
47 | date: Thu Jan 01 00:00:00 1970 +0000
48 | summary: f
49 |
50 o changeset: 2:493dc0964412
51 | user: test
52 | date: Thu Jan 01 00:00:00 1970 +0000
53 | summary: e
54 |
55 o changeset: 1:d2ae7f538514
56 | user: test
57 | date: Thu Jan 01 00:00:00 1970 +0000
58 | summary: b
59 |
60 o changeset: 0:cb9a9f314b8b
61 user: test
62 date: Thu Jan 01 00:00:00 1970 +0000
63 summary: a
64
65 % manifest after edit
66 a
67 b
68 d
69 e
70 f
71 % EOF
@@ -0,0 +1,79 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick 177f92b77385 c
14 pick 055a42cdd887 d
15 edit e860deea161a e
16 pick 652413bf663e f
17 EOF
18 initrepo ()
19 {
20 hg init r
21 cd r
22 for x in a b c d e f ; do
23 echo $x > $x
24 hg add $x
25 hg ci -m $x
26 done
27 }
28
29 initrepo
30
31 echo % log before edit
32 hg log --graph
33
34 echo % edit the history
35 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
36
37 echo % edit the revision
38 echo a > e
39 HGEDITOR='echo "foobaz" > ' hg histedit --continue 2>&1 | fixbundle
40
41 hg log --graph
42
43 echo '% contents of e:'
44 hg cat e
45
46 cat > $EDITED <<EOF
47 edit c38516e9ed62 f
48 EOF
49 HGEDITOR="cat $EDITED > " hg histedit tip 2>&1 | fixbundle
50 hg status
51 HGEDITOR='true' hg histedit --continue
52 hg status
53
54 echo % log after edit
55 hg log --limit 1
56
57 echo "% say we'll change the message, but don't."
58 cat > ../edit.sh <<EOF
59 #!/bin/sh
60 cat \$1 | sed s/pick/mess/ > tmp
61 mv tmp \$1
62 EOF
63 chmod +x ../edit.sh
64 HGEDITOR="../edit.sh" hg histedit tip 2>&1 | fixbundle
65 hg status
66 hg log --limit 1
67
68 echo % modify the message
69 cat > $EDITED <<EOF
70 mess c38516e9ed62 f
71 EOF
72 HGEDITOR="cat $EDITED > " hg histedit tip 2>&1 | fixbundle
73 hg status
74 hg log --limit 1
75
76 echo % rollback should not work after a histedit
77 hg rollback
78
79 echo % EOF
@@ -0,0 +1,105 b''
1 % log before edit
2 @ changeset: 5:652413bf663e
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: f
7 |
8 o changeset: 4:e860deea161a
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: e
12 |
13 o changeset: 3:055a42cdd887
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: d
17 |
18 o changeset: 2:177f92b77385
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: c
22 |
23 o changeset: 1:d2ae7f538514
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: b
27 |
28 o changeset: 0:cb9a9f314b8b
29 user: test
30 date: Thu Jan 01 00:00:00 1970 +0000
31 summary: a
32
33 % edit the history
34 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
35 abort: Make changes as needed, you may commit or record as needed now.
36 When you are finished, run hg histedit --continue to resume.
37 % edit the revision
38 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 @ changeset: 5:c38516e9ed62
41 | tag: tip
42 | user: test
43 | date: Thu Jan 01 00:00:00 1970 +0000
44 | summary: f
45 |
46 o changeset: 4:1da62d13177d
47 | user: test
48 | date: Thu Jan 01 00:00:00 1970 +0000
49 | summary: foobaz
50 |
51 o changeset: 3:055a42cdd887
52 | user: test
53 | date: Thu Jan 01 00:00:00 1970 +0000
54 | summary: d
55 |
56 o changeset: 2:177f92b77385
57 | user: test
58 | date: Thu Jan 01 00:00:00 1970 +0000
59 | summary: c
60 |
61 o changeset: 1:d2ae7f538514
62 | user: test
63 | date: Thu Jan 01 00:00:00 1970 +0000
64 | summary: b
65 |
66 o changeset: 0:cb9a9f314b8b
67 user: test
68 date: Thu Jan 01 00:00:00 1970 +0000
69 summary: a
70
71 % contents of e:
72 a
73 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
74 abort: Make changes as needed, you may commit or record as needed now.
75 When you are finished, run hg histedit --continue to resume.
76 A f
77 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 % log after edit
79 changeset: 5:c38516e9ed62
80 tag: tip
81 user: test
82 date: Thu Jan 01 00:00:00 1970 +0000
83 summary: f
84
85 % say we'll change the message, but don't.
86 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
88 changeset: 5:c38516e9ed62
89 tag: tip
90 user: test
91 date: Thu Jan 01 00:00:00 1970 +0000
92 summary: f
93
94 % modify the message
95 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
96 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 changeset: 5:4d6a10bcf3e3
98 tag: tip
99 user: test
100 date: Thu Jan 01 00:00:00 1970 +0000
101 summary: mess c38516e9ed62 f
102
103 % rollback should not work after a histedit
104 no rollback information available
105 % EOF
@@ -0,0 +1,43 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick e860deea161a e
14 pick 652413bf663e f
15 fold 177f92b77385 c
16 pick 055a42cdd887 d
17 EOF
18 initrepo ()
19 {
20 hg init r
21 cd r
22 for x in a b c d e f ; do
23 echo $x > $x
24 hg add $x
25 hg ci -m $x
26 done
27 }
28
29 initrepo
30
31 echo % log before edit
32 hg log --graph
33
34 echo % edit the history
35 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
36
37 echo % log after edit
38 hg log --graph
39
40 echo % post-fold manifest
41 hg manifest
42
43 echo % EOF
@@ -0,0 +1,65 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick 177f92b77385 c
14 pick 055a42cdd887 d
15 fold bfa474341cc9 does not commute with e
16 pick e860deea161a e
17 pick 652413bf663e f
18 EOF
19 initrepo ()
20 {
21 hg init r
22 cd r
23 for x in a b c d e f ; do
24 echo $x > $x
25 hg add $x
26 hg ci -m $x
27 done
28 echo a >> e
29 hg ci -m 'does not commute with e'
30 }
31
32 initrepo
33
34 echo % log before edit
35 hg log --graph
36
37 echo % edit the history
38 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
39
40 echo % fix up
41 echo a > e
42 hg add e
43 cat > cat.py <<EOF
44 import sys
45 print open(sys.argv[1]).read()
46 print
47 print
48 EOF
49 HGEDITOR="python cat.py" hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
50
51 echo
52 echo % just continue this time
53 hg histedit --continue 2>&1 | fixbundle
54
55
56 echo % log after edit
57 hg log --graph
58
59 echo % contents of e
60 hg cat e
61
62 echo % manifest
63 hg manifest
64
65 echo % EOF
@@ -0,0 +1,92 b''
1 % log before edit
2 @ changeset: 6:bfa474341cc9
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: does not commute with e
7 |
8 o changeset: 5:652413bf663e
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: f
12 |
13 o changeset: 4:e860deea161a
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: e
17 |
18 o changeset: 3:055a42cdd887
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: d
22 |
23 o changeset: 2:177f92b77385
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: c
27 |
28 o changeset: 1:d2ae7f538514
29 | user: test
30 | date: Thu Jan 01 00:00:00 1970 +0000
31 | summary: b
32 |
33 o changeset: 0:cb9a9f314b8b
34 user: test
35 date: Thu Jan 01 00:00:00 1970 +0000
36 summary: a
37
38 % edit the history
39 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
40 1 out of 1 hunks FAILED -- saving rejects to file e.rej
41 abort: Fix up the change and run hg histedit --continue
42 % fix up
43 d
44 ***
45 does not commute with e
46
47
48 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 file e already exists
50 1 out of 1 hunks FAILED -- saving rejects to file e.rej
51 abort: Fix up the change and run hg histedit --continue
52
53 % just continue this time
54 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
56 % log after edit
57 @ changeset: 4:f768fd60ca34
58 | tag: tip
59 | user: test
60 | date: Thu Jan 01 00:00:00 1970 +0000
61 | summary: f
62 |
63 o changeset: 3:671efe372e33
64 | user: test
65 | date: Thu Jan 01 00:00:00 1970 +0000
66 | summary: d
67 |
68 o changeset: 2:177f92b77385
69 | user: test
70 | date: Thu Jan 01 00:00:00 1970 +0000
71 | summary: c
72 |
73 o changeset: 1:d2ae7f538514
74 | user: test
75 | date: Thu Jan 01 00:00:00 1970 +0000
76 | summary: b
77 |
78 o changeset: 0:cb9a9f314b8b
79 user: test
80 date: Thu Jan 01 00:00:00 1970 +0000
81 summary: a
82
83 % contents of e
84 a
85 % manifest
86 a
87 b
88 c
89 d
90 e
91 f
92 % EOF
@@ -0,0 +1,74 b''
1 % log before edit
2 @ changeset: 5:652413bf663e
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: f
7 |
8 o changeset: 4:e860deea161a
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: e
12 |
13 o changeset: 3:055a42cdd887
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: d
17 |
18 o changeset: 2:177f92b77385
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: c
22 |
23 o changeset: 1:d2ae7f538514
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: b
27 |
28 o changeset: 0:cb9a9f314b8b
29 user: test
30 date: Thu Jan 01 00:00:00 1970 +0000
31 summary: a
32
33 % edit the history
34 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
35 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
38 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 % log after edit
41 @ changeset: 4:82b0c1ff1777
42 | tag: tip
43 | user: test
44 | date: Thu Jan 01 00:00:00 1970 +0000
45 | summary: d
46 |
47 o changeset: 3:150aafb44a91
48 | user: test
49 | date: Thu Jan 01 00:00:00 1970 +0000
50 | summary: pick e860deea161a e
51 |
52 o changeset: 2:493dc0964412
53 | user: test
54 | date: Thu Jan 01 00:00:00 1970 +0000
55 | summary: e
56 |
57 o changeset: 1:d2ae7f538514
58 | user: test
59 | date: Thu Jan 01 00:00:00 1970 +0000
60 | summary: b
61 |
62 o changeset: 0:cb9a9f314b8b
63 user: test
64 date: Thu Jan 01 00:00:00 1970 +0000
65 summary: a
66
67 % post-fold manifest
68 a
69 b
70 c
71 d
72 e
73 f
74 % EOF
@@ -0,0 +1,110 b''
1 #!/bin/sh
2
3 # test for issue #6:
4 # editing a changeset without any actual change would corrupt the repository
5
6 . "$TESTDIR/histedit-helpers.sh"
7
8 cat >> $HGRCPATH <<EOF
9 [extensions]
10 graphlog=
11 histedit=
12 EOF
13
14 initrepo ()
15 {
16 dir="$1"
17 comment="$2"
18
19 if [ -n "${comment}" ]; then
20 echo % ${comment}
21 echo % ${comment} | sed 's:.:-:g'
22 fi
23
24 hg init ${dir}
25 cd ${dir}
26 for x in a b c d e f ; do
27 echo $x > $x
28 hg add $x
29 hg ci -m $x
30 done
31 }
32
33 geneditor ()
34 {
35 # generate an editor script for selecting changesets to be edited
36
37 choice=$1 # changesets that should be edited (using sed line ranges)
38
39 cat <<EOF | sed 's:^....::'
40 #!/bin/sh
41
42 # editing the rules, replacing 'pick' with 'edit' for the chosen lines
43 sed '${choice}s:^pick:edit:' \$1 > \${1}.tmp
44 mv \${1}.tmp \$1
45
46 # displaying the resulting rules, minus comments and empty lines
47 sed '/^#/d;/^$/d;s:^:| :' \$1 >&2
48 EOF
49 }
50
51 startediting ()
52 {
53 # begin an editing session
54
55 choice="$1" # changesets that should be edited
56 number="$2" # number of changesets considered (from tip)
57 comment="$3"
58
59 geneditor "${choice}" > edit.sh
60 chmod +x edit.sh
61
62 echo % start editing the history ${comment}
63 HGEDITOR=./edit.sh hg histedit -- -${number} 2>&1 | fixbundle
64 }
65
66 continueediting ()
67 {
68 # continue an edit already in progress
69
70 editor="$1" # message editor when finalizing editing
71 comment="$2"
72
73 echo % finalize changeset editing ${comment}
74 HGEDITOR=${editor} hg histedit --continue 2>&1 | fixbundle
75 }
76
77 graphlog ()
78 {
79 comment="${1:-log}"
80
81 echo % "${comment}"
82 hg glog --template '{rev} {node} \"{desc|firstline}\"\n'
83 }
84
85
86
87 initrepo r1 "test editing with no change"
88 graphlog "log before editing"
89 startediting 2 3 "(not changing anything)" # edit the 2nd of 3 changesets
90 continueediting true "(leaving commit message unaltered)"
91
92 echo "% check state of working copy"
93 hg id
94
95 graphlog "log after history editing"
96
97
98 cd ..
99 initrepo r2 "test editing with no change, then abort"
100 graphlog "log before editing"
101 startediting 1,2 3 "(not changing anything)" # edit the 1st two of 3 changesets
102 continueediting true "(leaving commit message unaltered)"
103 graphlog "log after first edit"
104
105 echo % abort editing session
106 hg histedit --abort 2>&1 | fixbundle
107
108 graphlog "log after abort"
109
110 echo % EOF
@@ -0,0 +1,94 b''
1 % test editing with no change
2 -----------------------------
3 % log before editing
4 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
5 |
6 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
7 |
8 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
9 |
10 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
11 |
12 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
13 |
14 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
15
16 % start editing the history (not changing anything)
17 | pick 055a42cdd887 3 d
18 | edit e860deea161a 4 e
19 | pick 652413bf663e 5 f
20 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
21 abort: Make changes as needed, you may commit or record as needed now.
22 When you are finished, run hg histedit --continue to resume.
23 % finalize changeset editing (leaving commit message unaltered)
24 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
25 % check state of working copy
26 652413bf663e tip
27 % log after history editing
28 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
29 |
30 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
31 |
32 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
33 |
34 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
35 |
36 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
37 |
38 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
39
40 % test editing with no change, then abort
41 -----------------------------------------
42 % log before editing
43 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
44 |
45 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
46 |
47 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
48 |
49 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
50 |
51 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
52 |
53 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
54
55 % start editing the history (not changing anything)
56 | edit 055a42cdd887 3 d
57 | edit e860deea161a 4 e
58 | pick 652413bf663e 5 f
59 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
60 abort: Make changes as needed, you may commit or record as needed now.
61 When you are finished, run hg histedit --continue to resume.
62 % finalize changeset editing (leaving commit message unaltered)
63 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 abort: Make changes as needed, you may commit or record as needed now.
65 When you are finished, run hg histedit --continue to resume.
66 % log after first edit
67 o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
68 |
69 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
70 |
71 @ 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
72 |
73 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
74 |
75 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
76 |
77 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
78
79 % abort editing session
80 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
81 % log after abort
82 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
83 |
84 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
85 |
86 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
87 |
88 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
89 |
90 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
91 |
92 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
93
94 % EOF
@@ -0,0 +1,90 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick 177f92b77385 c
14 pick 055a42cdd887 d
15 pick bfa474341cc9 does not commute with e
16 pick e860deea161a e
17 pick 652413bf663e f
18 EOF
19 initrepo ()
20 {
21 hg init r
22 cd r
23 for x in a b c d e f ; do
24 echo $x > $x
25 hg add $x
26 hg ci -m $x
27 done
28 echo a >> e
29 hg ci -m 'does not commute with e'
30 }
31
32 initrepo
33
34 echo % log before edit
35 hg log --graph
36
37 echo % edit the history
38 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
39
40 echo % abort the edit
41 hg histedit --abort 2>&1 | fixbundle
42
43 echo
44 echo
45 echo % second edit set
46
47 hg log --graph
48
49 echo % edit the history
50 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
51
52 echo % fix up
53 echo a > e
54 hg add e
55 hg histedit --continue 2>&1 | fixbundle
56
57 echo
58 echo % just continue this time
59 hg histedit --continue 2>&1 | fixbundle
60
61 echo % log after edit
62 hg log --graph
63
64 echo % start over
65
66 cd ..
67 rm -r r
68 initrepo
69 cat > $EDITED <<EOF
70 pick 177f92b77385 c
71 pick 055a42cdd887 d
72 mess bfa474341cc9 does not commute with e
73 pick e860deea161a e
74 pick 652413bf663e f
75 EOF
76
77 echo % edit the history, this time with a fold action
78 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
79
80 echo
81 echo a > e
82 hg add e
83 HGEDITOR="cat $EDITED > " hg histedit --continue 2>&1 | fixbundle
84 echo % second edit also fails, but just continue
85 hg histedit --continue 2>&1 | fixbundle
86
87 echo % post message fix
88 hg log --graph
89
90 echo % EOF
@@ -0,0 +1,50 b''
1 #!/bin/sh
2
3 . "$TESTDIR/histedit-helpers.sh"
4
5 cat >> $HGRCPATH <<EOF
6 [extensions]
7 graphlog=
8 histedit=
9 EOF
10
11 EDITED=`pwd`/editedhistory
12 cat > $EDITED <<EOF
13 pick 177f92b77385 c
14 pick 055a42cdd887 d
15 pick bfa474341cc9 does not commute with e
16 pick e860deea161a e
17 pick 652413bf663e f
18 EOF
19 initrepo ()
20 {
21 hg init r
22 cd r
23 for x in a b c d e f ; do
24 echo $x > $x
25 hg add $x
26 hg ci -m $x
27 done
28 echo a >> e
29 hg ci -m 'does not commute with e'
30 }
31
32 initrepo
33
34 echo % log before edit
35 hg log --graph
36
37 echo % edit the history
38 HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
39
40 echo '% fix up (pre abort)'
41 echo a > e
42 hg add e
43 hg histedit --continue 2>&1 | fixbundle
44
45 echo % abort the edit
46 hg histedit --abort 2>&1 | fixbundle
47
48 echo % log after abort
49 hg log --graph
50 echo % EOF
@@ -0,0 +1,86 b''
1 % log before edit
2 @ changeset: 6:bfa474341cc9
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: does not commute with e
7 |
8 o changeset: 5:652413bf663e
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: f
12 |
13 o changeset: 4:e860deea161a
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: e
17 |
18 o changeset: 3:055a42cdd887
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: d
22 |
23 o changeset: 2:177f92b77385
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: c
27 |
28 o changeset: 1:d2ae7f538514
29 | user: test
30 | date: Thu Jan 01 00:00:00 1970 +0000
31 | summary: b
32 |
33 o changeset: 0:cb9a9f314b8b
34 user: test
35 date: Thu Jan 01 00:00:00 1970 +0000
36 summary: a
37
38 % edit the history
39 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
40 1 out of 1 hunks FAILED -- saving rejects to file e.rej
41 abort: Fix up the change and run hg histedit --continue
42 % fix up (pre abort)
43 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 file e already exists
45 1 out of 1 hunks FAILED -- saving rejects to file e.rej
46 abort: Fix up the change and run hg histedit --continue
47 % abort the edit
48 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 % log after abort
50 @ changeset: 6:bfa474341cc9
51 | tag: tip
52 | user: test
53 | date: Thu Jan 01 00:00:00 1970 +0000
54 | summary: does not commute with e
55 |
56 o changeset: 5:652413bf663e
57 | user: test
58 | date: Thu Jan 01 00:00:00 1970 +0000
59 | summary: f
60 |
61 o changeset: 4:e860deea161a
62 | user: test
63 | date: Thu Jan 01 00:00:00 1970 +0000
64 | summary: e
65 |
66 o changeset: 3:055a42cdd887
67 | user: test
68 | date: Thu Jan 01 00:00:00 1970 +0000
69 | summary: d
70 |
71 o changeset: 2:177f92b77385
72 | user: test
73 | date: Thu Jan 01 00:00:00 1970 +0000
74 | summary: c
75 |
76 o changeset: 1:d2ae7f538514
77 | user: test
78 | date: Thu Jan 01 00:00:00 1970 +0000
79 | summary: b
80 |
81 o changeset: 0:cb9a9f314b8b
82 user: test
83 date: Thu Jan 01 00:00:00 1970 +0000
84 summary: a
85
86 % EOF
@@ -0,0 +1,173 b''
1 % log before edit
2 @ changeset: 6:bfa474341cc9
3 | tag: tip
4 | user: test
5 | date: Thu Jan 01 00:00:00 1970 +0000
6 | summary: does not commute with e
7 |
8 o changeset: 5:652413bf663e
9 | user: test
10 | date: Thu Jan 01 00:00:00 1970 +0000
11 | summary: f
12 |
13 o changeset: 4:e860deea161a
14 | user: test
15 | date: Thu Jan 01 00:00:00 1970 +0000
16 | summary: e
17 |
18 o changeset: 3:055a42cdd887
19 | user: test
20 | date: Thu Jan 01 00:00:00 1970 +0000
21 | summary: d
22 |
23 o changeset: 2:177f92b77385
24 | user: test
25 | date: Thu Jan 01 00:00:00 1970 +0000
26 | summary: c
27 |
28 o changeset: 1:d2ae7f538514
29 | user: test
30 | date: Thu Jan 01 00:00:00 1970 +0000
31 | summary: b
32 |
33 o changeset: 0:cb9a9f314b8b
34 user: test
35 date: Thu Jan 01 00:00:00 1970 +0000
36 summary: a
37
38 % edit the history
39 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
40 1 out of 1 hunks FAILED -- saving rejects to file e.rej
41 abort: Fix up the change and run hg histedit --continue
42 % abort the edit
43 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
44
45
46 % second edit set
47 @ changeset: 6:bfa474341cc9
48 | tag: tip
49 | user: test
50 | date: Thu Jan 01 00:00:00 1970 +0000
51 | summary: does not commute with e
52 |
53 o changeset: 5:652413bf663e
54 | user: test
55 | date: Thu Jan 01 00:00:00 1970 +0000
56 | summary: f
57 |
58 o changeset: 4:e860deea161a
59 | user: test
60 | date: Thu Jan 01 00:00:00 1970 +0000
61 | summary: e
62 |
63 o changeset: 3:055a42cdd887
64 | user: test
65 | date: Thu Jan 01 00:00:00 1970 +0000
66 | summary: d
67 |
68 o changeset: 2:177f92b77385
69 | user: test
70 | date: Thu Jan 01 00:00:00 1970 +0000
71 | summary: c
72 |
73 o changeset: 1:d2ae7f538514
74 | user: test
75 | date: Thu Jan 01 00:00:00 1970 +0000
76 | summary: b
77 |
78 o changeset: 0:cb9a9f314b8b
79 user: test
80 date: Thu Jan 01 00:00:00 1970 +0000
81 summary: a
82
83 % edit the history
84 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
85 1 out of 1 hunks FAILED -- saving rejects to file e.rej
86 abort: Fix up the change and run hg histedit --continue
87 % fix up
88 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 file e already exists
90 1 out of 1 hunks FAILED -- saving rejects to file e.rej
91 abort: Fix up the change and run hg histedit --continue
92
93 % just continue this time
94 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
95 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
96 % log after edit
97 @ changeset: 5:9ab84894b459
98 | tag: tip
99 | user: test
100 | date: Thu Jan 01 00:00:00 1970 +0000
101 | summary: f
102 |
103 o changeset: 4:1fff3ae8199d
104 | user: test
105 | date: Thu Jan 01 00:00:00 1970 +0000
106 | summary: does not commute with e
107 |
108 o changeset: 3:055a42cdd887
109 | user: test
110 | date: Thu Jan 01 00:00:00 1970 +0000
111 | summary: d
112 |
113 o changeset: 2:177f92b77385
114 | user: test
115 | date: Thu Jan 01 00:00:00 1970 +0000
116 | summary: c
117 |
118 o changeset: 1:d2ae7f538514
119 | user: test
120 | date: Thu Jan 01 00:00:00 1970 +0000
121 | summary: b
122 |
123 o changeset: 0:cb9a9f314b8b
124 user: test
125 date: Thu Jan 01 00:00:00 1970 +0000
126 summary: a
127
128 % start over
129 % edit the history, this time with a fold action
130 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
131 1 out of 1 hunks FAILED -- saving rejects to file e.rej
132 abort: Fix up the change and run hg histedit --continue
133
134 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
135 file e already exists
136 1 out of 1 hunks FAILED -- saving rejects to file e.rej
137 abort: Fix up the change and run hg histedit --continue
138 % second edit also fails, but just continue
139 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 % post message fix
142 @ changeset: 5:6459970fb49b
143 | tag: tip
144 | user: test
145 | date: Thu Jan 01 00:00:00 1970 +0000
146 | summary: f
147 |
148 o changeset: 4:556f27c874b0
149 | user: test
150 | date: Thu Jan 01 00:00:00 1970 +0000
151 | summary: pick 177f92b77385 c
152 |
153 o changeset: 3:055a42cdd887
154 | user: test
155 | date: Thu Jan 01 00:00:00 1970 +0000
156 | summary: d
157 |
158 o changeset: 2:177f92b77385
159 | user: test
160 | date: Thu Jan 01 00:00:00 1970 +0000
161 | summary: c
162 |
163 o changeset: 1:d2ae7f538514
164 | user: test
165 | date: Thu Jan 01 00:00:00 1970 +0000
166 | summary: b
167 |
168 o changeset: 0:cb9a9f314b8b
169 user: test
170 date: Thu Jan 01 00:00:00 1970 +0000
171 summary: a
172
173 % EOF
@@ -0,0 +1,61 b''
1 #!/bin/sh
2
3 cat >> $HGRCPATH <<EOF
4 [extensions]
5 graphlog=
6 histedit=
7 EOF
8
9 EDITED=`pwd`/editedhistory
10 cat > $EDITED <<EOF
11 pick 177f92b77385 c
12 pick e860deea161a e
13 pick 652413bf663e f
14 pick 055a42cdd887 d
15 EOF
16 initrepo ()
17 {
18 hg init r
19 cd r
20 for x in a b c ; do
21 echo $x > $x
22 hg add $x
23 hg ci -m $x
24 done
25
26 cd ..
27 hg clone r r2 | grep -v updating
28 cd r2
29 for x in d e f ; do
30 echo $x > $x
31 hg add $x
32 hg ci -m $x
33 done
34
35 cd ..
36 hg init r3
37 cd r3
38 for x in g h i ; do
39 echo $x > $x
40 hg add $x
41 hg ci -m $x
42 done
43 cd ..
44 }
45
46 initrepo
47
48 echo % show the edit commands offered by outgoing
49 cd r2
50 HGEDITOR=cat hg histedit --outgoing ../r | grep -v comparing | grep -v searching
51 cd ..
52
53 echo % show the error from unrelated repos
54 cd r3
55 HGEDITOR=cat hg histedit --outgoing ../r | grep -v comparing | grep -v searching
56 cd ..
57
58 echo % show the error from unrelated repos
59 cd r3
60 HGEDITOR=cat hg histedit --force --outgoing ../r
61 cd ..
@@ -0,0 +1,36 b''
1 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
2 % show the edit commands offered by outgoing
3 pick 055a42cdd887 3 d
4 pick e860deea161a 4 e
5 pick 652413bf663e 5 f
6
7 # Edit history between 055a42cdd887 and 652413bf663e
8 #
9 # Commands:
10 # p, pick = use commit
11 # e, edit = use commit, but stop for amending
12 # f, fold = use commit, but fold into previous commit (combines N and N-1)
13 # d, drop = remove commit from history
14 # m, mess = edit message without changing commit content
15 #
16 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 % show the error from unrelated repos
18 abort: repository is unrelated
19 % show the error from unrelated repos
20 comparing with ../r
21 searching for changes
22 warning: repository is unrelated
23 pick 2a4042b45417 0 g
24 pick 68c46b4927ce 1 h
25 pick 51281e65ba79 2 i
26
27 # Edit history between 2a4042b45417 and 51281e65ba79
28 #
29 # Commands:
30 # p, pick = use commit
31 # e, edit = use commit, but stop for amending
32 # f, fold = use commit, but fold into previous commit (combines N and N-1)
33 # d, drop = remove commit from history
34 # m, mess = edit message without changing commit content
35 #
36 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -0,0 +1,62 b''
1 This test requires parentrevspec support in revsets, so check for that
2 and skip the test if we're on an unusual hg that supports .t tests but
3 not parentrevspec.
4 $ python -c 'from mercurial import revset ; revset.methods["parentpost"]' || exit 80
5
6 Enable extensions used by this test.
7 $ cat >>$HGRCPATH <<EOF
8 > [extensions]
9 > graphlog=
10 > histedit=
11 > EOF
12
13 Repo setup.
14 $ hg init foo
15 $ cd foo
16 $ echo alpha >> alpha
17 $ hg addr
18 adding alpha
19 $ hg ci -m one
20 $ echo alpha >> alpha
21 $ hg ci -m two
22 $ echo alpha >> alpha
23 $ hg ci -m three
24 $ echo alpha >> alpha
25 $ hg ci -m four
26 $ echo alpha >> alpha
27 $ hg ci -m five
28
29 $ hg log --style compact --graph
30 @ 4[tip] 08d98a8350f3 1970-01-01 00:00 +0000 test
31 | five
32 |
33 o 3 c8e68270e35a 1970-01-01 00:00 +0000 test
34 | four
35 |
36 o 2 eb57da33312f 1970-01-01 00:00 +0000 test
37 | three
38 |
39 o 1 579e40513370 1970-01-01 00:00 +0000 test
40 | two
41 |
42 o 0 6058cbb6cfd7 1970-01-01 00:00 +0000 test
43 one
44
45
46 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
47 $ HGEDITOR=cat hg histedit tip^^
48 pick eb57da33312f 2 three
49 pick c8e68270e35a 3 four
50 pick 08d98a8350f3 4 five
51
52 # Edit history between eb57da33312f and 08d98a8350f3
53 #
54 # Commands:
55 # p, pick = use commit
56 # e, edit = use commit, but stop for amending
57 # f, fold = use commit, but fold into previous commit (combines N and N-1)
58 # d, drop = remove commit from history
59 # m, mess = edit message without changing commit content
60 #
61 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
62
General Comments 0
You need to be logged in to leave comments. Login now