diff mercurial/commands.py @ 27176:54ace3372f84

dirstate: change debugrebuilddirstate --minimal to use dirstate.rebuild When debugrebuilddirstate --minimal is called, rebuilding the dirstate was done outside of the appropriate rebuild function. This patch makes debugrebuilddirstate use dirstate.rebuild. This was done to allow our extension to become aware debugrebuilddirstate --minimal
author Christian Delahousse <cdelahousse@fb.com>
date Mon, 30 Nov 2015 11:23:15 -0800
parents 8a8f5d71a49a
children a01d3d32b53a
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Dec 01 10:52:36 2015 -0800
+++ b/mercurial/commands.py	Mon Nov 30 11:23:15 2015 -0800
@@ -2965,21 +2965,17 @@
     wlock = repo.wlock()
     try:
         dirstate = repo.dirstate
-
+        changedfiles = None
         # See command doc for what minimal does.
         if opts.get('minimal'):
+            manifestfiles = set(ctx.manifest().keys())
             dirstatefiles = set(dirstate)
-            ctxfiles = set(ctx.manifest().keys())
-            for file in (dirstatefiles | ctxfiles):
-                indirstate = file in dirstatefiles
-                inctx = file in ctxfiles
-
-                if indirstate and not inctx and dirstate[file] != 'a':
-                    dirstate.drop(file)
-                elif inctx and not indirstate:
-                    dirstate.normallookup(file)
-        else:
-            dirstate.rebuild(ctx.node(), ctx.manifest())
+            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)
     finally:
         wlock.release()