@@ 43,6 43,7 @@ import re
import time
from mercurial.context import changectx
+from mercurial import bookmarks
# =============================================================================
# constants
@@ 79,18 80,11 @@ class RepoInfo(object):
# 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
@@ 126,21 120,6 @@ class RepoInfo(object):
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."""
@@ 193,7 172,8 @@ class NodeInfo(object):
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")
@@ 213,8 193,9 @@ class NodeInfo(object):
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=" ")
@@ 446,12 427,6 @@ def compass(ui, repo, **opts):
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)
# =============================================================================