Mercurial > hg
comparison mercurial/commands.py @ 6585:d3d1d39da2fa
walk: remove cmdutil.walk
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 May 2008 11:37:08 -0500 |
parents | 29c77e5dfb3c |
children | d3463007d368 |
comparison
equal
deleted
inserted
replaced
6584:29c77e5dfb3c | 6585:d3d1d39da2fa |
---|---|
31 rejected = None | 31 rejected = None |
32 exacts = {} | 32 exacts = {} |
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 cmdutil.walk(repo, m): | 36 for src, 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)) |
40 names.append(abs) | 40 names.append(abs) |
41 exacts[abs] = 1 | 41 exacts[abs] = 1 |
108 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) | 108 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) |
109 | 109 |
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 cmdutil.walk(repo, m, ctx.node()): | 113 for src, 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)) |
117 continue | 117 continue |
118 | 118 |
487 %p root-relative path name of file being printed | 487 %p root-relative path name of file being printed |
488 """ | 488 """ |
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 cmdutil.walk(repo, m, ctx.node()): | 492 for src, 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'): |
496 data = repo.wwritedata(abs, data) | 496 data = repo.wwritedata(abs, data) |
497 fp.write(data) | 497 fp.write(data) |
913 def debugrename(ui, repo, file1, *pats, **opts): | 913 def debugrename(ui, repo, file1, *pats, **opts): |
914 """dump rename information""" | 914 """dump rename information""" |
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 cmdutil.walk(repo, m, ctx.node()): | 918 for src, 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) |
922 if o: | 922 if o: |
923 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | 923 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
925 ui.write(_("%s not renamed\n") % rel) | 925 ui.write(_("%s not renamed\n") % rel) |
926 | 926 |
927 def debugwalk(ui, repo, *pats, **opts): | 927 def debugwalk(ui, repo, *pats, **opts): |
928 """show how files match on given patterns""" | 928 """show how files match on given patterns""" |
929 m = cmdutil.match(repo, pats, opts) | 929 m = cmdutil.match(repo, pats, opts) |
930 items = list(cmdutil.walk(repo, 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 = '%%s %%-%ds %%-%ds %%s' % ( |
934 max([len(abs) for (src, abs) in items]), | 934 max([len(abs) for (src, abs) in items]), |
935 max([len(m.rel(abs)) for (src, abs) in items])) | 935 max([len(m.rel(abs)) for (src, abs) in items])) |
1697 node = None | 1697 node = None |
1698 | 1698 |
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 cmdutil.walk(repo, m, node): | 1702 for src, 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']: |
1706 ui.write(os.path.join(repo.root, abs), end) | 1706 ui.write(os.path.join(repo.root, abs), end) |
1707 else: | 1707 else: |
2183 m = cmdutil.match(repo, pats, opts) | 2183 m = cmdutil.match(repo, pats, opts) |
2184 mardu = map(dict.fromkeys, repo.status(files=m.files(), match=m))[:5] | 2184 mardu = map(dict.fromkeys, repo.status(files=m.files(), match=m))[:5] |
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 cmdutil.walk(repo, m): | 2188 for src, 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: |
2192 continue | 2192 continue |
2193 | 2193 |
2340 # walk dirstate. | 2340 # walk dirstate. |
2341 files = [] | 2341 files = [] |
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 cmdutil.walk(repo, m): | 2345 for src, 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. |
2349 | 2349 |
2350 def badfn(path, msg): | 2350 def badfn(path, msg): |
2357 repo.ui.warn("%s: %s\n" % (m.rel(path), msg)) | 2357 repo.ui.warn("%s: %s\n" % (m.rel(path), msg)) |
2358 return False | 2358 return False |
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 cmdutil.walk(repo, m, node=node): | 2362 for src, 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 |
2366 changes = repo.status(files=files, match=names.has_key)[:4] | 2366 changes = repo.status(files=files, match=names.has_key)[:4] |
2367 modified, added, removed, deleted = map(dict.fromkeys, changes) | 2367 modified, added, removed, deleted = map(dict.fromkeys, changes) |