diff --git a/hgext3rd/fbsparse.py b/hgext3rd/fbsparse.py --- a/hgext3rd/fbsparse.py +++ b/hgext3rd/fbsparse.py @@ -1173,18 +1173,31 @@ _("the current working directory should begin " "with the root %s") % root) + tmf = None + if util.safehasattr(mf, '_treemanifest'): + # Hybrid manifest, use the (much) faster subtree support + tmf = mf._treemanifest() + + if tmf is not None: + # a treemanifest is available for this revision + matcher = matchmod.match( + repo.root, repo.getcwd(), + patterns=['path:' + cwd]) + files = tmf.matches(matcher) + else: + files = (f for f in mf if f.startswith(cwd)) + sparsematch = repo.sparsematch(ctx.rev()) checkedoutentries = set() allentries = set() cwdlength = len(cwd) - for filepath in mf: - if filepath.startswith(cwd): - entryname = filepath[cwdlength:].partition(os.sep)[0] + for filepath in files: + entryname = filepath[cwdlength:].partition(os.sep)[0] - allentries.add(entryname) - if sparsematch(filepath): - checkedoutentries.add(entryname) + allentries.add(entryname) + if sparsematch(filepath): + checkedoutentries.add(entryname) ui = repo.ui for entry in sorted(allentries):