diff hgext3rd/topic/__init__.py @ 2982:fef934b7ed86

topic: add a --topic option to "push" command This is symmetrical with --bookmark or --branch; it selects changesets in specified topic as revisions to push.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 22 Sep 2017 13:43:38 +0200
parents 7759d040d48d
children c0de0010ec30
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Fri Sep 22 12:48:57 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Sep 22 13:43:38 2017 +0200
@@ -198,6 +198,10 @@
     entry[1].append(('t', 'topic', '',
                      _("use specified topic"), _('TOPIC')))
 
+    entry = extensions.wrapcommand(commands.table, 'push', pushwrap)
+    entry[1].append(('t', 'topic', '',
+                     _("topic to push"), _('TOPIC')))
+
     extensions.wrapfunction(cmdutil, 'buildcommittext', committextwrap)
     extensions.wrapfunction(merge, 'update', mergeupdatewrap)
     # We need to check whether t0 or b0 is passed to override the default update
@@ -824,6 +828,12 @@
                           "\nHG: topic '%s'\nHG: branch" % t)
     return ret
 
+def pushwrap(orig, ui, repo, *args, **opts):
+    if opts.get('topic'):
+        topicrevs = repo.revs('topic(%s) - obsolete()', opts['topic'])
+        opts.setdefault('rev', []).extend(topicrevs)
+    return orig(ui, repo, *args, **opts)
+
 def mergeupdatewrap(orig, repo, node, branchmerge, force, *args, **kwargs):
     matcher = kwargs.get('matcher')
     partial = not (matcher is None or matcher.always())