Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 20572:c724cb0141ee
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
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 27 Feb 2014 13:46:32 -0600 |
parents | c21e1e3ab915 |
children | 02d0d3aa42e3 |
comparison
equal
deleted
inserted
replaced
20571:d4893e64f300 | 20572:c724cb0141ee |
---|---|
1460 return 1 | 1460 return 1 |
1461 | 1461 |
1462 cmdutil.commitstatus(repo, node, branch, bheads, opts) | 1462 cmdutil.commitstatus(repo, node, branch, bheads, opts) |
1463 | 1463 |
1464 @command('config|showconfig|debugconfig', | 1464 @command('config|showconfig|debugconfig', |
1465 [('u', 'untrusted', None, _('show untrusted configuration options'))], | 1465 [('u', 'untrusted', None, _('show untrusted configuration options')), |
1466 ('e', 'edit', None, _('start editor'))], | |
1466 _('[-u] [NAME]...')) | 1467 _('[-u] [NAME]...')) |
1467 def config(ui, repo, *values, **opts): | 1468 def config(ui, repo, *values, **opts): |
1468 """show combined config settings from all hgrc files | 1469 """show combined config settings from all hgrc files |
1469 | 1470 |
1470 With no arguments, print names and values of all config items. | 1471 With no arguments, print names and values of all config items. |
1478 With --debug, the source (filename and line number) is printed | 1479 With --debug, the source (filename and line number) is printed |
1479 for each config item. | 1480 for each config item. |
1480 | 1481 |
1481 Returns 0 on success. | 1482 Returns 0 on success. |
1482 """ | 1483 """ |
1484 | |
1485 if opts.get('edit'): | |
1486 paths = scmutil.userrcpath() | |
1487 for f in paths: | |
1488 if os.path.exists(f): | |
1489 break | |
1490 else: | |
1491 f = paths[0] | |
1492 editor = ui.geteditor() | |
1493 util.system("%s \"%s\"" % (editor, f), | |
1494 onerr=util.Abort, errprefix=_("edit failed"), | |
1495 out=ui.fout) | |
1496 return | |
1483 | 1497 |
1484 for f in scmutil.rcpath(): | 1498 for f in scmutil.rcpath(): |
1485 ui.debug('read config from: %s\n' % f) | 1499 ui.debug('read config from: %s\n' % f) |
1486 untrusted = bool(opts.get('untrusted')) | 1500 untrusted = bool(opts.get('untrusted')) |
1487 if values: | 1501 if values: |