Show More
@@ -55,6 +55,7 b' from . import (' | |||||
55 | pycompat, |
|
55 | pycompat, | |
56 | rcutil, |
|
56 | rcutil, | |
57 | registrar, |
|
57 | registrar, | |
|
58 | requirements, | |||
58 | revsetlang, |
|
59 | revsetlang, | |
59 | rewriteutil, |
|
60 | rewriteutil, | |
60 | scmutil, |
|
61 | scmutil, | |
@@ -66,6 +67,7 b' from . import (' | |||||
66 | ui as uimod, |
|
67 | ui as uimod, | |
67 | util, |
|
68 | util, | |
68 | verify as verifymod, |
|
69 | verify as verifymod, | |
|
70 | vfs as vfsmod, | |||
69 | wireprotoserver, |
|
71 | wireprotoserver, | |
70 | ) |
|
72 | ) | |
71 | from .utils import ( |
|
73 | from .utils import ( | |
@@ -2141,6 +2143,12 b' def _docommit(ui, repo, *pats, **opts):' | |||||
2141 | (b'u', b'untrusted', None, _(b'show untrusted configuration options')), |
|
2143 | (b'u', b'untrusted', None, _(b'show untrusted configuration options')), | |
2142 | (b'e', b'edit', None, _(b'edit user config')), |
|
2144 | (b'e', b'edit', None, _(b'edit user config')), | |
2143 | (b'l', b'local', None, _(b'edit repository config')), |
|
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 | (b'g', b'global', None, _(b'edit global config')), |
|
2152 | (b'g', b'global', None, _(b'edit global config')), | |
2145 | ] |
|
2153 | ] | |
2146 | + formatteropts, |
|
2154 | + formatteropts, | |
@@ -2179,22 +2187,37 b' def config(ui, repo, *values, **opts):' | |||||
2179 | :source: String. Filename and line number where the item is defined. |
|
2187 | :source: String. Filename and line number where the item is defined. | |
2180 | :value: String. Config value. |
|
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 | Returns 0 on success, 1 if NAME does not exist. |
|
2194 | Returns 0 on success, 1 if NAME does not exist. | |
2183 |
|
2195 | |||
2184 | """ |
|
2196 | """ | |
2185 |
|
2197 | |||
2186 | opts = pycompat.byteskwargs(opts) |
|
2198 | opts = pycompat.byteskwargs(opts) | |
2187 | editopts = (b'edit', b'local', b'global') |
|
2199 | editopts = (b'edit', b'local', b'global', b'shared') | |
2188 | if any(opts.get(o) for o in editopts): |
|
2200 | if any(opts.get(o) for o in editopts): | |
2189 | if opts.get(b'local') and opts.get(b'global'): |
|
2201 | cmdutil.check_at_most_one_arg(opts, *editopts[1:]) | |
2190 | raise error.Abort(_(b"can't use --local and --global together")) |
|
|||
2191 |
|
||||
2192 | if opts.get(b'local'): |
|
2202 | if opts.get(b'local'): | |
2193 | if not repo: |
|
2203 | if not repo: | |
2194 | raise error.Abort(_(b"can't use --local outside a repository")) |
|
2204 | raise error.Abort(_(b"can't use --local outside a repository")) | |
2195 | paths = [repo.vfs.join(b'hgrc')] |
|
2205 | paths = [repo.vfs.join(b'hgrc')] | |
2196 | elif opts.get(b'global'): |
|
2206 | elif opts.get(b'global'): | |
2197 | paths = rcutil.systemrcpath() |
|
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 | else: |
|
2221 | else: | |
2199 | paths = rcutil.userrcpath() |
|
2222 | paths = rcutil.userrcpath() | |
2200 |
|
2223 |
@@ -258,7 +258,7 b' Show all commands + options' | |||||
258 | cat: output, rev, decode, include, exclude, template |
|
258 | cat: output, rev, decode, include, exclude, template | |
259 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure |
|
259 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | |
260 | commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos |
|
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 | continue: dry-run |
|
262 | continue: dry-run | |
263 | copy: forget, after, at-rev, force, include, exclude, dry-run |
|
263 | copy: forget, after, at-rev, force, include, exclude, dry-run | |
264 | debugancestor: |
|
264 | debugancestor: |
@@ -33,6 +33,10 b' prepare source repo' | |||||
33 | $ hg ci -Aqm "added a" |
|
33 | $ hg ci -Aqm "added a" | |
34 | $ echo b > b |
|
34 | $ echo b > b | |
35 | $ hg ci -Aqm "added b" |
|
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 | $ cd .. |
|
40 | $ cd .. | |
37 |
|
41 | |||
38 | Create a shared repo and check the requirements are shared and read correctly |
|
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 | $ hg showconfig ui.curses |
|
89 | $ hg showconfig ui.curses | |
86 | false |
|
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 | Testing that hooks set in source repository also runs in shared repo |
|
100 | Testing that hooks set in source repository also runs in shared repo | |
89 |
|
101 | |||
90 | $ cd ../source |
|
102 | $ cd ../source |
General Comments 0
You need to be logged in to leave comments.
Login now