Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bookmarks.py @ 32420:b9942bc6b292
localrepo: extract bookmarkheads method to bookmarks.py
This method is only used internally by destutil, and it's obscure
enough I'm willing to just move it without a deprecation warning,
especially since the new method has more constrained functionality.
Design-wise I'd also like to get active bookmark handling folded into
the bookmark store, so that we don't squirrel away an extra attribute
for the active bookmark on the repository object.
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 18 May 2017 16:43:56 -0400 |
parents | 8a32d6352196 |
children | b5613bda454e |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Sat May 20 20:50:29 2017 -0400 +++ b/mercurial/bookmarks.py Thu May 18 16:43:56 2017 -0400 @@ -226,6 +226,28 @@ deleted = True return deleted +def headsforactive(repo): + """Given a repo with an active bookmark, return divergent bookmark nodes. + + Args: + repo: A repository with an active bookmark. + + Returns: + A list of binary node ids that is the full list of other + revisions with bookmarks divergent from the active bookmark. If + there were no divergent bookmarks, then this list will contain + only one entry. + """ + if not repo._activebookmark: + raise ValueError( + 'headsforactive() only makes sense with an active bookmark') + name = repo._activebookmark.split('@', 1)[0] + heads = [] + for mark, n in repo._bookmarks.iteritems(): + if mark.split('@', 1)[0] == name: + heads.append(n) + return heads + def calculateupdate(ui, repo, checkout): '''Return a tuple (targetrev, movemarkfrom) indicating the rev to check out and where to move the active bookmark from, if needed.'''