##// END OF EJS Templates
walk: return a single value
Matt Mackall -
r6586:d3463007 default
parent child Browse files
Show More
@@ -271,11 +271,11 b' def addremove(repo, pats=[], opts={}, dr'
271 add, remove = [], []
271 add, remove = [], []
272 mapping = {}
272 mapping = {}
273 m = match(repo, pats, opts)
273 m = match(repo, pats, opts)
274 for src, abs in repo.walk(m):
274 for abs in repo.walk(m):
275 target = repo.wjoin(abs)
275 target = repo.wjoin(abs)
276 rel = m.rel(abs)
276 rel = m.rel(abs)
277 exact = m.exact(abs)
277 exact = m.exact(abs)
278 if src == 'f' and abs not in repo.dirstate:
278 if abs not in repo.dirstate:
279 add.append(abs)
279 add.append(abs)
280 mapping[abs] = rel, m.exact(abs)
280 mapping[abs] = rel, m.exact(abs)
281 if repo.ui.verbose or not exact:
281 if repo.ui.verbose or not exact:
@@ -313,7 +313,7 b' def copy(ui, repo, pats, opts, rename=Fa'
313 def walkpat(pat):
313 def walkpat(pat):
314 srcs = []
314 srcs = []
315 m = match(repo, [pat], opts, globbed=True)
315 m = match(repo, [pat], opts, globbed=True)
316 for tag, abs in repo.walk(m):
316 for abs in repo.walk(m):
317 state = repo.dirstate[abs]
317 state = repo.dirstate[abs]
318 rel = m.rel(abs)
318 rel = m.rel(abs)
319 exact = m.exact(abs)
319 exact = m.exact(abs)
@@ -33,7 +33,7 b' def add(ui, repo, *pats, **opts):'
33 names = []
33 names = []
34 m = cmdutil.match(repo, pats, opts)
34 m = cmdutil.match(repo, pats, opts)
35 m.bad = lambda x,y: True
35 m.bad = lambda x,y: True
36 for src, abs in repo.walk(m):
36 for abs in repo.walk(m):
37 if m.exact(abs):
37 if m.exact(abs):
38 if ui.verbose:
38 if ui.verbose:
39 ui.status(_('adding %s\n') % m.rel(abs))
39 ui.status(_('adding %s\n') % m.rel(abs))
@@ -110,7 +110,7 b' def annotate(ui, repo, *pats, **opts):'
110 ctx = repo.changectx(opts['rev'])
110 ctx = repo.changectx(opts['rev'])
111
111
112 m = cmdutil.match(repo, pats, opts)
112 m = cmdutil.match(repo, pats, opts)
113 for src, abs in repo.walk(m, ctx.node()):
113 for abs in repo.walk(m, ctx.node()):
114 fctx = ctx.filectx(abs)
114 fctx = ctx.filectx(abs)
115 if not opts['text'] and util.binary(fctx.data()):
115 if not opts['text'] and util.binary(fctx.data()):
116 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
116 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
@@ -489,7 +489,7 b' def cat(ui, repo, file1, *pats, **opts):'
489 ctx = repo.changectx(opts['rev'])
489 ctx = repo.changectx(opts['rev'])
490 err = 1
490 err = 1
491 m = cmdutil.match(repo, (file1,) + pats, opts)
491 m = cmdutil.match(repo, (file1,) + pats, opts)
492 for src, abs in repo.walk(m, ctx.node()):
492 for abs in repo.walk(m, ctx.node()):
493 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
493 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
494 data = ctx.filectx(abs).data()
494 data = ctx.filectx(abs).data()
495 if opts.get('decode'):
495 if opts.get('decode'):
@@ -915,7 +915,7 b' def debugrename(ui, repo, file1, *pats, '
915
915
916 ctx = repo.changectx(opts.get('rev', 'tip'))
916 ctx = repo.changectx(opts.get('rev', 'tip'))
917 m = cmdutil.match(repo, (file1,) + pats, opts)
917 m = cmdutil.match(repo, (file1,) + pats, opts)
918 for src, abs in repo.walk(m, ctx.node()):
918 for abs in repo.walk(m, ctx.node()):
919 fctx = ctx.filectx(abs)
919 fctx = ctx.filectx(abs)
920 o = fctx.filelog().renamed(fctx.filenode())
920 o = fctx.filelog().renamed(fctx.filenode())
921 rel = m.rel(abs)
921 rel = m.rel(abs)
@@ -930,11 +930,11 b' def debugwalk(ui, repo, *pats, **opts):'
930 items = list(repo.walk(m))
930 items = list(repo.walk(m))
931 if not items:
931 if not items:
932 return
932 return
933 fmt = '%%s %%-%ds %%-%ds %%s' % (
933 fmt = 'f %%-%ds %%-%ds %%s' % (
934 max([len(abs) for (src, abs) in items]),
934 max([len(abs) for abs in items]),
935 max([len(m.rel(abs)) for (src, abs) in items]))
935 max([len(m.rel(abs)) for abs in items]))
936 for src, abs in items:
936 for abs in items:
937 line = fmt % (src, abs, m.rel(abs), m.exact(abs) and 'exact' or '')
937 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
938 ui.write("%s\n" % line.rstrip())
938 ui.write("%s\n" % line.rstrip())
939
939
940 def diff(ui, repo, *pats, **opts):
940 def diff(ui, repo, *pats, **opts):
@@ -1699,7 +1699,7 b' def locate(ui, repo, *pats, **opts):'
1699 ret = 1
1699 ret = 1
1700 m = cmdutil.match(repo, pats, opts, default='relglob')
1700 m = cmdutil.match(repo, pats, opts, default='relglob')
1701 m.bad = lambda x,y: False
1701 m.bad = lambda x,y: False
1702 for src, abs in repo.walk(m, node):
1702 for abs in repo.walk(m, node):
1703 if not node and abs not in repo.dirstate:
1703 if not node and abs not in repo.dirstate:
1704 continue
1704 continue
1705 if opts['fullpath']:
1705 if opts['fullpath']:
@@ -2185,7 +2185,7 b' def remove(ui, repo, *pats, **opts):'
2185 modified, added, removed, deleted, unknown = mardu
2185 modified, added, removed, deleted, unknown = mardu
2186
2186
2187 remove, forget = [], []
2187 remove, forget = [], []
2188 for src, abs in repo.walk(m):
2188 for abs in repo.walk(m):
2189
2189
2190 reason = None
2190 reason = None
2191 if abs in removed or abs in unknown:
2191 if abs in removed or abs in unknown:
@@ -2342,7 +2342,7 b' def revert(ui, repo, *pats, **opts):'
2342
2342
2343 m = cmdutil.match(repo, pats, opts)
2343 m = cmdutil.match(repo, pats, opts)
2344 m.bad = lambda x,y: False
2344 m.bad = lambda x,y: False
2345 for src, abs in repo.walk(m):
2345 for abs in repo.walk(m):
2346 names[abs] = m.rel(abs), m.exact(abs)
2346 names[abs] = m.rel(abs), m.exact(abs)
2347
2347
2348 # walk target manifest.
2348 # walk target manifest.
@@ -2359,7 +2359,7 b' def revert(ui, repo, *pats, **opts):'
2359
2359
2360 m = cmdutil.match(repo, pats, opts)
2360 m = cmdutil.match(repo, pats, opts)
2361 m.bad = badfn
2361 m.bad = badfn
2362 for src, abs in repo.walk(m, node=node):
2362 for abs in repo.walk(m, node=node):
2363 if abs not in names:
2363 if abs not in names:
2364 names[abs] = m.rel(abs), m.exact(abs)
2364 names[abs] = m.rel(abs), m.exact(abs)
2365
2365
@@ -936,11 +936,6 b' class localrepository(repo.repository):'
936 walk recursively through the directory tree or a given
936 walk recursively through the directory tree or a given
937 changeset, finding all files matched by the match
937 changeset, finding all files matched by the match
938 function
938 function
939
940 results are yielded in a tuple (src, filename), where src
941 is one of:
942 'f' the file was found in the directory tree
943 'm' the file was only in the dirstate and not in the tree
944 '''
939 '''
945
940
946 if node:
941 if node:
@@ -958,16 +953,16 b' class localrepository(repo.repository):'
958 del fdict[ffn]
953 del fdict[ffn]
959 break
954 break
960 if match(fn):
955 if match(fn):
961 yield 'm', fn
956 yield fn
962 ffiles = fdict.keys()
957 ffiles = fdict.keys()
963 ffiles.sort()
958 ffiles.sort()
964 for fn in ffiles:
959 for fn in ffiles:
965 if match.bad(fn, 'No such file in rev ' + short(node)) \
960 if match.bad(fn, 'No such file in rev ' + short(node)) \
966 and match(fn):
961 and match(fn):
967 yield 'f', fn
962 yield fn
968 else:
963 else:
969 for src, fn in self.dirstate.walk(match):
964 for src, fn in self.dirstate.walk(match):
970 yield src, fn
965 yield fn
971
966
972 def status(self, node1=None, node2=None, files=[], match=util.always,
967 def status(self, node1=None, node2=None, files=[], match=util.always,
973 list_ignored=False, list_clean=False, list_unknown=True):
968 list_ignored=False, list_clean=False, list_unknown=True):
@@ -275,10 +275,10 b' hg debugwalk fifo'
275 fifo: unsupported file type (type is fifo)
275 fifo: unsupported file type (type is fifo)
276
276
277 hg debugwalk fenugreek
277 hg debugwalk fenugreek
278 m fenugreek fenugreek exact
278 f fenugreek fenugreek exact
279
279
280 hg debugwalk fenugreek
280 hg debugwalk fenugreek
281 m fenugreek fenugreek exact
281 f fenugreek fenugreek exact
282
282
283 hg debugwalk new
283 hg debugwalk new
284 f new new exact
284 f new new exact
General Comments 0
You need to be logged in to leave comments. Login now