[PATCH] dirstate: make subrepos an optional arg to status() and walk()
Greg Ward
greg-hg at gerg.ca
Fri Mar 5 08:19:29 CST 2010
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1266244676 18000
# Branch stable
# Node ID cf238442eb60e1abc5a54bc1362b3e0d7513db99
# Parent eab98889e7924972ca4ea5664198a01e83d69532
dirstate: make subrepos an optional arg to status() and walk().
This makes the incompatible API change in 24ce8f0c0a39 much less
annoying for third-party extension authors who need to maintain
compatibility with Mercurial 1.4 and 1.5.
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -32,7 +32,7 @@
def perfwalk(ui, repo, *pats):
try:
m = cmdutil.match(repo, pats, {})
- timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
+ timer(lambda: len(list(repo.dirstate.walk(m, True, False))))
except:
try:
m = cmdutil.match(repo, pats, {})
diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py
--- a/hgext/inotify/__init__.py
+++ b/hgext/inotify/__init__.py
@@ -41,7 +41,7 @@
# to start an inotify server if it won't start.
_inotifyon = True
- def status(self, match, subrepos, ignored, clean, unknown=True):
+ def status(self, match, ignored, clean, unknown=True, subrepos=None):
files = match.files()
if '.' in files:
files = []
@@ -69,7 +69,7 @@
result = r2
return result
return super(inotifydirstate, self).status(
- match, subrepos, ignored, clean, unknown)
+ match, ignored, clean, unknown, subrepos=subrepos)
repo.dirstate.__class__ = inotifydirstate
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -692,8 +692,9 @@
return self._parents[0].ancestor(c2) # punt on two parents for now
def walk(self, match):
- return sorted(self._repo.dirstate.walk(match, self.substate.keys(),
- True, False))
+ return sorted(self._repo.dirstate.walk(match,
+ True, False,
+ subrepos=self.substate.keys()))
def dirty(self, missing=False):
"check whether a working directory is modified"
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -430,7 +430,7 @@
return True
return False
- def walk(self, match, subrepos, unknown, ignored):
+ def walk(self, match, unknown, ignored, subrepos=None):
'''
Walk recursively through the directory tree, finding all files
matched by match.
@@ -496,8 +496,9 @@
files = set(match.files())
if not files or '.' in files:
files = ['']
- results = dict.fromkeys(subrepos)
- results['.hg'] = None
+ results = {'.hg': None}
+ if subrepos is not None:
+ results.update(dict.fromkeys(subrepos))
# step 1: find all explicit files
for ff in sorted(files):
@@ -575,12 +576,13 @@
if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
st = None
results[nf] = st
- for s in subrepos:
- del results[s]
+ if subrepos is not None:
+ for s in subrepos:
+ del results[s]
del results['.hg']
return results
- def status(self, match, subrepos, ignored, clean, unknown):
+ def status(self, match, ignored, clean, unknown, subrepos=None):
'''Determine the status of the working copy relative to the
dirstate and return a tuple of lists (unsure, modified, added,
removed, deleted, unknown, ignored, clean), where:
@@ -621,8 +623,9 @@
dadd = deleted.append
cadd = clean.append
- for fn, st in self.walk(match, subrepos, listunknown,
- listignored).iteritems():
+ statusmap = self.walk(match, listunknown, listignored,
+ subrepos=subrepos)
+ for fn, st in statusmap.iteritems():
if fn not in dmap:
if (listignored or match.exact(fn)) and self._dirignore(fn):
if listignored:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1011,8 +1011,9 @@
if working: # we need to scan the working dir
subrepos = ctx1.substate.keys()
- s = self.dirstate.status(match, subrepos, listignored,
- listclean, listunknown)
+ s = self.dirstate.status(match,
+ listignored, listclean, listunknown,
+ subrepos=subrepos)
cmp, modified, added, removed, deleted, unknown, ignored, clean = s
# check for any possibly clean files
More information about the Mercurial-devel
mailing list