mercurial/debugcommands.py
changeset 32256 9bc36198338e
parent 32229 75e93d95aae6
child 32265 ccef71de7d41
equal deleted inserted replaced
32255:7e35d31b41fd 32256:9bc36198338e
    38     dagutil,
    38     dagutil,
    39     encoding,
    39     encoding,
    40     error,
    40     error,
    41     exchange,
    41     exchange,
    42     extensions,
    42     extensions,
       
    43     filemerge,
    43     fileset,
    44     fileset,
    44     formatter,
    45     formatter,
    45     hg,
    46     hg,
    46     localrepo,
    47     localrepo,
    47     lock as lockmod,
    48     lock as lockmod,
  1500         dirs.update(d)
  1501         dirs.update(d)
  1501     files.update(dirs)
  1502     files.update(dirs)
  1502     ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
  1503     ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
  1503     ui.write('\n')
  1504     ui.write('\n')
  1504 
  1505 
       
  1506 @command('debugpickmergetool',
       
  1507         [('r', 'rev', '', _('check for files in this revision'), _('REV')),
       
  1508          ('', 'changedelete', None, _('emulate merging change and delete')),
       
  1509         ] + commands.walkopts + commands.mergetoolopts,
       
  1510         _('[PATTERN]...'),
       
  1511         inferrepo=True)
       
  1512 def debugpickmergetool(ui, repo, *pats, **opts):
       
  1513     """examine which merge tool is chosen for specified file
       
  1514 
       
  1515     As described in :hg:`help merge-tools`, Mercurial examines
       
  1516     configurations below in this order to decide which merge tool is
       
  1517     chosen for specified file.
       
  1518 
       
  1519     1. ``--tool`` option
       
  1520     2. ``HGMERGE`` environment variable
       
  1521     3. configurations in ``merge-patterns`` section
       
  1522     4. configuration of ``ui.merge``
       
  1523     5. configurations in ``merge-tools`` section
       
  1524     6. ``hgmerge`` tool (for historical reason only)
       
  1525     7. default tool for fallback (``:merge`` or ``:prompt``)
       
  1526 
       
  1527     This command writes out examination result in the style below::
       
  1528 
       
  1529         FILE = MERGETOOL
       
  1530 
       
  1531     By default, all files known in the first parent context of the
       
  1532     working directory are examined. Use file patterns and/or -I/-X
       
  1533     options to limit target files. -r/--rev is also useful to examine
       
  1534     files in another context without actual updating to it.
       
  1535 
       
  1536     With --debug, this command shows warning messages while matching
       
  1537     against ``merge-patterns`` and so on, too. It is recommended to
       
  1538     use this option with explicit file patterns and/or -I/-X options,
       
  1539     because this option increases amount of output per file according
       
  1540     to configurations in hgrc.
       
  1541 
       
  1542     With -v/--verbose, this command shows configurations below at
       
  1543     first (only if specified).
       
  1544 
       
  1545     - ``--tool`` option
       
  1546     - ``HGMERGE`` environment variable
       
  1547     - configuration of ``ui.merge``
       
  1548 
       
  1549     If merge tool is chosen before matching against
       
  1550     ``merge-patterns``, this command can't show any helpful
       
  1551     information, even with --debug. In such case, information above is
       
  1552     useful to know why a merge tool is chosen.
       
  1553     """
       
  1554     overrides = {}
       
  1555     if opts['tool']:
       
  1556         overrides[('ui', 'forcemerge')] = opts['tool']
       
  1557         ui.note(('with --tool %r\n') % (opts['tool']))
       
  1558 
       
  1559     with ui.configoverride(overrides, 'debugmergepatterns'):
       
  1560         hgmerge = encoding.environ.get("HGMERGE")
       
  1561         if hgmerge is not None:
       
  1562             ui.note(('with HGMERGE=%r\n') % (hgmerge))
       
  1563         uimerge = ui.config("ui", "merge")
       
  1564         if uimerge:
       
  1565             ui.note(('with ui.merge=%r\n') % (uimerge))
       
  1566 
       
  1567         ctx = scmutil.revsingle(repo, opts.get('rev'))
       
  1568         m = scmutil.match(ctx, pats, opts)
       
  1569         changedelete = opts['changedelete']
       
  1570         for path in ctx.walk(m):
       
  1571             fctx = ctx[path]
       
  1572             try:
       
  1573                 if not ui.debugflag:
       
  1574                     ui.pushbuffer(error=True)
       
  1575                 tool, toolpath = filemerge._picktool(repo, ui, path,
       
  1576                                                      fctx.isbinary(),
       
  1577                                                      'l' in fctx.flags(),
       
  1578                                                      changedelete)
       
  1579             finally:
       
  1580                 if not ui.debugflag:
       
  1581                     ui.popbuffer()
       
  1582             ui.write(('%s = %s\n') % (path, tool))
       
  1583 
  1505 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
  1584 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
  1506 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
  1585 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
  1507     '''access the pushkey key/value protocol
  1586     '''access the pushkey key/value protocol
  1508 
  1587 
  1509     With two args, list the keys in the given namespace.
  1588     With two args, list the keys in the given namespace.