Show More
@@ -215,6 +215,30 b' def canonpath(root, cwd, myname):' | |||||
215 | elif name == root: |
|
215 | elif name == root: | |
216 | return '' |
|
216 | return '' | |
217 | else: |
|
217 | else: | |
|
218 | # Determine whether `name' is in the hierarchy at or beneath `root', | |||
|
219 | # by iterating name=dirname(name) until that causes no change (can't | |||
|
220 | # check name == '/', because that doesn't work on windows). For each | |||
|
221 | # `name', compare dev/inode numbers. If they match, the list `rel' | |||
|
222 | # holds the reversed list of components making up the relative file | |||
|
223 | # name we want. | |||
|
224 | root_st = os.stat(root) | |||
|
225 | rel = [] | |||
|
226 | while True: | |||
|
227 | try: | |||
|
228 | name_st = os.stat(name) | |||
|
229 | except OSError: | |||
|
230 | break | |||
|
231 | if os.path.samestat(name_st, root_st): | |||
|
232 | rel.reverse() | |||
|
233 | name = os.path.join(*rel) | |||
|
234 | audit_path(name) | |||
|
235 | return pconvert(name) | |||
|
236 | dirname, basename = os.path.split(name) | |||
|
237 | rel.append(basename) | |||
|
238 | if dirname == name: | |||
|
239 | break | |||
|
240 | name = dirname | |||
|
241 | ||||
218 | raise Abort('%s not under root' % myname) |
|
242 | raise Abort('%s not under root' % myname) | |
219 |
|
243 | |||
220 | def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): |
|
244 | def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): |
@@ -40,3 +40,18 b' mkfifo a.c' | |||||
40 | # it should show a.c, dir/a.o and dir/b.o deleted |
|
40 | # it should show a.c, dir/a.o and dir/b.o deleted | |
41 | hg status |
|
41 | hg status | |
42 | hg status a.c |
|
42 | hg status a.c | |
|
43 | ||||
|
44 | echo '# test absolute path through symlink outside repo' | |||
|
45 | cd .. | |||
|
46 | p=`pwd` | |||
|
47 | hg init x | |||
|
48 | ln -s x y | |||
|
49 | cd x | |||
|
50 | touch f | |||
|
51 | hg add f | |||
|
52 | hg status $p/y/f | |||
|
53 | ||||
|
54 | echo '# try symlink outside repo to file inside' | |||
|
55 | ln -s x/f ../z | |||
|
56 | # this should fail | |||
|
57 | hg status ../z && { echo hg mistakenly exited with status 0; exit 1; } || : |
@@ -9,3 +9,7 b' adding dir/b.o' | |||||
9 | ? .hgignore |
|
9 | ? .hgignore | |
10 | a.c: unsupported file type (type is fifo) |
|
10 | a.c: unsupported file type (type is fifo) | |
11 | ! a.c |
|
11 | ! a.c | |
|
12 | # test absolute path through symlink outside repo | |||
|
13 | A f | |||
|
14 | # try symlink outside repo to file inside | |||
|
15 | abort: ../z not under root |
General Comments 0
You need to be logged in to leave comments.
Login now