Commits

Oben Sonne committed 7fb0595

Update bookmarks handling for Mercurial 1.8.1

Comments (0)

Files changed (1)

 import time
 
 from mercurial.context import changectx
+from mercurial import bookmarks
 
 # =============================================================================
 # constants
         # all head revisions
         self.head_revs = _csi2rev(repo, repo.heads())
         
-        # name of currently active bookmark (if enabled)
-        self.bm_track_current = repo.ui.configbool("bookmarks", "track.current")
-        bm_current_file = os.path.join(repo.root, ".hg", "bookmarks.current")
-        if self.bm_track_current and os.path.exists(bm_current_file):
-            fp = open(bm_current_file)
-            self.bm_current = fp.read()
-            fp.close()
-        else:                
-            self.bm_current = None  
+        # name of currently active bookmark
+        self.bm_current = bookmarks.readcurrent(repo)
         
         # all bookmarked revisions
-        bm_names = self.tags_and_bookmarks()[1]
+        bm_names = bookmarks.read(repo).keys()
         self.bm_revs = [repo[x].rev() for x in bm_names]
         
         # branch info objects, heads and tips
             revs.remove(ctx.rev())
         return revs
     
-    def tags_and_bookmarks(self, csi=None):
-        """Get tags and bookmarks of the repository or a specific changeset."""
-        
-        if csi is None:
-            tbm = self.repo.tags()
-        elif isinstance(csi, changectx):
-            tbm = csi.tags()
-        else:
-            tbm = self.repo[csi].tags()
-        
-        bm = [x for x in tbm if x != "tip" and self.repo.tagtype(x) is None]
-        tags = [x for x in tbm if not x in bm]
-        
-        return tags, bm
-
 class BranchInfo(object):
     """Various information about a branch."""
     
         self.rev = ctx.rev()
         self.branch = ctx.branch()
         self.bi = ri.bi_map[self.branch]
-        self.tags, self.bookmarks = ri.tags_and_bookmarks(ctx)
+        self.bookmarks = ctx.bookmarks()
+        self.tags = ctx.tags()
         self.labels = []
         if self.bi.closed:
             self.labels.append("closed")
         td["age"] = self.__format_age()
         td["branch"] = self.branch
         td["bookmarks"] = _slist(self.bookmarks, pre="(", suf=")")
-        td["bookmarks"] = re.sub(r'([( ])(%s)([ )])' % self.ri.bm_current,
-                                 r'\1\2*\3', td["bookmarks"])
+        if self.ctx == self.ri.repo["."]:
+            td["bookmarks"] = re.sub(r'([( ])(%s)([ )])' % self.ri.bm_current,
+                                     r'\1\2*\3', td["bookmarks"])
         td["tags"] = _slist(self.tags, suf=" ")
         self.labels = [("@%s" % x) for x in self.labels]
         td["labels"] = _slist(self.labels, suf=" ")
     if not ni.rev in ri.head_revs:
         s += _header("Next commit will create a new head!", fc="-")
     
-    ### sleeping bookmarks warning  ###
-    
-    if ni.bookmarks and ri.bm_track_current and not ri.bm_current:
-        s += _header("None of your bookmarks (%s) will move on commit!" %
-                     ' '.join(ni.bookmarks), fc="-")
-    
     ui.write(s)
     
 # =============================================================================