[PATCH 2 of 2 sparse-ext maybe-for-stable] sparse: treat paths as cwd-relative
Kostia Balytskyi
ikostia at fb.com
Wed Jul 26 19:11:54 EDT 2017
# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1501110087 25200
# Wed Jul 26 16:01:27 2017 -0700
# Branch stable
# Node ID 6bc64227f84e6a17aa1f8e71916915644531a04e
# Parent 681f8819475ed5546e712d9ce04116b8b5a04f9b
sparse: treat paths as cwd-relative
This commit makes it so sparse treats passed paths as CWD-relative,
not repo-root-realive. This is a more intuitive behavior in my (and some
other FB people's) opinion.
This is breaking change however. My hope here is that since sparse is
experimental, it's ok to introduce BCs. That is also the reason why I am
sending this during a freeze: the experimental status of the feature probably
means that these two patches can just land on stable.
diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -155,7 +155,8 @@ def _clonesparsecmd(orig, ui, repo, *arg
if include or exclude or enableprofile:
def clonesparse(orig, self, node, overwrite, *args, **kwargs):
sparse.updateconfig(self.unfiltered(), pat, {}, include=include,
- exclude=exclude, enableprofile=enableprofile)
+ exclude=exclude, enableprofile=enableprofile,
+ usereporootpaths=True)
return orig(self, node, overwrite, *args, **kwargs)
extensions.wrapfunction(hg, 'updaterepo', clonesparse)
return orig(ui, repo, *args, **opts)
diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -616,7 +616,7 @@ def importfromfiles(repo, opts, paths, f
def updateconfig(repo, pats, opts, include=False, exclude=False, reset=False,
delete=False, enableprofile=False, disableprofile=False,
- force=False):
+ force=False, usereporootpaths=False):
"""Perform a sparse config update.
Only one of the actions may be performed.
@@ -639,6 +639,10 @@ def updateconfig(repo, pats, opts, inclu
if any(os.path.isabs(pat) for pat in pats):
raise error.Abort(_('paths cannot be absolute'))
+ if not usereporootpaths:
+ # let's treat paths as relative to cwd
+ pats = scmutil.match(repo['.'], pats).files()
+
if include:
newinclude.update(pats)
elif exclude:
More information about the Mercurial-devel
mailing list