##// END OF EJS Templates
pushvars: move fb extension pushvars to core...
Pulkit Goyal -
r33656:db3dc113 default
parent child Browse files
Show More
@@ -0,0 +1,71 b''
1 Setup
2
3 $ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
4 $ export PYTHONPATH
5
6 $ cat > $TESTTMP/pretxnchangegroup.sh << EOF
7 > #!/bin/sh
8 > env | egrep "^HG_USERVAR_(DEBUG|BYPASS_REVIEW)" | sort
9 > exit 0
10 > EOF
11 $ chmod +x $TESTTMP/pretxnchangegroup.sh
12 $ cat >> $HGRCPATH << EOF
13 > [hooks]
14 > pretxnchangegroup = $TESTTMP/pretxnchangegroup.sh
15 > [experimental]
16 > bundle2-exp = true
17 > EOF
18
19 $ hg init repo
20 $ hg clone -q repo child
21 $ cd child
22
23 Test pushing vars to repo with pushvars.server not set
24
25 $ echo b > a
26 $ hg commit -Aqm a
27 $ hg push --pushvars "DEBUG=1" --pushvars "BYPASS_REVIEW=true"
28 pushing to $TESTTMP/repo (glob)
29 searching for changes
30 adding changesets
31 adding manifests
32 adding file changes
33 added 1 changesets with 1 changes to 1 files
34
35 Setting pushvars.sever = true and then pushing.
36
37 $ echo [push] >> $HGRCPATH
38 $ echo "pushvars.server = true" >> $HGRCPATH
39 $ echo b >> a
40 $ hg commit -Aqm a
41 $ hg push --pushvars "DEBUG=1" --pushvars "BYPASS_REVIEW=true"
42 pushing to $TESTTMP/repo (glob)
43 searching for changes
44 adding changesets
45 adding manifests
46 adding file changes
47 added 1 changesets with 1 changes to 1 files
48 HG_USERVAR_BYPASS_REVIEW=true
49 HG_USERVAR_DEBUG=1
50
51 Test pushing var with empty right-hand side
52
53 $ echo b >> a
54 $ hg commit -Aqm a
55 $ hg push --pushvars "DEBUG="
56 pushing to $TESTTMP/repo (glob)
57 searching for changes
58 adding changesets
59 adding manifests
60 adding file changes
61 added 1 changesets with 1 changes to 1 files
62 HG_USERVAR_DEBUG=
63
64 Test pushing bad vars
65
66 $ echo b >> a
67 $ hg commit -Aqm b
68 $ hg push --pushvars "DEBUG"
69 pushing to $TESTTMP/repo (glob)
70 abort: unable to parse variable 'DEBUG', should follow 'KEY=VALUE' or 'KEY=' format
71 [255]
@@ -1879,3 +1879,17 b' def handlehgtagsfnodes(op, inpart):'
1879
1879
1880 cache.write()
1880 cache.write()
1881 op.ui.debug('applied %i hgtags fnodes cache entries\n' % count)
1881 op.ui.debug('applied %i hgtags fnodes cache entries\n' % count)
1882
1883 @parthandler('pushvars')
1884 def bundle2getvars(op, part):
1885 '''unbundle a bundle2 containing shellvars on the server'''
1886 # An option to disable unbundling on server-side for security reasons
1887 if op.ui.configbool('push', 'pushvars.server', False):
1888 hookargs = {}
1889 for key, value in part.advisoryparams:
1890 key = key.upper()
1891 # We want pushed variables to have USERVAR_ prepended so we know
1892 # they came from the --pushvar flag.
1893 key = "USERVAR_" + key
1894 hookargs[key] = value
1895 op.addhookargs(hookargs)
@@ -3970,6 +3970,7 b' def pull(ui, repo, source="default", **o'
3970 ('b', 'branch', [],
3970 ('b', 'branch', [],
3971 _('a specific branch you would like to push'), _('BRANCH')),
3971 _('a specific branch you would like to push'), _('BRANCH')),
3972 ('', 'new-branch', False, _('allow pushing a new branch')),
3972 ('', 'new-branch', False, _('allow pushing a new branch')),
3973 ('', 'pushvars', [], _('variables that can be sent to server (ADVANCED)')),
3973 ] + remoteopts,
3974 ] + remoteopts,
3974 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
3975 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
3975 def push(ui, repo, dest=None, **opts):
3976 def push(ui, repo, dest=None, **opts):
@@ -4007,6 +4008,25 b' def push(ui, repo, dest=None, **opts):'
4007 Please see :hg:`help urls` for important details about ``ssh://``
4008 Please see :hg:`help urls` for important details about ``ssh://``
4008 URLs. If DESTINATION is omitted, a default path will be used.
4009 URLs. If DESTINATION is omitted, a default path will be used.
4009
4010
4011 .. container:: verbose
4012
4013 The --pushvars option sends strings to the server that become
4014 environment variables prepended with ``HG_USERVAR_``. For example,
4015 ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with
4016 ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment.
4017
4018 pushvars can provide for user-overridable hooks as well as set debug
4019 levels. One example is having a hook that blocks commits containing
4020 conflict markers, but enables the user to override the hook if the file
4021 is using conflict markers for testing purposes or the file format has
4022 strings that look like conflict markers.
4023
4024 By default, servers will ignore `--pushvars`. To enable it add the
4025 following to your configuration file
4026
4027 [push]
4028 pushvars.server = true
4029
4010 Returns 0 if push was successful, 1 if nothing to push.
4030 Returns 0 if push was successful, 1 if nothing to push.
4011 """
4031 """
4012
4032
@@ -4059,11 +4079,28 b' def push(ui, repo, dest=None, **opts):'
4059 return not result
4079 return not result
4060 finally:
4080 finally:
4061 del repo._subtoppath
4081 del repo._subtoppath
4082
4083 pushvars = opts.get('pushvars')
4084 if pushvars:
4085 shellvars = {}
4086 for raw in pushvars:
4087 if '=' not in raw:
4088 msg = ("unable to parse variable '%s', should follow "
4089 "'KEY=VALUE' or 'KEY=' format")
4090 raise error.Abort(msg % raw)
4091 k, v = raw.split('=', 1)
4092 shellvars[k] = v
4093
4094 repo._shellvars = shellvars
4095
4062 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4096 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
4063 newbranch=opts.get('new_branch'),
4097 newbranch=opts.get('new_branch'),
4064 bookmarks=opts.get('bookmark', ()),
4098 bookmarks=opts.get('bookmark', ()),
4065 opargs=opts.get('opargs'))
4099 opargs=opts.get('opargs'))
4066
4100
4101 if pushvars:
4102 del repo._shellvars
4103
4067 result = not pushop.cgresult
4104 result = not pushop.cgresult
4068
4105
4069 if pushop.bkresult is not None:
4106 if pushop.bkresult is not None:
@@ -893,6 +893,14 b' def _pushb2bookmarks(pushop, bundler):'
893 pushop.bkresult = 1
893 pushop.bkresult = 1
894 return handlereply
894 return handlereply
895
895
896 @b2partsgenerator('pushvars', idx=0)
897 def _getbundlesendvars(pushop, bundler):
898 '''send shellvars via bundle2'''
899 if getattr(pushop.repo, '_shellvars', ()):
900 part = bundler.newpart('pushvars')
901
902 for key, value in pushop.repo._shellvars.iteritems():
903 part.addparam(key, value, mandatory=False)
896
904
897 def _pushbundle2(pushop):
905 def _pushbundle2(pushop):
898 """push data to the remote using bundle2
906 """push data to the remote using bundle2
@@ -228,7 +228,7 b' Show all commands + options'
228 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
228 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
229 merge: force, rev, preview, tool
229 merge: force, rev, preview, tool
230 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
230 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
231 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
231 push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure
232 remove: after, force, subrepos, include, exclude
232 remove: after, force, subrepos, include, exclude
233 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
233 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
234 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
234 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template
General Comments 0
You need to be logged in to leave comments. Login now