comparison mercurial/cmdutil.py @ 41661:f8b18583049f

add: pass around uipathfn and use instead of m.rel() (API) For now, the uipathfn we pass around always prints relative paths just like before, so this should have no effect. Well, there's one little change: I also made the "skipping missing subrepository: %s\n" message relative. Differential Revision: https://phab.mercurial-scm.org/D5901
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 07 Feb 2019 11:15:30 -0800
parents 799e156785f7
children b2df5dc3ebfb
comparison
equal deleted inserted replaced
41660:799e156785f7 41661:f8b18583049f
2025 if stopiteration: 2025 if stopiteration:
2026 break 2026 break
2027 2027
2028 return iterate() 2028 return iterate()
2029 2029
2030 def add(ui, repo, match, prefix, explicitonly, **opts): 2030 def add(ui, repo, match, prefix, uipathfn, explicitonly, **opts):
2031 bad = [] 2031 bad = []
2032 2032
2033 badfn = lambda x, y: bad.append(x) or match.bad(x, y) 2033 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
2034 names = [] 2034 names = []
2035 wctx = repo[None] 2035 wctx = repo[None]
2049 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f): 2049 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f):
2050 if cca: 2050 if cca:
2051 cca(f) 2051 cca(f)
2052 names.append(f) 2052 names.append(f)
2053 if ui.verbose or not exact: 2053 if ui.verbose or not exact:
2054 ui.status(_('adding %s\n') % match.rel(f), 2054 ui.status(_('adding %s\n') % uipathfn(f),
2055 label='ui.addremove.added') 2055 label='ui.addremove.added')
2056 2056
2057 for subpath in sorted(wctx.substate): 2057 for subpath in sorted(wctx.substate):
2058 sub = wctx.sub(subpath) 2058 sub = wctx.sub(subpath)
2059 try: 2059 try:
2060 submatch = matchmod.subdirmatcher(subpath, match) 2060 submatch = matchmod.subdirmatcher(subpath, match)
2061 subprefix = repo.wvfs.reljoin(prefix, subpath) 2061 subprefix = repo.wvfs.reljoin(prefix, subpath)
2062 subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
2062 if opts.get(r'subrepos'): 2063 if opts.get(r'subrepos'):
2063 bad.extend(sub.add(ui, submatch, subprefix, False, **opts)) 2064 bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, False,
2065 **opts))
2064 else: 2066 else:
2065 bad.extend(sub.add(ui, submatch, subprefix, True, **opts)) 2067 bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, True,
2068 **opts))
2066 except error.LookupError: 2069 except error.LookupError:
2067 ui.status(_("skipping missing subrepository: %s\n") 2070 ui.status(_("skipping missing subrepository: %s\n")
2068 % match.rel(subpath)) 2071 % uipathfn(subpath))
2069 2072
2070 if not opts.get(r'dry_run'): 2073 if not opts.get(r'dry_run'):
2071 rejected = wctx.add(names, prefix) 2074 rejected = wctx.add(names, prefix)
2072 bad.extend(f for f in rejected if f in match.files()) 2075 bad.extend(f for f in rejected if f in match.files())
2073 return bad 2076 return bad