mercurial/util.py
changeset 4229 24c22a3f2ef8
parent 4129 e817c68edfed
child 4230 c93562fb12cc
equal deleted inserted replaced
4228:c52b7176af94 4229:24c22a3f2ef8
   312             res += re.escape(c)
   312             res += re.escape(c)
   313     return head + res + tail
   313     return head + res + tail
   314 
   314 
   315 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
   315 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
   316 
   316 
   317 def pathto(n1, n2):
   317 def pathto(root, n1, n2):
   318     '''return the relative path from one place to another.
   318     '''return the relative path from one place to another.
       
   319     root should use os.sep to separate directories
   319     n1 should use os.sep to separate directories
   320     n1 should use os.sep to separate directories
   320     n2 should use "/" to separate directories
   321     n2 should use "/" to separate directories
   321     returns an os.sep-separated path.
   322     returns an os.sep-separated path.
       
   323 
       
   324     If n1 is a relative path, it's assumed it's
       
   325     relative to root.
       
   326     n2 should always be relative to root.
   322     '''
   327     '''
   323     if not n1: return localpath(n2)
   328     if not n1: return localpath(n2)
   324     a, b = n1.split(os.sep), n2.split('/')
   329     a, b = n1.split(os.sep), n2.split('/')
   325     a.reverse()
   330     a.reverse()
   326     b.reverse()
   331     b.reverse()