Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 41663:6a447a3d1bd0
addremove: pass around uipathfn and use instead of m.uipath() (API)
Differential Revision: https://phab.mercurial-scm.org/D5903
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 07 Feb 2019 23:25:39 -0800 |
parents | f8b18583049f |
children | 0a5a6675c86c |
line wrap: on
line diff
--- a/mercurial/scmutil.py Thu Feb 07 23:19:33 2019 -0800 +++ b/mercurial/scmutil.py Thu Feb 07 23:25:39 2019 -0800 @@ -763,6 +763,14 @@ '''Create a new uipathfn that treats the file as relative to subpath.''' return lambda f: uipathfn(posixpath.join(subpath, f)) +def anypats(pats, opts): + '''Checks if any patterns, including --include and --exclude were given. + + Some commands (e.g. addremove) use this condition for deciding whether to + print absolute or relative paths. + ''' + return bool(pats or opts.get('include') or opts.get('exclude')) + def expandpats(pats): '''Expand bare globs when running on windows. On posix we assume it already has already been done by sh.''' @@ -1031,7 +1039,7 @@ repair.delayedstrip(repo.ui, repo, tostrip, operation, backup=backup) -def addremove(repo, matcher, prefix, opts=None): +def addremove(repo, matcher, prefix, uipathfn, opts=None): if opts is None: opts = {} m = matcher @@ -1052,12 +1060,13 @@ if opts.get('subrepos') or m.exact(subpath) or any(submatch.files()): sub = wctx.sub(subpath) subprefix = repo.wvfs.reljoin(prefix, subpath) + subuipathfn = subdiruipathfn(subpath, uipathfn) try: - if sub.addremove(submatch, subprefix, opts): + if sub.addremove(submatch, subprefix, subuipathfn, opts): ret = 1 except error.LookupError: repo.ui.status(_("skipping missing subrepository: %s\n") - % m.uipath(subpath)) + % uipathfn(subpath)) rejected = [] def badfn(f, msg): @@ -1075,10 +1084,10 @@ for abs in sorted(toprint): if repo.ui.verbose or not m.exact(abs): if abs in unknownset: - status = _('adding %s\n') % m.uipath(abs) + status = _('adding %s\n') % uipathfn(abs) label = 'ui.addremove.added' else: - status = _('removing %s\n') % m.uipath(abs) + status = _('removing %s\n') % uipathfn(abs) label = 'ui.addremove.removed' repo.ui.status(status, label=label)