##// END OF EJS Templates
update: update to current bookmark if it moved out from under us (issue3682)...
Kevin Bullock -
r18471:2096e025 stable
parent child Browse files
Show More
@@ -134,6 +134,19 b' def unsetcurrent(repo):'
134 finally:
134 finally:
135 wlock.release()
135 wlock.release()
136
136
137 def iscurrent(repo, mark=None, parents=None):
138 '''Tell whether the current bookmark is also active
139
140 I.e., the bookmark listed in .hg/bookmarks.current also points to a
141 parent of the working directory.
142 '''
143 if not mark:
144 mark = repo._bookmarkcurrent
145 if not parents:
146 parents = [p.node() for p in repo[None].parents()]
147 marks = repo._bookmarks
148 return (mark in marks and marks[mark] in parents)
149
137 def updatecurrentbookmark(repo, oldnode, curbranch):
150 def updatecurrentbookmark(repo, oldnode, curbranch):
138 try:
151 try:
139 return update(repo, oldnode, repo.branchtip(curbranch))
152 return update(repo, oldnode, repo.branchtip(curbranch))
@@ -5961,7 +5961,12 b' def update(ui, repo, node=None, rev=None'
5961 # with no argument, we also move the current bookmark, if any
5961 # with no argument, we also move the current bookmark, if any
5962 movemarkfrom = None
5962 movemarkfrom = None
5963 if rev is None:
5963 if rev is None:
5964 curmark = repo._bookmarkcurrent
5965 if bookmarks.iscurrent(repo):
5964 movemarkfrom = repo['.'].node()
5966 movemarkfrom = repo['.'].node()
5967 elif curmark:
5968 ui.status(_("updating to active bookmark %s\n") % curmark)
5969 rev = curmark
5965
5970
5966 # if we defined a bookmark, we have to remember the original bookmark name
5971 # if we defined a bookmark, we have to remember the original bookmark name
5967 brev = rev
5972 brev = rev
@@ -458,7 +458,11 b' create bundle with two heads'
458 adding file changes
458 adding file changes
459 added 2 changesets with 2 changes to 2 files (+1 heads)
459 added 2 changesets with 2 changes to 2 files (+1 heads)
460 (run 'hg heads' to see heads, 'hg merge' to merge)
460 (run 'hg heads' to see heads, 'hg merge' to merge)
461
462 update to current bookmark if it's not the parent
463
461 $ hg update
464 $ hg update
465 updating to active bookmark Z
462 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
466 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
463 $ hg bookmarks
467 $ hg bookmarks
464 X2 1:925d80f479bb
468 X2 1:925d80f479bb
General Comments 0
You need to be logged in to leave comments. Login now