Show More
@@ -0,0 +1,95 b'' | |||||
|
1 | $ . "$TESTDIR/histedit-helpers.sh" | |||
|
2 | ||||
|
3 | Enable extension used by this test | |||
|
4 | $ cat >>$HGRCPATH <<EOF | |||
|
5 | > [extensions] | |||
|
6 | > histedit= | |||
|
7 | > EOF | |||
|
8 | ||||
|
9 | Repo setup: | |||
|
10 | $ hg init foo | |||
|
11 | $ cd foo | |||
|
12 | $ echo first>file | |||
|
13 | $ hg ci -qAm one | |||
|
14 | $ echo second>>file | |||
|
15 | $ hg ci -m two | |||
|
16 | $ echo third>>file | |||
|
17 | $ hg ci -m three | |||
|
18 | $ echo forth>>file | |||
|
19 | $ hg ci -m four | |||
|
20 | $ hg log -G --style compact | |||
|
21 | @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test | |||
|
22 | | four | |||
|
23 | | | |||
|
24 | o 2 80d23dfa866d 1970-01-01 00:00 +0000 test | |||
|
25 | | three | |||
|
26 | | | |||
|
27 | o 1 6153eb23e623 1970-01-01 00:00 +0000 test | |||
|
28 | | two | |||
|
29 | | | |||
|
30 | o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test | |||
|
31 | one | |||
|
32 | ||||
|
33 | Check when --no-backup is not passed | |||
|
34 | $ hg histedit -r '36b4bdd91f5b' --commands - << EOF | |||
|
35 | > pick 36b4bdd91f5b 0 one | |||
|
36 | > pick 6153eb23e623 1 two | |||
|
37 | > roll 80d23dfa866d 2 three | |||
|
38 | > edit 7d5187087c79 3 four | |||
|
39 | > EOF | |||
|
40 | merging file | |||
|
41 | Editing (7d5187087c79), you may commit or record as needed now. | |||
|
42 | (hg histedit --continue to resume) | |||
|
43 | [1] | |||
|
44 | ||||
|
45 | $ hg histedit --abort | |||
|
46 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
47 | saved backup bundle to $TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg | |||
|
48 | saved backup bundle to $TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg | |||
|
49 | ||||
|
50 | $ hg st | |||
|
51 | $ hg diff | |||
|
52 | $ hg log -G --style compact | |||
|
53 | @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test | |||
|
54 | | four | |||
|
55 | | | |||
|
56 | o 2 80d23dfa866d 1970-01-01 00:00 +0000 test | |||
|
57 | | three | |||
|
58 | | | |||
|
59 | o 1 6153eb23e623 1970-01-01 00:00 +0000 test | |||
|
60 | | two | |||
|
61 | | | |||
|
62 | o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test | |||
|
63 | one | |||
|
64 | ||||
|
65 | ||||
|
66 | Check when --no-backup is passed | |||
|
67 | $ hg histedit -r '36b4bdd91f5b' --commands - << EOF | |||
|
68 | > pick 36b4bdd91f5b 0 one | |||
|
69 | > pick 6153eb23e623 1 two | |||
|
70 | > roll 80d23dfa866d 2 three | |||
|
71 | > edit 7d5187087c79 3 four | |||
|
72 | > EOF | |||
|
73 | merging file | |||
|
74 | Editing (7d5187087c79), you may commit or record as needed now. | |||
|
75 | (hg histedit --continue to resume) | |||
|
76 | [1] | |||
|
77 | ||||
|
78 | $ hg histedit --abort --no-backup | |||
|
79 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
80 | ||||
|
81 | $ hg st | |||
|
82 | $ hg diff | |||
|
83 | $ hg log -G --style compact | |||
|
84 | @ 3[tip] 7d5187087c79 1970-01-01 00:00 +0000 test | |||
|
85 | | four | |||
|
86 | | | |||
|
87 | o 2 80d23dfa866d 1970-01-01 00:00 +0000 test | |||
|
88 | | three | |||
|
89 | | | |||
|
90 | o 1 6153eb23e623 1970-01-01 00:00 +0000 test | |||
|
91 | | two | |||
|
92 | | | |||
|
93 | o 0 36b4bdd91f5b 1970-01-01 00:00 +0000 test | |||
|
94 | one | |||
|
95 |
@@ -925,6 +925,7 b' def findoutgoing(ui, repo, remote=None, ' | |||||
925 | _("don't strip old nodes after edit is complete")), |
|
925 | _("don't strip old nodes after edit is complete")), | |
926 | ('', 'abort', False, _('abort an edit in progress')), |
|
926 | ('', 'abort', False, _('abort an edit in progress')), | |
927 | ('o', 'outgoing', False, _('changesets not found in destination')), |
|
927 | ('o', 'outgoing', False, _('changesets not found in destination')), | |
|
928 | ('', 'no-backup', False, _('no backup')), | |||
928 | ('f', 'force', False, |
|
929 | ('f', 'force', False, | |
929 | _('force outgoing even for unrelated repositories')), |
|
930 | _('force outgoing even for unrelated repositories')), | |
930 | ('r', 'rev', [], _('first revision to be edited'), _('REV'))] + |
|
931 | ('r', 'rev', [], _('first revision to be edited'), _('REV'))] + | |
@@ -1110,6 +1111,7 b' def _histedit(ui, repo, state, *freeargs' | |||||
1110 | fm.startitem() |
|
1111 | fm.startitem() | |
1111 | goal = _getgoal(opts) |
|
1112 | goal = _getgoal(opts) | |
1112 | revs = opts.get('rev', []) |
|
1113 | revs = opts.get('rev', []) | |
|
1114 | nobackup = opts.get('no_backup') | |||
1113 | rules = opts.get('commands', '') |
|
1115 | rules = opts.get('commands', '') | |
1114 | state.keep = opts.get('keep', False) |
|
1116 | state.keep = opts.get('keep', False) | |
1115 |
|
1117 | |||
@@ -1123,7 +1125,7 b' def _histedit(ui, repo, state, *freeargs' | |||||
1123 | _edithisteditplan(ui, repo, state, rules) |
|
1125 | _edithisteditplan(ui, repo, state, rules) | |
1124 | return |
|
1126 | return | |
1125 | elif goal == goalabort: |
|
1127 | elif goal == goalabort: | |
1126 | _aborthistedit(ui, repo, state) |
|
1128 | _aborthistedit(ui, repo, state, nobackup=nobackup) | |
1127 | return |
|
1129 | return | |
1128 | else: |
|
1130 | else: | |
1129 | # goal == goalnew |
|
1131 | # goal == goalnew | |
@@ -1221,7 +1223,7 b' def _finishhistedit(ui, repo, state, fm)' | |||||
1221 | if repo.vfs.exists('histedit-last-edit.txt'): |
|
1223 | if repo.vfs.exists('histedit-last-edit.txt'): | |
1222 | repo.vfs.unlink('histedit-last-edit.txt') |
|
1224 | repo.vfs.unlink('histedit-last-edit.txt') | |
1223 |
|
1225 | |||
1224 | def _aborthistedit(ui, repo, state): |
|
1226 | def _aborthistedit(ui, repo, state, nobackup=False): | |
1225 | try: |
|
1227 | try: | |
1226 | state.read() |
|
1228 | state.read() | |
1227 | __, leafs, tmpnodes, __ = processreplacement(state) |
|
1229 | __, leafs, tmpnodes, __ = processreplacement(state) | |
@@ -1243,8 +1245,8 b' def _aborthistedit(ui, repo, state):' | |||||
1243 | if repo.unfiltered().revs('parents() and (%n or %ln::)', |
|
1245 | if repo.unfiltered().revs('parents() and (%n or %ln::)', | |
1244 | state.parentctxnode, leafs | tmpnodes): |
|
1246 | state.parentctxnode, leafs | tmpnodes): | |
1245 | hg.clean(repo, state.topmost, show_stats=True, quietempty=True) |
|
1247 | hg.clean(repo, state.topmost, show_stats=True, quietempty=True) | |
1246 | cleanupnode(ui, repo, tmpnodes) |
|
1248 | cleanupnode(ui, repo, tmpnodes, nobackup=nobackup) | |
1247 | cleanupnode(ui, repo, leafs) |
|
1249 | cleanupnode(ui, repo, leafs, nobackup=nobackup) | |
1248 | except Exception: |
|
1250 | except Exception: | |
1249 | if state.inprogress(): |
|
1251 | if state.inprogress(): | |
1250 | ui.warn(_('warning: encountered an exception during histedit ' |
|
1252 | ui.warn(_('warning: encountered an exception during histedit ' | |
@@ -1601,7 +1603,7 b' def movetopmostbookmarks(repo, oldtopmos' | |||||
1601 | changes.append((name, newtopmost)) |
|
1603 | changes.append((name, newtopmost)) | |
1602 | marks.applychanges(repo, tr, changes) |
|
1604 | marks.applychanges(repo, tr, changes) | |
1603 |
|
1605 | |||
1604 | def cleanupnode(ui, repo, nodes): |
|
1606 | def cleanupnode(ui, repo, nodes, nobackup=False): | |
1605 | """strip a group of nodes from the repository |
|
1607 | """strip a group of nodes from the repository | |
1606 |
|
1608 | |||
1607 | The set of node to strip may contains unknown nodes.""" |
|
1609 | The set of node to strip may contains unknown nodes.""" | |
@@ -1616,7 +1618,8 b' def cleanupnode(ui, repo, nodes):' | |||||
1616 | nodes = sorted(n for n in nodes if n in nm) |
|
1618 | nodes = sorted(n for n in nodes if n in nm) | |
1617 | roots = [c.node() for c in repo.set("roots(%ln)", nodes)] |
|
1619 | roots = [c.node() for c in repo.set("roots(%ln)", nodes)] | |
1618 | if roots: |
|
1620 | if roots: | |
1619 | repair.strip(ui, repo, roots) |
|
1621 | backup = not nobackup | |
|
1622 | repair.strip(ui, repo, roots, backup=backup) | |||
1620 |
|
1623 | |||
1621 | def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): |
|
1624 | def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): | |
1622 | if isinstance(nodelist, str): |
|
1625 | if isinstance(nodelist, str): |
General Comments 0
You need to be logged in to leave comments.
Login now