Mercurial > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
41147:eb172f9c208c | 41148:8eaf693b1409 |
---|---|
139 | 139 |
140 def _clonesparsecmd(orig, ui, repo, *args, **opts): | 140 def _clonesparsecmd(orig, ui, repo, *args, **opts): |
141 include_pat = opts.get(r'include') | 141 include_pat = opts.get(r'include') |
142 exclude_pat = opts.get(r'exclude') | 142 exclude_pat = opts.get(r'exclude') |
143 enableprofile_pat = opts.get(r'enable_profile') | 143 enableprofile_pat = opts.get(r'enable_profile') |
144 narrow_pat = opts.get(r'narrow') | |
144 include = exclude = enableprofile = False | 145 include = exclude = enableprofile = False |
145 if include_pat: | 146 if include_pat: |
146 pat = include_pat | 147 pat = include_pat |
147 include = True | 148 include = True |
148 if exclude_pat: | 149 if exclude_pat: |
151 if enableprofile_pat: | 152 if enableprofile_pat: |
152 pat = enableprofile_pat | 153 pat = enableprofile_pat |
153 enableprofile = True | 154 enableprofile = True |
154 if sum([include, exclude, enableprofile]) > 1: | 155 if sum([include, exclude, enableprofile]) > 1: |
155 raise error.Abort(_("too many flags specified.")) | 156 raise error.Abort(_("too many flags specified.")) |
156 if include or exclude or enableprofile: | 157 # if --narrow is passed, it means they are includes and excludes for narrow |
158 # clone | |
159 if not narrow_pat and (include or exclude or enableprofile): | |
157 def clonesparse(orig, self, node, overwrite, *args, **kwargs): | 160 def clonesparse(orig, self, node, overwrite, *args, **kwargs): |
158 sparse.updateconfig(self.unfiltered(), pat, {}, include=include, | 161 sparse.updateconfig(self.unfiltered(), pat, {}, include=include, |
159 exclude=exclude, enableprofile=enableprofile, | 162 exclude=exclude, enableprofile=enableprofile, |
160 usereporootpaths=True) | 163 usereporootpaths=True) |
161 return orig(self, node, overwrite, *args, **kwargs) | 164 return orig(self, node, overwrite, *args, **kwargs) |