diff hgext/sparse.py @ 41148:8eaf693b1409

sparse: don't enable on clone if it was a narrow clone When both sparse and narrow extensions are enabled and we do a narrow clone, sparse enables itself because it reads --include flag and thinks that user is trying to do a sparse clone. This patch changes that behavior, and now if both extensions are enabled and user passes `--narrow`, then the includes and excludes won't be considered as part of sparse profile. Differential Revision: https://phab.mercurial-scm.org/D5479
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 24 Dec 2018 15:30:39 +0300
parents fa88170c10bb
children b05eb98a6b67
line wrap: on
line diff
--- a/hgext/sparse.py	Mon Dec 24 15:01:47 2018 +0300
+++ b/hgext/sparse.py	Mon Dec 24 15:30:39 2018 +0300
@@ -141,6 +141,7 @@
     include_pat = opts.get(r'include')
     exclude_pat = opts.get(r'exclude')
     enableprofile_pat = opts.get(r'enable_profile')
+    narrow_pat = opts.get(r'narrow')
     include = exclude = enableprofile = False
     if include_pat:
         pat = include_pat
@@ -153,7 +154,9 @@
         enableprofile = True
     if sum([include, exclude, enableprofile]) > 1:
         raise error.Abort(_("too many flags specified."))
-    if include or exclude or enableprofile:
+    # if --narrow is passed, it means they are includes and excludes for narrow
+    # clone
+    if not narrow_pat and (include or exclude or enableprofile):
         def clonesparse(orig, self, node, overwrite, *args, **kwargs):
             sparse.updateconfig(self.unfiltered(), pat, {}, include=include,
                                 exclude=exclude, enableprofile=enableprofile,