D5902: remove: pass around uipathfn and use instead of m.rel()
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Feb 8 19:17:01 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Same as previous commit, but now for remove.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5902
AFFECTED FILES
hgext/largefiles/overrides.py
mercurial/cmdutil.py
mercurial/commands.py
mercurial/subrepo.py
CHANGE DETAILS
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -358,7 +358,7 @@
def forget(self, match, prefix, dryrun, interactive):
return ([], [])
- def removefiles(self, matcher, prefix, after, force, subrepos,
+ def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
dryrun, warnings):
"""remove the matched files from the subrepository and the filesystem,
possibly by force and/or after the file has been removed from the
@@ -841,9 +841,9 @@
True, dryrun=dryrun, interactive=interactive)
@annotatesubrepoerror
- def removefiles(self, matcher, prefix, after, force, subrepos,
+ def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos,
dryrun, warnings):
- return cmdutil.remove(self.ui, self._repo, matcher, prefix,
+ return cmdutil.remove(self.ui, self._repo, matcher, prefix, uipathfn,
after, force, subrepos, dryrun)
@annotatesubrepoerror
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4716,7 +4716,8 @@
m = scmutil.match(repo[None], pats, opts)
subrepos = opts.get('subrepos')
- return cmdutil.remove(ui, repo, m, "", after, force, subrepos,
+ uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True)
+ return cmdutil.remove(ui, repo, m, "", uipathfn, after, force, subrepos,
dryrun=dryrun)
@command('rename|move|mv',
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2192,7 +2192,8 @@
return ret
-def remove(ui, repo, m, prefix, after, force, subrepos, dryrun, warnings=None):
+def remove(ui, repo, m, prefix, uipathfn, after, force, subrepos, dryrun,
+ warnings=None):
ret = 0
s = repo.status(match=m, clean=True)
modified, added, deleted, clean = s[0], s[1], s[3], s[6]
@@ -2211,12 +2212,13 @@
for subpath in subs:
submatch = matchmod.subdirmatcher(subpath, m)
subprefix = repo.wvfs.reljoin(prefix, subpath)
+ subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
if subrepos or m.exact(subpath) or any(submatch.files()):
progress.increment()
sub = wctx.sub(subpath)
try:
- if sub.removefiles(submatch, subprefix, after, force, subrepos,
- dryrun, warnings):
+ if sub.removefiles(submatch, subprefix, subuipathfn, after,
+ force, subrepos, dryrun, warnings):
ret = 1
except error.LookupError:
warnings.append(_("skipping missing subrepository: %s\n")
@@ -2244,10 +2246,10 @@
if repo.wvfs.exists(f):
if repo.wvfs.isdir(f):
warnings.append(_('not removing %s: no tracked files\n')
- % m.rel(f))
+ % uipathfn(f))
else:
warnings.append(_('not removing %s: file is untracked\n')
- % m.rel(f))
+ % uipathfn(f))
# missing files will generate a warning elsewhere
ret = 1
progress.complete()
@@ -2263,7 +2265,7 @@
progress.increment()
if ui.verbose or (f in files):
warnings.append(_('not removing %s: file still exists\n')
- % m.rel(f))
+ % uipathfn(f))
ret = 1
progress.complete()
else:
@@ -2274,12 +2276,12 @@
for f in modified:
progress.increment()
warnings.append(_('not removing %s: file is modified (use -f'
- ' to force removal)\n') % m.rel(f))
+ ' to force removal)\n') % uipathfn(f))
ret = 1
for f in added:
progress.increment()
warnings.append(_("not removing %s: file has been marked for add"
- " (use 'hg forget' to undo add)\n") % m.rel(f))
+ " (use 'hg forget' to undo add)\n") % uipathfn(f))
ret = 1
progress.complete()
@@ -2289,7 +2291,7 @@
for f in list:
if ui.verbose or not m.exact(f):
progress.increment()
- ui.status(_('removing %s\n') % m.rel(f),
+ ui.status(_('removing %s\n') % uipathfn(f),
label='ui.addremove.removed')
progress.complete()
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -249,11 +249,11 @@
return bad
@eh.wrapfunction(cmdutil, 'remove')
-def cmdutilremove(orig, ui, repo, matcher, prefix, after, force, subrepos,
- dryrun):
+def cmdutilremove(orig, ui, repo, matcher, prefix, uipathfn, after, force,
+ subrepos, dryrun):
normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
- result = orig(ui, repo, normalmatcher, prefix, after, force, subrepos,
- dryrun)
+ result = orig(ui, repo, normalmatcher, prefix, uipathfn, after, force,
+ subrepos, dryrun)
return removelargefiles(ui, repo, False, matcher, dryrun, after=after,
force=force) or result
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list