##// END OF EJS Templates
change locate to use relglobs by default...
Alexis S. L. Carvalho -
r4195:e8ee8fde default
parent child Browse files
Show More
@@ -127,15 +127,16 b' def make_file(repo, pat, node=None,'
127 pathname),
127 pathname),
128 mode)
128 mode)
129
129
130 def matchpats(repo, pats=[], opts={}, head='', globbed=False):
130 def matchpats(repo, pats=[], opts={}, head='', globbed=False, default=None):
131 cwd = repo.getcwd()
131 cwd = repo.getcwd()
132 return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'),
132 return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'),
133 opts.get('exclude'), head, globbed=globbed)
133 opts.get('exclude'), head, globbed=globbed,
134 default=default)
134
135
135 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
136 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
136 globbed=False):
137 globbed=False, default=None):
137 files, matchfn, anypats = matchpats(repo, pats, opts, head,
138 files, matchfn, anypats = matchpats(repo, pats, opts, head,
138 globbed=globbed)
139 globbed=globbed, default=default)
139 exact = dict.fromkeys(files)
140 exact = dict.fromkeys(files)
140 for src, fn in repo.walk(node=node, files=files, match=matchfn,
141 for src, fn in repo.walk(node=node, files=files, match=matchfn,
141 badmatch=badmatch):
142 badmatch=badmatch):
@@ -1602,9 +1602,8 b' def locate(ui, repo, *pats, **opts):'
1602 Print all files under Mercurial control whose names match the
1602 Print all files under Mercurial control whose names match the
1603 given patterns.
1603 given patterns.
1604
1604
1605 This command searches the current directory and its
1605 This command searches the entire repository by default. To search
1606 subdirectories. To search an entire repository, move to the root
1606 just the current directory and its subdirectories, use "--include .".
1607 of the repository.
1608
1607
1609 If no patterns are given to match, this command prints all file
1608 If no patterns are given to match, this command prints all file
1610 names.
1609 names.
@@ -1622,7 +1621,7 b' def locate(ui, repo, *pats, **opts):'
1622 node = None
1621 node = None
1623
1622
1624 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
1623 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
1625 head='(?:.*/|)'):
1624 default='relglob'):
1626 if not node and repo.dirstate.state(abs) == '?':
1625 if not node and repo.dirstate.state(abs) == '?':
1627 continue
1626 continue
1628 if opts['fullpath']:
1627 if opts['fullpath']:
@@ -832,6 +832,9 b' class localrepository(repo.repository):'
832
832
833 if node:
833 if node:
834 fdict = dict.fromkeys(files)
834 fdict = dict.fromkeys(files)
835 # for dirstate.walk, files=['.'] means "walk the whole tree".
836 # follow that here, too
837 fdict.pop('.', None)
835 mdict = self.manifest.read(self.changelog.read(node)[0])
838 mdict = self.manifest.read(self.changelog.read(node)[0])
836 mfiles = mdict.keys()
839 mfiles = mdict.keys()
837 mfiles.sort()
840 mfiles.sort()
@@ -382,10 +382,11 b" def matcher(canonroot, cwd='', names=[],"
382 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
382 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
383
383
384 def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], head='',
384 def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], head='',
385 src=None, globbed=False):
385 src=None, globbed=False, default=None):
386 if not globbed:
386 default = default or 'relpath'
387 if default == 'relpath' and not globbed:
387 names = expand_glob(names)
388 names = expand_glob(names)
388 return _matcher(canonroot, cwd, names, inc, exc, head, 'relpath', src)
389 return _matcher(canonroot, cwd, names, inc, exc, head, default, src)
389
390
390 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
391 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
391 """build a function to match a set of file patterns
392 """build a function to match a set of file patterns
@@ -28,7 +28,6 b' reverting a'
28 changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5
28 changeset 3:4cbb1e70196a backs out changeset 1:22bca4c721e5
29 the backout changeset is a new head - do not forget to merge
29 the backout changeset is a new head - do not forget to merge
30 (use "backout --merge" if you want to auto-merge)
30 (use "backout --merge" if you want to auto-merge)
31 b: No such file or directory
32 adding a
31 adding a
33 adding b
32 adding b
34 adding c
33 adding c
@@ -31,7 +31,6 b' a'
31 a
31 a
32 % rename and modify
32 % rename and modify
33 applying patch from stdin
33 applying patch from stdin
34 copy2: No such file or directory
35 a
34 a
36 a
35 a
37 b
36 b
@@ -40,7 +39,6 b' a'
40 % one file renamed multiple times
39 % one file renamed multiple times
41 applying patch from stdin
40 applying patch from stdin
42 9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
41 9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
43 rename2: No such file or directory
44 rename3
42 rename3
45 rename3-2
43 rename3-2
46 a
44 a
@@ -3,18 +3,14 b' adding b'
3 adding t.h
3 adding t.h
4 adding t/x
4 adding t/x
5 a
5 a
6 NONEXISTENT: No such file or directory
7 a
6 a
8 b
7 b
9 t.h
8 t.h
10 t/x
9 t/x
11 a: No such file or directory
12 NONEXISTENT: No such file or directory
13 b
10 b
14 t.h
11 t.h
15 t/x
12 t/x
16 a
13 a
17 NONEXISTENT: No such file in rev ce18e5bc5cd3
18 a
14 a
19 b
15 b
20 t.h
16 t.h
General Comments 0
You need to be logged in to leave comments. Login now