comparison mercurial/localrepo.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 96d8a56d4ef9
children 0ac7fee4f024
comparison
equal deleted inserted replaced
4524:6c58139f4eaa 4525:78b6add1f966
503 return context.filectx(self, path, changeid, fileid) 503 return context.filectx(self, path, changeid, fileid)
504 504
505 def getcwd(self): 505 def getcwd(self):
506 return self.dirstate.getcwd() 506 return self.dirstate.getcwd()
507 507
508 def pathto(self, f, cwd=None):
509 return self.dirstate.pathto(f, cwd)
510
508 def wfile(self, f, mode='r'): 511 def wfile(self, f, mode='r'):
509 return self.wopener(f, mode) 512 return self.wopener(f, mode)
510 513
511 def _link(self, f): 514 def _link(self, f):
512 return os.path.islink(self.wjoin(f)) 515 return os.path.islink(self.wjoin(f))
886 for fn in ffiles: 889 for fn in ffiles:
887 if badmatch and badmatch(fn): 890 if badmatch and badmatch(fn):
888 if match(fn): 891 if match(fn):
889 yield 'b', fn 892 yield 'b', fn
890 else: 893 else:
891 self.ui.warn(_('%s: No such file in rev %s\n') % ( 894 self.ui.warn(_('%s: No such file in rev %s\n')
892 util.pathto(self.root, self.getcwd(), fn), short(node))) 895 % (self.pathto(fn), short(node)))
893 else: 896 else:
894 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch): 897 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
895 yield src, fn 898 yield src, fn
896 899
897 def status(self, node1=None, node2=None, files=[], match=util.always, 900 def status(self, node1=None, node2=None, files=[], match=util.always,