Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstate.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 | 289ec1f36b11 |
children | b422b558015b |
line wrap: on
line diff
--- a/mercurial/dirstate.py Fri Jun 08 23:49:12 2007 -0300 +++ b/mercurial/dirstate.py Fri Jun 08 23:49:12 2007 -0300 @@ -44,6 +44,11 @@ # we're outside the repo. return an absolute path. return cwd + def pathto(self, f, cwd=None): + if cwd is None: + cwd = self.getcwd() + return util.pathto(self.root, cwd, f) + def hgignore(self): '''return the contents of .hgignore files as a list of patterns. @@ -403,9 +408,8 @@ elif stat.S_ISFIFO(st.st_mode): kind = _('fifo') elif stat.S_ISSOCK(st.st_mode): kind = _('socket') elif stat.S_ISDIR(st.st_mode): kind = _('directory') - self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( - util.pathto(self.root, self.getcwd(), f), - kind)) + self.ui.warn(_('%s: unsupported file type (type is %s)\n') + % (self.pathto(f), kind)) return False def walk(self, files=None, match=util.always, badmatch=None): @@ -513,9 +517,8 @@ break if not found: if inst.errno != errno.ENOENT or not badmatch: - self.ui.warn('%s: %s\n' % ( - util.pathto(self.root, self.getcwd(), ff), - inst.strerror)) + self.ui.warn('%s: %s\n' % (self.pathto(ff), + inst.strerror)) elif badmatch and badmatch(ff) and imatch(nf): yield 'b', ff, None continue