comparison mercurial/util.py @ 1541:bf4e7ef08741

fixed some stuff pychecker shows, marked unclear/wrong stuff with XXX
author twaldmann@thinkmo.de
date Mon, 14 Nov 2005 03:59:35 +0200
parents c9f33196805b
children 487e256ad545
comparison
equal deleted inserted replaced
1540:8ca9f5b17257 1541:bf4e7ef08741
156 def pathto(n1, n2): 156 def pathto(n1, n2):
157 '''return the relative path from one place to another. 157 '''return the relative path from one place to another.
158 this returns a path in the form used by the local filesystem, not hg.''' 158 this returns a path in the form used by the local filesystem, not hg.'''
159 if not n1: return localpath(n2) 159 if not n1: return localpath(n2)
160 a, b = n1.split('/'), n2.split('/') 160 a, b = n1.split('/'), n2.split('/')
161 a.reverse(), b.reverse() 161 a.reverse()
162 b.reverse()
162 while a and b and a[-1] == b[-1]: 163 while a and b and a[-1] == b[-1]:
163 a.pop(), b.pop() 164 a.pop()
165 b.pop()
164 b.reverse() 166 b.reverse()
165 return os.sep.join((['..'] * len(a)) + b) 167 return os.sep.join((['..'] * len(a)) + b)
166 168
167 def canonpath(root, cwd, myname): 169 def canonpath(root, cwd, myname):
168 """return the canonical path of myname, given cwd and root""" 170 """return the canonical path of myname, given cwd and root"""
251 matches = [] 253 matches = []
252 for k, p in pats: 254 for k, p in pats:
253 try: 255 try:
254 pat = '(?:%s)' % regex(k, p, tail) 256 pat = '(?:%s)' % regex(k, p, tail)
255 matches.append(re.compile(pat).match) 257 matches.append(re.compile(pat).match)
256 except re.error, inst: 258 except re.error:
257 raise Abort("invalid pattern: %s:%s" % (k, p)) 259 raise Abort("invalid pattern: %s:%s" % (k, p))
258 260
259 def buildfn(text): 261 def buildfn(text):
260 for m in matches: 262 for m in matches:
261 r = m(text) 263 r = m(text)