# HG changeset patch # User Bryan O'Sullivan # Date 1121786159 28800 # Node ID 809a870a0e73ddfe5d3febc3168efe8481800d6b # Parent c6b912f8b5b2538567d40466b6d0036542d650bd Add a source designator to the walk methods. If the source is 'f' (the filesystem), the file definitely exists in the filesystem. If 'm' (a rev or dirstate manifest), the file may not still exist with the given name. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -65,9 +65,9 @@ def matchpats(ui, cwd, pats = [], opts = def walk(repo, pats, opts): cwd = repo.getcwd() if cwd: c = len(cwd) + 1 - for fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)): - if cwd: yield fn, fn[c:] - else: yield fn, fn + for src, fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)): + if cwd: yield src, fn, fn[c:] + else: yield src, fn, fn revrangesep = ':' @@ -325,7 +325,7 @@ def add(ui, repo, *pats, **opts): '''add the specified files on the next commit''' names = [] q = dict(zip(pats, pats)) - for abs, rel in walk(repo, pats, opts): + for src, abs, rel in walk(repo, pats, opts): if rel in q or abs in q: names.append(abs) elif repo.dirstate.state(abs) == '?': @@ -715,7 +715,7 @@ def locate(ui, repo, *pats, **opts): if opts['print0']: end = '\0' else: end = '\n' opts['rootless'] = True - for abs, rel in walk(repo, pats, opts): + for src, abs, rel in walk(repo, pats, opts): if repo.dirstate.state(abs) == '?': continue if opts['fullpath']: ui.write(os.path.join(repo.root, abs), end) diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -434,30 +434,30 @@ class dirstate: subdirs.remove(sd) for fn in fl: fn = util.pconvert(os.path.join(d, fn)) - yield fn + yield 'f', fn else: - yield f[len(self.root) + 1:] + yield 'f', f[len(self.root) + 1:] for k in dc.keys(): - yield k + yield 'm', k # yield only files that match: all in dirstate, others only if # not in .hgignore - for fn in util.unique(traverse()): + for src, fn in util.unique(traverse()): if fn in dc: del dc[fn] elif self.ignore(fn): continue if match(fn): - yield fn + yield src, fn def changes(self, files = None, match = util.always): self.read() dc = self.map.copy() lookup, changed, added, unknown = [], [], [], [] - for fn in self.walk(files, match): + for src, fn in self.walk(files, match): try: s = os.stat(os.path.join(self.root, fn)) except: continue @@ -840,11 +840,11 @@ class localrepository: def walk(self, node = None, files = [], match = util.always): if node: - change = self.changelog.read(node) - fns = filter(match, self.manifest.read(change[0])) + for fn in self.manifest.read(self.changelog.read(node)[0]): + yield 'm', fn else: - fns = self.dirstate.walk(files, match) - for fn in fns: yield fn + for src, fn in self.dirstate.walk(files, match): + yield src, fn def changes(self, node1 = None, node2 = None, files = [], match = util.always):