##// END OF EJS Templates
sparse: treat paths as cwd-relative...
Kostia Balytskyi -
r33648:e1c56486 default
parent child Browse files
Show More
@@ -155,7 +155,8 b' def _clonesparsecmd(orig, ui, repo, *arg'
155 155 if include or exclude or enableprofile:
156 156 def clonesparse(orig, self, node, overwrite, *args, **kwargs):
157 157 sparse.updateconfig(self.unfiltered(), pat, {}, include=include,
158 exclude=exclude, enableprofile=enableprofile)
158 exclude=exclude, enableprofile=enableprofile,
159 usereporootpaths=True)
159 160 return orig(self, node, overwrite, *args, **kwargs)
160 161 extensions.wrapfunction(hg, 'updaterepo', clonesparse)
161 162 return orig(ui, repo, *args, **opts)
@@ -17,6 +17,7 b' from . import ('
17 17 error,
18 18 match as matchmod,
19 19 merge as mergemod,
20 pathutil,
20 21 pycompat,
21 22 scmutil,
22 23 util,
@@ -616,7 +617,7 b' def importfromfiles(repo, opts, paths, f'
616 617
617 618 def updateconfig(repo, pats, opts, include=False, exclude=False, reset=False,
618 619 delete=False, enableprofile=False, disableprofile=False,
619 force=False):
620 force=False, usereporootpaths=False):
620 621 """Perform a sparse config update.
621 622
622 623 Only one of the actions may be performed.
@@ -639,6 +640,20 b' def updateconfig(repo, pats, opts, inclu'
639 640 if any(os.path.isabs(pat) for pat in pats):
640 641 raise error.Abort(_('paths cannot be absolute'))
641 642
643 if not usereporootpaths:
644 # let's treat paths as relative to cwd
645 root, cwd = repo.root, repo.getcwd()
646 abspats = []
647 for kindpat in pats:
648 kind, pat = matchmod._patsplit(kindpat, None)
649 if kind in matchmod.cwdrelativepatternkinds or kind is None:
650 ap = (kind + ':' if kind else '') +\
651 pathutil.canonpath(root, cwd, pat)
652 abspats.append(ap)
653 else:
654 abspats.append(kindpat)
655 pats = abspats
656
642 657 if include:
643 658 newinclude.update(pats)
644 659 elif exclude:
@@ -48,6 +48,31 b' TODO: See if this can be made to fail th'
48 48 [255]
49 49 #endif
50 50
51 Paths should be treated as cwd-relative, not repo-root-relative
52 $ mkdir subdir && cd subdir
53 $ hg debugsparse --include path
54 $ hg debugsparse
55 [include]
56 $TESTTMP/myrepo/hide
57 hide
58 subdir/path (glob)
59
60 $ cd ..
61 $ echo hello > subdir/file2.ext
62 $ cd subdir
63 $ hg debugsparse --include '**.ext' # let us test globs
64 $ hg debugsparse --include 'path:abspath' # and a path: pattern
65 $ cd ..
66 $ hg debugsparse
67 [include]
68 $TESTTMP/myrepo/hide
69 hide
70 path:abspath
71 subdir/**.ext
72 subdir/path (glob)
73
74 $ rm -rf subdir
75
51 76 Verify commiting while sparse includes other files
52 77
53 78 $ echo z > hide
General Comments 0
You need to be logged in to leave comments. Login now