Commits

Oben Sonne  committed 53394fb

Conider bookmarks track.current option

If the track.current option if the bookmarks extensions is enabled the
acitve bookmark is annotated with a '*'. Furhter, when being at a
bookmarked revisions with no active bookmark, a warning is printed that
none of the bookmarks will move on commit.

Fixes issue #1.

  • Participants
  • Parent commits d001c1c

Comments (0)

Files changed (1)

 
 """
 
+import os.path
 import re
 import time
 
         # all head revisions
         self.head_revs = _csi2rev(repo, repo.heads())
         
+        # name of currently active bookmark (if enabled)
+        self.bm_track_current = repo.ui.config("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  
+        
         # all bookmarked revisions
         bm_names = self.tags_and_bookmarks()[1]
         self.bm_revs = [repo[x].rev() for x in bm_names]
             whether to provide detailed or short output in __str__()
             
         """
+        self.ri = ri
         self.ctx = ctx
         self.verbose = verbose
 
         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"])
         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)
     
 # =============================================================================