Show More
@@ -1658,7 +1658,10 b' def locate(ui, repo, *pats, **opts):' | |||
|
1658 | 1658 | |
|
1659 | 1659 | ret = 1 |
|
1660 | 1660 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, |
|
1661 | badmatch=util.always, | |
|
1661 | 1662 | default='relglob'): |
|
1663 | if src == 'b': | |
|
1664 | continue | |
|
1662 | 1665 | if not node and repo.dirstate.state(abs) == '?': |
|
1663 | 1666 | continue |
|
1664 | 1667 | if opts['fullpath']: |
@@ -447,7 +447,7 b' def _matcher(canonroot, cwd, names, inc,' | |||
|
447 | 447 | if c in _globchars: return True |
|
448 | 448 | return False |
|
449 | 449 | |
|
450 | def regex(kind, name): | |
|
450 | def regex(kind, name, tail): | |
|
451 | 451 | '''convert a pattern into a regular expression''' |
|
452 | 452 | if not name: |
|
453 | 453 | return '' |
@@ -456,23 +456,23 b' def _matcher(canonroot, cwd, names, inc,' | |||
|
456 | 456 | elif kind == 'path': |
|
457 | 457 | return '^' + re.escape(name) + '(?:/|$)' |
|
458 | 458 | elif kind == 'relglob': |
|
459 |
return globre(name, '(?:|.*/)', |
|
|
459 | return globre(name, '(?:|.*/)', tail) | |
|
460 | 460 | elif kind == 'relpath': |
|
461 | 461 | return re.escape(name) + '(?:/|$)' |
|
462 | 462 | elif kind == 'relre': |
|
463 | 463 | if name.startswith('^'): |
|
464 | 464 | return name |
|
465 | 465 | return '.*' + name |
|
466 |
return globre(name, '', |
|
|
466 | return globre(name, '', tail) | |
|
467 | 467 | |
|
468 | def matchfn(pats): | |
|
468 | def matchfn(pats, tail): | |
|
469 | 469 | """build a matching function from a set of patterns""" |
|
470 | 470 | if not pats: |
|
471 | 471 | return |
|
472 | 472 | matches = [] |
|
473 | 473 | for k, p in pats: |
|
474 | 474 | try: |
|
475 | pat = '(?:%s)' % regex(k, p) | |
|
475 | pat = '(?:%s)' % regex(k, p, tail) | |
|
476 | 476 | matches.append(re.compile(pat).match) |
|
477 | 477 | except re.error: |
|
478 | 478 | if src: raise Abort("%s: invalid pattern (%s): %s" % (src, k, p)) |
@@ -520,15 +520,15 b' def _matcher(canonroot, cwd, names, inc,' | |||
|
520 | 520 | |
|
521 | 521 | roots, pats, anypats = normalizepats(names, dflt_pat) |
|
522 | 522 | |
|
523 | patmatch = matchfn(pats) or always | |
|
523 | patmatch = matchfn(pats, '$') or always | |
|
524 | 524 | incmatch = always |
|
525 | 525 | if inc: |
|
526 | 526 | dummy, inckinds, dummy = normalizepats(inc, 'glob') |
|
527 | incmatch = matchfn(inckinds) | |
|
527 | incmatch = matchfn(inckinds, '(?:/|$)') | |
|
528 | 528 | excmatch = lambda fn: False |
|
529 | 529 | if exc: |
|
530 | 530 | dummy, exckinds, dummy = normalizepats(exc, 'glob') |
|
531 | excmatch = matchfn(exckinds) | |
|
531 | excmatch = matchfn(exckinds, '(?:/|$)') | |
|
532 | 532 | |
|
533 | 533 | if not names and inc and not exc: |
|
534 | 534 | # common case: hgignore patterns |
@@ -19,6 +19,8 b' mkdir t' | |||
|
19 | 19 | echo 0 > t/x |
|
20 | 20 | echo 0 > t/b |
|
21 | 21 | echo 0 > t/e.h |
|
22 | mkdir dir.h | |
|
23 | echo 0 > dir.h/foo | |
|
22 | 24 | hg ci -A -m m -d "1000000 0" |
|
23 | 25 | touch nottracked |
|
24 | 26 | hglocate a && echo locate succeeded || echo locate failed |
@@ -28,9 +30,11 b' hg rm a' | |||
|
28 | 30 | hg ci -m m -d "1000000 0" |
|
29 | 31 | hglocate a |
|
30 | 32 | hglocate NONEXISTENT |
|
33 | hglocate relpath:NONEXISTENT | |
|
31 | 34 | hglocate |
|
32 | 35 | hglocate -r 0 a |
|
33 | 36 | hglocate -r 0 NONEXISTENT |
|
37 | hglocate -r 0 relpath:NONEXISTENT | |
|
34 | 38 | hglocate -r 0 |
|
35 | 39 | echo % -I/-X with relative path should work |
|
36 | 40 | cd t |
@@ -39,14 +43,14 b' hglocate -I ../t' | |||
|
39 | 43 | # test issue294 |
|
40 | 44 | cd .. |
|
41 | 45 | rm -r t |
|
42 | hglocate t | |
|
46 | hglocate 't/**' | |
|
43 | 47 | mkdir otherdir |
|
44 | 48 | cd otherdir |
|
45 | 49 | hglocate b |
|
46 | 50 | hglocate '*.h' |
|
47 | 51 | hglocate path:t/x |
|
48 | hglocate 're:.*\.h' | |
|
52 | hglocate 're:.*\.h$' | |
|
49 | 53 | hglocate -r 0 b |
|
50 | 54 | hglocate -r 0 '*.h' |
|
51 | 55 | hglocate -r 0 path:t/x |
|
52 | hglocate -r 0 're:.*\.h' | |
|
56 | hglocate -r 0 're:.*\.h$' |
@@ -1,5 +1,6 b'' | |||
|
1 | 1 | adding a |
|
2 | 2 | adding b |
|
3 | adding dir.h/foo | |
|
3 | 4 | adding t.h |
|
4 | 5 | adding t/b |
|
5 | 6 | adding t/e.h |
@@ -14,6 +15,7 b' locate failed' | |||
|
14 | 15 | hg locate |
|
15 | 16 | a |
|
16 | 17 | b |
|
18 | dir.h/foo | |
|
17 | 19 | t.h |
|
18 | 20 | t/b |
|
19 | 21 | t/e.h |
@@ -23,8 +25,11 b' hg locate a' | |||
|
23 | 25 | |
|
24 | 26 | hg locate NONEXISTENT |
|
25 | 27 | |
|
28 | hg locate relpath:NONEXISTENT | |
|
29 | ||
|
26 | 30 | hg locate |
|
27 | 31 | b |
|
32 | dir.h/foo | |
|
28 | 33 | t.h |
|
29 | 34 | t/b |
|
30 | 35 | t/e.h |
@@ -35,9 +40,12 b' a' | |||
|
35 | 40 | |
|
36 | 41 | hg locate -r 0 NONEXISTENT |
|
37 | 42 | |
|
43 | hg locate -r 0 relpath:NONEXISTENT | |
|
44 | ||
|
38 | 45 | hg locate -r 0 |
|
39 | 46 | a |
|
40 | 47 | b |
|
48 | dir.h/foo | |
|
41 | 49 | t.h |
|
42 | 50 | t/b |
|
43 | 51 | t/e.h |
@@ -46,6 +54,7 b' t/x' | |||
|
46 | 54 | % -I/-X with relative path should work |
|
47 | 55 | hg locate |
|
48 | 56 | b |
|
57 | dir.h/foo | |
|
49 | 58 | t.h |
|
50 | 59 | t/b |
|
51 | 60 | t/e.h |
@@ -56,7 +65,7 b' t/b' | |||
|
56 | 65 | t/e.h |
|
57 | 66 | t/x |
|
58 | 67 | |
|
59 | hg locate t | |
|
68 | hg locate t/** | |
|
60 | 69 | t/b |
|
61 | 70 | t/e.h |
|
62 | 71 | t/x |
@@ -72,7 +81,7 b' hg locate *.h' | |||
|
72 | 81 | hg locate path:t/x |
|
73 | 82 | ../t/x |
|
74 | 83 | |
|
75 | hg locate re:.*\.h | |
|
84 | hg locate re:.*\.h$ | |
|
76 | 85 | ../t.h |
|
77 | 86 | ../t/e.h |
|
78 | 87 | |
@@ -87,7 +96,7 b' hg locate -r 0 *.h' | |||
|
87 | 96 | hg locate -r 0 path:t/x |
|
88 | 97 | ../t/x |
|
89 | 98 | |
|
90 | hg locate -r 0 re:.*\.h | |
|
99 | hg locate -r 0 re:.*\.h$ | |
|
91 | 100 | ../t.h |
|
92 | 101 | ../t/e.h |
|
93 | 102 |
@@ -72,11 +72,13 b' debugwalk beans/.hg' | |||
|
72 | 72 | #debugwalk `pwd`/beans |
|
73 | 73 | #debugwalk `pwd`/.. |
|
74 | 74 | debugwalk glob:\* |
|
75 | debugwalk 'glob:**e' | |
|
75 | 76 | debugwalk 're:.*[kb]$' |
|
76 | 77 | debugwalk path:beans/black |
|
77 | 78 | debugwalk path:beans//black |
|
78 | 79 | debugwalk relglob:Procyonidae |
|
79 |
debugwalk relglob:Procyonidae/ |
|
|
80 | debugwalk 'relglob:Procyonidae/**' | |
|
81 | debugwalk 'relglob:Procyonidae/**' fennel | |
|
80 | 82 | debugwalk beans 'glob:beans/*' |
|
81 | 83 | debugwalk 'glob:mamm**' |
|
82 | 84 | debugwalk 'glob:mamm**' fennel |
@@ -210,20 +210,14 b' hg debugwalk beans/.hg' | |||
|
210 | 210 | beans/.hg: No such file or directory |
|
211 | 211 | |
|
212 | 212 | hg debugwalk glob:* |
|
213 | f beans/black beans/black | |
|
214 | f beans/borlotti beans/borlotti | |
|
215 | f beans/kidney beans/kidney | |
|
216 | f beans/navy beans/navy | |
|
217 | f beans/pinto beans/pinto | |
|
213 | f fennel fennel | |
|
214 | f fenugreek fenugreek | |
|
215 | f fiddlehead fiddlehead | |
|
216 | f glob:glob glob:glob | |
|
217 | ||
|
218 | hg debugwalk glob:**e | |
|
218 | 219 | f beans/turtle beans/turtle |
|
219 | f fennel fennel | |
|
220 | f fenugreek fenugreek | |
|
221 | f fiddlehead fiddlehead | |
|
222 | f glob:glob glob:glob | |
|
223 | 220 | f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle |
|
224 | f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi | |
|
225 | f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon | |
|
226 | f mammals/skunk mammals/skunk | |
|
227 | 221 | |
|
228 | 222 | hg debugwalk re:.*[kb]$ |
|
229 | 223 | f beans/black beans/black |
@@ -238,11 +232,13 b' hg debugwalk path:beans//black' | |||
|
238 | 232 | f beans/black beans/black exact |
|
239 | 233 | |
|
240 | 234 | hg debugwalk relglob:Procyonidae |
|
235 | ||
|
236 | hg debugwalk relglob:Procyonidae/** | |
|
241 | 237 | f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle |
|
242 | 238 | f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi |
|
243 | 239 | f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon |
|
244 | 240 | |
|
245 | hg debugwalk relglob:Procyonidae/ fennel | |
|
241 | hg debugwalk relglob:Procyonidae/** fennel | |
|
246 | 242 | f fennel fennel exact |
|
247 | 243 | f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle |
|
248 | 244 | f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi |
General Comments 0
You need to be logged in to leave comments.
Login now