Patchwork [1,of,6] dirstate: rename dirs to iterdirs, and return only dir names

login
register
mail settings
Submitter Bryan O'Sullivan
Date March 29, 2013, 1:22 a.m.
Message ID <d6bb127c3380f9ee6227.1364520163@australite.local>
Download mbox | patch
Permalink /patch/1208/
State Superseded
Headers show

Comments

Bryan O'Sullivan - March 29, 2013, 1:22 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1364520135 25200
#      Thu Mar 28 18:22:15 2013 -0700
# Node ID d6bb127c3380f9ee622703d87bae4bc1fd0f8421
# Parent  e9a558d9ee06a72beb8b4168862371596aa45386
dirstate: rename dirs to iterdirs, and return only dir names

The refcounts that we maintain behind the scenes are not public, so make
sure we don't expose them to callers (who don't care anyway).
Bryan O'Sullivan - March 29, 2013, 11:09 p.m.
On Thu, Mar 28, 2013 at 6:22 PM, Bryan O'Sullivan <bos@serpentine.com>wrote:

> The refcounts that we maintain behind the scenes are not public, so make
> sure we don't expose them to callers (who don't care anyway).
>

After some further code inspection (thanks to Siddharth), it turns out that
context.changectx has an almost identical need to compute a bunch of dirs.

To accommodate that cleanly, I'm going to rework this patchset a little.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1155,7 +1155,7 @@  class workingctx(changectx):
         self._repo.dirstate.setparents(node)
 
     def dirs(self):
-        return set(self._repo.dirstate.dirs())
+        return set(self._repo.dirstate.iterdirs())
 
 class workingfilectx(filectx):
     """A workingfilectx object makes access to data related to a particular
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -119,8 +119,8 @@  class dirstate(object):
                 _incdirs(dirs, f)
         return dirs
 
-    def dirs(self):
-        return self._dirs
+    def iterdirs(self):
+        return self._dirs.iterkeys()
 
     @rootcache('.hgignore')
     def _ignore(self):