hgext/bookmarks.py
changeset 13352 f9cd37fca5ba
parent 13351 6c5368cd2df9
child 13353 689bf32b3bbd
equal deleted inserted replaced
13351:6c5368cd2df9 13352:f9cd37fca5ba
   162 def reposetup(ui, repo):
   162 def reposetup(ui, repo):
   163     if not repo.local():
   163     if not repo.local():
   164         return
   164         return
   165 
   165 
   166     class bookmark_repo(repo.__class__):
   166     class bookmark_repo(repo.__class__):
   167 
       
   168         @util.propertycache
   167         @util.propertycache
   169         def _bookmarks(self):
   168         def _bookmarks(self):
   170             return bookmarks.read(self)
   169             return bookmarks.read(self)
   171 
   170 
   172         @util.propertycache
   171         @util.propertycache
   184 
   183 
   185         def lookup(self, key):
   184         def lookup(self, key):
   186             if key in self._bookmarks:
   185             if key in self._bookmarks:
   187                 key = self._bookmarks[key]
   186                 key = self._bookmarks[key]
   188             return super(bookmark_repo, self).lookup(key)
   187             return super(bookmark_repo, self).lookup(key)
   189 
       
   190         def _bookmarksupdate(self, parents, node):
       
   191             marks = self._bookmarks
       
   192             update = False
       
   193             if ui.configbool('bookmarks', 'track.current'):
       
   194                 mark = self._bookmarkcurrent
       
   195                 if mark and marks[mark] in parents:
       
   196                     marks[mark] = node
       
   197                     update = True
       
   198             else:
       
   199                 for mark, n in marks.items():
       
   200                     if n in parents:
       
   201                         marks[mark] = node
       
   202                         update = True
       
   203             if update:
       
   204                 bookmarks.write(self)
       
   205 
   188 
   206         def commitctx(self, ctx, error=False):
   189         def commitctx(self, ctx, error=False):
   207             """Add a revision to the repository and
   190             """Add a revision to the repository and
   208             move the bookmark"""
   191             move the bookmark"""
   209             wlock = self.wlock() # do both commit and bookmark with lock held
   192             wlock = self.wlock() # do both commit and bookmark with lock held
   213                     return None
   196                     return None
   214                 parents = self.changelog.parents(node)
   197                 parents = self.changelog.parents(node)
   215                 if parents[1] == nullid:
   198                 if parents[1] == nullid:
   216                     parents = (parents[0],)
   199                     parents = (parents[0],)
   217 
   200 
   218                 self._bookmarksupdate(parents, node)
   201                 bookmarks.update(self, parents, node)
   219                 return node
   202                 return node
   220             finally:
   203             finally:
   221                 wlock.release()
   204                 wlock.release()
   222 
   205 
   223         def pull(self, remote, heads=None, force=False):
   206         def pull(self, remote, heads=None, force=False):
   273             if result > 1:
   256             if result > 1:
   274                 # We have more heads than before
   257                 # We have more heads than before
   275                 return result
   258                 return result
   276             node = self.changelog.tip()
   259             node = self.changelog.tip()
   277             parents = self.dirstate.parents()
   260             parents = self.dirstate.parents()
   278             self._bookmarksupdate(parents, node)
   261             bookmarks.update(self, parents, node)
   279             return result
   262             return result
   280 
   263 
   281         def _findtags(self):
   264         def _findtags(self):
   282             """Merge bookmarks with normal tags"""
   265             """Merge bookmarks with normal tags"""
   283             (tags, tagtypes) = super(bookmark_repo, self)._findtags()
   266             (tags, tagtypes) = super(bookmark_repo, self)._findtags()