Patchwork workingctx: use normal dirs() instead of dirstate.dirs()

login
register
mail settings
Submitter Durham Goode
Date March 6, 2015, 6:53 a.m.
Message ID <7d86f76025f5858844fc.1425624810@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7907/
State Accepted
Commit e0c1328df87212fb0819a955919635aa80a58882
Headers show

Comments

Durham Goode - March 6, 2015, 6:53 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1425622588 28800
#      Thu Mar 05 22:16:28 2015 -0800
# Node ID 7d86f76025f5858844fc52c8015665c1102069db
# Parent  4ef4e3c3c00693868ba428e21ac092e559e4fcea
workingctx: use normal dirs() instead of dirstate.dirs()

The workingctx class was using dirstate.dirs() as it's implementation. The
sparse extension maintains a pruned down version of the dirstate, so this
resulted in the workingctx reporting an incorrect listing of directories
during merge calculations (it was detecting directory renames when it
shouldn't have).

The fix is to use the default implementation, which uses workingctx._manifest,
which unions the manifest with the dirstate to produce the correct overall
picture. This also produces more accurate output since it will no longer
return directories that have been entirely deleted in the dirstate.

Tests will be added to the sparse extension to detect regressions for this.
Matt Mackall - March 6, 2015, 5:31 p.m.
On Thu, 2015-03-05 at 22:53 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1425622588 28800
> #      Thu Mar 05 22:16:28 2015 -0800
> # Node ID 7d86f76025f5858844fc52c8015665c1102069db
> # Parent  4ef4e3c3c00693868ba428e21ac092e559e4fcea
> workingctx: use normal dirs() instead of dirstate.dirs()

Queued for default, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2071,6 +2071,7 @@  def remove(ui, repo, m, prefix, after, f
                                % join(subpath))
 
     # warn about failure to delete explicit files/dirs
+    deleteddirs = scmutil.dirs(deleted)
     for f in m.files():
         def insubrepo():
             for subpath in wctx.substate:
@@ -2078,7 +2079,8 @@  def remove(ui, repo, m, prefix, after, f
                     return True
             return False
 
-        if f in repo.dirstate or f in wctx.dirs() or f == '.' or insubrepo():
+        isdir = f in deleteddirs or f in wctx.dirs()
+        if f in repo.dirstate or isdir or f == '.' or insubrepo():
             continue
 
         if repo.wvfs.exists(f):
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1289,9 +1289,6 @@  class committablectx(basectx):
         self._repo.dirstate.setparents(node)
         self._repo.dirstate.endparentchange()
 
-    def dirs(self):
-        return self._repo.dirstate.dirs()
-
 class workingctx(committablectx):
     """A workingctx object makes access to data related to
     the current working directory convenient.