Mercurial > hg
comparison mercurial/util.py @ 4230:c93562fb12cc
Fix handling of paths when run outside the repo.
The main problem was that dirstate.getcwd() returned just "",
which was interpreted as "we're at the repo root". It now returns
an absolute path.
The util.pathto function was also changed to deal with the "cwd is
an absolute path" case.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 16 Mar 2007 00:22:58 -0300 |
parents | 24c22a3f2ef8 |
children | 0d51eb296fb9 5e3936eabe5d |
comparison
equal
deleted
inserted
replaced
4229:24c22a3f2ef8 | 4230:c93562fb12cc |
---|---|
324 If n1 is a relative path, it's assumed it's | 324 If n1 is a relative path, it's assumed it's |
325 relative to root. | 325 relative to root. |
326 n2 should always be relative to root. | 326 n2 should always be relative to root. |
327 ''' | 327 ''' |
328 if not n1: return localpath(n2) | 328 if not n1: return localpath(n2) |
329 if os.path.isabs(n1): | |
330 if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]: | |
331 return os.path.join(root, localpath(n2)) | |
332 n2 = '/'.join((pconvert(root), n2)) | |
329 a, b = n1.split(os.sep), n2.split('/') | 333 a, b = n1.split(os.sep), n2.split('/') |
330 a.reverse() | 334 a.reverse() |
331 b.reverse() | 335 b.reverse() |
332 while a and b and a[-1] == b[-1]: | 336 while a and b and a[-1] == b[-1]: |
333 a.pop() | 337 a.pop() |