Mercurial > hg
comparison mercurial/cmdutil.py @ 4525:78b6add1f966
Add dirstate.pathto and localrepo.pathto.
Every time util.pathto is called, we have to pass the repo root and the
repo cwd.
dirstate.pathto is a simple convenience function that knows about the
root and the cwd arguments. It's still possible to pass the cwd as an
optimization.
localrepo.pathto is a convenience function that just calls
dirstate.pathto, just like localrepo.getcwd.
dirstate.pathto becomes a single point that converts most (all?) paths
from the internal representation to some OS-specific relative path for
display purposes.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 08 Jun 2007 23:49:12 -0300 |
parents | 591322269fed |
children | c9fcebbfc422 |
comparison
equal
deleted
inserted
replaced
4524:6c58139f4eaa | 4525:78b6add1f966 |
---|---|
143 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, | 143 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
144 default=None): | 144 default=None): |
145 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed, | 145 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed, |
146 default=default) | 146 default=default) |
147 exact = dict.fromkeys(files) | 147 exact = dict.fromkeys(files) |
148 cwd = repo.getcwd() | |
148 for src, fn in repo.walk(node=node, files=files, match=matchfn, | 149 for src, fn in repo.walk(node=node, files=files, match=matchfn, |
149 badmatch=badmatch): | 150 badmatch=badmatch): |
150 yield src, fn, util.pathto(repo.root, repo.getcwd(), fn), fn in exact | 151 yield src, fn, repo.pathto(fn, cwd), fn in exact |
151 | 152 |
152 def findrenames(repo, added=None, removed=None, threshold=0.5): | 153 def findrenames(repo, added=None, removed=None, threshold=0.5): |
153 '''find renamed files -- yields (before, after, score) tuples''' | 154 '''find renamed files -- yields (before, after, score) tuples''' |
154 if added is None or removed is None: | 155 if added is None or removed is None: |
155 added, removed = repo.status()[1:3] | 156 added, removed = repo.status()[1:3] |