diff options
author | shimizukawa <shimizukawa@gmail.com> | 2012-12-10 10:18:32 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2012-12-10 10:18:32 +0900 |
commit | d45dcfbd7e5add4495a7e31ee53e672ee180d534 (patch) | |
tree | e3ccbee28f06bfccb66ab2c54cb3b1648409e704 /sphinx/util/osutil.py | |
parent | 207e12471f451fee53a95ca6918c93abfef3a632 (diff) | |
parent | 5818df7941b73abecdb1b399fee7956ea283d698 (diff) | |
download | sphinx-d45dcfbd7e5add4495a7e31ee53e672ee180d534.tar.gz |
merge heads
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r-- | sphinx/util/osutil.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 8dc3b9d3..17619ee1 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 |