Patchwork [3,of,6] debugcommands: move 'debugrebuilddirstate' in the new module

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 14, 2017, 6:36 p.m.
Message ID <d6250c557c1d81598f90.1487097380@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18487/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 14, 2017, 6:36 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1486026026 -3600
#      Thu Feb 02 10:00:26 2017 +0100
# Node ID d6250c557c1d81598f90e6544fb0edd25ff10993
# Parent  e4f463fec5ef6ec538e007686e0374a90cc59aa4
# EXP-Topic debugcommands
debugcommands: move 'debugrebuilddirstate' in the new module

Patch

diff -r e4f463fec5ef -r d6250c557c1d mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 02 09:59:47 2017 +0100
+++ b/mercurial/commands.py	Thu Feb 02 10:00:26 2017 +0100
@@ -1859,44 +1859,6 @@  def copy(ui, repo, *pats, **opts):
     with repo.wlock(False):
         return cmdutil.copy(ui, repo, pats, opts)
 
-@command('debugrebuilddirstate|debugrebuildstate',
-    [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
-     ('', 'minimal', None, _('only rebuild files that are inconsistent with '
-                             'the working copy parent')),
-    ],
-    _('[-r REV]'))
-def debugrebuilddirstate(ui, repo, rev, **opts):
-    """rebuild the dirstate as it would look like for the given revision
-
-    If no revision is specified the first current parent will be used.
-
-    The dirstate will be set to the files of the given revision.
-    The actual working directory content or existing dirstate
-    information such as adds or removes is not considered.
-
-    ``minimal`` will only rebuild the dirstate status for files that claim to be
-    tracked but are not in the parent manifest, or that exist in the parent
-    manifest but are not in the dirstate. It will not change adds, removes, or
-    modified files that are in the working copy parent.
-
-    One use of this command is to make the next :hg:`status` invocation
-    check the actual file content.
-    """
-    ctx = scmutil.revsingle(repo, rev)
-    with repo.wlock():
-        dirstate = repo.dirstate
-        changedfiles = None
-        # See command doc for what minimal does.
-        if opts.get('minimal'):
-            manifestfiles = set(ctx.manifest().keys())
-            dirstatefiles = set(dirstate)
-            manifestonly = manifestfiles - dirstatefiles
-            dsonly = dirstatefiles - manifestfiles
-            dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
-            changedfiles = manifestonly | dsnotadded
-
-        dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
-
 @command('debugrebuildfncache', [], '')
 def debugrebuildfncache(ui, repo):
     """rebuild the fncache file"""
diff -r e4f463fec5ef -r d6250c557c1d mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Thu Feb 02 09:59:47 2017 +0100
+++ b/mercurial/debugcommands.py	Thu Feb 02 10:00:26 2017 +0100
@@ -1457,6 +1457,44 @@  def debugpvec(ui, repo, a, b=None):
              (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
               pa.distance(pb), rel))
 
+@command('debugrebuilddirstate|debugrebuildstate',
+    [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
+     ('', 'minimal', None, _('only rebuild files that are inconsistent with '
+                             'the working copy parent')),
+    ],
+    _('[-r REV]'))
+def debugrebuilddirstate(ui, repo, rev, **opts):
+    """rebuild the dirstate as it would look like for the given revision
+
+    If no revision is specified the first current parent will be used.
+
+    The dirstate will be set to the files of the given revision.
+    The actual working directory content or existing dirstate
+    information such as adds or removes is not considered.
+
+    ``minimal`` will only rebuild the dirstate status for files that claim to be
+    tracked but are not in the parent manifest, or that exist in the parent
+    manifest but are not in the dirstate. It will not change adds, removes, or
+    modified files that are in the working copy parent.
+
+    One use of this command is to make the next :hg:`status` invocation
+    check the actual file content.
+    """
+    ctx = scmutil.revsingle(repo, rev)
+    with repo.wlock():
+        dirstate = repo.dirstate
+        changedfiles = None
+        # See command doc for what minimal does.
+        if opts.get('minimal'):
+            manifestfiles = set(ctx.manifest().keys())
+            dirstatefiles = set(dirstate)
+            manifestonly = manifestfiles - dirstatefiles
+            dsonly = dirstatefiles - manifestfiles
+            dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
+            changedfiles = manifestonly | dsnotadded
+
+        dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
+
 @command('debugupgraderepo', [
     ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
     ('', 'run', False, _('performs an upgrade')),