##// 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 def walk(repo, match, node=None):
238 def walk(repo, match, node=None):
239 for src, fn in repo.walk(node, match):
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 def findrenames(repo, added=None, removed=None, threshold=0.5):
242 def findrenames(repo, added=None, removed=None, threshold=0.5):
243 '''find renamed files -- yields (before, after, score) tuples'''
243 '''find renamed files -- yields (before, after, score) tuples'''
@@ -275,11 +275,13 b' def addremove(repo, pats=[], opts={}, dr'
275 add, remove = [], []
275 add, remove = [], []
276 mapping = {}
276 mapping = {}
277 m = match(repo, pats, opts)
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 target = repo.wjoin(abs)
279 target = repo.wjoin(abs)
280 rel = m.rel(abs)
281 exact = m.exact(abs)
280 if src == 'f' and abs not in repo.dirstate:
282 if src == 'f' and abs not in repo.dirstate:
281 add.append(abs)
283 add.append(abs)
282 mapping[abs] = rel, exact
284 mapping[abs] = rel, m.exact(abs)
283 if repo.ui.verbose or not exact:
285 if repo.ui.verbose or not exact:
284 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
286 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
285 if repo.dirstate[abs] != 'r' and (not util.lexists(target)
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 def walkpat(pat):
317 def walkpat(pat):
316 srcs = []
318 srcs = []
317 m = match(repo, [pat], opts, globbed=True)
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 state = repo.dirstate[abs]
321 state = repo.dirstate[abs]
322 rel = m.rel(abs)
323 exact = m.exact(abs)
320 if state in '?r':
324 if state in '?r':
321 if exact and state == '?':
325 if exact and state == '?':
322 ui.warn(_('%s: not copying - file is not managed\n') % rel)
326 ui.warn(_('%s: not copying - file is not managed\n') % rel)
@@ -33,14 +33,14 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, rel, exact in cmdutil.walk(repo, m):
36 for src, abs in cmdutil.walk(repo, m):
37 if exact:
37 if m.exact(abs):
38 if ui.verbose:
38 if ui.verbose:
39 ui.status(_('adding %s\n') % rel)
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
42 elif abs not in repo.dirstate:
42 elif abs not in repo.dirstate:
43 ui.status(_('adding %s\n') % rel)
43 ui.status(_('adding %s\n') % m.rel(abs))
44 names.append(abs)
44 names.append(abs)
45 if not opts.get('dry_run'):
45 if not opts.get('dry_run'):
46 rejected = repo.add(names)
46 rejected = repo.add(names)
@@ -110,10 +110,10 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, rel, exact in cmdutil.walk(repo, m, ctx.node()):
113 for src, abs in cmdutil.walk(repo, 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 rel) or abs))
116 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
117 continue
117 continue
118
118
119 lines = fctx.annotate(follow=opts.get('follow'),
119 lines = fctx.annotate(follow=opts.get('follow'),
@@ -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, rel, exact in cmdutil.walk(repo, m, ctx.node()):
492 for src, abs in cmdutil.walk(repo, 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,9 +915,10 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, rel, exact in cmdutil.walk(repo, m, ctx.node()):
918 for src, abs in cmdutil.walk(repo, 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 if o:
922 if o:
922 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])))
923 else:
924 else:
@@ -930,10 +931,10 b' def debugwalk(ui, repo, *pats, **opts):'
930 if not items:
931 if not items:
931 return
932 return
932 fmt = '%%s %%-%ds %%-%ds %%s' % (
933 fmt = '%%s %%-%ds %%-%ds %%s' % (
933 max([len(abs) for (src, abs, rel, exact) in items]),
934 max([len(abs) for (src, abs) in items]),
934 max([len(rel) for (src, abs, rel, exact) in items]))
935 max([len(m.rel(abs)) for (src, abs) in items]))
935 for src, abs, rel, exact in items:
936 for src, abs in items:
936 line = fmt % (src, abs, rel, exact and 'exact' or '')
937 line = fmt % (src, abs, m.rel(abs), m.exact(abs) and 'exact' or '')
937 ui.write("%s\n" % line.rstrip())
938 ui.write("%s\n" % line.rstrip())
938
939
939 def diff(ui, repo, *pats, **opts):
940 def diff(ui, repo, *pats, **opts):
@@ -1698,13 +1699,13 b' def locate(ui, repo, *pats, **opts):'
1698 ret = 1
1699 ret = 1
1699 m = cmdutil.match(repo, pats, opts, default='relglob')
1700 m = cmdutil.match(repo, pats, opts, default='relglob')
1700 m.bad = lambda x,y: False
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 if not node and abs not in repo.dirstate:
1703 if not node and abs not in repo.dirstate:
1703 continue
1704 continue
1704 if opts['fullpath']:
1705 if opts['fullpath']:
1705 ui.write(os.path.join(repo.root, abs), end)
1706 ui.write(os.path.join(repo.root, abs), end)
1706 else:
1707 else:
1707 ui.write(((pats and rel) or abs), end)
1708 ui.write(((pats and m.rel(abs)) or abs), end)
1708 ret = 0
1709 ret = 0
1709
1710
1710 return ret
1711 return ret
@@ -2184,7 +2185,7 b' def remove(ui, repo, *pats, **opts):'
2184 modified, added, removed, deleted, unknown = mardu
2185 modified, added, removed, deleted, unknown = mardu
2185
2186
2186 remove, forget = [], []
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 reason = None
2190 reason = None
2190 if abs in removed or abs in unknown:
2191 if abs in removed or abs in unknown:
@@ -2217,9 +2218,9 b' def remove(ui, repo, *pats, **opts):'
2217 remove.append(abs)
2218 remove.append(abs)
2218
2219
2219 if reason:
2220 if reason:
2220 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
2221 ui.warn(_('not removing %s: file %s\n') % (m.rel(abs), reason))
2221 elif ui.verbose or not exact:
2222 elif ui.verbose or not m.exact(abs):
2222 ui.status(_('removing %s\n') % rel)
2223 ui.status(_('removing %s\n') % m.rel(abs))
2223
2224
2224 repo.forget(forget)
2225 repo.forget(forget)
2225 repo.remove(remove, unlink=not after)
2226 repo.remove(remove, unlink=not after)
@@ -2341,8 +2342,8 b' def revert(ui, repo, *pats, **opts):'
2341
2342
2342 m = cmdutil.match(repo, pats, opts)
2343 m = cmdutil.match(repo, pats, opts)
2343 m.bad = lambda x,y: False
2344 m.bad = lambda x,y: False
2344 for src, abs, rel, exact in cmdutil.walk(repo, m):
2345 for src, abs in cmdutil.walk(repo, m):
2345 names[abs] = (rel, exact)
2346 names[abs] = m.rel(abs), m.exact(abs)
2346
2347
2347 # walk target manifest.
2348 # walk target manifest.
2348
2349
@@ -2358,10 +2359,9 b' def revert(ui, repo, *pats, **opts):'
2358
2359
2359 m = cmdutil.match(repo, pats, opts)
2360 m = cmdutil.match(repo, pats, opts)
2360 m.bad = badfn
2361 m.bad = badfn
2361 for src, abs, rel, exact in cmdutil.walk(repo, m, node=node):
2362 for src, abs in cmdutil.walk(repo, m, node=node):
2362 if abs in names:
2363 if abs not in names:
2363 continue
2364 names[abs] = m.rel(abs), m.exact(abs)
2364 names[abs] = (rel, exact)
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)
General Comments 0
You need to be logged in to leave comments. Login now