Mercurial > hg
comparison hgext/rebase.py @ 17046:4116504d1ec4 stable
bookmarks: correctly update current bookmarks on rebase (issue2277)
When you rebased with a currently active bookmark, that bookmark would
always point at the new tip, regardless of what revision it pointed at
before the rebase.
All bookmarks will now point at the equivalent post-rebase commit.
However, the currently active bookmark will cease to be active unless
it points at the new tip post-rebase. Rebase will always leave the
new tip as the working copy parent, which is incompatible with having
an active bookmark that points at some other revision. The common
case should be that the active bookmark will point at the new tip
post-rebase.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Fri, 22 Jun 2012 11:40:31 -0700 |
parents | f8af57c00a29 |
children | fba17a64fa49 |
comparison
equal
deleted
inserted
replaced
17045:52ea9ce5b641 | 17046:4116504d1ec4 |
---|---|
245 targetancestors = set(repo.changelog.ancestors(target)) | 245 targetancestors = set(repo.changelog.ancestors(target)) |
246 targetancestors.add(target) | 246 targetancestors.add(target) |
247 | 247 |
248 # Keep track of the current bookmarks in order to reset them later | 248 # Keep track of the current bookmarks in order to reset them later |
249 currentbookmarks = repo._bookmarks.copy() | 249 currentbookmarks = repo._bookmarks.copy() |
250 activebookmark = repo._bookmarkcurrent | |
251 if activebookmark: | |
252 bookmarks.unsetcurrent(repo) | |
250 | 253 |
251 sortedstate = sorted(state) | 254 sortedstate = sorted(state) |
252 total = len(sortedstate) | 255 total = len(sortedstate) |
253 pos = 0 | 256 pos = 0 |
254 for rev in sortedstate: | 257 for rev in sortedstate: |
334 ui.note(_("rebase completed\n")) | 337 ui.note(_("rebase completed\n")) |
335 if os.path.exists(repo.sjoin('undo')): | 338 if os.path.exists(repo.sjoin('undo')): |
336 util.unlinkpath(repo.sjoin('undo')) | 339 util.unlinkpath(repo.sjoin('undo')) |
337 if skipped: | 340 if skipped: |
338 ui.note(_("%d revisions have been skipped\n") % len(skipped)) | 341 ui.note(_("%d revisions have been skipped\n") % len(skipped)) |
342 | |
343 if (activebookmark and | |
344 repo['tip'].node() == repo._bookmarks[activebookmark]): | |
345 bookmarks.setcurrent(repo, activebookmark) | |
346 | |
339 finally: | 347 finally: |
340 release(lock, wlock) | 348 release(lock, wlock) |
341 | 349 |
342 def checkexternal(repo, state, targetancestors): | 350 def checkexternal(repo, state, targetancestors): |
343 """Check whether one or more external revisions need to be taken in | 351 """Check whether one or more external revisions need to be taken in |
481 mq.seriesdirty = True | 489 mq.seriesdirty = True |
482 mq.savedirty() | 490 mq.savedirty() |
483 | 491 |
484 def updatebookmarks(repo, nstate, originalbookmarks, **opts): | 492 def updatebookmarks(repo, nstate, originalbookmarks, **opts): |
485 'Move bookmarks to their correct changesets' | 493 'Move bookmarks to their correct changesets' |
486 current = repo._bookmarkcurrent | |
487 for k, v in originalbookmarks.iteritems(): | 494 for k, v in originalbookmarks.iteritems(): |
488 if v in nstate: | 495 if v in nstate: |
489 if nstate[v] != nullmerge: | 496 if nstate[v] != nullmerge: |
490 # reset the pointer if the bookmark was moved incorrectly | 497 # update the bookmarks for revs that have moved |
491 if k != current: | 498 repo._bookmarks[k] = nstate[v] |
492 repo._bookmarks[k] = nstate[v] | |
493 | 499 |
494 bookmarks.write(repo) | 500 bookmarks.write(repo) |
495 | 501 |
496 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches, | 502 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches, |
497 external): | 503 external): |