Patchwork [3,of,6] dirstate: move initial dirs calculation to a top-level function

login
register
mail settings
Submitter Bryan O'Sullivan
Date March 29, 2013, 1:22 a.m.
Message ID <9479dece303d06808cce.1364520165@australite.local>
Download mbox | patch
Permalink /patch/1210/
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 1364520157 25200
#      Thu Mar 28 18:22:37 2013 -0700
# Node ID 9479dece303d06808cce9e2e3d0a196511fe6ba8
# Parent  42348ed8d9a218eee27b40b48d368aed552c1452
dirstate: move initial dirs calculation to a top-level function

This refactoring prepares us for an upcoming rewrite in C.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -45,6 +45,13 @@  def _decdirs(dirs, path):
             return
         del dirs[base]
 
+def _calcdirs(m):
+    dirs = {}
+    for f, s in m.iteritems():
+        if s[0] != 'r':
+            _incdirs(dirs, f)
+    return dirs
+
 class dirstate(object):
 
     def __init__(self, opener, ui, root, validate):
@@ -113,11 +120,7 @@  class dirstate(object):
 
     @propertycache
     def _dirs(self):
-        dirs = {}
-        for f, s in self._map.iteritems():
-            if s[0] != 'r':
-                _incdirs(dirs, f)
-        return dirs
+        return _calcdirs(self._map)
 
     def iterdirs(self):
         return self._dirs.iterkeys()