##// END OF EJS Templates
walk: remove rel and exact returns
Matt Mackall -
r6584:29c77e5d default
parent child Browse files
Show More
@@ -237,7 +237,7 b' def match(repo, pats=[], opts={}, globbe'
237 237
238 238 def walk(repo, match, node=None):
239 239 for src, fn in repo.walk(node, match):
240 yield src, fn, match.rel(fn), match.exact(fn)
240 yield src, fn
241 241
242 242 def findrenames(repo, added=None, removed=None, threshold=0.5):
243 243 '''find renamed files -- yields (before, after, score) tuples'''
@@ -275,11 +275,13 b' def addremove(repo, pats=[], opts={}, dr'
275 275 add, remove = [], []
276 276 mapping = {}
277 277 m = match(repo, pats, opts)
278 for src, abs, rel, exact in walk(repo, m):
278 for src, abs in walk(repo, m):
279 279 target = repo.wjoin(abs)
280 rel = m.rel(abs)
281 exact = m.exact(abs)
280 282 if src == 'f' and abs not in repo.dirstate:
281 283 add.append(abs)
282 mapping[abs] = rel, exact
284 mapping[abs] = rel, m.exact(abs)
283 285 if repo.ui.verbose or not exact:
284 286 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
285 287 if repo.dirstate[abs] != 'r' and (not util.lexists(target)
@@ -315,8 +317,10 b' def copy(ui, repo, pats, opts, rename=Fa'
315 317 def walkpat(pat):
316 318 srcs = []
317 319 m = match(repo, [pat], opts, globbed=True)
318 for tag, abs, rel, exact in walk(repo, m):
320 for tag, abs in walk(repo, m):
319 321 state = repo.dirstate[abs]
322 rel = m.rel(abs)
323 exact = m.exact(abs)
320 324 if state in '?r':
321 325 if exact and state == '?':
322 326 ui.warn(_('%s: not copying - file is not managed\n') % rel)
@@ -33,14 +33,14 b' def add(ui, repo, *pats, **opts):'
33 33 names = []
34 34 m = cmdutil.match(repo, pats, opts)
35 35 m.bad = lambda x,y: True
36 for src, abs, rel, exact in cmdutil.walk(repo, m):
37 if exact:
36 for src, abs in cmdutil.walk(repo, m):
37 if m.exact(abs):
38 38 if ui.verbose:
39 ui.status(_('adding %s\n') % rel)
39 ui.status(_('adding %s\n') % m.rel(abs))
40 40 names.append(abs)
41 41 exacts[abs] = 1
42 42 elif abs not in repo.dirstate:
43 ui.status(_('adding %s\n') % rel)
43 ui.status(_('adding %s\n') % m.rel(abs))
44 44 names.append(abs)
45 45 if not opts.get('dry_run'):
46 46 rejected = repo.add(names)
@@ -110,10 +110,10 b' def annotate(ui, repo, *pats, **opts):'
110 110 ctx = repo.changectx(opts['rev'])
111 111
112 112 m = cmdutil.match(repo, pats, opts)
113 for src, abs, rel, exact in cmdutil.walk(repo, m, ctx.node()):
113 for src, abs in cmdutil.walk(repo, m, ctx.node()):
114 114 fctx = ctx.filectx(abs)
115 115 if not opts['text'] and util.binary(fctx.data()):
116 ui.write(_("%s: binary file\n") % ((pats and rel) or abs))
116 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
117 117 continue
118 118
119 119 lines = fctx.annotate(follow=opts.get('follow'),
@@ -489,7 +489,7 b' def cat(ui, repo, file1, *pats, **opts):'
489 489 ctx = repo.changectx(opts['rev'])
490 490 err = 1
491 491 m = cmdutil.match(repo, (file1,) + pats, opts)
492 for src, abs, rel, exact in cmdutil.walk(repo, m, ctx.node()):
492 for src, abs in cmdutil.walk(repo, m, ctx.node()):
493 493 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
494 494 data = ctx.filectx(abs).data()
495 495 if opts.get('decode'):
@@ -915,9 +915,10 b' def debugrename(ui, repo, file1, *pats, '
915 915
916 916 ctx = repo.changectx(opts.get('rev', 'tip'))
917 917 m = cmdutil.match(repo, (file1,) + pats, opts)
918 for src, abs, rel, exact in cmdutil.walk(repo, m, ctx.node()):
918 for src, abs in cmdutil.walk(repo, m, ctx.node()):
919 919 fctx = ctx.filectx(abs)
920 920 o = fctx.filelog().renamed(fctx.filenode())
921 rel = m.rel(abs)
921 922 if o:
922 923 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
923 924 else:
@@ -930,10 +931,10 b' def debugwalk(ui, repo, *pats, **opts):'
930 931 if not items:
931 932 return
932 933 fmt = '%%s %%-%ds %%-%ds %%s' % (
933 max([len(abs) for (src, abs, rel, exact) in items]),
934 max([len(rel) for (src, abs, rel, exact) in items]))
935 for src, abs, rel, exact in items:
936 line = fmt % (src, abs, rel, exact and 'exact' or '')
934 max([len(abs) for (src, abs) in items]),
935 max([len(m.rel(abs)) for (src, abs) in items]))
936 for src, abs in items:
937 line = fmt % (src, abs, m.rel(abs), m.exact(abs) and 'exact' or '')
937 938 ui.write("%s\n" % line.rstrip())
938 939
939 940 def diff(ui, repo, *pats, **opts):
@@ -1698,13 +1699,13 b' def locate(ui, repo, *pats, **opts):'
1698 1699 ret = 1
1699 1700 m = cmdutil.match(repo, pats, opts, default='relglob')
1700 1701 m.bad = lambda x,y: False
1701 for src, abs, rel, exact in cmdutil.walk(repo, m, node):
1702 for src, abs in cmdutil.walk(repo, m, node):
1702 1703 if not node and abs not in repo.dirstate:
1703 1704 continue
1704 1705 if opts['fullpath']:
1705 1706 ui.write(os.path.join(repo.root, abs), end)
1706 1707 else:
1707 ui.write(((pats and rel) or abs), end)
1708 ui.write(((pats and m.rel(abs)) or abs), end)
1708 1709 ret = 0
1709 1710
1710 1711 return ret
@@ -2184,7 +2185,7 b' def remove(ui, repo, *pats, **opts):'
2184 2185 modified, added, removed, deleted, unknown = mardu
2185 2186
2186 2187 remove, forget = [], []
2187 for src, abs, rel, exact in cmdutil.walk(repo, m):
2188 for src, abs in cmdutil.walk(repo, m):
2188 2189
2189 2190 reason = None
2190 2191 if abs in removed or abs in unknown:
@@ -2217,9 +2218,9 b' def remove(ui, repo, *pats, **opts):'
2217 2218 remove.append(abs)
2218 2219
2219 2220 if reason:
2220 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
2221 elif ui.verbose or not exact:
2222 ui.status(_('removing %s\n') % rel)
2221 ui.warn(_('not removing %s: file %s\n') % (m.rel(abs), reason))
2222 elif ui.verbose or not m.exact(abs):
2223 ui.status(_('removing %s\n') % m.rel(abs))
2223 2224
2224 2225 repo.forget(forget)
2225 2226 repo.remove(remove, unlink=not after)
@@ -2341,8 +2342,8 b' def revert(ui, repo, *pats, **opts):'
2341 2342
2342 2343 m = cmdutil.match(repo, pats, opts)
2343 2344 m.bad = lambda x,y: False
2344 for src, abs, rel, exact in cmdutil.walk(repo, m):
2345 names[abs] = (rel, exact)
2345 for src, abs in cmdutil.walk(repo, m):
2346 names[abs] = m.rel(abs), m.exact(abs)
2346 2347
2347 2348 # walk target manifest.
2348 2349
@@ -2358,10 +2359,9 b' def revert(ui, repo, *pats, **opts):'
2358 2359
2359 2360 m = cmdutil.match(repo, pats, opts)
2360 2361 m.bad = badfn
2361 for src, abs, rel, exact in cmdutil.walk(repo, m, node=node):
2362 if abs in names:
2363 continue
2364 names[abs] = (rel, exact)
2362 for src, abs in cmdutil.walk(repo, m, node=node):
2363 if abs not in names:
2364 names[abs] = m.rel(abs), m.exact(abs)
2365 2365
2366 2366 changes = repo.status(files=files, match=names.has_key)[:4]
2367 2367 modified, added, removed, deleted = map(dict.fromkeys, changes)
General Comments 0
You need to be logged in to leave comments. Login now