1328 tr.release() |
1328 tr.release() |
1329 |
1329 |
1330 if tags: |
1330 if tags: |
1331 repo.opener.write("localtags", "".join(tags)) |
1331 repo.opener.write("localtags", "".join(tags)) |
1332 |
1332 |
1333 @command('debugcommands', [], _('[COMMAND]')) |
1333 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE')) |
1334 def debugcommands(ui, cmd='', *args): |
1334 def debugbundle(ui, bundlepath, all=None, **opts): |
1335 """list all available commands and options""" |
1335 """lists the contents of a bundle""" |
1336 for cmd, vals in sorted(table.iteritems()): |
1336 f = url.open(ui, bundlepath) |
1337 cmd = cmd.split('|')[0].strip('^') |
|
1338 opts = ', '.join([i[1] for i in vals[1]]) |
|
1339 ui.write('%s: %s\n' % (cmd, opts)) |
|
1340 |
|
1341 @command('debugcomplete', |
|
1342 [('o', 'options', None, _('show the command options'))], |
|
1343 _('[-o] CMD')) |
|
1344 def debugcomplete(ui, cmd='', **opts): |
|
1345 """returns the completion list associated with the given command""" |
|
1346 |
|
1347 if opts.get('options'): |
|
1348 options = [] |
|
1349 otables = [globalopts] |
|
1350 if cmd: |
|
1351 aliases, entry = cmdutil.findcmd(cmd, table, False) |
|
1352 otables.append(entry[1]) |
|
1353 for t in otables: |
|
1354 for o in t: |
|
1355 if "(DEPRECATED)" in o[3]: |
|
1356 continue |
|
1357 if o[0]: |
|
1358 options.append('-%s' % o[0]) |
|
1359 options.append('--%s' % o[1]) |
|
1360 ui.write("%s\n" % "\n".join(options)) |
|
1361 return |
|
1362 |
|
1363 cmdlist = cmdutil.findpossible(cmd, table) |
|
1364 if ui.verbose: |
|
1365 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
|
1366 ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
|
1367 |
|
1368 @command('debugfsinfo', [], _('[PATH]')) |
|
1369 def debugfsinfo(ui, path = "."): |
|
1370 """show information detected about current filesystem""" |
|
1371 util.writefile('.debugfsinfo', '') |
|
1372 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
|
1373 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
|
1374 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
|
1375 and 'yes' or 'no')) |
|
1376 os.unlink('.debugfsinfo') |
|
1377 |
|
1378 @command('debugrebuildstate', |
|
1379 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))], |
|
1380 _('[-r REV] [REV]')) |
|
1381 def debugrebuildstate(ui, repo, rev="tip"): |
|
1382 """rebuild the dirstate as it would look like for the given revision""" |
|
1383 ctx = cmdutil.revsingle(repo, rev) |
|
1384 wlock = repo.wlock() |
|
1385 try: |
1337 try: |
1386 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
1338 gen = changegroup.readbundle(f, bundlepath) |
|
1339 if all: |
|
1340 ui.write("format: id, p1, p2, cset, delta base, len(delta)\n") |
|
1341 |
|
1342 def showchunks(named): |
|
1343 ui.write("\n%s\n" % named) |
|
1344 chain = None |
|
1345 while 1: |
|
1346 chunkdata = gen.deltachunk(chain) |
|
1347 if not chunkdata: |
|
1348 break |
|
1349 node = chunkdata['node'] |
|
1350 p1 = chunkdata['p1'] |
|
1351 p2 = chunkdata['p2'] |
|
1352 cs = chunkdata['cs'] |
|
1353 deltabase = chunkdata['deltabase'] |
|
1354 delta = chunkdata['delta'] |
|
1355 ui.write("%s %s %s %s %s %s\n" % |
|
1356 (hex(node), hex(p1), hex(p2), |
|
1357 hex(cs), hex(deltabase), len(delta))) |
|
1358 chain = node |
|
1359 |
|
1360 chunkdata = gen.changelogheader() |
|
1361 showchunks("changelog") |
|
1362 chunkdata = gen.manifestheader() |
|
1363 showchunks("manifest") |
|
1364 while 1: |
|
1365 chunkdata = gen.filelogheader() |
|
1366 if not chunkdata: |
|
1367 break |
|
1368 fname = chunkdata['filename'] |
|
1369 showchunks(fname) |
|
1370 else: |
|
1371 chunkdata = gen.changelogheader() |
|
1372 chain = None |
|
1373 while 1: |
|
1374 chunkdata = gen.deltachunk(chain) |
|
1375 if not chunkdata: |
|
1376 break |
|
1377 node = chunkdata['node'] |
|
1378 ui.write("%s\n" % hex(node)) |
|
1379 chain = node |
1387 finally: |
1380 finally: |
1388 wlock.release() |
1381 f.close() |
1389 |
1382 |
1390 @command('debugcheckstate', [], '') |
1383 @command('debugcheckstate', [], '') |
1391 def debugcheckstate(ui, repo): |
1384 def debugcheckstate(ui, repo): |
1392 """validate the correctness of the current dirstate""" |
1385 """validate the correctness of the current dirstate""" |
1393 parent1, parent2 = repo.dirstate.parents() |
1386 parent1, parent2 = repo.dirstate.parents() |
1413 errors += 1 |
1406 errors += 1 |
1414 if errors: |
1407 if errors: |
1415 error = _(".hg/dirstate inconsistent with current parent's manifest") |
1408 error = _(".hg/dirstate inconsistent with current parent's manifest") |
1416 raise util.Abort(error) |
1409 raise util.Abort(error) |
1417 |
1410 |
1418 @command('showconfig|debugconfig', |
1411 @command('debugcommands', [], _('[COMMAND]')) |
1419 [('u', 'untrusted', None, _('show untrusted configuration options'))], |
1412 def debugcommands(ui, cmd='', *args): |
1420 _('[-u] [NAME]...')) |
1413 """list all available commands and options""" |
1421 def showconfig(ui, repo, *values, **opts): |
1414 for cmd, vals in sorted(table.iteritems()): |
1422 """show combined config settings from all hgrc files |
1415 cmd = cmd.split('|')[0].strip('^') |
1423 |
1416 opts = ', '.join([i[1] for i in vals[1]]) |
1424 With no arguments, print names and values of all config items. |
1417 ui.write('%s: %s\n' % (cmd, opts)) |
1425 |
1418 |
1426 With one argument of the form section.name, print just the value |
1419 @command('debugcomplete', |
1427 of that config item. |
1420 [('o', 'options', None, _('show the command options'))], |
1428 |
1421 _('[-o] CMD')) |
1429 With multiple arguments, print names and values of all config |
1422 def debugcomplete(ui, cmd='', **opts): |
1430 items with matching section names. |
1423 """returns the completion list associated with the given command""" |
1431 |
1424 |
1432 With --debug, the source (filename and line number) is printed |
1425 if opts.get('options'): |
1433 for each config item. |
1426 options = [] |
1434 |
1427 otables = [globalopts] |
1435 Returns 0 on success. |
1428 if cmd: |
1436 """ |
1429 aliases, entry = cmdutil.findcmd(cmd, table, False) |
1437 |
1430 otables.append(entry[1]) |
1438 for f in scmutil.rcpath(): |
1431 for t in otables: |
1439 ui.debug(_('read config from: %s\n') % f) |
1432 for o in t: |
1440 untrusted = bool(opts.get('untrusted')) |
1433 if "(DEPRECATED)" in o[3]: |
1441 if values: |
1434 continue |
1442 sections = [v for v in values if '.' not in v] |
1435 if o[0]: |
1443 items = [v for v in values if '.' in v] |
1436 options.append('-%s' % o[0]) |
1444 if len(items) > 1 or items and sections: |
1437 options.append('--%s' % o[1]) |
1445 raise util.Abort(_('only one config item permitted')) |
1438 ui.write("%s\n" % "\n".join(options)) |
1446 for section, name, value in ui.walkconfig(untrusted=untrusted): |
1439 return |
1447 value = str(value).replace('\n', '\\n') |
1440 |
1448 sectname = section + '.' + name |
1441 cmdlist = cmdutil.findpossible(cmd, table) |
1449 if values: |
|
1450 for v in values: |
|
1451 if v == section: |
|
1452 ui.debug('%s: ' % |
|
1453 ui.configsource(section, name, untrusted)) |
|
1454 ui.write('%s=%s\n' % (sectname, value)) |
|
1455 elif v == sectname: |
|
1456 ui.debug('%s: ' % |
|
1457 ui.configsource(section, name, untrusted)) |
|
1458 ui.write(value, '\n') |
|
1459 else: |
|
1460 ui.debug('%s: ' % |
|
1461 ui.configsource(section, name, untrusted)) |
|
1462 ui.write('%s=%s\n' % (sectname, value)) |
|
1463 |
|
1464 @command('debugknown', [], _('REPO ID...')) |
|
1465 def debugknown(ui, repopath, *ids, **opts): |
|
1466 """test whether node ids are known to a repo |
|
1467 |
|
1468 Every ID must be a full-length hex node id string. Returns a list of 0s and 1s |
|
1469 indicating unknown/known. |
|
1470 """ |
|
1471 repo = hg.repository(ui, repopath) |
|
1472 if not repo.capable('known'): |
|
1473 raise util.Abort("known() not supported by target repository") |
|
1474 flags = repo.known([bin(s) for s in ids]) |
|
1475 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
|
1476 |
|
1477 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE')) |
|
1478 def debugbundle(ui, bundlepath, all=None, **opts): |
|
1479 """lists the contents of a bundle""" |
|
1480 f = url.open(ui, bundlepath) |
|
1481 try: |
|
1482 gen = changegroup.readbundle(f, bundlepath) |
|
1483 if all: |
|
1484 ui.write("format: id, p1, p2, cset, delta base, len(delta)\n") |
|
1485 |
|
1486 def showchunks(named): |
|
1487 ui.write("\n%s\n" % named) |
|
1488 chain = None |
|
1489 while 1: |
|
1490 chunkdata = gen.deltachunk(chain) |
|
1491 if not chunkdata: |
|
1492 break |
|
1493 node = chunkdata['node'] |
|
1494 p1 = chunkdata['p1'] |
|
1495 p2 = chunkdata['p2'] |
|
1496 cs = chunkdata['cs'] |
|
1497 deltabase = chunkdata['deltabase'] |
|
1498 delta = chunkdata['delta'] |
|
1499 ui.write("%s %s %s %s %s %s\n" % |
|
1500 (hex(node), hex(p1), hex(p2), |
|
1501 hex(cs), hex(deltabase), len(delta))) |
|
1502 chain = node |
|
1503 |
|
1504 chunkdata = gen.changelogheader() |
|
1505 showchunks("changelog") |
|
1506 chunkdata = gen.manifestheader() |
|
1507 showchunks("manifest") |
|
1508 while 1: |
|
1509 chunkdata = gen.filelogheader() |
|
1510 if not chunkdata: |
|
1511 break |
|
1512 fname = chunkdata['filename'] |
|
1513 showchunks(fname) |
|
1514 else: |
|
1515 chunkdata = gen.changelogheader() |
|
1516 chain = None |
|
1517 while 1: |
|
1518 chunkdata = gen.deltachunk(chain) |
|
1519 if not chunkdata: |
|
1520 break |
|
1521 node = chunkdata['node'] |
|
1522 ui.write("%s\n" % hex(node)) |
|
1523 chain = node |
|
1524 finally: |
|
1525 f.close() |
|
1526 |
|
1527 @command('debuggetbundle', |
|
1528 [('H', 'head', [], _('id of head node'), _('ID')), |
|
1529 ('C', 'common', [], _('id of common node'), _('ID')), |
|
1530 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
|
1531 _('REPO FILE [-H|-C ID]...')) |
|
1532 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
|
1533 """retrieves a bundle from a repo |
|
1534 |
|
1535 Every ID must be a full-length hex node id string. Saves the bundle to the |
|
1536 given file. |
|
1537 """ |
|
1538 repo = hg.repository(ui, repopath) |
|
1539 if not repo.capable('getbundle'): |
|
1540 raise util.Abort("getbundle() not supported by target repository") |
|
1541 args = {} |
|
1542 if common: |
|
1543 args['common'] = [bin(s) for s in common] |
|
1544 if head: |
|
1545 args['heads'] = [bin(s) for s in head] |
|
1546 bundle = repo.getbundle('debug', **args) |
|
1547 |
|
1548 bundletype = opts.get('type', 'bzip2').lower() |
|
1549 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
|
1550 bundletype = btypes.get(bundletype) |
|
1551 if bundletype not in changegroup.bundletypes: |
|
1552 raise util.Abort(_('unknown bundle type specified with --type')) |
|
1553 changegroup.writebundle(bundle, bundlepath, bundletype) |
|
1554 |
|
1555 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) |
|
1556 def debugpushkey(ui, repopath, namespace, *keyinfo): |
|
1557 '''access the pushkey key/value protocol |
|
1558 |
|
1559 With two args, list the keys in the given namespace. |
|
1560 |
|
1561 With five args, set a key to new if it currently is set to old. |
|
1562 Reports success or failure. |
|
1563 ''' |
|
1564 |
|
1565 target = hg.repository(ui, repopath) |
|
1566 if keyinfo: |
|
1567 key, old, new = keyinfo |
|
1568 r = target.pushkey(namespace, key, old, new) |
|
1569 ui.status(str(r) + '\n') |
|
1570 return not r |
|
1571 else: |
|
1572 for k, v in target.listkeys(namespace).iteritems(): |
|
1573 ui.write("%s\t%s\n" % (k.encode('string-escape'), |
|
1574 v.encode('string-escape'))) |
|
1575 |
|
1576 @command('debugrevspec', [], ('REVSPEC')) |
|
1577 def debugrevspec(ui, repo, expr): |
|
1578 '''parse and apply a revision specification''' |
|
1579 if ui.verbose: |
1442 if ui.verbose: |
1580 tree = revset.parse(expr)[0] |
1443 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
1581 ui.note(tree, "\n") |
1444 ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
1582 newtree = revset.findaliases(ui, tree) |
|
1583 if newtree != tree: |
|
1584 ui.note(newtree, "\n") |
|
1585 func = revset.match(ui, expr) |
|
1586 for c in func(repo, range(len(repo))): |
|
1587 ui.write("%s\n" % c) |
|
1588 |
|
1589 @command('debugsetparents', [], _('REV1 [REV2]')) |
|
1590 def debugsetparents(ui, repo, rev1, rev2=None): |
|
1591 """manually set the parents of the current working directory |
|
1592 |
|
1593 This is useful for writing repository conversion tools, but should |
|
1594 be used with care. |
|
1595 |
|
1596 Returns 0 on success. |
|
1597 """ |
|
1598 |
|
1599 r1 = cmdutil.revsingle(repo, rev1).node() |
|
1600 r2 = cmdutil.revsingle(repo, rev2, 'null').node() |
|
1601 |
|
1602 wlock = repo.wlock() |
|
1603 try: |
|
1604 repo.dirstate.setparents(r1, r2) |
|
1605 finally: |
|
1606 wlock.release() |
|
1607 |
|
1608 @command('debugstate', |
|
1609 [('', 'nodates', None, _('do not display the saved mtime')), |
|
1610 ('', 'datesort', None, _('sort by saved mtime'))], |
|
1611 _('[OPTION]...')) |
|
1612 def debugstate(ui, repo, nodates=None, datesort=None): |
|
1613 """show the contents of the current dirstate""" |
|
1614 timestr = "" |
|
1615 showdate = not nodates |
|
1616 if datesort: |
|
1617 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
|
1618 else: |
|
1619 keyfunc = None # sort by filename |
|
1620 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
|
1621 if showdate: |
|
1622 if ent[3] == -1: |
|
1623 # Pad or slice to locale representation |
|
1624 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1625 time.localtime(0))) |
|
1626 timestr = 'unset' |
|
1627 timestr = (timestr[:locale_len] + |
|
1628 ' ' * (locale_len - len(timestr))) |
|
1629 else: |
|
1630 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1631 time.localtime(ent[3])) |
|
1632 if ent[1] & 020000: |
|
1633 mode = 'lnk' |
|
1634 else: |
|
1635 mode = '%3o' % (ent[1] & 0777) |
|
1636 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
1637 for f in repo.dirstate.copies(): |
|
1638 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
1639 |
|
1640 @command('debugsub', |
|
1641 [('r', 'rev', '', |
|
1642 _('revision to check'), _('REV'))], |
|
1643 _('[-r REV] [REV]')) |
|
1644 def debugsub(ui, repo, rev=None): |
|
1645 ctx = cmdutil.revsingle(repo, rev, None) |
|
1646 for k, v in sorted(ctx.substate.items()): |
|
1647 ui.write('path %s\n' % k) |
|
1648 ui.write(' source %s\n' % v[0]) |
|
1649 ui.write(' revision %s\n' % v[1]) |
|
1650 |
1445 |
1651 @command('debugdag', |
1446 @command('debugdag', |
1652 [('t', 'tags', None, _('use tags as labels')), |
1447 [('t', 'tags', None, _('use tags as labels')), |
1653 ('b', 'branches', None, _('annotate with branch names')), |
1448 ('b', 'branches', None, _('annotate with branch names')), |
1654 ('', 'dots', None, _('use dots for runs')), |
1449 ('', 'dots', None, _('use dots for runs')), |
1809 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
1595 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
1810 opts.get('remote_head')) |
1596 opts.get('remote_head')) |
1811 localrevs = opts.get('local_head') |
1597 localrevs = opts.get('local_head') |
1812 doit(localrevs, remoterevs) |
1598 doit(localrevs, remoterevs) |
1813 |
1599 |
|
1600 @command('debugfsinfo', [], _('[PATH]')) |
|
1601 def debugfsinfo(ui, path = "."): |
|
1602 """show information detected about current filesystem""" |
|
1603 util.writefile('.debugfsinfo', '') |
|
1604 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
|
1605 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
|
1606 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
|
1607 and 'yes' or 'no')) |
|
1608 os.unlink('.debugfsinfo') |
|
1609 |
|
1610 @command('debuggetbundle', |
|
1611 [('H', 'head', [], _('id of head node'), _('ID')), |
|
1612 ('C', 'common', [], _('id of common node'), _('ID')), |
|
1613 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
|
1614 _('REPO FILE [-H|-C ID]...')) |
|
1615 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
|
1616 """retrieves a bundle from a repo |
|
1617 |
|
1618 Every ID must be a full-length hex node id string. Saves the bundle to the |
|
1619 given file. |
|
1620 """ |
|
1621 repo = hg.repository(ui, repopath) |
|
1622 if not repo.capable('getbundle'): |
|
1623 raise util.Abort("getbundle() not supported by target repository") |
|
1624 args = {} |
|
1625 if common: |
|
1626 args['common'] = [bin(s) for s in common] |
|
1627 if head: |
|
1628 args['heads'] = [bin(s) for s in head] |
|
1629 bundle = repo.getbundle('debug', **args) |
|
1630 |
|
1631 bundletype = opts.get('type', 'bzip2').lower() |
|
1632 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
|
1633 bundletype = btypes.get(bundletype) |
|
1634 if bundletype not in changegroup.bundletypes: |
|
1635 raise util.Abort(_('unknown bundle type specified with --type')) |
|
1636 changegroup.writebundle(bundle, bundlepath, bundletype) |
|
1637 |
|
1638 @command('debugignore', [], '') |
|
1639 def debugignore(ui, repo, *values, **opts): |
|
1640 """display the combined ignore pattern""" |
|
1641 ignore = repo.dirstate._ignore |
|
1642 if hasattr(ignore, 'includepat'): |
|
1643 ui.write("%s\n" % ignore.includepat) |
|
1644 else: |
|
1645 raise util.Abort(_("no ignore patterns found")) |
|
1646 |
1814 @command('debugindex', |
1647 @command('debugindex', |
1815 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
1648 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
1816 _('FILE')) |
1649 _('FILE')) |
1817 def debugindex(ui, repo, file_, **opts): |
1650 def debugindex(ui, repo, file_, **opts): |
1818 """dump the contents of an index file""" |
1651 """dump the contents of an index file""" |
1957 ui.write(_("%s problems detected," |
1790 ui.write(_("%s problems detected," |
1958 " please check your install!\n") % problems) |
1791 " please check your install!\n") % problems) |
1959 |
1792 |
1960 return problems |
1793 return problems |
1961 |
1794 |
|
1795 @command('debugknown', [], _('REPO ID...')) |
|
1796 def debugknown(ui, repopath, *ids, **opts): |
|
1797 """test whether node ids are known to a repo |
|
1798 |
|
1799 Every ID must be a full-length hex node id string. Returns a list of 0s and 1s |
|
1800 indicating unknown/known. |
|
1801 """ |
|
1802 repo = hg.repository(ui, repopath) |
|
1803 if not repo.capable('known'): |
|
1804 raise util.Abort("known() not supported by target repository") |
|
1805 flags = repo.known([bin(s) for s in ids]) |
|
1806 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
|
1807 |
|
1808 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) |
|
1809 def debugpushkey(ui, repopath, namespace, *keyinfo): |
|
1810 '''access the pushkey key/value protocol |
|
1811 |
|
1812 With two args, list the keys in the given namespace. |
|
1813 |
|
1814 With five args, set a key to new if it currently is set to old. |
|
1815 Reports success or failure. |
|
1816 ''' |
|
1817 |
|
1818 target = hg.repository(ui, repopath) |
|
1819 if keyinfo: |
|
1820 key, old, new = keyinfo |
|
1821 r = target.pushkey(namespace, key, old, new) |
|
1822 ui.status(str(r) + '\n') |
|
1823 return not r |
|
1824 else: |
|
1825 for k, v in target.listkeys(namespace).iteritems(): |
|
1826 ui.write("%s\t%s\n" % (k.encode('string-escape'), |
|
1827 v.encode('string-escape'))) |
|
1828 |
|
1829 @command('debugrebuildstate', |
|
1830 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))], |
|
1831 _('[-r REV] [REV]')) |
|
1832 def debugrebuildstate(ui, repo, rev="tip"): |
|
1833 """rebuild the dirstate as it would look like for the given revision""" |
|
1834 ctx = cmdutil.revsingle(repo, rev) |
|
1835 wlock = repo.wlock() |
|
1836 try: |
|
1837 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
|
1838 finally: |
|
1839 wlock.release() |
|
1840 |
1962 @command('debugrename', |
1841 @command('debugrename', |
1963 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
1842 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
1964 _('[-r REV] FILE')) |
1843 _('[-r REV] FILE')) |
1965 def debugrename(ui, repo, file1, *pats, **opts): |
1844 def debugrename(ui, repo, file1, *pats, **opts): |
1966 """dump rename information""" |
1845 """dump rename information""" |
1973 rel = m.rel(abs) |
1852 rel = m.rel(abs) |
1974 if o: |
1853 if o: |
1975 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
1854 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
1976 else: |
1855 else: |
1977 ui.write(_("%s not renamed\n") % rel) |
1856 ui.write(_("%s not renamed\n") % rel) |
|
1857 |
|
1858 @command('debugrevspec', [], ('REVSPEC')) |
|
1859 def debugrevspec(ui, repo, expr): |
|
1860 '''parse and apply a revision specification''' |
|
1861 if ui.verbose: |
|
1862 tree = revset.parse(expr)[0] |
|
1863 ui.note(tree, "\n") |
|
1864 newtree = revset.findaliases(ui, tree) |
|
1865 if newtree != tree: |
|
1866 ui.note(newtree, "\n") |
|
1867 func = revset.match(ui, expr) |
|
1868 for c in func(repo, range(len(repo))): |
|
1869 ui.write("%s\n" % c) |
|
1870 |
|
1871 @command('debugsetparents', [], _('REV1 [REV2]')) |
|
1872 def debugsetparents(ui, repo, rev1, rev2=None): |
|
1873 """manually set the parents of the current working directory |
|
1874 |
|
1875 This is useful for writing repository conversion tools, but should |
|
1876 be used with care. |
|
1877 |
|
1878 Returns 0 on success. |
|
1879 """ |
|
1880 |
|
1881 r1 = cmdutil.revsingle(repo, rev1).node() |
|
1882 r2 = cmdutil.revsingle(repo, rev2, 'null').node() |
|
1883 |
|
1884 wlock = repo.wlock() |
|
1885 try: |
|
1886 repo.dirstate.setparents(r1, r2) |
|
1887 finally: |
|
1888 wlock.release() |
|
1889 |
|
1890 @command('debugstate', |
|
1891 [('', 'nodates', None, _('do not display the saved mtime')), |
|
1892 ('', 'datesort', None, _('sort by saved mtime'))], |
|
1893 _('[OPTION]...')) |
|
1894 def debugstate(ui, repo, nodates=None, datesort=None): |
|
1895 """show the contents of the current dirstate""" |
|
1896 timestr = "" |
|
1897 showdate = not nodates |
|
1898 if datesort: |
|
1899 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
|
1900 else: |
|
1901 keyfunc = None # sort by filename |
|
1902 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
|
1903 if showdate: |
|
1904 if ent[3] == -1: |
|
1905 # Pad or slice to locale representation |
|
1906 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1907 time.localtime(0))) |
|
1908 timestr = 'unset' |
|
1909 timestr = (timestr[:locale_len] + |
|
1910 ' ' * (locale_len - len(timestr))) |
|
1911 else: |
|
1912 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1913 time.localtime(ent[3])) |
|
1914 if ent[1] & 020000: |
|
1915 mode = 'lnk' |
|
1916 else: |
|
1917 mode = '%3o' % (ent[1] & 0777) |
|
1918 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
1919 for f in repo.dirstate.copies(): |
|
1920 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
1921 |
|
1922 @command('debugsub', |
|
1923 [('r', 'rev', '', |
|
1924 _('revision to check'), _('REV'))], |
|
1925 _('[-r REV] [REV]')) |
|
1926 def debugsub(ui, repo, rev=None): |
|
1927 ctx = cmdutil.revsingle(repo, rev, None) |
|
1928 for k, v in sorted(ctx.substate.items()): |
|
1929 ui.write('path %s\n' % k) |
|
1930 ui.write(' source %s\n' % v[0]) |
|
1931 ui.write(' revision %s\n' % v[1]) |
1978 |
1932 |
1979 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...')) |
1933 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...')) |
1980 def debugwalk(ui, repo, *pats, **opts): |
1934 def debugwalk(ui, repo, *pats, **opts): |
1981 """show how files match on given patterns""" |
1935 """show how files match on given patterns""" |
1982 m = cmdutil.match(repo, pats, opts) |
1936 m = cmdutil.match(repo, pats, opts) |
4319 |
4273 |
4320 service = service() |
4274 service = service() |
4321 |
4275 |
4322 cmdutil.service(opts, initfn=service.init, runfn=service.run) |
4276 cmdutil.service(opts, initfn=service.init, runfn=service.run) |
4323 |
4277 |
|
4278 @command('showconfig|debugconfig', |
|
4279 [('u', 'untrusted', None, _('show untrusted configuration options'))], |
|
4280 _('[-u] [NAME]...')) |
|
4281 def showconfig(ui, repo, *values, **opts): |
|
4282 """show combined config settings from all hgrc files |
|
4283 |
|
4284 With no arguments, print names and values of all config items. |
|
4285 |
|
4286 With one argument of the form section.name, print just the value |
|
4287 of that config item. |
|
4288 |
|
4289 With multiple arguments, print names and values of all config |
|
4290 items with matching section names. |
|
4291 |
|
4292 With --debug, the source (filename and line number) is printed |
|
4293 for each config item. |
|
4294 |
|
4295 Returns 0 on success. |
|
4296 """ |
|
4297 |
|
4298 for f in scmutil.rcpath(): |
|
4299 ui.debug(_('read config from: %s\n') % f) |
|
4300 untrusted = bool(opts.get('untrusted')) |
|
4301 if values: |
|
4302 sections = [v for v in values if '.' not in v] |
|
4303 items = [v for v in values if '.' in v] |
|
4304 if len(items) > 1 or items and sections: |
|
4305 raise util.Abort(_('only one config item permitted')) |
|
4306 for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
4307 value = str(value).replace('\n', '\\n') |
|
4308 sectname = section + '.' + name |
|
4309 if values: |
|
4310 for v in values: |
|
4311 if v == section: |
|
4312 ui.debug('%s: ' % |
|
4313 ui.configsource(section, name, untrusted)) |
|
4314 ui.write('%s=%s\n' % (sectname, value)) |
|
4315 elif v == sectname: |
|
4316 ui.debug('%s: ' % |
|
4317 ui.configsource(section, name, untrusted)) |
|
4318 ui.write(value, '\n') |
|
4319 else: |
|
4320 ui.debug('%s: ' % |
|
4321 ui.configsource(section, name, untrusted)) |
|
4322 ui.write('%s=%s\n' % (sectname, value)) |
|
4323 |
4324 @command('^status|st', |
4324 @command('^status|st', |
4325 [('A', 'all', None, _('show status of all files')), |
4325 [('A', 'all', None, _('show status of all files')), |
4326 ('m', 'modified', None, _('show only modified files')), |
4326 ('m', 'modified', None, _('show only modified files')), |
4327 ('a', 'added', None, _('show only added files')), |
4327 ('a', 'added', None, _('show only added files')), |
4328 ('r', 'removed', None, _('show only removed files')), |
4328 ('r', 'removed', None, _('show only removed files')), |