Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
33883:e5d104c35e51 | 33885:800bb35d891e |
---|---|
4080 if result == 0: | 4080 if result == 0: |
4081 return not result | 4081 return not result |
4082 finally: | 4082 finally: |
4083 del repo._subtoppath | 4083 del repo._subtoppath |
4084 | 4084 |
4085 pushvars = opts.get('pushvars') | 4085 opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it |
4086 if pushvars: | 4086 opargs.setdefault('pushvars', []).extend(opts.get('pushvars', [])) |
4087 shellvars = {} | |
4088 for raw in pushvars: | |
4089 if '=' not in raw: | |
4090 msg = ("unable to parse variable '%s', should follow " | |
4091 "'KEY=VALUE' or 'KEY=' format") | |
4092 raise error.Abort(msg % raw) | |
4093 k, v = raw.split('=', 1) | |
4094 shellvars[k] = v | |
4095 | |
4096 repo._shellvars = shellvars | |
4097 | 4087 |
4098 pushop = exchange.push(repo, other, opts.get('force'), revs=revs, | 4088 pushop = exchange.push(repo, other, opts.get('force'), revs=revs, |
4099 newbranch=opts.get('new_branch'), | 4089 newbranch=opts.get('new_branch'), |
4100 bookmarks=opts.get('bookmark', ()), | 4090 bookmarks=opts.get('bookmark', ()), |
4101 opargs=opts.get('opargs')) | 4091 opargs=opargs) |
4102 | |
4103 if pushvars: | |
4104 del repo._shellvars | |
4105 | 4092 |
4106 result = not pushop.cgresult | 4093 result = not pushop.cgresult |
4107 | 4094 |
4108 if pushop.bkresult is not None: | 4095 if pushop.bkresult is not None: |
4109 if pushop.bkresult == 2: | 4096 if pushop.bkresult == 2: |