Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 29802:35560189677c
subrepo: cleanup of subrepo filematcher logic
Previously in the worst case we iterated the files in matcher twice and
had a method only for this, which reimplemented logic in subdirmatchers
constructor. So we replaced the method with a subdirmatcher.files() call.
author | Hannes Oldenburg <hannes.christian.oldenburg@gmail.com> |
---|---|
date | Tue, 16 Aug 2016 08:15:12 +0000 |
parents | 142ae01820a3 |
children | 2cec6eaf3610 |
comparison
equal
deleted
inserted
replaced
29801:c63ab0524db7 | 29802:35560189677c |
---|---|
2414 fm.data(abspath=f) | 2414 fm.data(abspath=f) |
2415 fm.write('path', fmt, m.rel(f)) | 2415 fm.write('path', fmt, m.rel(f)) |
2416 ret = 0 | 2416 ret = 0 |
2417 | 2417 |
2418 for subpath in sorted(ctx.substate): | 2418 for subpath in sorted(ctx.substate): |
2419 if subrepos or m.matchessubrepo(subpath): | 2419 submatch = matchmod.subdirmatcher(subpath, m) |
2420 if (subrepos or m.exact(subpath) or any(submatch.files())): | |
2420 sub = ctx.sub(subpath) | 2421 sub = ctx.sub(subpath) |
2421 try: | 2422 try: |
2422 submatch = matchmod.subdirmatcher(subpath, m) | |
2423 recurse = m.exact(subpath) or subrepos | 2423 recurse = m.exact(subpath) or subrepos |
2424 if sub.printfiles(ui, submatch, fm, fmt, recurse) == 0: | 2424 if sub.printfiles(ui, submatch, fm, fmt, recurse) == 0: |
2425 ret = 0 | 2425 ret = 0 |
2426 except error.LookupError: | 2426 except error.LookupError: |
2427 ui.status(_("skipping missing subrepository: %s\n") | 2427 ui.status(_("skipping missing subrepository: %s\n") |
2446 subs = sorted(wctx.substate) | 2446 subs = sorted(wctx.substate) |
2447 total = len(subs) | 2447 total = len(subs) |
2448 count = 0 | 2448 count = 0 |
2449 for subpath in subs: | 2449 for subpath in subs: |
2450 count += 1 | 2450 count += 1 |
2451 if subrepos or m.matchessubrepo(subpath): | 2451 submatch = matchmod.subdirmatcher(subpath, m) |
2452 if subrepos or m.exact(subpath) or any(submatch.files()): | |
2452 ui.progress(_('searching'), count, total=total, unit=_('subrepos')) | 2453 ui.progress(_('searching'), count, total=total, unit=_('subrepos')) |
2453 | |
2454 sub = wctx.sub(subpath) | 2454 sub = wctx.sub(subpath) |
2455 try: | 2455 try: |
2456 submatch = matchmod.subdirmatcher(subpath, m) | |
2457 if sub.removefiles(submatch, prefix, after, force, subrepos, | 2456 if sub.removefiles(submatch, prefix, after, force, subrepos, |
2458 warnings): | 2457 warnings): |
2459 ret = 1 | 2458 ret = 1 |
2460 except error.LookupError: | 2459 except error.LookupError: |
2461 warnings.append(_("skipping missing subrepository: %s\n") | 2460 warnings.append(_("skipping missing subrepository: %s\n") |