summaryrefslogtreecommitdiff
path: root/sphinx/util/osutil.py
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2012-12-10 10:18:32 +0900
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2012-12-10 10:18:32 +0900
commit3f9598394bd3f240852834bbc063712cf28dd085 (patch)
treee3ccbee28f06bfccb66ab2c54cb3b1648409e704 /sphinx/util/osutil.py
parent1bb4923da1aa1878af44c4608d63025e4fae9d3b (diff)
parentdbbfdcddcf4e43a2d9d6c4a73d7ec6d10a214285 (diff)
downloadsphinx-git-3f9598394bd3f240852834bbc063712cf28dd085.tar.gz
merge heads
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r--sphinx/util/osutil.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index 8dc3b9d36..17619ee1d 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -40,12 +40,20 @@ def relative_uri(base, to):
return to
b2 = base.split(SEP)
t2 = to.split(SEP)
- # remove common segments
- for x, y in zip(b2, t2):
+ # remove common segments (except the last segment)
+ for x, y in zip(b2[:-1], t2[:-1]):
if x != y:
break
b2.pop(0)
t2.pop(0)
+ if b2 == t2:
+ # Special case: relative_uri('f/index.html','f/index.html')
+ # returns '', not 'index.html'
+ return ''
+ if len(b2) == 1 and t2 == ['']:
+ # Special case: relative_uri('f/index.html','f/') should
+ # return './', not ''
+ return '.' + SEP
return ('..' + SEP) * (len(b2)-1) + SEP.join(t2)
@@ -136,8 +144,9 @@ else:
def safe_relpath(path, start=None):
+ from sphinx.util.pycompat import relpath
try:
- return os.path.relpath(path, start)
+ return relpath(path, start)
except ValueError:
return path