##// END OF EJS Templates
Fix handling of paths when run outside the repo....
Alexis S. L. Carvalho -
r4230:c93562fb default
parent child Browse files
Show More
@@ -34,10 +34,14 b' class dirstate(object):'
34 cwd = os.getcwd()
34 cwd = os.getcwd()
35 if cwd == self.root: return ''
35 if cwd == self.root: return ''
36 # self.root ends with a path separator if self.root is '/' or 'C:\'
36 # self.root ends with a path separator if self.root is '/' or 'C:\'
37 common_prefix_len = len(self.root)
37 rootsep = self.root
38 if not self.root.endswith(os.sep):
38 if not rootsep.endswith(os.sep):
39 common_prefix_len += 1
39 rootsep += os.sep
40 return cwd[common_prefix_len:]
40 if cwd.startswith(rootsep):
41 return cwd[len(rootsep):]
42 else:
43 # we're outside the repo. return an absolute path.
44 return cwd
41
45
42 def hgignore(self):
46 def hgignore(self):
43 '''return the contents of .hgignore files as a list of patterns.
47 '''return the contents of .hgignore files as a list of patterns.
@@ -326,6 +326,10 b' def pathto(root, n1, n2):'
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()
@@ -32,6 +32,17 b' hg --cwd a diff -r0:1 > tip.patch'
32 hg --cwd b import -mpatch ../tip.patch
32 hg --cwd b import -mpatch ../tip.patch
33 rm -r b
33 rm -r b
34
34
35 echo % hg -R repo import
36 # put the clone in a subdir - having a directory named "a"
37 # used to hide a bug.
38 mkdir dir
39 hg clone -r0 a dir/b
40 hg --cwd a export tip > dir/tip.patch
41 cd dir
42 hg -R b import tip.patch
43 cd ..
44 rm -r dir
45
35 echo % import from stdin
46 echo % import from stdin
36 hg clone -r0 a b
47 hg clone -r0 a b
37 hg --cwd a export tip | hg --cwd b import -
48 hg --cwd a export tip | hg --cwd b import -
@@ -30,6 +30,14 b' adding file changes'
30 added 1 changesets with 2 changes to 2 files
30 added 1 changesets with 2 changes to 2 files
31 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
31 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 applying ../tip.patch
32 applying ../tip.patch
33 % hg -R repo import
34 requesting all changes
35 adding changesets
36 adding manifests
37 adding file changes
38 added 1 changesets with 2 changes to 2 files
39 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 applying tip.patch
33 % import from stdin
41 % import from stdin
34 requesting all changes
42 requesting all changes
35 adding changesets
43 adding changesets
@@ -59,3 +59,9 b' hg rm fenugreek'
59 hg debugwalk fenugreek
59 hg debugwalk fenugreek
60 touch new
60 touch new
61 hg debugwalk new
61 hg debugwalk new
62 cd ..
63 hg -R t debugwalk t/mammals/skunk
64 mkdir t2
65 cd t2
66 hg -R ../t debugwalk ../t/mammals/skunk
67 hg --cwd ../t debugwalk mammals/skunk
@@ -95,3 +95,6 b' fifo: unsupported file type (type is fif'
95 m fenugreek fenugreek exact
95 m fenugreek fenugreek exact
96 m fenugreek fenugreek exact
96 m fenugreek fenugreek exact
97 f new new exact
97 f new new exact
98 f mammals/skunk t/mammals/skunk exact
99 f mammals/skunk ../t/mammals/skunk exact
100 f mammals/skunk mammals/skunk exact
General Comments 0
You need to be logged in to leave comments. Login now