##// END OF EJS Templates
Merge some matcher fixes/cleanups and add some more hg locate tests
Alexis S. L. Carvalho -
r4237:da6b1487 merge default
parent child Browse files
Show More
@@ -496,7 +496,6 b' def _matcher(canonroot, cwd, names, inc,'
496
496
497 def normalizepats(names, default):
497 def normalizepats(names, default):
498 pats = []
498 pats = []
499 files = []
500 roots = []
499 roots = []
501 anypats = False
500 anypats = False
502 for kind, name in [patkind(p, default) for p in names]:
501 for kind, name in [patkind(p, default) for p in names]:
@@ -504,18 +503,20 b' def _matcher(canonroot, cwd, names, inc,'
504 name = canonpath(canonroot, cwd, name)
503 name = canonpath(canonroot, cwd, name)
505 elif kind in ('relglob', 'path'):
504 elif kind in ('relglob', 'path'):
506 name = normpath(name)
505 name = normpath(name)
506
507 pats.append((kind, name))
508
507 if kind in ('glob', 're', 'relglob', 'relre'):
509 if kind in ('glob', 're', 'relglob', 'relre'):
508 pats.append((kind, name))
509 anypats = True
510 anypats = True
511
510 if kind == 'glob':
512 if kind == 'glob':
511 root = globprefix(name)
513 root = globprefix(name)
512 roots.append(root)
514 roots.append(root)
513 elif kind in ('relpath', 'path'):
515 elif kind in ('relpath', 'path'):
514 files.append((kind, name))
516 roots.append(name or '.')
515 roots.append(name)
516 elif kind == 'relglob':
517 elif kind == 'relglob':
517 roots.append('.')
518 roots.append('.')
518 return roots, pats + files, anypats
519 return roots, pats, anypats
519
520
520 roots, pats, anypats = normalizepats(names, dflt_pat)
521 roots, pats, anypats = normalizepats(names, dflt_pat)
521
522
@@ -1,5 +1,14 b''
1 #!/bin/sh
1 #!/bin/sh
2 #
2
3 hglocate()
4 {
5 echo "hg locate $@"
6 hg locate "$@"
7 ret=$?
8 echo
9 return $ret
10 }
11
3 mkdir t
12 mkdir t
4 cd t
13 cd t
5 hg init
14 hg init
@@ -8,24 +17,36 b' echo 0 > b'
8 echo 0 > t.h
17 echo 0 > t.h
9 mkdir t
18 mkdir t
10 echo 0 > t/x
19 echo 0 > t/x
20 echo 0 > t/b
21 echo 0 > t/e.h
11 hg ci -A -m m -d "1000000 0"
22 hg ci -A -m m -d "1000000 0"
12 touch nottracked
23 touch nottracked
13 hg locate a && echo locate succeeded || echo locate failed
24 hglocate a && echo locate succeeded || echo locate failed
14 hg locate NONEXISTENT && echo locate succeeded || echo locate failed
25 hglocate NONEXISTENT && echo locate succeeded || echo locate failed
15 hg locate
26 hglocate
16 hg rm a
27 hg rm a
17 hg ci -m m -d "1000000 0"
28 hg ci -m m -d "1000000 0"
18 hg locate a
29 hglocate a
19 hg locate NONEXISTENT
30 hglocate NONEXISTENT
20 hg locate
31 hglocate
21 hg locate -r 0 a
32 hglocate -r 0 a
22 hg locate -r 0 NONEXISTENT
33 hglocate -r 0 NONEXISTENT
23 hg locate -r 0
34 hglocate -r 0
24 echo % -I/-X with relative path should work
35 echo % -I/-X with relative path should work
25 cd t
36 cd t
26 hg locate
37 hglocate
27 hg locate -I ../t
38 hglocate -I ../t
28 # test issue294
39 # test issue294
29 cd ..
40 cd ..
30 rm -r t
41 rm -r t
31 hg locate t
42 hglocate t
43 mkdir otherdir
44 cd otherdir
45 hglocate b
46 hglocate '*.h'
47 hglocate path:t/x
48 hglocate 're:.*\.h'
49 hglocate -r 0 b
50 hglocate -r 0 '*.h'
51 hglocate -r 0 path:t/x
52 hglocate -r 0 're:.*\.h'
@@ -1,25 +1,93 b''
1 adding a
1 adding a
2 adding b
2 adding b
3 adding t.h
3 adding t.h
4 adding t/b
5 adding t/e.h
4 adding t/x
6 adding t/x
7 hg locate a
8 a
9
10 locate succeeded
11 hg locate NONEXISTENT
12
13 locate failed
14 hg locate
5 a
15 a
6 locate succeeded
16 b
7 locate failed
17 t.h
18 t/b
19 t/e.h
20 t/x
21
22 hg locate a
23
24 hg locate NONEXISTENT
25
26 hg locate
27 b
28 t.h
29 t/b
30 t/e.h
31 t/x
32
33 hg locate -r 0 a
34 a
35
36 hg locate -r 0 NONEXISTENT
37
38 hg locate -r 0
8 a
39 a
9 b
40 b
10 t.h
41 t.h
42 t/b
43 t/e.h
11 t/x
44 t/x
12 b
45
13 t.h
46 % -I/-X with relative path should work
14 t/x
47 hg locate
15 a
16 a
17 b
48 b
18 t.h
49 t.h
50 t/b
51 t/e.h
19 t/x
52 t/x
20 % -I/-X with relative path should work
53
21 b
54 hg locate -I ../t
22 t.h
55 t/b
56 t/e.h
57 t/x
58
59 hg locate t
60 t/b
61 t/e.h
23 t/x
62 t/x
24 t/x
63
25 t/x
64 hg locate b
65 ../b
66 ../t/b
67
68 hg locate *.h
69 ../t.h
70 ../t/e.h
71
72 hg locate path:t/x
73 ../t/x
74
75 hg locate re:.*\.h
76 ../t.h
77 ../t/e.h
78
79 hg locate -r 0 b
80 ../b
81 ../t/b
82
83 hg locate -r 0 *.h
84 ../t.h
85 ../t/e.h
86
87 hg locate -r 0 path:t/x
88 ../t/x
89
90 hg locate -r 0 re:.*\.h
91 ../t.h
92 ../t/e.h
93
@@ -92,4 +92,6 b' mkdir newdir'
92 echo foo > newdir/newfile
92 echo foo > newdir/newfile
93 hg add newdir/newfile
93 hg add newdir/newfile
94 hg revert b newdir
94 hg revert b newdir
95 echo foobar > b/b
96 hg revert .
95 true
97 true
@@ -62,3 +62,4 b' reverting a'
62 adding b/b
62 adding b/b
63 reverting b/b
63 reverting b/b
64 forgetting newdir/newfile
64 forgetting newdir/newfile
65 reverting b/b
General Comments 0
You need to be logged in to leave comments. Login now