##// END OF EJS Templates
histedit: add "roll" command to fold commit data and drop message (issue4256)...
Mike Edgar -
r22152:d2a5986c default
parent child Browse files
Show More
@@ -36,6 +36,7 b' file open in your editor::'
36 36 # p, pick = use commit
37 37 # e, edit = use commit, but stop for amending
38 38 # f, fold = use commit, but combine it with the one above
39 # r, roll = like fold, but discard this commit's description
39 40 # d, drop = remove commit from history
40 41 # m, mess = edit message without changing commit content
41 42 #
@@ -57,6 +58,7 b' would reorganize the file to look like t'
57 58 # p, pick = use commit
58 59 # e, edit = use commit, but stop for amending
59 60 # f, fold = use commit, but combine it with the one above
61 # r, roll = like fold, but discard this commit's description
60 62 # d, drop = remove commit from history
61 63 # m, mess = edit message without changing commit content
62 64 #
@@ -179,6 +181,7 b' editcomment = _("""# Edit history betwee'
179 181 # p, pick = use commit
180 182 # e, edit = use commit, but stop for amending
181 183 # f, fold = use commit, but combine it with the one above
184 # r, roll = like fold, but discard this commit's description
182 185 # d, drop = remove commit from history
183 186 # m, mess = edit message without changing commit content
184 187 #
@@ -291,7 +294,9 b' def collapse(repo, first, last, commitop'
291 294 extra = commitopts.get('extra')
292 295
293 296 parents = (first.p1().node(), first.p2().node())
294 editor = cmdutil.getcommiteditor(edit=True, editform='histedit.fold')
297 editor = None
298 if not commitopts.get('rollup'):
299 editor = cmdutil.getcommiteditor(edit=True, editform='histedit.fold')
295 300 new = context.memctx(repo,
296 301 parents=parents,
297 302 text=message,
@@ -333,6 +338,11 b' def edit(ui, repo, ctx, ha, opts):'
333 338 _('Make changes as needed, you may commit or record as needed now.\n'
334 339 'When you are finished, run hg histedit --continue to resume.'))
335 340
341 def rollup(ui, repo, ctx, ha, opts):
342 rollupopts = opts.copy()
343 rollupopts['rollup'] = True
344 return fold(ui, repo, ctx, ha, rollupopts)
345
336 346 def fold(ui, repo, ctx, ha, opts):
337 347 oldctx = repo[ha]
338 348 hg.update(repo, ctx.node())
@@ -360,10 +370,13 b' def finishfold(ui, repo, ctx, oldctx, ne'
360 370 username = ui.username()
361 371 commitopts['user'] = username
362 372 # commit message
363 newmessage = '\n***\n'.join(
364 [ctx.description()] +
365 [repo[r].description() for r in internalchanges] +
366 [oldctx.description()]) + '\n'
373 if opts.get('rollup'):
374 newmessage = ctx.description()
375 else:
376 newmessage = '\n***\n'.join(
377 [ctx.description()] +
378 [repo[r].description() for r in internalchanges] +
379 [oldctx.description()]) + '\n'
367 380 commitopts['message'] = newmessage
368 381 # date
369 382 commitopts['date'] = max(ctx.date(), oldctx.date())
@@ -444,6 +457,8 b" actiontable = {'p': pick,"
444 457 'edit': edit,
445 458 'f': fold,
446 459 'fold': fold,
460 'r': rollup,
461 'roll': rollup,
447 462 'd': drop,
448 463 'drop': drop,
449 464 'm': message,
@@ -679,7 +694,7 b' def bootstrapcontinue(ui, repo, parentct'
679 694 m, a, r, d = repo.status()[:4]
680 695 if m or a or r or d:
681 696 # prepare the message for the commit to comes
682 if action in ('f', 'fold'):
697 if action in ('f', 'fold', 'r', 'roll'):
683 698 message = 'fold-temp-revision %s' % currentnode
684 699 else:
685 700 message = ctx.description()
@@ -702,15 +717,19 b' def bootstrapcontinue(ui, repo, parentct'
702 717 # to parent.
703 718 replacements.append((ctx.node(), tuple(newchildren)))
704 719
705 if action in ('f', 'fold'):
720 if action in ('f', 'fold', 'r', 'roll'):
706 721 if newchildren:
707 722 # finalize fold operation if applicable
708 723 if new is None:
709 724 new = newchildren[-1]
710 725 else:
711 726 newchildren.pop() # remove new from internal changes
712 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new, opts,
713 newchildren)
727 foldopts = opts
728 if action in ('r', 'roll'):
729 foldopts = foldopts.copy()
730 foldopts['rollup'] = True
731 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new,
732 foldopts, newchildren)
714 733 replacements.extend(repl)
715 734 else:
716 735 # newchildren is empty if the fold did not result in any commit
@@ -57,6 +57,7 b' Run a dummy edit to make sure we get tip'
57 57 # p, pick = use commit
58 58 # e, edit = use commit, but stop for amending
59 59 # f, fold = use commit, but combine it with the one above
60 # r, roll = like fold, but discard this commit's description
60 61 # d, drop = remove commit from history
61 62 # m, mess = edit message without changing commit content
62 63 #
@@ -255,6 +256,7 b' Test that trimming description using mul'
255 256 # p, pick = use commit
256 257 # e, edit = use commit, but stop for amending
257 258 # f, fold = use commit, but combine it with the one above
259 # r, roll = like fold, but discard this commit's description
258 260 # d, drop = remove commit from history
259 261 # m, mess = edit message without changing commit content
260 262 #
@@ -73,6 +73,7 b''
73 73 # p, pick = use commit
74 74 # e, edit = use commit, but stop for amending
75 75 # f, fold = use commit, but combine it with the one above
76 # r, roll = like fold, but discard this commit's description
76 77 # d, drop = remove commit from history
77 78 # m, mess = edit message without changing commit content
78 79 #
@@ -133,6 +134,7 b''
133 134 # p, pick = use commit
134 135 # e, edit = use commit, but stop for amending
135 136 # f, fold = use commit, but combine it with the one above
137 # r, roll = like fold, but discard this commit's description
136 138 # d, drop = remove commit from history
137 139 # m, mess = edit message without changing commit content
138 140 #
@@ -67,6 +67,7 b' show the edit commands offered'
67 67 # p, pick = use commit
68 68 # e, edit = use commit, but stop for amending
69 69 # f, fold = use commit, but combine it with the one above
70 # r, roll = like fold, but discard this commit's description
70 71 # d, drop = remove commit from history
71 72 # m, mess = edit message without changing commit content
72 73 #
@@ -344,6 +345,7 b' Verify that revsetalias entries work wit'
344 345 # p, pick = use commit
345 346 # e, edit = use commit, but stop for amending
346 347 # f, fold = use commit, but combine it with the one above
348 # r, roll = like fold, but discard this commit's description
347 349 # d, drop = remove commit from history
348 350 # m, mess = edit message without changing commit content
349 351 #
@@ -183,3 +183,165 b' manifest'
183 183 f
184 184
185 185 $ cd ..
186
187 Repeat test using "roll", not "fold". "roll" folds in changes but drops message
188
189 $ initrepo r2
190 $ cd r2
191
192 Initial generation of the command files
193
194 $ EDITED="$TESTTMP/editedhistory.2"
195 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
196 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
197 $ hg log --template 'roll {node|short} {rev} {desc}\n' -r 7 >> $EDITED
198 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
199 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
200 $ cat $EDITED
201 pick 65a9a84f33fd 3 c
202 pick 00f1c5383965 4 d
203 roll 39522b764e3d 7 does not commute with e
204 pick 7b4e2f4b7bcd 5 e
205 pick 500cac37a696 6 f
206
207 log before edit
208 $ hg log --graph
209 @ changeset: 7:39522b764e3d
210 | tag: tip
211 | user: test
212 | date: Thu Jan 01 00:00:00 1970 +0000
213 | summary: does not commute with e
214 |
215 o changeset: 6:500cac37a696
216 | user: test
217 | date: Thu Jan 01 00:00:00 1970 +0000
218 | summary: f
219 |
220 o changeset: 5:7b4e2f4b7bcd
221 | user: test
222 | date: Thu Jan 01 00:00:00 1970 +0000
223 | summary: e
224 |
225 o changeset: 4:00f1c5383965
226 | user: test
227 | date: Thu Jan 01 00:00:00 1970 +0000
228 | summary: d
229 |
230 o changeset: 3:65a9a84f33fd
231 | user: test
232 | date: Thu Jan 01 00:00:00 1970 +0000
233 | summary: c
234 |
235 o changeset: 2:da6535b52e45
236 | user: test
237 | date: Thu Jan 01 00:00:00 1970 +0000
238 | summary: b
239 |
240 o changeset: 1:c1f09da44841
241 | user: test
242 | date: Thu Jan 01 00:00:00 1970 +0000
243 | summary: a
244 |
245 o changeset: 0:1715188a53c7
246 user: test
247 date: Thu Jan 01 00:00:00 1970 +0000
248 summary: Initial commit
249
250
251 edit the history
252 $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
253 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 merging e
255 warning: conflicts during merge.
256 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
257 Fix up the change and run hg histedit --continue
258
259 fix up
260 $ echo 'I can haz no commute' > e
261 $ hg resolve --mark e
262 (no more unresolved files)
263 $ hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
264 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
266 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 merging e
268 warning: conflicts during merge.
269 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
270 Fix up the change and run hg histedit --continue
271
272 just continue this time
273 $ hg revert -r 'p1()' e
274 $ hg resolve --mark e
275 (no more unresolved files)
276 $ hg histedit --continue 2>&1 | fixbundle
277 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
278 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
279
280 log after edit
281 $ hg log --graph
282 @ changeset: 5:e7c4f5d4eb75
283 | tag: tip
284 | user: test
285 | date: Thu Jan 01 00:00:00 1970 +0000
286 | summary: f
287 |
288 o changeset: 4:803d1bb561fc
289 | user: test
290 | date: Thu Jan 01 00:00:00 1970 +0000
291 | summary: d
292 |
293 o changeset: 3:65a9a84f33fd
294 | user: test
295 | date: Thu Jan 01 00:00:00 1970 +0000
296 | summary: c
297 |
298 o changeset: 2:da6535b52e45
299 | user: test
300 | date: Thu Jan 01 00:00:00 1970 +0000
301 | summary: b
302 |
303 o changeset: 1:c1f09da44841
304 | user: test
305 | date: Thu Jan 01 00:00:00 1970 +0000
306 | summary: a
307 |
308 o changeset: 0:1715188a53c7
309 user: test
310 date: Thu Jan 01 00:00:00 1970 +0000
311 summary: Initial commit
312
313
314 contents of e
315 $ hg cat e
316 I can haz no commute
317
318 manifest
319 $ hg manifest
320 a
321 b
322 c
323 d
324 e
325 f
326
327 description is taken from rollup target commit
328
329 $ hg log --debug --rev 4
330 changeset: 4:803d1bb561fceac3129ec778db9da249a3106fc3
331 phase: draft
332 parent: 3:65a9a84f33fdeb1ad5679b3941ec885d2b24027b
333 parent: -1:0000000000000000000000000000000000000000
334 manifest: 4:b068a323d969f22af1296ec6a5ea9384cef437ac
335 user: test
336 date: Thu Jan 01 00:00:00 1970 +0000
337 files: d e
338 extra: branch=default
339 extra: histedit_source=00f1c53839651fa5c76d423606811ea5455a79d0,39522b764e3d26103f08bd1fa2ccd3e3d7dbcf4e
340 description:
341 d
342
343
344
345 done with repo r2
346
347 $ cd ..
@@ -105,6 +105,50 b' check histedit_source'
105 105
106 106
107 107
108 rollup will fold without preserving the folded commit's message
109
110 $ hg histedit d2ae7f538514 --commands - 2>&1 <<EOF | fixbundle
111 > pick d2ae7f538514 b
112 > roll ee283cb5f2d5 e
113 > pick 6de59d13424a f
114 > pick 9c277da72c9b d
115 > EOF
116 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
117 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
118 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
119 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
121 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
122
123 log after edit
124 $ hg logt --graph
125 @ 3:c4a9eb7989fc d
126 |
127 o 2:8e03a72b6f83 f
128 |
129 o 1:391ee782c689 b
130 |
131 o 0:cb9a9f314b8b a
132
133
134 description is taken from rollup target commit
135
136 $ hg log --debug --rev 1
137 changeset: 1:391ee782c68930be438ccf4c6a403daedbfbffa5
138 phase: draft
139 parent: 0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
140 parent: -1:0000000000000000000000000000000000000000
141 manifest: 1:b5e112a3a8354e269b1524729f0918662d847c38
142 user: test
143 date: Thu Jan 01 00:00:00 1970 +0000
144 files+: b e
145 extra: branch=default
146 extra: histedit_source=d2ae7f538514cd87c17547b0de4cea71fe1af9fb,ee283cb5f2d5955443f23a27b697a04339e9a39a
147 description:
148 b
149
150
151
108 152 check saving last-message.txt
109 153
110 154 $ cat > $TESTTMP/abortfolding.py <<EOF
@@ -128,9 +172,9 b' check saving last-message.txt'
128 172 > EOF
129 173
130 174 $ rm -f .hg/last-message.txt
131 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle
132 > pick 6de59d13424a f
133 > fold 9c277da72c9b d
175 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF | fixbundle
176 > pick 8e03a72b6f83 f
177 > fold c4a9eb7989fc d
134 178 > EOF
135 179 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
136 180 allow non-folding commit
@@ -57,6 +57,7 b' Enable obsolete'
57 57 # p, pick = use commit
58 58 # e, edit = use commit, but stop for amending
59 59 # f, fold = use commit, but combine it with the one above
60 # r, roll = like fold, but discard this commit's description
60 61 # d, drop = remove commit from history
61 62 # m, mess = edit message without changing commit content
62 63 #
@@ -49,6 +49,7 b' show the edit commands offered by outgoi'
49 49 # p, pick = use commit
50 50 # e, edit = use commit, but stop for amending
51 51 # f, fold = use commit, but combine it with the one above
52 # r, roll = like fold, but discard this commit's description
52 53 # d, drop = remove commit from history
53 54 # m, mess = edit message without changing commit content
54 55 #
@@ -80,6 +81,7 b' show the error from unrelated repos'
80 81 # p, pick = use commit
81 82 # e, edit = use commit, but stop for amending
82 83 # f, fold = use commit, but combine it with the one above
84 # r, roll = like fold, but discard this commit's description
83 85 # d, drop = remove commit from history
84 86 # m, mess = edit message without changing commit content
85 87 #
@@ -103,6 +105,7 b' test sensitivity to branch in URL:'
103 105 # p, pick = use commit
104 106 # e, edit = use commit, but stop for amending
105 107 # f, fold = use commit, but combine it with the one above
108 # r, roll = like fold, but discard this commit's description
106 109 # d, drop = remove commit from history
107 110 # m, mess = edit message without changing commit content
108 111 #
General Comments 0
You need to be logged in to leave comments. Login now