comparison mercurial/debugcommands.py @ 30948:cc2b537b1966

debugcommands: move 'debugrebuilddirstate' in the new module
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 02 Feb 2017 10:00:26 +0100
parents 3c766ca89377
children e7d7335819f4
comparison
equal deleted inserted replaced
30947:3c766ca89377 30948:cc2b537b1966
1455 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) 1455 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
1456 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % 1456 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
1457 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), 1457 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
1458 pa.distance(pb), rel)) 1458 pa.distance(pb), rel))
1459 1459
1460 @command('debugrebuilddirstate|debugrebuildstate',
1461 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
1462 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
1463 'the working copy parent')),
1464 ],
1465 _('[-r REV]'))
1466 def debugrebuilddirstate(ui, repo, rev, **opts):
1467 """rebuild the dirstate as it would look like for the given revision
1468
1469 If no revision is specified the first current parent will be used.
1470
1471 The dirstate will be set to the files of the given revision.
1472 The actual working directory content or existing dirstate
1473 information such as adds or removes is not considered.
1474
1475 ``minimal`` will only rebuild the dirstate status for files that claim to be
1476 tracked but are not in the parent manifest, or that exist in the parent
1477 manifest but are not in the dirstate. It will not change adds, removes, or
1478 modified files that are in the working copy parent.
1479
1480 One use of this command is to make the next :hg:`status` invocation
1481 check the actual file content.
1482 """
1483 ctx = scmutil.revsingle(repo, rev)
1484 with repo.wlock():
1485 dirstate = repo.dirstate
1486 changedfiles = None
1487 # See command doc for what minimal does.
1488 if opts.get('minimal'):
1489 manifestfiles = set(ctx.manifest().keys())
1490 dirstatefiles = set(dirstate)
1491 manifestonly = manifestfiles - dirstatefiles
1492 dsonly = dirstatefiles - manifestfiles
1493 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
1494 changedfiles = manifestonly | dsnotadded
1495
1496 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
1497
1460 @command('debugupgraderepo', [ 1498 @command('debugupgraderepo', [
1461 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), 1499 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
1462 ('', 'run', False, _('performs an upgrade')), 1500 ('', 'run', False, _('performs an upgrade')),
1463 ]) 1501 ])
1464 def debugupgraderepo(ui, repo, run=False, optimize=None): 1502 def debugupgraderepo(ui, repo, run=False, optimize=None):