Mercurial > public > mercurial-scm > evolve
diff hgext3rd/topic/__init__.py @ 2669:b933a8068c17
topic: add some initial support for using stack on named branch
Stack is a useful command that can make sense in other context. The current
support is hacky and awful, but we have something!
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 28 Jun 2017 02:45:57 +0200 |
parents | 1d2c66dc4ee3 |
children | 8cdee1b9ee92 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Wed Jun 28 01:58:09 2017 +0200 +++ b/hgext3rd/topic/__init__.py Wed Jun 28 02:45:57 2017 +0200 @@ -122,19 +122,29 @@ context.basectx.topic = _contexttopic topicrev = re.compile(r'^t\d+$') +branchrev = re.compile(r'^b\d+$') def _namemap(repo, name): + revs = None if topicrev.match(name): idx = int(name[1:]) - topic = repo.currenttopic - if not topic: + ttype = 'topic' + tname = topic = repo.currenttopic + if not tname: raise error.Abort(_('cannot resolve "%s": no active topic') % name) revs = list(stack.getstack(repo, topic=topic)) + elif branchrev.match(name): + ttype = 'branch' + idx = int(name[1:]) + tname = branch = repo[None].branch() + revs = list(stack.getstack(repo, branch=branch)) + + if revs is not None: try: r = revs[idx - 1] except IndexError: - msg = _('cannot resolve "%s": topic "%s" has only %d changesets') - raise error.Abort(msg % (name, topic, len(revs))) + msg = _('cannot resolve "%s": %s "%s" has only %d changesets') + raise error.Abort(msg % (name, ttype, tname, len(revs))) return [repo[r].node()] if name not in repo.topics: return [] @@ -282,7 +292,7 @@ topic = repo.currenttopic if not topic: raise error.Abort(_('no active topic to list')) - return stack.showstack(ui, repo, topic, opts) + return stack.showstack(ui, repo, topic=topic, opts=opts) if rev: if not obsolete.isenabled(repo, obsolete.createmarkersopt): @@ -309,10 +319,13 @@ List the current topic by default.""" if not topic: + topic = None + branch = None + if topic is None and repo.currenttopic: topic = repo.currenttopic - if not topic: - raise error.Abort(_('no active topic to list')) - return stack.showstack(ui, repo, topic=topic, opts=opts) + if topic is None: + branch = repo[None].branch() + return stack.showstack(ui, repo, branch=branch, topic=topic, opts=opts) def _changecurrenttopic(repo, newtopic): """changes the current topic."""