Mercurial > evolve
view src/topic/revset.py @ 1885:d49f75eab6a3
topic: take topic in account for all branch head computation
This changeset introduce a "topicmap" that is tracking not just the head of all
branches, but the heads of all branch+topic pair. Including the head of the part
of the branch without any topic. In practice this means that BRANCHNAME now
resolve to the tipmost part for the branch without topic and impact various
other logic like head checking during push and default destination for update and
merge (these aspect will need adjustment in later changesets).
The on-the-fly-temporary-monkey-patching process is pretty horrible, but allow
to move forward without waiting on having core patched.
We use 'branch:topic' as the branchmap key, this is a small and easy hack that
help use a lot for (future) support of heads discovery/checking and on disc
cache. I'm not sure it is worthwhile to improve this until an implementation
into core.
Note that this changeset change the branchmap in all cases, including during
exchange, see next changeset for improved behavior.
We also currently have the on-disk cache disabled because the core branchmap is
lacking phase information in its cache key. This will get done in a later
changesets
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 12 Mar 2016 15:36:17 +0000 |
parents | 8dd5200b4086 |
children |
line wrap: on
line source
from mercurial import revset from mercurial import util from . import constants, destination try: mkmatcher = revset._stringmatcher except AttributeError: mkmatcher = util.stringmatcher def topicset(repo, subset, x): """`topic([topic])` Specified topic or all changes with any topic specified. If `topic` starts with `re:` the remainder of the name is treated as a regular expression. TODO: make `topic(revset)` work the same as `branch(revset)`. """ args = revset.getargs(x, 0, 1, 'topic takes one or no arguments') if args: # match a specific topic topic = revset.getstring(args[0], 'topic() argument must be a string') if topic == '.': topic = repo['.'].extra().get('topic', '') _kind, _pattern, matcher = mkmatcher(topic) else: matcher = lambda t: bool(t) drafts = subset.filter(lambda r: repo[r].mutable()) return drafts.filter( lambda r: matcher(repo[r].extra().get(constants.extrakey, ''))) def ngtipset(repo, subset, x): """`ngtip([branch])` The untopiced tip. Name is horrible so that people change it. """ args = revset.getargs(x, 1, 1, 'topic takes one') # match a specific topic branch = revset.getstring(args[0], 'ngtip() argument must be a string') if branch == '.': branch = repo['.'].branch() return subset & destination.ngtip(repo, branch) def modsetup(): revset.symbols.update({'topic': topicset}) revset.symbols.update({'ngtip': ngtipset})