mercurial/commands.py
changeset 30948 cc2b537b1966
parent 30947 3c766ca89377
child 30949 e7d7335819f4
equal deleted inserted replaced
30947:3c766ca89377 30948:cc2b537b1966
  1857     Returns 0 on success, 1 if errors are encountered.
  1857     Returns 0 on success, 1 if errors are encountered.
  1858     """
  1858     """
  1859     with repo.wlock(False):
  1859     with repo.wlock(False):
  1860         return cmdutil.copy(ui, repo, pats, opts)
  1860         return cmdutil.copy(ui, repo, pats, opts)
  1861 
  1861 
  1862 @command('debugrebuilddirstate|debugrebuildstate',
       
  1863     [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
       
  1864      ('', 'minimal', None, _('only rebuild files that are inconsistent with '
       
  1865                              'the working copy parent')),
       
  1866     ],
       
  1867     _('[-r REV]'))
       
  1868 def debugrebuilddirstate(ui, repo, rev, **opts):
       
  1869     """rebuild the dirstate as it would look like for the given revision
       
  1870 
       
  1871     If no revision is specified the first current parent will be used.
       
  1872 
       
  1873     The dirstate will be set to the files of the given revision.
       
  1874     The actual working directory content or existing dirstate
       
  1875     information such as adds or removes is not considered.
       
  1876 
       
  1877     ``minimal`` will only rebuild the dirstate status for files that claim to be
       
  1878     tracked but are not in the parent manifest, or that exist in the parent
       
  1879     manifest but are not in the dirstate. It will not change adds, removes, or
       
  1880     modified files that are in the working copy parent.
       
  1881 
       
  1882     One use of this command is to make the next :hg:`status` invocation
       
  1883     check the actual file content.
       
  1884     """
       
  1885     ctx = scmutil.revsingle(repo, rev)
       
  1886     with repo.wlock():
       
  1887         dirstate = repo.dirstate
       
  1888         changedfiles = None
       
  1889         # See command doc for what minimal does.
       
  1890         if opts.get('minimal'):
       
  1891             manifestfiles = set(ctx.manifest().keys())
       
  1892             dirstatefiles = set(dirstate)
       
  1893             manifestonly = manifestfiles - dirstatefiles
       
  1894             dsonly = dirstatefiles - manifestfiles
       
  1895             dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
       
  1896             changedfiles = manifestonly | dsnotadded
       
  1897 
       
  1898         dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
       
  1899 
       
  1900 @command('debugrebuildfncache', [], '')
  1862 @command('debugrebuildfncache', [], '')
  1901 def debugrebuildfncache(ui, repo):
  1863 def debugrebuildfncache(ui, repo):
  1902     """rebuild the fncache file"""
  1864     """rebuild the fncache file"""
  1903     repair.rebuildfncache(ui, repo)
  1865     repair.rebuildfncache(ui, repo)
  1904 
  1866