mercurial/util.py
changeset 884 087771ebe2e6
parent 883 63ca8a68d59e
child 885 6594ba2a0f51
child 886 509de8ab6f31
--- a/mercurial/util.py	Fri Aug 12 07:42:32 2005 -0800
+++ b/mercurial/util.py	Fri Aug 12 11:16:58 2005 -0800
@@ -69,6 +69,16 @@
 
 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
 
+def pathto(n1, n2):
+    '''return the relative path from one place to another'''
+    if not n1: return n2
+    a, b = n1.split(os.sep), n2.split(os.sep)
+    a.reverse(), b.reverse()
+    while a and b and a[-1] == b[-1]:
+        a.pop(), b.pop()
+    b.reverse()
+    return os.sep.join((['..'] * len(a)) + b)
+
 def canonpath(repo, cwd, myname):
     rootsep = repo.root + os.sep
     name = myname