# HG changeset patch # User Oben Sonne # Date 1257291498 -3600 # Wed Nov 04 00:38:18 2009 +0100 # Node ID 53394fbc3bc06c5c1a737e56bb825474f4c849f5 # Parent d001c1cf93b9b7f4d575c16114ee4a3552eeb4e9 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. diff --git a/compass.py b/compass.py --- a/compass.py +++ b/compass.py @@ -38,6 +38,7 @@ """ +import os.path import re import time @@ -78,6 +79,16 @@ # 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] @@ -175,6 +186,7 @@ whether to provide detailed or short output in __str__() """ + self.ri = ri self.ctx = ctx self.verbose = verbose @@ -201,6 +213,8 @@ 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=" ") @@ -428,6 +442,12 @@ 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) # =============================================================================