mercurial/commands.py
changeset 22367 c5df4af17110
parent 22315 188b8aa2120b
parent 22316 816be4ca4ae2
child 22381 392ae5cb8d62
equal deleted inserted replaced
22364:5c153c69fdb2 22367:c5df4af17110
  1496     With --debug, the source (filename and line number) is printed
  1496     With --debug, the source (filename and line number) is printed
  1497     for each config item.
  1497     for each config item.
  1498 
  1498 
  1499     See :hg:`help config` for more information about config files.
  1499     See :hg:`help config` for more information about config files.
  1500 
  1500 
  1501     Returns 0 on success.
  1501     Returns 0 on success, 1 if NAME does not exist.
  1502 
  1502 
  1503     """
  1503     """
  1504 
  1504 
  1505     if opts.get('edit') or opts.get('local') or opts.get('global'):
  1505     if opts.get('edit') or opts.get('local') or opts.get('global'):
  1506         if opts.get('local') and opts.get('global'):
  1506         if opts.get('local') and opts.get('global'):
  1549     if values:
  1549     if values:
  1550         sections = [v for v in values if '.' not in v]
  1550         sections = [v for v in values if '.' not in v]
  1551         items = [v for v in values if '.' in v]
  1551         items = [v for v in values if '.' in v]
  1552         if len(items) > 1 or items and sections:
  1552         if len(items) > 1 or items and sections:
  1553             raise util.Abort(_('only one config item permitted'))
  1553             raise util.Abort(_('only one config item permitted'))
       
  1554     matched = False
  1554     for section, name, value in ui.walkconfig(untrusted=untrusted):
  1555     for section, name, value in ui.walkconfig(untrusted=untrusted):
  1555         value = str(value).replace('\n', '\\n')
  1556         value = str(value).replace('\n', '\\n')
  1556         sectname = section + '.' + name
  1557         sectname = section + '.' + name
  1557         if values:
  1558         if values:
  1558             for v in values:
  1559             for v in values:
  1559                 if v == section:
  1560                 if v == section:
  1560                     ui.debug('%s: ' %
  1561                     ui.debug('%s: ' %
  1561                              ui.configsource(section, name, untrusted))
  1562                              ui.configsource(section, name, untrusted))
  1562                     ui.write('%s=%s\n' % (sectname, value))
  1563                     ui.write('%s=%s\n' % (sectname, value))
       
  1564                     matched = True
  1563                 elif v == sectname:
  1565                 elif v == sectname:
  1564                     ui.debug('%s: ' %
  1566                     ui.debug('%s: ' %
  1565                              ui.configsource(section, name, untrusted))
  1567                              ui.configsource(section, name, untrusted))
  1566                     ui.write(value, '\n')
  1568                     ui.write(value, '\n')
       
  1569                     matched = True
  1567         else:
  1570         else:
  1568             ui.debug('%s: ' %
  1571             ui.debug('%s: ' %
  1569                      ui.configsource(section, name, untrusted))
  1572                      ui.configsource(section, name, untrusted))
  1570             ui.write('%s=%s\n' % (sectname, value))
  1573             ui.write('%s=%s\n' % (sectname, value))
       
  1574             matched = True
       
  1575     if matched:
       
  1576         return 0
       
  1577     return 1
  1571 
  1578 
  1572 @command('copy|cp',
  1579 @command('copy|cp',
  1573     [('A', 'after', None, _('record a copy that has already occurred')),
  1580     [('A', 'after', None, _('record a copy that has already occurred')),
  1574     ('f', 'force', None, _('forcibly copy over an existing managed file')),
  1581     ('f', 'force', None, _('forcibly copy over an existing managed file')),
  1575     ] + walkopts + dryrunopts,
  1582     ] + walkopts + dryrunopts,