D4477: merge: move purge logic from extension
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Thu Sep 6 08:47:56 EDT 2018
yuja added a comment.
> +def purge(repo, dirs=None, ignored=False, removeemptydirs=True,
> + removefiles=True, abortonerror=False, include=None, exclude=None,
> + noop=False):
Nit: can't we pass in matcher instead of (dirs, include, exclude)?
> + if removefiles:
> + for f in sorted(status.unknown + status.ignored):
> + if not noop:
> + repo.ui.note(_('removing file %s\n') % f)
> + remove(util.unlink, f)
> + yield f
> +
> + if removeemptydirs:
> + for f in sorted(directories, reverse=True):
> + if match(f) and not os.listdir(repo.wvfs.join(f)):
> + if not noop:
> + repo.ui.note(_('removing directory %s\n') % f)
> + remove(os.rmdir, f)
> + yield f
This means `mergemod.purge()` itself does nothing unless the return value
is fully consumed. That's IMHO a bad API.
> + paths = mergemod.purge(
> + repo, dirs, ignored=opts.get('all', False),
> + removeemptydirs=removedirs, removefiles=removefiles,
> + abortonerror=opts.get('abort_on_err'),
> + include=opts.get('include'), exclude=opts.get('exclude'),
> + noop=opts.get('print') or opts.get('print0'))
Nit: perhaps `noop=not act`?
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4477
To: indygreg, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list