mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
config: add initial implementation of --edit
This launches the preferred editor on either: a) the first non-empty user rc file found b) the first user rc file in the search list
This commit is contained in:
parent
8e74d42689
commit
6b078f60b5
@ -1462,7 +1462,8 @@ def commit(ui, repo, *pats, **opts):
|
||||
cmdutil.commitstatus(repo, node, branch, bheads, opts)
|
||||
|
||||
@command('config|showconfig|debugconfig',
|
||||
[('u', 'untrusted', None, _('show untrusted configuration options'))],
|
||||
[('u', 'untrusted', None, _('show untrusted configuration options')),
|
||||
('e', 'edit', None, _('start editor'))],
|
||||
_('[-u] [NAME]...'))
|
||||
def config(ui, repo, *values, **opts):
|
||||
"""show combined config settings from all hgrc files
|
||||
@ -1481,6 +1482,19 @@ def config(ui, repo, *values, **opts):
|
||||
Returns 0 on success.
|
||||
"""
|
||||
|
||||
if opts.get('edit'):
|
||||
paths = scmutil.userrcpath()
|
||||
for f in paths:
|
||||
if os.path.exists(f):
|
||||
break
|
||||
else:
|
||||
f = paths[0]
|
||||
editor = ui.geteditor()
|
||||
util.system("%s \"%s\"" % (editor, f),
|
||||
onerr=util.Abort, errprefix=_("edit failed"),
|
||||
out=ui.fout)
|
||||
return
|
||||
|
||||
for f in scmutil.rcpath():
|
||||
ui.debug('read config from: %s\n' % f)
|
||||
untrusted = bool(opts.get('untrusted'))
|
||||
|
@ -222,7 +222,7 @@ Show all commands + options
|
||||
branches: active, closed
|
||||
bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
|
||||
cat: output, rev, decode, include, exclude
|
||||
config: untrusted
|
||||
config: untrusted, edit
|
||||
copy: after, force, include, exclude, dry-run
|
||||
debugancestor:
|
||||
debugbuilddag: mergeable-file, overwritten-file, new-file
|
||||
|
Loading…
Reference in New Issue
Block a user