mercurial/bookmarks.py
changeset 24986 fb9b7b937b3e
parent 24962 eecd48369caa
child 25081 7642f119c2a2
equal deleted inserted replaced
24985:20bff5d09018 24986:fb9b7b937b3e
   163             if inst.errno != errno.ENOENT:
   163             if inst.errno != errno.ENOENT:
   164                 raise
   164                 raise
   165     finally:
   165     finally:
   166         wlock.release()
   166         wlock.release()
   167 
   167 
   168 def iscurrent(repo, mark=None, parents=None):
   168 def isactivewdirparent(repo):
   169     '''Tell whether the current bookmark is also active
   169     """
   170 
   170     Tell whether the 'active' bookmark (the one that follows new commits)
   171     I.e., the bookmark listed in .hg/bookmarks.current also points to a
   171     points to one of the parents of the current working directory (wdir).
   172     parent of the working directory.
   172 
   173     '''
   173     While this is normally the case, it can on occasion be false; for example,
   174     if not mark:
   174     immediately after a pull, the active bookmark can be moved to point
   175         mark = repo._activebookmark
   175     to a place different than the wdir. This is solved by running `hg update`.
   176     if not parents:
   176     """
   177         parents = [p.node() for p in repo[None].parents()]
   177     mark = repo._activebookmark
   178     marks = repo._bookmarks
   178     marks = repo._bookmarks
       
   179     parents = [p.node() for p in repo[None].parents()]
   179     return (mark in marks and marks[mark] in parents)
   180     return (mark in marks and marks[mark] in parents)
   180 
   181 
   181 def deletedivergent(repo, deletefrom, bm):
   182 def deletedivergent(repo, deletefrom, bm):
   182     '''Delete divergent versions of bm on nodes in deletefrom.
   183     '''Delete divergent versions of bm on nodes in deletefrom.
   183 
   184 
   199     '''Return a tuple (targetrev, movemarkfrom) indicating the rev to
   200     '''Return a tuple (targetrev, movemarkfrom) indicating the rev to
   200     check out and where to move the active bookmark from, if needed.'''
   201     check out and where to move the active bookmark from, if needed.'''
   201     movemarkfrom = None
   202     movemarkfrom = None
   202     if checkout is None:
   203     if checkout is None:
   203         curmark = repo._activebookmark
   204         curmark = repo._activebookmark
   204         if iscurrent(repo):
   205         if isactivewdirparent(repo):
   205             movemarkfrom = repo['.'].node()
   206             movemarkfrom = repo['.'].node()
   206         elif curmark:
   207         elif curmark:
   207             ui.status(_("updating to active bookmark %s\n") % curmark)
   208             ui.status(_("updating to active bookmark %s\n") % curmark)
   208             checkout = curmark
   209             checkout = curmark
   209     return (checkout, movemarkfrom)
   210     return (checkout, movemarkfrom)