2139 b'config|showconfig|debugconfig', |
2141 b'config|showconfig|debugconfig', |
2140 [ |
2142 [ |
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, |
2147 _(b'[-u] [NAME]...'), |
2155 _(b'[-u] [NAME]...'), |
2148 helpcategory=command.CATEGORY_HELP, |
2156 helpcategory=command.CATEGORY_HELP, |
2177 |
2185 |
2178 :name: String. Config name. |
2186 :name: String. Config name. |
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 |
2201 for f in paths: |
2224 for f in paths: |
2202 if os.path.exists(f): |
2225 if os.path.exists(f): |