##// END OF EJS Templates
config: add `--shared` flag to edit config file of shared source...
Pulkit Goyal -
r46058:ac7a3da0 default
parent child Browse files
Show More
@@ -55,6 +55,7 b' from . import ('
55 55 pycompat,
56 56 rcutil,
57 57 registrar,
58 requirements,
58 59 revsetlang,
59 60 rewriteutil,
60 61 scmutil,
@@ -66,6 +67,7 b' from . import ('
66 67 ui as uimod,
67 68 util,
68 69 verify as verifymod,
70 vfs as vfsmod,
69 71 wireprotoserver,
70 72 )
71 73 from .utils import (
@@ -2141,6 +2143,12 b' def _docommit(ui, repo, *pats, **opts):'
2141 2143 (b'u', b'untrusted', None, _(b'show untrusted configuration options')),
2142 2144 (b'e', b'edit', None, _(b'edit user config')),
2143 2145 (b'l', b'local', None, _(b'edit repository config')),
2146 (
2147 b'',
2148 b'shared',
2149 None,
2150 _(b'edit shared source repository config (EXPERIMENTAL)'),
2151 ),
2144 2152 (b'g', b'global', None, _(b'edit global config')),
2145 2153 ]
2146 2154 + formatteropts,
@@ -2179,22 +2187,37 b' def config(ui, repo, *values, **opts):'
2179 2187 :source: String. Filename and line number where the item is defined.
2180 2188 :value: String. Config value.
2181 2189
2190 The --shared flag can be used to edit the config file of shared source
2191 repository. It only works when you have shared using the experimental
2192 share safe feature.
2193
2182 2194 Returns 0 on success, 1 if NAME does not exist.
2183 2195
2184 2196 """
2185 2197
2186 2198 opts = pycompat.byteskwargs(opts)
2187 editopts = (b'edit', b'local', b'global')
2199 editopts = (b'edit', b'local', b'global', b'shared')
2188 2200 if any(opts.get(o) for o in editopts):
2189 if opts.get(b'local') and opts.get(b'global'):
2190 raise error.Abort(_(b"can't use --local and --global together"))
2191
2201 cmdutil.check_at_most_one_arg(opts, *editopts[1:])
2192 2202 if opts.get(b'local'):
2193 2203 if not repo:
2194 2204 raise error.Abort(_(b"can't use --local outside a repository"))
2195 2205 paths = [repo.vfs.join(b'hgrc')]
2196 2206 elif opts.get(b'global'):
2197 2207 paths = rcutil.systemrcpath()
2208 elif opts.get(b'shared'):
2209 if not repo.shared():
2210 raise error.Abort(
2211 _(b"repository is not shared; can't use --shared")
2212 )
2213 if requirements.SHARESAFE_REQUIREMENT not in repo.requirements:
2214 raise error.Abort(
2215 _(
2216 b"share safe feature not unabled; "
2217 b"unable to edit shared source repository config"
2218 )
2219 )
2220 paths = [vfsmod.vfs(repo.sharedpath).join(b'hgrc')]
2198 2221 else:
2199 2222 paths = rcutil.userrcpath()
2200 2223
@@ -258,7 +258,7 b' Show all commands + options'
258 258 cat: output, rev, decode, include, exclude, template
259 259 clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
260 260 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
261 config: untrusted, edit, local, global, template
261 config: untrusted, edit, local, shared, global, template
262 262 continue: dry-run
263 263 copy: forget, after, at-rev, force, include, exclude, dry-run
264 264 debugancestor:
@@ -33,6 +33,10 b' prepare source repo'
33 33 $ hg ci -Aqm "added a"
34 34 $ echo b > b
35 35 $ hg ci -Aqm "added b"
36
37 $ HGEDITOR=cat hg config --shared
38 abort: repository is not shared; can't use --shared
39 [255]
36 40 $ cd ..
37 41
38 42 Create a shared repo and check the requirements are shared and read correctly
@@ -85,6 +89,14 b' However, local .hg/hgrc should override '
85 89 $ hg showconfig ui.curses
86 90 false
87 91
92 $ HGEDITOR=cat hg config --shared
93 [ui]
94 curses=true
95
96 $ HGEDITOR=cat hg config --local
97 [ui]
98 curses=false
99
88 100 Testing that hooks set in source repository also runs in shared repo
89 101
90 102 $ cd ../source
General Comments 0
You need to be logged in to leave comments. Login now