Show More
@@ -0,0 +1,54 b'' | |||
|
1 | Testing templating for histedit command | |
|
2 | ||
|
3 | Setup | |
|
4 | ||
|
5 | $ cat >> $HGRCPATH <<EOF | |
|
6 | > [extensions] | |
|
7 | > histedit= | |
|
8 | > [experimental] | |
|
9 | > evolution=createmarkers | |
|
10 | > EOF | |
|
11 | ||
|
12 | $ hg init repo | |
|
13 | $ cd repo | |
|
14 | $ for ch in a b c d; do echo foo > $ch; hg commit -Aqm "Added "$ch; done | |
|
15 | ||
|
16 | $ hg log -G -T "{rev}:{node|short} {desc}" | |
|
17 | @ 3:62615734edd5 Added d | |
|
18 | | | |
|
19 | o 2:28ad74487de9 Added c | |
|
20 | | | |
|
21 | o 1:29becc82797a Added b | |
|
22 | | | |
|
23 | o 0:18d04c59bb5d Added a | |
|
24 | ||
|
25 | Getting the JSON output for nodechanges | |
|
26 | ||
|
27 | $ hg histedit -Tjson --commands - 2>&1 <<EOF | |
|
28 | > pick 28ad74487de9 Added c | |
|
29 | > pick 62615734edd5 Added d | |
|
30 | > pick 18d04c59bb5d Added a | |
|
31 | > pick 29becc82797a Added b | |
|
32 | > EOF | |
|
33 | [ | |
|
34 | { | |
|
35 | "nodechanges": {"18d04c59bb5d2d4090ad9a5b59bd6274adb63add": ["109f8ec895447f81b380ba8d4d8b66539ccdcb94"], "28ad74487de9599d00d81085be739c61fc340652": ["bff9e07c1807942b161dab768aa793b48e9a7f9d"], "29becc82797a4bc11ec8880b58eaecd2ab3e7760": ["f5dcf3b4db23f31f1aacf46c33d1393de303d26f"], "62615734edd52f06b6fb9c2beb429e4fe30d57b8": ["201423b441c84d9e6858daed653e0d22485c1cfa"]} | |
|
36 | } | |
|
37 | ] | |
|
38 | ||
|
39 | $ hg log -G -T "{rev}:{node|short} {desc}" | |
|
40 | @ 7:f5dcf3b4db23 Added b | |
|
41 | | | |
|
42 | o 6:109f8ec89544 Added a | |
|
43 | | | |
|
44 | o 5:201423b441c8 Added d | |
|
45 | | | |
|
46 | o 4:bff9e07c1807 Added c | |
|
47 | ||
|
48 | $ hg histedit -T "{nodechanges|json}" --commands - 2>&1 <<EOF | |
|
49 | > pick bff9e07c1807 Added c | |
|
50 | > pick 201423b441c8 Added d | |
|
51 | > pick 109f8ec89544 Added a | |
|
52 | > roll f5dcf3b4db23 Added b | |
|
53 | > EOF | |
|
54 | {"109f8ec895447f81b380ba8d4d8b66539ccdcb94": ["8d01470bfeab64d3de13c49adb79d88790d38396"], "f3ec56a374bdbdf1953cacca505161442c6f3a3e": [], "f5dcf3b4db23f31f1aacf46c33d1393de303d26f": ["8d01470bfeab64d3de13c49adb79d88790d38396"]} (no-eol) |
@@ -917,7 +917,8 b' def findoutgoing(ui, repo, remote=None, ' | |||
|
917 | 917 | ('o', 'outgoing', False, _('changesets not found in destination')), |
|
918 | 918 | ('f', 'force', False, |
|
919 | 919 | _('force outgoing even for unrelated repositories')), |
|
920 |
('r', 'rev', [], _('first revision to be edited'), _('REV'))] |
|
|
920 | ('r', 'rev', [], _('first revision to be edited'), _('REV'))] + | |
|
921 | cmdutil.formatteropts, | |
|
921 | 922 | _("[OPTIONS] ([ANCESTOR] | --outgoing [URL])")) |
|
922 | 923 | def histedit(ui, repo, *freeargs, **opts): |
|
923 | 924 | """interactively edit changeset history |
@@ -1095,6 +1096,8 b' def _validateargs(ui, repo, state, freea' | |||
|
1095 | 1096 | |
|
1096 | 1097 | def _histedit(ui, repo, state, *freeargs, **opts): |
|
1097 | 1098 | opts = pycompat.byteskwargs(opts) |
|
1099 | fm = ui.formatter('histedit', opts) | |
|
1100 | fm.startitem() | |
|
1098 | 1101 | goal = _getgoal(opts) |
|
1099 | 1102 | revs = opts.get('rev', []) |
|
1100 | 1103 | rules = opts.get('commands', '') |
@@ -1117,7 +1120,8 b' def _histedit(ui, repo, state, *freeargs' | |||
|
1117 | 1120 | _newhistedit(ui, repo, state, revs, freeargs, opts) |
|
1118 | 1121 | |
|
1119 | 1122 | _continuehistedit(ui, repo, state) |
|
1120 | _finishhistedit(ui, repo, state) | |
|
1123 | _finishhistedit(ui, repo, state, fm) | |
|
1124 | fm.end() | |
|
1121 | 1125 | |
|
1122 | 1126 | def _continuehistedit(ui, repo, state): |
|
1123 | 1127 | """This function runs after either: |
@@ -1164,7 +1168,7 b' def _continuehistedit(ui, repo, state):' | |||
|
1164 | 1168 | state.write() |
|
1165 | 1169 | ui.progress(_("editing"), None) |
|
1166 | 1170 | |
|
1167 | def _finishhistedit(ui, repo, state): | |
|
1171 | def _finishhistedit(ui, repo, state, fm): | |
|
1168 | 1172 | """This action runs when histedit is finishing its session""" |
|
1169 | 1173 | repo.ui.pushbuffer() |
|
1170 | 1174 | hg.update(repo, state.parentctxnode, quietempty=True) |
@@ -1198,6 +1202,13 b' def _finishhistedit(ui, repo, state):' | |||
|
1198 | 1202 | mapping = {k: v for k, v in mapping.items() |
|
1199 | 1203 | if k in nodemap and all(n in nodemap for n in v)} |
|
1200 | 1204 | scmutil.cleanupnodes(repo, mapping, 'histedit') |
|
1205 | hf = fm.hexfunc | |
|
1206 | fl = fm.formatlist | |
|
1207 | fd = fm.formatdict | |
|
1208 | nodechanges = fd({hf(oldn): fl([hf(n) for n in newn], name='node') | |
|
1209 | for oldn, newn in mapping.iteritems()}, | |
|
1210 | key="oldnode", value="newnodes") | |
|
1211 | fm.data(nodechanges=nodechanges) | |
|
1201 | 1212 | |
|
1202 | 1213 | state.clear() |
|
1203 | 1214 | if os.path.exists(repo.sjoin('undo')): |
General Comments 0
You need to be logged in to leave comments.
Login now