##// 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 # p, pick = use commit
36 # p, pick = use commit
37 # e, edit = use commit, but stop for amending
37 # e, edit = use commit, but stop for amending
38 # f, fold = use commit, but combine it with the one above
38 # f, fold = use commit, but combine it with the one above
39 # r, roll = like fold, but discard this commit's description
39 # d, drop = remove commit from history
40 # d, drop = remove commit from history
40 # m, mess = edit message without changing commit content
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 # p, pick = use commit
58 # p, pick = use commit
58 # e, edit = use commit, but stop for amending
59 # e, edit = use commit, but stop for amending
59 # f, fold = use commit, but combine it with the one above
60 # f, fold = use commit, but combine it with the one above
61 # r, roll = like fold, but discard this commit's description
60 # d, drop = remove commit from history
62 # d, drop = remove commit from history
61 # m, mess = edit message without changing commit content
63 # m, mess = edit message without changing commit content
62 #
64 #
@@ -179,6 +181,7 b' editcomment = _("""# Edit history betwee'
179 # p, pick = use commit
181 # p, pick = use commit
180 # e, edit = use commit, but stop for amending
182 # e, edit = use commit, but stop for amending
181 # f, fold = use commit, but combine it with the one above
183 # f, fold = use commit, but combine it with the one above
184 # r, roll = like fold, but discard this commit's description
182 # d, drop = remove commit from history
185 # d, drop = remove commit from history
183 # m, mess = edit message without changing commit content
186 # m, mess = edit message without changing commit content
184 #
187 #
@@ -291,7 +294,9 b' def collapse(repo, first, last, commitop'
291 extra = commitopts.get('extra')
294 extra = commitopts.get('extra')
292
295
293 parents = (first.p1().node(), first.p2().node())
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 new = context.memctx(repo,
300 new = context.memctx(repo,
296 parents=parents,
301 parents=parents,
297 text=message,
302 text=message,
@@ -333,6 +338,11 b' def edit(ui, repo, ctx, ha, opts):'
333 _('Make changes as needed, you may commit or record as needed now.\n'
338 _('Make changes as needed, you may commit or record as needed now.\n'
334 'When you are finished, run hg histedit --continue to resume.'))
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 def fold(ui, repo, ctx, ha, opts):
346 def fold(ui, repo, ctx, ha, opts):
337 oldctx = repo[ha]
347 oldctx = repo[ha]
338 hg.update(repo, ctx.node())
348 hg.update(repo, ctx.node())
@@ -360,10 +370,13 b' def finishfold(ui, repo, ctx, oldctx, ne'
360 username = ui.username()
370 username = ui.username()
361 commitopts['user'] = username
371 commitopts['user'] = username
362 # commit message
372 # commit message
363 newmessage = '\n***\n'.join(
373 if opts.get('rollup'):
364 [ctx.description()] +
374 newmessage = ctx.description()
365 [repo[r].description() for r in internalchanges] +
375 else:
366 [oldctx.description()]) + '\n'
376 newmessage = '\n***\n'.join(
377 [ctx.description()] +
378 [repo[r].description() for r in internalchanges] +
379 [oldctx.description()]) + '\n'
367 commitopts['message'] = newmessage
380 commitopts['message'] = newmessage
368 # date
381 # date
369 commitopts['date'] = max(ctx.date(), oldctx.date())
382 commitopts['date'] = max(ctx.date(), oldctx.date())
@@ -444,6 +457,8 b" actiontable = {'p': pick,"
444 'edit': edit,
457 'edit': edit,
445 'f': fold,
458 'f': fold,
446 'fold': fold,
459 'fold': fold,
460 'r': rollup,
461 'roll': rollup,
447 'd': drop,
462 'd': drop,
448 'drop': drop,
463 'drop': drop,
449 'm': message,
464 'm': message,
@@ -679,7 +694,7 b' def bootstrapcontinue(ui, repo, parentct'
679 m, a, r, d = repo.status()[:4]
694 m, a, r, d = repo.status()[:4]
680 if m or a or r or d:
695 if m or a or r or d:
681 # prepare the message for the commit to comes
696 # prepare the message for the commit to comes
682 if action in ('f', 'fold'):
697 if action in ('f', 'fold', 'r', 'roll'):
683 message = 'fold-temp-revision %s' % currentnode
698 message = 'fold-temp-revision %s' % currentnode
684 else:
699 else:
685 message = ctx.description()
700 message = ctx.description()
@@ -702,15 +717,19 b' def bootstrapcontinue(ui, repo, parentct'
702 # to parent.
717 # to parent.
703 replacements.append((ctx.node(), tuple(newchildren)))
718 replacements.append((ctx.node(), tuple(newchildren)))
704
719
705 if action in ('f', 'fold'):
720 if action in ('f', 'fold', 'r', 'roll'):
706 if newchildren:
721 if newchildren:
707 # finalize fold operation if applicable
722 # finalize fold operation if applicable
708 if new is None:
723 if new is None:
709 new = newchildren[-1]
724 new = newchildren[-1]
710 else:
725 else:
711 newchildren.pop() # remove new from internal changes
726 newchildren.pop() # remove new from internal changes
712 parentctx, repl = finishfold(ui, repo, parentctx, ctx, new, opts,
727 foldopts = opts
713 newchildren)
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 replacements.extend(repl)
733 replacements.extend(repl)
715 else:
734 else:
716 # newchildren is empty if the fold did not result in any commit
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 # p, pick = use commit
57 # p, pick = use commit
58 # e, edit = use commit, but stop for amending
58 # e, edit = use commit, but stop for amending
59 # f, fold = use commit, but combine it with the one above
59 # f, fold = use commit, but combine it with the one above
60 # r, roll = like fold, but discard this commit's description
60 # d, drop = remove commit from history
61 # d, drop = remove commit from history
61 # m, mess = edit message without changing commit content
62 # m, mess = edit message without changing commit content
62 #
63 #
@@ -255,6 +256,7 b' Test that trimming description using mul'
255 # p, pick = use commit
256 # p, pick = use commit
256 # e, edit = use commit, but stop for amending
257 # e, edit = use commit, but stop for amending
257 # f, fold = use commit, but combine it with the one above
258 # f, fold = use commit, but combine it with the one above
259 # r, roll = like fold, but discard this commit's description
258 # d, drop = remove commit from history
260 # d, drop = remove commit from history
259 # m, mess = edit message without changing commit content
261 # m, mess = edit message without changing commit content
260 #
262 #
@@ -73,6 +73,7 b''
73 # p, pick = use commit
73 # p, pick = use commit
74 # e, edit = use commit, but stop for amending
74 # e, edit = use commit, but stop for amending
75 # f, fold = use commit, but combine it with the one above
75 # f, fold = use commit, but combine it with the one above
76 # r, roll = like fold, but discard this commit's description
76 # d, drop = remove commit from history
77 # d, drop = remove commit from history
77 # m, mess = edit message without changing commit content
78 # m, mess = edit message without changing commit content
78 #
79 #
@@ -133,6 +134,7 b''
133 # p, pick = use commit
134 # p, pick = use commit
134 # e, edit = use commit, but stop for amending
135 # e, edit = use commit, but stop for amending
135 # f, fold = use commit, but combine it with the one above
136 # f, fold = use commit, but combine it with the one above
137 # r, roll = like fold, but discard this commit's description
136 # d, drop = remove commit from history
138 # d, drop = remove commit from history
137 # m, mess = edit message without changing commit content
139 # m, mess = edit message without changing commit content
138 #
140 #
@@ -67,6 +67,7 b' show the edit commands offered'
67 # p, pick = use commit
67 # p, pick = use commit
68 # e, edit = use commit, but stop for amending
68 # e, edit = use commit, but stop for amending
69 # f, fold = use commit, but combine it with the one above
69 # f, fold = use commit, but combine it with the one above
70 # r, roll = like fold, but discard this commit's description
70 # d, drop = remove commit from history
71 # d, drop = remove commit from history
71 # m, mess = edit message without changing commit content
72 # m, mess = edit message without changing commit content
72 #
73 #
@@ -344,6 +345,7 b' Verify that revsetalias entries work wit'
344 # p, pick = use commit
345 # p, pick = use commit
345 # e, edit = use commit, but stop for amending
346 # e, edit = use commit, but stop for amending
346 # f, fold = use commit, but combine it with the one above
347 # f, fold = use commit, but combine it with the one above
348 # r, roll = like fold, but discard this commit's description
347 # d, drop = remove commit from history
349 # d, drop = remove commit from history
348 # m, mess = edit message without changing commit content
350 # m, mess = edit message without changing commit content
349 #
351 #
@@ -183,3 +183,165 b' manifest'
183 f
183 f
184
184
185 $ cd ..
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 check saving last-message.txt
152 check saving last-message.txt
109
153
110 $ cat > $TESTTMP/abortfolding.py <<EOF
154 $ cat > $TESTTMP/abortfolding.py <<EOF
@@ -128,9 +172,9 b' check saving last-message.txt'
128 > EOF
172 > EOF
129
173
130 $ rm -f .hg/last-message.txt
174 $ rm -f .hg/last-message.txt
131 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle
175 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 8e03a72b6f83 --commands - 2>&1 <<EOF | fixbundle
132 > pick 6de59d13424a f
176 > pick 8e03a72b6f83 f
133 > fold 9c277da72c9b d
177 > fold c4a9eb7989fc d
134 > EOF
178 > EOF
135 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
179 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
136 allow non-folding commit
180 allow non-folding commit
@@ -57,6 +57,7 b' Enable obsolete'
57 # p, pick = use commit
57 # p, pick = use commit
58 # e, edit = use commit, but stop for amending
58 # e, edit = use commit, but stop for amending
59 # f, fold = use commit, but combine it with the one above
59 # f, fold = use commit, but combine it with the one above
60 # r, roll = like fold, but discard this commit's description
60 # d, drop = remove commit from history
61 # d, drop = remove commit from history
61 # m, mess = edit message without changing commit content
62 # m, mess = edit message without changing commit content
62 #
63 #
@@ -49,6 +49,7 b' show the edit commands offered by outgoi'
49 # p, pick = use commit
49 # p, pick = use commit
50 # e, edit = use commit, but stop for amending
50 # e, edit = use commit, but stop for amending
51 # f, fold = use commit, but combine it with the one above
51 # f, fold = use commit, but combine it with the one above
52 # r, roll = like fold, but discard this commit's description
52 # d, drop = remove commit from history
53 # d, drop = remove commit from history
53 # m, mess = edit message without changing commit content
54 # m, mess = edit message without changing commit content
54 #
55 #
@@ -80,6 +81,7 b' show the error from unrelated repos'
80 # p, pick = use commit
81 # p, pick = use commit
81 # e, edit = use commit, but stop for amending
82 # e, edit = use commit, but stop for amending
82 # f, fold = use commit, but combine it with the one above
83 # f, fold = use commit, but combine it with the one above
84 # r, roll = like fold, but discard this commit's description
83 # d, drop = remove commit from history
85 # d, drop = remove commit from history
84 # m, mess = edit message without changing commit content
86 # m, mess = edit message without changing commit content
85 #
87 #
@@ -103,6 +105,7 b' test sensitivity to branch in URL:'
103 # p, pick = use commit
105 # p, pick = use commit
104 # e, edit = use commit, but stop for amending
106 # e, edit = use commit, but stop for amending
105 # f, fold = use commit, but combine it with the one above
107 # f, fold = use commit, but combine it with the one above
108 # r, roll = like fold, but discard this commit's description
106 # d, drop = remove commit from history
109 # d, drop = remove commit from history
107 # m, mess = edit message without changing commit content
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