comparison mercurial/hg.py @ 870:a82eae840447

Teach walk code about absolute paths. The first consequence of this is that absolute and relative paths now all work in the same way. The second is that paths that lie outside the repository now cause an error to be reported, instead of something arbitrary and expensive being done. Internally, all of the serious work is in the util package. The new canonpath function takes an arbitrary path and either returns a canonical path or raises an error. Because it needs to know where the repository root is, it must be fed a repository or dirstate object, which has given commands.matchpats and friends a new parameter to pass along. The util.matcher function uses this to canonicalise globs and relative path names. Meanwhile, I've moved the Abort exception from commands to util, and killed off the redundant util.CommandError exception.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 07 Aug 2005 12:43:11 -0800
parents 9c918287d10b
children c2e77581bc84
comparison
equal deleted inserted replaced
869:1e3a23719662 870:a82eae840447
297 self.copies = {} 297 self.copies = {}
298 self.ignorefunc = None 298 self.ignorefunc = None
299 299
300 def wjoin(self, f): 300 def wjoin(self, f):
301 return os.path.join(self.root, f) 301 return os.path.join(self.root, f)
302
303 def getcwd(self):
304 cwd = os.getcwd()
305 if cwd == self.root: return ''
306 return cwd[len(self.root) + 1:]
302 307
303 def ignore(self, f): 308 def ignore(self, f):
304 if not self.ignorefunc: 309 if not self.ignorefunc:
305 bigpat = [] 310 bigpat = []
306 try: 311 try:
685 def file(self, f): 690 def file(self, f):
686 if f[0] == '/': f = f[1:] 691 if f[0] == '/': f = f[1:]
687 return filelog(self.opener, f) 692 return filelog(self.opener, f)
688 693
689 def getcwd(self): 694 def getcwd(self):
690 cwd = os.getcwd() 695 return self.dirstate.getcwd()
691 if cwd == self.root: return ''
692 return cwd[len(self.root) + 1:]
693 696
694 def wfile(self, f, mode='r'): 697 def wfile(self, f, mode='r'):
695 return self.wopener(f, mode) 698 return self.wopener(f, mode)
696 699
697 def transaction(self): 700 def transaction(self):