--- a/hgext3rd/topic/__init__.py Fri Sep 01 17:37:47 2017 +0200
+++ b/hgext3rd/topic/__init__.py Fri Sep 01 17:53:14 2017 +0200
@@ -310,7 +310,7 @@
@command('topics', [
('', 'clear', False, 'clear active topic if any'),
- ('r', 'rev', '', 'revset of existing revisions', _('REV')),
+ ('r', 'rev', [], 'revset of existing revisions', _('REV')),
('l', 'list', False, 'show the stack of changeset in the topic'),
('', 'age', False, 'show when you last touched the topics'),
('', 'current', None, 'display the current topic only'),
@@ -354,6 +354,10 @@
if clear and topic:
raise error.Abort(_("cannot use --clear when setting a topic"))
+ touchedrevs = set()
+ if rev:
+ touchedrevs = scmutil.revrange(repo, rev)
+
if topic:
topic = topic.strip()
if not topic:
@@ -370,7 +374,7 @@
raise error.Abort(_('no active topic to list'))
return stack.showstack(ui, repo, topic=topic, opts=opts)
- if rev:
+ if touchedrevs:
if not obsolete.isenabled(repo, obsolete.createmarkersopt):
raise error.Abort(_('must have obsolete enabled to change topics'))
if clear:
@@ -379,14 +383,14 @@
topic = repo.currenttopic
elif not topic:
raise error.Abort('changing topic requires a topic name or --clear')
- if any(not c.mutable() for c in repo.set('%r and public()', rev)):
+ if repo.revs('%ld and public()', touchedrevs):
raise error.Abort("can't change topic of a public change")
wl = l = txn = None
try:
wl = repo.wlock()
l = repo.lock()
txn = repo.transaction('rewrite-topics')
- rewrote = _changetopics(ui, repo, rev, topic)
+ rewrote = _changetopics(ui, repo, touchedrevs, topic)
txn.close()
ui.status('changed topic on %d changes\n' % rewrote)
finally:
@@ -446,7 +450,7 @@
if repo.vfs.exists('topic'):
repo.vfs.unlink('topic')
-def _changetopics(ui, repo, revset, newtopic):
+def _changetopics(ui, repo, revs, newtopic):
""" Changes topic to newtopic of all the revisions in the revset and return
the count of revisions whose topic has been changed.
"""
@@ -454,7 +458,9 @@
p1 = None
p2 = None
successors = {}
- for c in repo.set('%r', revset):
+ for r in revs:
+ c = repo[r]
+
def filectxfn(repo, ctx, path):
try:
return c[path]