##// END OF EJS Templates
strip: move bookmarks to nearest ancestor rather than '.'...
Augie Fackler -
r17264:ec7b9bec stable
parent child Browse files
Show More
@@ -1298,10 +1298,20 b' def commit(ui, repo, *pats, **opts):'
1298 editor=editor,
1298 editor=editor,
1299 extra=extra)
1299 extra=extra)
1300
1300
1301 current = repo._bookmarkcurrent
1302 marks = old.bookmarks()
1301 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1303 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1302 if node == old.node():
1304 if node == old.node():
1303 ui.status(_("nothing changed\n"))
1305 ui.status(_("nothing changed\n"))
1304 return 1
1306 return 1
1307 elif marks:
1308 ui.debug('moving bookmarks %r from %s to %s\n' %
1309 (marks, old.hex(), hex(node)))
1310 for bm in marks:
1311 repo._bookmarks[bm] = node
1312 if bm == current:
1313 bookmarks.setcurrent(repo, bm)
1314 bookmarks.write(repo)
1305 else:
1315 else:
1306 e = cmdutil.commiteditor
1316 e = cmdutil.commiteditor
1307 if opts.get('force_editor'):
1317 if opts.get('force_editor'):
@@ -111,6 +111,13 b' def strip(ui, repo, nodelist, backup="al'
111 saverevs.difference_update(descendants)
111 saverevs.difference_update(descendants)
112 savebases = [cl.node(r) for r in saverevs]
112 savebases = [cl.node(r) for r in saverevs]
113 stripbases = [cl.node(r) for r in tostrip]
113 stripbases = [cl.node(r) for r in tostrip]
114 rset = ' or '.join([str(r) for r in tostrip])
115 newbmtarget = repo.revs('sort(heads(ancestors(%r) - (%r)), -rev)',
116 rset, rset)
117 if newbmtarget:
118 newbmtarget = newbmtarget[0]
119 else:
120 newbmtarget = '.'
114
121
115 bm = repo._bookmarks
122 bm = repo._bookmarks
116 updatebm = []
123 updatebm = []
@@ -174,7 +181,7 b' def strip(ui, repo, nodelist, backup="al'
174 ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
181 ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
175
182
176 for m in updatebm:
183 for m in updatebm:
177 bm[m] = repo['.'].node()
184 bm[m] = repo[newbmtarget].node()
178 bookmarks.write(repo)
185 bookmarks.write(repo)
179 except: # re-raises
186 except: # re-raises
180 if backupfile:
187 if backupfile:
@@ -192,4 +199,3 b' def strip(ui, repo, nodelist, backup="al'
192 # Multiple branches involved in strip. Will allow branchcache to become
199 # Multiple branches involved in strip. Will allow branchcache to become
193 # invalid and later on rebuilt from scratch
200 # invalid and later on rebuilt from scratch
194 repo.destroyed()
201 repo.destroyed()
195
@@ -60,8 +60,8 b' strip to revision 1'
60 list bookmarks
60 list bookmarks
61
61
62 $ hg book
62 $ hg book
63 test 1:8cf31af87a2b
63 test 0:5c9ad3787638
64 test2 1:8cf31af87a2b
64 test2 0:5c9ad3787638
65
65
66 immediate rollback and reentrancy issue
66 immediate rollback and reentrancy issue
67
67
@@ -390,3 +390,70 b' test missing revisions'
390 $ echo "925d80f479bc z" > .hg/bookmarks
390 $ echo "925d80f479bc z" > .hg/bookmarks
391 $ hg book
391 $ hg book
392 no bookmarks set
392 no bookmarks set
393
394 test stripping a non-checked-out but bookmarked revision
395
396 $ hg --config extensions.graphlog= log --graph
397 o changeset: 4:9ba5f110a0b3
398 | branch: test
399 | tag: tip
400 | parent: 2:db815d6d32e6
401 | user: test
402 | date: Thu Jan 01 00:00:00 1970 +0000
403 | summary: y
404 |
405 | @ changeset: 3:125c9a1d6df6
406 |/ user: test
407 | date: Thu Jan 01 00:00:00 1970 +0000
408 | summary: x
409 |
410 o changeset: 2:db815d6d32e6
411 | parent: 0:f7b1eb17ad24
412 | user: test
413 | date: Thu Jan 01 00:00:00 1970 +0000
414 | summary: 2
415 |
416 | o changeset: 1:925d80f479bb
417 |/ user: test
418 | date: Thu Jan 01 00:00:00 1970 +0000
419 | summary: 1
420 |
421 o changeset: 0:f7b1eb17ad24
422 user: test
423 date: Thu Jan 01 00:00:00 1970 +0000
424 summary: 0
425
426 $ hg book should-end-on-two
427 $ hg co --clean 4
428 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
429 $ hg book four
430 $ hg --config extensions.mq= strip 3
431 saved backup bundle to * (glob)
432 should-end-on-two should end up pointing to revision 2, as that's the
433 tipmost surviving ancestor of the stripped revision.
434 $ hg --config extensions.graphlog= log --graph
435 @ changeset: 3:9ba5f110a0b3
436 | branch: test
437 | bookmark: four
438 | tag: tip
439 | user: test
440 | date: Thu Jan 01 00:00:00 1970 +0000
441 | summary: y
442 |
443 o changeset: 2:db815d6d32e6
444 | bookmark: should-end-on-two
445 | parent: 0:f7b1eb17ad24
446 | user: test
447 | date: Thu Jan 01 00:00:00 1970 +0000
448 | summary: 2
449 |
450 | o changeset: 1:925d80f479bb
451 |/ user: test
452 | date: Thu Jan 01 00:00:00 1970 +0000
453 | summary: 1
454 |
455 o changeset: 0:f7b1eb17ad24
456 user: test
457 date: Thu Jan 01 00:00:00 1970 +0000
458 summary: 0
459
General Comments 0
You need to be logged in to leave comments. Login now