##// END OF EJS Templates
Add a source designator to the walk methods....
Bryan O'Sullivan -
r726:809a870a default
parent child Browse files
Show More
@@ -65,9 +65,9 b' def matchpats(ui, cwd, pats = [], opts ='
65 def walk(repo, pats, opts):
65 def walk(repo, pats, opts):
66 cwd = repo.getcwd()
66 cwd = repo.getcwd()
67 if cwd: c = len(cwd) + 1
67 if cwd: c = len(cwd) + 1
68 for fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)):
68 for src, fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)):
69 if cwd: yield fn, fn[c:]
69 if cwd: yield src, fn, fn[c:]
70 else: yield fn, fn
70 else: yield src, fn, fn
71
71
72 revrangesep = ':'
72 revrangesep = ':'
73
73
@@ -325,7 +325,7 b' def add(ui, repo, *pats, **opts):'
325 '''add the specified files on the next commit'''
325 '''add the specified files on the next commit'''
326 names = []
326 names = []
327 q = dict(zip(pats, pats))
327 q = dict(zip(pats, pats))
328 for abs, rel in walk(repo, pats, opts):
328 for src, abs, rel in walk(repo, pats, opts):
329 if rel in q or abs in q:
329 if rel in q or abs in q:
330 names.append(abs)
330 names.append(abs)
331 elif repo.dirstate.state(abs) == '?':
331 elif repo.dirstate.state(abs) == '?':
@@ -715,7 +715,7 b' def locate(ui, repo, *pats, **opts):'
715 if opts['print0']: end = '\0'
715 if opts['print0']: end = '\0'
716 else: end = '\n'
716 else: end = '\n'
717 opts['rootless'] = True
717 opts['rootless'] = True
718 for abs, rel in walk(repo, pats, opts):
718 for src, abs, rel in walk(repo, pats, opts):
719 if repo.dirstate.state(abs) == '?': continue
719 if repo.dirstate.state(abs) == '?': continue
720 if opts['fullpath']:
720 if opts['fullpath']:
721 ui.write(os.path.join(repo.root, abs), end)
721 ui.write(os.path.join(repo.root, abs), end)
@@ -434,30 +434,30 b' class dirstate:'
434 subdirs.remove(sd)
434 subdirs.remove(sd)
435 for fn in fl:
435 for fn in fl:
436 fn = util.pconvert(os.path.join(d, fn))
436 fn = util.pconvert(os.path.join(d, fn))
437 yield fn
437 yield 'f', fn
438 else:
438 else:
439 yield f[len(self.root) + 1:]
439 yield 'f', f[len(self.root) + 1:]
440
440
441 for k in dc.keys():
441 for k in dc.keys():
442 yield k
442 yield 'm', k
443
443
444 # yield only files that match: all in dirstate, others only if
444 # yield only files that match: all in dirstate, others only if
445 # not in .hgignore
445 # not in .hgignore
446
446
447 for fn in util.unique(traverse()):
447 for src, fn in util.unique(traverse()):
448 if fn in dc:
448 if fn in dc:
449 del dc[fn]
449 del dc[fn]
450 elif self.ignore(fn):
450 elif self.ignore(fn):
451 continue
451 continue
452 if match(fn):
452 if match(fn):
453 yield fn
453 yield src, fn
454
454
455 def changes(self, files = None, match = util.always):
455 def changes(self, files = None, match = util.always):
456 self.read()
456 self.read()
457 dc = self.map.copy()
457 dc = self.map.copy()
458 lookup, changed, added, unknown = [], [], [], []
458 lookup, changed, added, unknown = [], [], [], []
459
459
460 for fn in self.walk(files, match):
460 for src, fn in self.walk(files, match):
461 try: s = os.stat(os.path.join(self.root, fn))
461 try: s = os.stat(os.path.join(self.root, fn))
462 except: continue
462 except: continue
463
463
@@ -840,11 +840,11 b' class localrepository:'
840
840
841 def walk(self, node = None, files = [], match = util.always):
841 def walk(self, node = None, files = [], match = util.always):
842 if node:
842 if node:
843 change = self.changelog.read(node)
843 for fn in self.manifest.read(self.changelog.read(node)[0]):
844 fns = filter(match, self.manifest.read(change[0]))
844 yield 'm', fn
845 else:
845 else:
846 fns = self.dirstate.walk(files, match)
846 for src, fn in self.dirstate.walk(files, match):
847 for fn in fns: yield fn
847 yield src, fn
848
848
849 def changes(self, node1 = None, node2 = None, files = [],
849 def changes(self, node1 = None, node2 = None, files = [],
850 match = util.always):
850 match = util.always):
General Comments 0
You need to be logged in to leave comments. Login now