diff --git a/hgext3rd/fbsparse.py b/hgext3rd/fbsparse.py --- a/hgext3rd/fbsparse.py +++ b/hgext3rd/fbsparse.py @@ -1161,26 +1161,26 @@ """ ctx = repo['.'] mf = ctx.manifest() - cwd = util.normpath(os.getcwd()) # Get the root of the repo so that we remove the content of # the root from the current working directory root = repo.root - if cwd.startswith(root): - cwd = cwd[len(root):] - else: - raise error.Abort(_("the current working directory should begin " + - "with the root %s") % root) + cwd = util.normpath(os.getcwd()) + cwd = os.path.relpath(cwd, root) + cwd = '' if cwd == os.curdir else cwd + os.sep + if cwd.startswith(os.pardir + os.sep): + raise error.Abort( + _("the current working directory should begin " + "with the root %s") % root) - cwd = cwd.strip("/") sparsematch = repo.sparsematch(ctx.rev()) checkedoutentries = set() allentries = set() - cwdlength = len(cwd) + 1 + cwdlength = len(cwd) + for filepath in mf: if filepath.startswith(cwd): - tail = filepath[cwdlength:] if cwdlength > 1 else filepath - entryname = tail.split('/', 1)[0] + entryname = filepath[cwdlength:].partition(os.sep)[0] allentries.add(entryname) if sparsematch(filepath):