diff mercurial/commands.py @ 33885:800bb35d891e

pushvars: do not mangle repo state Setting `repo._shellvars` works but is not a clean way to pass the pushvars information from the push command to the exchange operation. Therefore change it to actually pass `pushvars` as a push operation argument instead. This makes third party extension like remotenames easier to support pushvars cleanly. The key value parsing and verification code has been moved to a lower level so it's harder to be bypassed and easier to be used in remotenames which could replace `push` command entirely. Differential Revision: https://phab.mercurial-scm.org/D423
author Jun Wu <quark@fb.com>
date Wed, 16 Aug 2017 15:48:48 -0700
parents af20468eb0a4
children 10f1809ab98f
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Aug 21 16:43:37 2017 +0530
+++ b/mercurial/commands.py	Wed Aug 16 15:48:48 2017 -0700
@@ -4082,26 +4082,13 @@
     finally:
         del repo._subtoppath
 
-    pushvars = opts.get('pushvars')
-    if pushvars:
-        shellvars = {}
-        for raw in pushvars:
-            if '=' not in raw:
-                msg = ("unable to parse variable '%s', should follow "
-                        "'KEY=VALUE' or 'KEY=' format")
-                raise error.Abort(msg % raw)
-            k, v = raw.split('=', 1)
-            shellvars[k] = v
-
-        repo._shellvars = shellvars
+    opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it
+    opargs.setdefault('pushvars', []).extend(opts.get('pushvars', []))
 
     pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
                            newbranch=opts.get('new_branch'),
                            bookmarks=opts.get('bookmark', ()),
-                           opargs=opts.get('opargs'))
-
-    if pushvars:
-        del repo._shellvars
+                           opargs=opargs)
 
     result = not pushop.cgresult