comparison mercurial/util.py @ 3651:48768b1ab23c

fix util.pathto All users of this function pass a local path (which uses os.sep) as the first argument and a "/"-separated path as the second argument.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Wed, 15 Nov 2006 18:56:47 -0200
parents 4cfb72bcb978
children eb0b4a2d70a9
comparison
equal deleted inserted replaced
3650:6f6696962986 3651:48768b1ab23c
205 205
206 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} 206 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
207 207
208 def pathto(n1, n2): 208 def pathto(n1, n2):
209 '''return the relative path from one place to another. 209 '''return the relative path from one place to another.
210 this returns a path in the form used by the local filesystem, not hg.''' 210 n1 should use os.sep to separate directories
211 n2 should use "/" to separate directories
212 returns an os.sep-separated path.
213 '''
211 if not n1: return localpath(n2) 214 if not n1: return localpath(n2)
212 a, b = n1.split('/'), n2.split('/') 215 a, b = n1.split(os.sep), n2.split('/')
213 a.reverse() 216 a.reverse()
214 b.reverse() 217 b.reverse()
215 while a and b and a[-1] == b[-1]: 218 while a and b and a[-1] == b[-1]:
216 a.pop() 219 a.pop()
217 b.pop() 220 b.pop()