##// END OF EJS Templates
narrow: add a --narrowspec flag to clone command...
Pulkit Goyal -
r39523:f4d4bd8c default
parent child Browse files
Show More
@@ -1,403 +1,428 b''
1 # narrowcommands.py - command modifications for narrowhg extension
1 # narrowcommands.py - command modifications for narrowhg extension
2 #
2 #
3 # Copyright 2017 Google, Inc.
3 # Copyright 2017 Google, Inc.
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7 from __future__ import absolute_import
7 from __future__ import absolute_import
8
8
9 import itertools
9 import itertools
10 import os
10
11
11 from mercurial.i18n import _
12 from mercurial.i18n import _
12 from mercurial import (
13 from mercurial import (
13 cmdutil,
14 cmdutil,
14 commands,
15 commands,
15 discovery,
16 discovery,
16 error,
17 error,
17 exchange,
18 exchange,
18 extensions,
19 extensions,
19 hg,
20 hg,
20 merge,
21 merge,
21 narrowspec,
22 narrowspec,
22 node,
23 node,
23 pycompat,
24 pycompat,
24 registrar,
25 registrar,
25 repair,
26 repair,
26 repository,
27 repository,
27 repoview,
28 repoview,
29 sparse,
28 util,
30 util,
29 )
31 )
30
32
31 from . import (
33 from . import (
32 narrowbundle2,
34 narrowbundle2,
33 )
35 )
34
36
35 table = {}
37 table = {}
36 command = registrar.command(table)
38 command = registrar.command(table)
37
39
38 def setup():
40 def setup():
39 """Wraps user-facing mercurial commands with narrow-aware versions."""
41 """Wraps user-facing mercurial commands with narrow-aware versions."""
40
42
41 entry = extensions.wrapcommand(commands.table, 'clone', clonenarrowcmd)
43 entry = extensions.wrapcommand(commands.table, 'clone', clonenarrowcmd)
42 entry[1].append(('', 'narrow', None,
44 entry[1].append(('', 'narrow', None,
43 _("create a narrow clone of select files")))
45 _("create a narrow clone of select files")))
44 entry[1].append(('', 'depth', '',
46 entry[1].append(('', 'depth', '',
45 _("limit the history fetched by distance from heads")))
47 _("limit the history fetched by distance from heads")))
48 entry[1].append(('', 'narrowspec', '',
49 _("read narrowspecs from file")))
46 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
50 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
47 if 'sparse' not in extensions.enabled():
51 if 'sparse' not in extensions.enabled():
48 entry[1].append(('', 'include', [],
52 entry[1].append(('', 'include', [],
49 _("specifically fetch this file/directory")))
53 _("specifically fetch this file/directory")))
50 entry[1].append(
54 entry[1].append(
51 ('', 'exclude', [],
55 ('', 'exclude', [],
52 _("do not fetch this file/directory, even if included")))
56 _("do not fetch this file/directory, even if included")))
53
57
54 entry = extensions.wrapcommand(commands.table, 'pull', pullnarrowcmd)
58 entry = extensions.wrapcommand(commands.table, 'pull', pullnarrowcmd)
55 entry[1].append(('', 'depth', '',
59 entry[1].append(('', 'depth', '',
56 _("limit the history fetched by distance from heads")))
60 _("limit the history fetched by distance from heads")))
57
61
58 extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
62 extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
59
63
60 def expandpull(pullop, includepats, excludepats):
64 def expandpull(pullop, includepats, excludepats):
61 if not narrowspec.needsexpansion(includepats):
65 if not narrowspec.needsexpansion(includepats):
62 return includepats, excludepats
66 return includepats, excludepats
63
67
64 heads = pullop.heads or pullop.rheads
68 heads = pullop.heads or pullop.rheads
65 includepats, excludepats = pullop.remote.expandnarrow(
69 includepats, excludepats = pullop.remote.expandnarrow(
66 includepats, excludepats, heads)
70 includepats, excludepats, heads)
67 pullop.repo.ui.debug('Expanded narrowspec to inc=%s, exc=%s\n' % (
71 pullop.repo.ui.debug('Expanded narrowspec to inc=%s, exc=%s\n' % (
68 includepats, excludepats))
72 includepats, excludepats))
69 return set(includepats), set(excludepats)
73 return set(includepats), set(excludepats)
70
74
71 def clonenarrowcmd(orig, ui, repo, *args, **opts):
75 def clonenarrowcmd(orig, ui, repo, *args, **opts):
72 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
76 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
73 opts = pycompat.byteskwargs(opts)
77 opts = pycompat.byteskwargs(opts)
74 wrappedextraprepare = util.nullcontextmanager()
78 wrappedextraprepare = util.nullcontextmanager()
75 opts_narrow = opts['narrow']
79 opts_narrow = opts['narrow']
80 narrowspecfile = opts['narrowspec']
81
82 if narrowspecfile:
83 filepath = os.path.join(pycompat.getcwd(), narrowspecfile)
84 ui.status(_("reading narrowspec from '%s'\n") % filepath)
85 try:
86 fp = open(filepath, 'rb')
87 except IOError:
88 raise error.Abort(_("file '%s' not found") % filepath)
89
90 includes, excludes, profiles = sparse.parseconfig(ui, fp.read(),
91 'narrow')
92 if profiles:
93 raise error.Abort(_("cannot specify other files using '%include' in"
94 " narrowspec"))
95
96 # narrowspec is passed so we should assume that user wants narrow clone
97 opts_narrow = True
98 opts['include'].extend(includes)
99 opts['exclude'].extend(excludes)
100
76 if opts_narrow:
101 if opts_narrow:
77 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
102 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
78 # Create narrow spec patterns from clone flags
103 # Create narrow spec patterns from clone flags
79 includepats = narrowspec.parsepatterns(opts['include'])
104 includepats = narrowspec.parsepatterns(opts['include'])
80 excludepats = narrowspec.parsepatterns(opts['exclude'])
105 excludepats = narrowspec.parsepatterns(opts['exclude'])
81
106
82 # If necessary, ask the server to expand the narrowspec.
107 # If necessary, ask the server to expand the narrowspec.
83 includepats, excludepats = expandpull(
108 includepats, excludepats = expandpull(
84 pullop, includepats, excludepats)
109 pullop, includepats, excludepats)
85
110
86 if not includepats and excludepats:
111 if not includepats and excludepats:
87 # If nothing was included, we assume the user meant to include
112 # If nothing was included, we assume the user meant to include
88 # everything, except what they asked to exclude.
113 # everything, except what they asked to exclude.
89 includepats = {'path:.'}
114 includepats = {'path:.'}
90
115
91 pullop.repo.setnarrowpats(includepats, excludepats)
116 pullop.repo.setnarrowpats(includepats, excludepats)
92
117
93 # This will populate 'includepats' etc with the values from the
118 # This will populate 'includepats' etc with the values from the
94 # narrowspec we just saved.
119 # narrowspec we just saved.
95 orig(pullop, kwargs)
120 orig(pullop, kwargs)
96
121
97 if opts.get('depth'):
122 if opts.get('depth'):
98 kwargs['depth'] = opts['depth']
123 kwargs['depth'] = opts['depth']
99 wrappedextraprepare = extensions.wrappedfunction(exchange,
124 wrappedextraprepare = extensions.wrappedfunction(exchange,
100 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
125 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
101
126
102 def pullnarrow(orig, repo, *args, **kwargs):
127 def pullnarrow(orig, repo, *args, **kwargs):
103 if opts_narrow:
128 if opts_narrow:
104 repo.requirements.add(repository.NARROW_REQUIREMENT)
129 repo.requirements.add(repository.NARROW_REQUIREMENT)
105 repo._writerequirements()
130 repo._writerequirements()
106
131
107 return orig(repo, *args, **kwargs)
132 return orig(repo, *args, **kwargs)
108
133
109 wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow)
134 wrappedpull = extensions.wrappedfunction(exchange, 'pull', pullnarrow)
110
135
111 with wrappedextraprepare, wrappedpull:
136 with wrappedextraprepare, wrappedpull:
112 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
137 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
113
138
114 def pullnarrowcmd(orig, ui, repo, *args, **opts):
139 def pullnarrowcmd(orig, ui, repo, *args, **opts):
115 """Wraps pull command to allow modifying narrow spec."""
140 """Wraps pull command to allow modifying narrow spec."""
116 wrappedextraprepare = util.nullcontextmanager()
141 wrappedextraprepare = util.nullcontextmanager()
117 if repository.NARROW_REQUIREMENT in repo.requirements:
142 if repository.NARROW_REQUIREMENT in repo.requirements:
118
143
119 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
144 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
120 orig(pullop, kwargs)
145 orig(pullop, kwargs)
121 if opts.get(r'depth'):
146 if opts.get(r'depth'):
122 kwargs['depth'] = opts[r'depth']
147 kwargs['depth'] = opts[r'depth']
123 wrappedextraprepare = extensions.wrappedfunction(exchange,
148 wrappedextraprepare = extensions.wrappedfunction(exchange,
124 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
149 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
125
150
126 with wrappedextraprepare:
151 with wrappedextraprepare:
127 return orig(ui, repo, *args, **opts)
152 return orig(ui, repo, *args, **opts)
128
153
129 def archivenarrowcmd(orig, ui, repo, *args, **opts):
154 def archivenarrowcmd(orig, ui, repo, *args, **opts):
130 """Wraps archive command to narrow the default includes."""
155 """Wraps archive command to narrow the default includes."""
131 if repository.NARROW_REQUIREMENT in repo.requirements:
156 if repository.NARROW_REQUIREMENT in repo.requirements:
132 repo_includes, repo_excludes = repo.narrowpats
157 repo_includes, repo_excludes = repo.narrowpats
133 includes = set(opts.get(r'include', []))
158 includes = set(opts.get(r'include', []))
134 excludes = set(opts.get(r'exclude', []))
159 excludes = set(opts.get(r'exclude', []))
135 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
160 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
136 includes, excludes, repo_includes, repo_excludes)
161 includes, excludes, repo_includes, repo_excludes)
137 if includes:
162 if includes:
138 opts[r'include'] = includes
163 opts[r'include'] = includes
139 if excludes:
164 if excludes:
140 opts[r'exclude'] = excludes
165 opts[r'exclude'] = excludes
141 return orig(ui, repo, *args, **opts)
166 return orig(ui, repo, *args, **opts)
142
167
143 def pullbundle2extraprepare(orig, pullop, kwargs):
168 def pullbundle2extraprepare(orig, pullop, kwargs):
144 repo = pullop.repo
169 repo = pullop.repo
145 if repository.NARROW_REQUIREMENT not in repo.requirements:
170 if repository.NARROW_REQUIREMENT not in repo.requirements:
146 return orig(pullop, kwargs)
171 return orig(pullop, kwargs)
147
172
148 if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
173 if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
149 raise error.Abort(_("server doesn't support narrow clones"))
174 raise error.Abort(_("server doesn't support narrow clones"))
150 orig(pullop, kwargs)
175 orig(pullop, kwargs)
151 kwargs['narrow'] = True
176 kwargs['narrow'] = True
152 include, exclude = repo.narrowpats
177 include, exclude = repo.narrowpats
153 kwargs['oldincludepats'] = include
178 kwargs['oldincludepats'] = include
154 kwargs['oldexcludepats'] = exclude
179 kwargs['oldexcludepats'] = exclude
155 kwargs['includepats'] = include
180 kwargs['includepats'] = include
156 kwargs['excludepats'] = exclude
181 kwargs['excludepats'] = exclude
157 kwargs['known'] = [node.hex(ctx.node()) for ctx in
182 kwargs['known'] = [node.hex(ctx.node()) for ctx in
158 repo.set('::%ln', pullop.common)
183 repo.set('::%ln', pullop.common)
159 if ctx.node() != node.nullid]
184 if ctx.node() != node.nullid]
160 if not kwargs['known']:
185 if not kwargs['known']:
161 # Mercurial serialized an empty list as '' and deserializes it as
186 # Mercurial serialized an empty list as '' and deserializes it as
162 # [''], so delete it instead to avoid handling the empty string on the
187 # [''], so delete it instead to avoid handling the empty string on the
163 # server.
188 # server.
164 del kwargs['known']
189 del kwargs['known']
165
190
166 extensions.wrapfunction(exchange,'_pullbundle2extraprepare',
191 extensions.wrapfunction(exchange,'_pullbundle2extraprepare',
167 pullbundle2extraprepare)
192 pullbundle2extraprepare)
168
193
169 def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
194 def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
170 newincludes, newexcludes, force):
195 newincludes, newexcludes, force):
171 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
196 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
172 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
197 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
173
198
174 # This is essentially doing "hg outgoing" to find all local-only
199 # This is essentially doing "hg outgoing" to find all local-only
175 # commits. We will then check that the local-only commits don't
200 # commits. We will then check that the local-only commits don't
176 # have any changes to files that will be untracked.
201 # have any changes to files that will be untracked.
177 unfi = repo.unfiltered()
202 unfi = repo.unfiltered()
178 outgoing = discovery.findcommonoutgoing(unfi, remote,
203 outgoing = discovery.findcommonoutgoing(unfi, remote,
179 commoninc=commoninc)
204 commoninc=commoninc)
180 ui.status(_('looking for local changes to affected paths\n'))
205 ui.status(_('looking for local changes to affected paths\n'))
181 localnodes = []
206 localnodes = []
182 for n in itertools.chain(outgoing.missing, outgoing.excluded):
207 for n in itertools.chain(outgoing.missing, outgoing.excluded):
183 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
208 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
184 localnodes.append(n)
209 localnodes.append(n)
185 revstostrip = unfi.revs('descendants(%ln)', localnodes)
210 revstostrip = unfi.revs('descendants(%ln)', localnodes)
186 hiddenrevs = repoview.filterrevs(repo, 'visible')
211 hiddenrevs = repoview.filterrevs(repo, 'visible')
187 visibletostrip = list(repo.changelog.node(r)
212 visibletostrip = list(repo.changelog.node(r)
188 for r in (revstostrip - hiddenrevs))
213 for r in (revstostrip - hiddenrevs))
189 if visibletostrip:
214 if visibletostrip:
190 ui.status(_('The following changeset(s) or their ancestors have '
215 ui.status(_('The following changeset(s) or their ancestors have '
191 'local changes not on the remote:\n'))
216 'local changes not on the remote:\n'))
192 maxnodes = 10
217 maxnodes = 10
193 if ui.verbose or len(visibletostrip) <= maxnodes:
218 if ui.verbose or len(visibletostrip) <= maxnodes:
194 for n in visibletostrip:
219 for n in visibletostrip:
195 ui.status('%s\n' % node.short(n))
220 ui.status('%s\n' % node.short(n))
196 else:
221 else:
197 for n in visibletostrip[:maxnodes]:
222 for n in visibletostrip[:maxnodes]:
198 ui.status('%s\n' % node.short(n))
223 ui.status('%s\n' % node.short(n))
199 ui.status(_('...and %d more, use --verbose to list all\n') %
224 ui.status(_('...and %d more, use --verbose to list all\n') %
200 (len(visibletostrip) - maxnodes))
225 (len(visibletostrip) - maxnodes))
201 if not force:
226 if not force:
202 raise error.Abort(_('local changes found'),
227 raise error.Abort(_('local changes found'),
203 hint=_('use --force-delete-local-changes to '
228 hint=_('use --force-delete-local-changes to '
204 'ignore'))
229 'ignore'))
205
230
206 with ui.uninterruptable():
231 with ui.uninterruptable():
207 if revstostrip:
232 if revstostrip:
208 tostrip = [unfi.changelog.node(r) for r in revstostrip]
233 tostrip = [unfi.changelog.node(r) for r in revstostrip]
209 if repo['.'].node() in tostrip:
234 if repo['.'].node() in tostrip:
210 # stripping working copy, so move to a different commit first
235 # stripping working copy, so move to a different commit first
211 urev = max(repo.revs('(::%n) - %ln + null',
236 urev = max(repo.revs('(::%n) - %ln + null',
212 repo['.'].node(), visibletostrip))
237 repo['.'].node(), visibletostrip))
213 hg.clean(repo, urev)
238 hg.clean(repo, urev)
214 repair.strip(ui, unfi, tostrip, topic='narrow')
239 repair.strip(ui, unfi, tostrip, topic='narrow')
215
240
216 todelete = []
241 todelete = []
217 for f, f2, size in repo.store.datafiles():
242 for f, f2, size in repo.store.datafiles():
218 if f.startswith('data/'):
243 if f.startswith('data/'):
219 file = f[5:-2]
244 file = f[5:-2]
220 if not newmatch(file):
245 if not newmatch(file):
221 todelete.append(f)
246 todelete.append(f)
222 elif f.startswith('meta/'):
247 elif f.startswith('meta/'):
223 dir = f[5:-13]
248 dir = f[5:-13]
224 dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
249 dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
225 include = True
250 include = True
226 for d in dirs:
251 for d in dirs:
227 visit = newmatch.visitdir(d)
252 visit = newmatch.visitdir(d)
228 if not visit:
253 if not visit:
229 include = False
254 include = False
230 break
255 break
231 if visit == 'all':
256 if visit == 'all':
232 break
257 break
233 if not include:
258 if not include:
234 todelete.append(f)
259 todelete.append(f)
235
260
236 repo.destroying()
261 repo.destroying()
237
262
238 with repo.transaction("narrowing"):
263 with repo.transaction("narrowing"):
239 for f in todelete:
264 for f in todelete:
240 ui.status(_('deleting %s\n') % f)
265 ui.status(_('deleting %s\n') % f)
241 util.unlinkpath(repo.svfs.join(f))
266 util.unlinkpath(repo.svfs.join(f))
242 repo.store.markremoved(f)
267 repo.store.markremoved(f)
243
268
244 for f in repo.dirstate:
269 for f in repo.dirstate:
245 if not newmatch(f):
270 if not newmatch(f):
246 repo.dirstate.drop(f)
271 repo.dirstate.drop(f)
247 repo.wvfs.unlinkpath(f)
272 repo.wvfs.unlinkpath(f)
248 repo.setnarrowpats(newincludes, newexcludes)
273 repo.setnarrowpats(newincludes, newexcludes)
249
274
250 repo.destroyed()
275 repo.destroyed()
251
276
252 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
277 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
253 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
278 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
254
279
255 # TODO(martinvonz): Get expansion working with widening/narrowing.
280 # TODO(martinvonz): Get expansion working with widening/narrowing.
256 if narrowspec.needsexpansion(newincludes):
281 if narrowspec.needsexpansion(newincludes):
257 raise error.Abort('Expansion not yet supported on pull')
282 raise error.Abort('Expansion not yet supported on pull')
258
283
259 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
284 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
260 orig(pullop, kwargs)
285 orig(pullop, kwargs)
261 # The old{in,ex}cludepats have already been set by orig()
286 # The old{in,ex}cludepats have already been set by orig()
262 kwargs['includepats'] = newincludes
287 kwargs['includepats'] = newincludes
263 kwargs['excludepats'] = newexcludes
288 kwargs['excludepats'] = newexcludes
264 wrappedextraprepare = extensions.wrappedfunction(exchange,
289 wrappedextraprepare = extensions.wrappedfunction(exchange,
265 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
290 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
266
291
267 # define a function that narrowbundle2 can call after creating the
292 # define a function that narrowbundle2 can call after creating the
268 # backup bundle, but before applying the bundle from the server
293 # backup bundle, but before applying the bundle from the server
269 def setnewnarrowpats():
294 def setnewnarrowpats():
270 repo.setnarrowpats(newincludes, newexcludes)
295 repo.setnarrowpats(newincludes, newexcludes)
271 repo.setnewnarrowpats = setnewnarrowpats
296 repo.setnewnarrowpats = setnewnarrowpats
272
297
273 with ui.uninterruptable():
298 with ui.uninterruptable():
274 ds = repo.dirstate
299 ds = repo.dirstate
275 p1, p2 = ds.p1(), ds.p2()
300 p1, p2 = ds.p1(), ds.p2()
276 with ds.parentchange():
301 with ds.parentchange():
277 ds.setparents(node.nullid, node.nullid)
302 ds.setparents(node.nullid, node.nullid)
278 common = commoninc[0]
303 common = commoninc[0]
279 with wrappedextraprepare:
304 with wrappedextraprepare:
280 exchange.pull(repo, remote, heads=common)
305 exchange.pull(repo, remote, heads=common)
281 with ds.parentchange():
306 with ds.parentchange():
282 ds.setparents(p1, p2)
307 ds.setparents(p1, p2)
283
308
284 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
309 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
285 addgaction = actions['g'].append
310 addgaction = actions['g'].append
286
311
287 mf = repo['.'].manifest().matches(newmatch)
312 mf = repo['.'].manifest().matches(newmatch)
288 for f, fn in mf.iteritems():
313 for f, fn in mf.iteritems():
289 if f not in repo.dirstate:
314 if f not in repo.dirstate:
290 addgaction((f, (mf.flags(f), False),
315 addgaction((f, (mf.flags(f), False),
291 "add from widened narrow clone"))
316 "add from widened narrow clone"))
292
317
293 merge.applyupdates(repo, actions, wctx=repo[None],
318 merge.applyupdates(repo, actions, wctx=repo[None],
294 mctx=repo['.'], overwrite=False)
319 mctx=repo['.'], overwrite=False)
295 merge.recordupdates(repo, actions, branchmerge=False)
320 merge.recordupdates(repo, actions, branchmerge=False)
296
321
297 # TODO(rdamazio): Make new matcher format and update description
322 # TODO(rdamazio): Make new matcher format and update description
298 @command('tracked',
323 @command('tracked',
299 [('', 'addinclude', [], _('new paths to include')),
324 [('', 'addinclude', [], _('new paths to include')),
300 ('', 'removeinclude', [], _('old paths to no longer include')),
325 ('', 'removeinclude', [], _('old paths to no longer include')),
301 ('', 'addexclude', [], _('new paths to exclude')),
326 ('', 'addexclude', [], _('new paths to exclude')),
302 ('', 'removeexclude', [], _('old paths to no longer exclude')),
327 ('', 'removeexclude', [], _('old paths to no longer exclude')),
303 ('', 'clear', False, _('whether to replace the existing narrowspec')),
328 ('', 'clear', False, _('whether to replace the existing narrowspec')),
304 ('', 'force-delete-local-changes', False,
329 ('', 'force-delete-local-changes', False,
305 _('forces deletion of local changes when narrowing')),
330 _('forces deletion of local changes when narrowing')),
306 ] + commands.remoteopts,
331 ] + commands.remoteopts,
307 _('[OPTIONS]... [REMOTE]'),
332 _('[OPTIONS]... [REMOTE]'),
308 inferrepo=True)
333 inferrepo=True)
309 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
334 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
310 """show or change the current narrowspec
335 """show or change the current narrowspec
311
336
312 With no argument, shows the current narrowspec entries, one per line. Each
337 With no argument, shows the current narrowspec entries, one per line. Each
313 line will be prefixed with 'I' or 'X' for included or excluded patterns,
338 line will be prefixed with 'I' or 'X' for included or excluded patterns,
314 respectively.
339 respectively.
315
340
316 The narrowspec is comprised of expressions to match remote files and/or
341 The narrowspec is comprised of expressions to match remote files and/or
317 directories that should be pulled into your client.
342 directories that should be pulled into your client.
318 The narrowspec has *include* and *exclude* expressions, with excludes always
343 The narrowspec has *include* and *exclude* expressions, with excludes always
319 trumping includes: that is, if a file matches an exclude expression, it will
344 trumping includes: that is, if a file matches an exclude expression, it will
320 be excluded even if it also matches an include expression.
345 be excluded even if it also matches an include expression.
321 Excluding files that were never included has no effect.
346 Excluding files that were never included has no effect.
322
347
323 Each included or excluded entry is in the format described by
348 Each included or excluded entry is in the format described by
324 'hg help patterns'.
349 'hg help patterns'.
325
350
326 The options allow you to add or remove included and excluded expressions.
351 The options allow you to add or remove included and excluded expressions.
327
352
328 If --clear is specified, then all previous includes and excludes are DROPPED
353 If --clear is specified, then all previous includes and excludes are DROPPED
329 and replaced by the new ones specified to --addinclude and --addexclude.
354 and replaced by the new ones specified to --addinclude and --addexclude.
330 If --clear is specified without any further options, the narrowspec will be
355 If --clear is specified without any further options, the narrowspec will be
331 empty and will not match any files.
356 empty and will not match any files.
332 """
357 """
333 opts = pycompat.byteskwargs(opts)
358 opts = pycompat.byteskwargs(opts)
334 if repository.NARROW_REQUIREMENT not in repo.requirements:
359 if repository.NARROW_REQUIREMENT not in repo.requirements:
335 ui.warn(_('The narrow command is only supported on respositories cloned'
360 ui.warn(_('The narrow command is only supported on respositories cloned'
336 ' with --narrow.\n'))
361 ' with --narrow.\n'))
337 return 1
362 return 1
338
363
339 # Before supporting, decide whether it "hg tracked --clear" should mean
364 # Before supporting, decide whether it "hg tracked --clear" should mean
340 # tracking no paths or all paths.
365 # tracking no paths or all paths.
341 if opts['clear']:
366 if opts['clear']:
342 ui.warn(_('The --clear option is not yet supported.\n'))
367 ui.warn(_('The --clear option is not yet supported.\n'))
343 return 1
368 return 1
344
369
345 if narrowspec.needsexpansion(opts['addinclude'] + opts['addexclude']):
370 if narrowspec.needsexpansion(opts['addinclude'] + opts['addexclude']):
346 raise error.Abort('Expansion not yet supported on widen/narrow')
371 raise error.Abort('Expansion not yet supported on widen/narrow')
347
372
348 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
373 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
349 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
374 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
350 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
375 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
351 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
376 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
352 widening = addedincludes or removedexcludes
377 widening = addedincludes or removedexcludes
353 narrowing = removedincludes or addedexcludes
378 narrowing = removedincludes or addedexcludes
354 only_show = not widening and not narrowing
379 only_show = not widening and not narrowing
355
380
356 # Only print the current narrowspec.
381 # Only print the current narrowspec.
357 if only_show:
382 if only_show:
358 include, exclude = repo.narrowpats
383 include, exclude = repo.narrowpats
359
384
360 ui.pager('tracked')
385 ui.pager('tracked')
361 fm = ui.formatter('narrow', opts)
386 fm = ui.formatter('narrow', opts)
362 for i in sorted(include):
387 for i in sorted(include):
363 fm.startitem()
388 fm.startitem()
364 fm.write('status', '%s ', 'I', label='narrow.included')
389 fm.write('status', '%s ', 'I', label='narrow.included')
365 fm.write('pat', '%s\n', i, label='narrow.included')
390 fm.write('pat', '%s\n', i, label='narrow.included')
366 for i in sorted(exclude):
391 for i in sorted(exclude):
367 fm.startitem()
392 fm.startitem()
368 fm.write('status', '%s ', 'X', label='narrow.excluded')
393 fm.write('status', '%s ', 'X', label='narrow.excluded')
369 fm.write('pat', '%s\n', i, label='narrow.excluded')
394 fm.write('pat', '%s\n', i, label='narrow.excluded')
370 fm.end()
395 fm.end()
371 return 0
396 return 0
372
397
373 with repo.wlock(), repo.lock():
398 with repo.wlock(), repo.lock():
374 cmdutil.bailifchanged(repo)
399 cmdutil.bailifchanged(repo)
375
400
376 # Find the revisions we have in common with the remote. These will
401 # Find the revisions we have in common with the remote. These will
377 # be used for finding local-only changes for narrowing. They will
402 # be used for finding local-only changes for narrowing. They will
378 # also define the set of revisions to update for widening.
403 # also define the set of revisions to update for widening.
379 remotepath = ui.expandpath(remotepath or 'default')
404 remotepath = ui.expandpath(remotepath or 'default')
380 url, branches = hg.parseurl(remotepath)
405 url, branches = hg.parseurl(remotepath)
381 ui.status(_('comparing with %s\n') % util.hidepassword(url))
406 ui.status(_('comparing with %s\n') % util.hidepassword(url))
382 remote = hg.peer(repo, opts, url)
407 remote = hg.peer(repo, opts, url)
383 commoninc = discovery.findcommonincoming(repo, remote)
408 commoninc = discovery.findcommonincoming(repo, remote)
384
409
385 oldincludes, oldexcludes = repo.narrowpats
410 oldincludes, oldexcludes = repo.narrowpats
386 if narrowing:
411 if narrowing:
387 newincludes = oldincludes - removedincludes
412 newincludes = oldincludes - removedincludes
388 newexcludes = oldexcludes | addedexcludes
413 newexcludes = oldexcludes | addedexcludes
389 _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
414 _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
390 newincludes, newexcludes,
415 newincludes, newexcludes,
391 opts['force_delete_local_changes'])
416 opts['force_delete_local_changes'])
392 # _narrow() updated the narrowspec and _widen() below needs to
417 # _narrow() updated the narrowspec and _widen() below needs to
393 # use the updated values as its base (otherwise removed includes
418 # use the updated values as its base (otherwise removed includes
394 # and addedexcludes will be lost in the resulting narrowspec)
419 # and addedexcludes will be lost in the resulting narrowspec)
395 oldincludes = newincludes
420 oldincludes = newincludes
396 oldexcludes = newexcludes
421 oldexcludes = newexcludes
397
422
398 if widening:
423 if widening:
399 newincludes = oldincludes | addedincludes
424 newincludes = oldincludes | addedincludes
400 newexcludes = oldexcludes - removedexcludes
425 newexcludes = oldexcludes - removedexcludes
401 _widen(ui, repo, remote, commoninc, newincludes, newexcludes)
426 _widen(ui, repo, remote, commoninc, newincludes, newexcludes)
402
427
403 return 0
428 return 0
@@ -1,125 +1,161 b''
1 $ . "$TESTDIR/narrow-library.sh"
1 $ . "$TESTDIR/narrow-library.sh"
2
2
3 $ hg init master
3 $ hg init master
4 $ cd master
4 $ cd master
5 $ mkdir dir
5 $ mkdir dir
6 $ mkdir dir/src
6 $ mkdir dir/src
7 $ cd dir/src
7 $ cd dir/src
8 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
8 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
9 $ cd ..
9 $ cd ..
10 $ mkdir tests
10 $ mkdir tests
11 $ cd tests
11 $ cd tests
12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
13 $ cd ../../..
13 $ cd ../../..
14
14
15 narrow clone a file, f10
15 narrow clone a file, f10
16
16
17 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
17 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
18 requesting all changes
18 requesting all changes
19 adding changesets
19 adding changesets
20 adding manifests
20 adding manifests
21 adding file changes
21 adding file changes
22 added 40 changesets with 1 changes to 1 files
22 added 40 changesets with 1 changes to 1 files
23 new changesets *:* (glob)
23 new changesets *:* (glob)
24 $ cd narrow
24 $ cd narrow
25 $ cat .hg/requires | grep -v generaldelta
25 $ cat .hg/requires | grep -v generaldelta
26 dotencode
26 dotencode
27 fncache
27 fncache
28 narrowhg-experimental
28 narrowhg-experimental
29 revlogv1
29 revlogv1
30 store
30 store
31 testonly-simplestore (reposimplestore !)
31 testonly-simplestore (reposimplestore !)
32
32
33 $ hg tracked
33 $ hg tracked
34 I path:dir/src/f10
34 I path:dir/src/f10
35 $ hg update
35 $ hg update
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 $ find * | sort
37 $ find * | sort
38 dir
38 dir
39 dir/src
39 dir/src
40 dir/src/f10
40 dir/src/f10
41 $ cat dir/src/f10
41 $ cat dir/src/f10
42 10
42 10
43
43
44 $ cd ..
44 $ cd ..
45
45
46 narrow clone a directory, tests/, except tests/t19
46 narrow clone a directory, tests/, except tests/t19
47
47
48 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
48 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
49 requesting all changes
49 requesting all changes
50 adding changesets
50 adding changesets
51 adding manifests
51 adding manifests
52 adding file changes
52 adding file changes
53 added 40 changesets with 19 changes to 19 files
53 added 40 changesets with 19 changes to 19 files
54 new changesets *:* (glob)
54 new changesets *:* (glob)
55 $ cd narrowdir
55 $ cd narrowdir
56 $ hg tracked
56 $ hg tracked
57 I path:dir/tests
57 I path:dir/tests
58 X path:dir/tests/t19
58 X path:dir/tests/t19
59 $ hg update
59 $ hg update
60 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 $ find * | sort
61 $ find * | sort
62 dir
62 dir
63 dir/tests
63 dir/tests
64 dir/tests/t1
64 dir/tests/t1
65 dir/tests/t10
65 dir/tests/t10
66 dir/tests/t11
66 dir/tests/t11
67 dir/tests/t12
67 dir/tests/t12
68 dir/tests/t13
68 dir/tests/t13
69 dir/tests/t14
69 dir/tests/t14
70 dir/tests/t15
70 dir/tests/t15
71 dir/tests/t16
71 dir/tests/t16
72 dir/tests/t17
72 dir/tests/t17
73 dir/tests/t18
73 dir/tests/t18
74 dir/tests/t2
74 dir/tests/t2
75 dir/tests/t20
75 dir/tests/t20
76 dir/tests/t3
76 dir/tests/t3
77 dir/tests/t4
77 dir/tests/t4
78 dir/tests/t5
78 dir/tests/t5
79 dir/tests/t6
79 dir/tests/t6
80 dir/tests/t7
80 dir/tests/t7
81 dir/tests/t8
81 dir/tests/t8
82 dir/tests/t9
82 dir/tests/t9
83
83
84 $ cd ..
84 $ cd ..
85
85
86 narrow clone everything but a directory (tests/)
86 narrow clone everything but a directory (tests/)
87
87
88 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
88 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
89 requesting all changes
89 requesting all changes
90 adding changesets
90 adding changesets
91 adding manifests
91 adding manifests
92 adding file changes
92 adding file changes
93 added 40 changesets with 20 changes to 20 files
93 added 40 changesets with 20 changes to 20 files
94 new changesets *:* (glob)
94 new changesets *:* (glob)
95 $ cd narrowroot
95 $ cd narrowroot
96 $ hg tracked
96 $ hg tracked
97 I path:.
97 I path:.
98 X path:dir/tests
98 X path:dir/tests
99 $ hg update
99 $ hg update
100 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 $ find * | sort
101 $ find * | sort
102 dir
102 dir
103 dir/src
103 dir/src
104 dir/src/f1
104 dir/src/f1
105 dir/src/f10
105 dir/src/f10
106 dir/src/f11
106 dir/src/f11
107 dir/src/f12
107 dir/src/f12
108 dir/src/f13
108 dir/src/f13
109 dir/src/f14
109 dir/src/f14
110 dir/src/f15
110 dir/src/f15
111 dir/src/f16
111 dir/src/f16
112 dir/src/f17
112 dir/src/f17
113 dir/src/f18
113 dir/src/f18
114 dir/src/f19
114 dir/src/f19
115 dir/src/f2
115 dir/src/f2
116 dir/src/f20
116 dir/src/f20
117 dir/src/f3
117 dir/src/f3
118 dir/src/f4
118 dir/src/f4
119 dir/src/f5
119 dir/src/f5
120 dir/src/f6
120 dir/src/f6
121 dir/src/f7
121 dir/src/f7
122 dir/src/f8
122 dir/src/f8
123 dir/src/f9
123 dir/src/f9
124
124
125 $ cd ..
125 $ cd ..
126
127 Testing the --narrowspec flag to clone
128
129 $ cat >> narrowspecs <<EOF
130 > %include foo
131 > [include]
132 > path:dir/tests/
133 > file:dir/src/f12
134 > EOF
135
136 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
137 reading narrowspec from '$TESTTMP/narrowspecs'
138 abort: cannot specify other files using '%include' in narrowspec
139 [255]
140
141 $ cat > narrowspecs <<EOF
142 > [include]
143 > path:dir/tests/
144 > file:dir/src/f12
145 > EOF
146
147 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
148 reading narrowspec from '$TESTTMP/narrowspecs'
149 requesting all changes
150 adding changesets
151 adding manifests
152 adding file changes
153 added 40 changesets with 20 changes to 20 files
154 new changesets 681085829a73:26ce255d5b5d
155 updating to branch default
156 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 $ cd specfile
158 $ hg tracked
159 I path:dir/tests
160 I path:file:dir/src/f12
161 $ cd ..
@@ -1,220 +1,256 b''
1 $ . "$TESTDIR/narrow-library.sh"
1 $ . "$TESTDIR/narrow-library.sh"
2
2
3 $ hg init master
3 $ hg init master
4 $ cd master
4 $ cd master
5 $ cat >> .hg/hgrc <<EOF
5 $ cat >> .hg/hgrc <<EOF
6 > [narrow]
6 > [narrow]
7 > serveellipses=True
7 > serveellipses=True
8 > EOF
8 > EOF
9 $ mkdir dir
9 $ mkdir dir
10 $ mkdir dir/src
10 $ mkdir dir/src
11 $ cd dir/src
11 $ cd dir/src
12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
13 $ cd ..
13 $ cd ..
14 $ mkdir tests
14 $ mkdir tests
15 $ cd tests
15 $ cd tests
16 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
16 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
17 $ cd ../../..
17 $ cd ../../..
18
18
19 narrow clone a file, f10
19 narrow clone a file, f10
20
20
21 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
21 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
22 requesting all changes
22 requesting all changes
23 adding changesets
23 adding changesets
24 adding manifests
24 adding manifests
25 adding file changes
25 adding file changes
26 added 3 changesets with 1 changes to 1 files
26 added 3 changesets with 1 changes to 1 files
27 new changesets *:* (glob)
27 new changesets *:* (glob)
28 $ cd narrow
28 $ cd narrow
29 $ cat .hg/requires | grep -v generaldelta
29 $ cat .hg/requires | grep -v generaldelta
30 dotencode
30 dotencode
31 fncache
31 fncache
32 narrowhg-experimental
32 narrowhg-experimental
33 revlogv1
33 revlogv1
34 store
34 store
35 testonly-simplestore (reposimplestore !)
35 testonly-simplestore (reposimplestore !)
36
36
37 $ hg tracked
37 $ hg tracked
38 I path:dir/src/f10
38 I path:dir/src/f10
39 $ hg tracked
39 $ hg tracked
40 I path:dir/src/f10
40 I path:dir/src/f10
41 $ hg update
41 $ hg update
42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 $ find * | sort
43 $ find * | sort
44 dir
44 dir
45 dir/src
45 dir/src
46 dir/src/f10
46 dir/src/f10
47 $ cat dir/src/f10
47 $ cat dir/src/f10
48 10
48 10
49
49
50 $ cd ..
50 $ cd ..
51
51
52 narrow clone with a newline should fail
52 narrow clone with a newline should fail
53
53
54 $ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
54 $ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
55 > '
55 > '
56 requesting all changes
56 requesting all changes
57 abort: newlines are not allowed in narrowspec paths
57 abort: newlines are not allowed in narrowspec paths
58 [255]
58 [255]
59
59
60 narrow clone a directory, tests/, except tests/t19
60 narrow clone a directory, tests/, except tests/t19
61
61
62 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
62 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
63 requesting all changes
63 requesting all changes
64 adding changesets
64 adding changesets
65 adding manifests
65 adding manifests
66 adding file changes
66 adding file changes
67 added 21 changesets with 19 changes to 19 files
67 added 21 changesets with 19 changes to 19 files
68 new changesets *:* (glob)
68 new changesets *:* (glob)
69 $ cd narrowdir
69 $ cd narrowdir
70 $ hg tracked
70 $ hg tracked
71 I path:dir/tests
71 I path:dir/tests
72 X path:dir/tests/t19
72 X path:dir/tests/t19
73 $ hg tracked
73 $ hg tracked
74 I path:dir/tests
74 I path:dir/tests
75 X path:dir/tests/t19
75 X path:dir/tests/t19
76 $ hg update
76 $ hg update
77 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 $ find * | sort
78 $ find * | sort
79 dir
79 dir
80 dir/tests
80 dir/tests
81 dir/tests/t1
81 dir/tests/t1
82 dir/tests/t10
82 dir/tests/t10
83 dir/tests/t11
83 dir/tests/t11
84 dir/tests/t12
84 dir/tests/t12
85 dir/tests/t13
85 dir/tests/t13
86 dir/tests/t14
86 dir/tests/t14
87 dir/tests/t15
87 dir/tests/t15
88 dir/tests/t16
88 dir/tests/t16
89 dir/tests/t17
89 dir/tests/t17
90 dir/tests/t18
90 dir/tests/t18
91 dir/tests/t2
91 dir/tests/t2
92 dir/tests/t20
92 dir/tests/t20
93 dir/tests/t3
93 dir/tests/t3
94 dir/tests/t4
94 dir/tests/t4
95 dir/tests/t5
95 dir/tests/t5
96 dir/tests/t6
96 dir/tests/t6
97 dir/tests/t7
97 dir/tests/t7
98 dir/tests/t8
98 dir/tests/t8
99 dir/tests/t9
99 dir/tests/t9
100
100
101 $ cd ..
101 $ cd ..
102
102
103 narrow clone everything but a directory (tests/)
103 narrow clone everything but a directory (tests/)
104
104
105 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
105 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
106 requesting all changes
106 requesting all changes
107 adding changesets
107 adding changesets
108 adding manifests
108 adding manifests
109 adding file changes
109 adding file changes
110 added 21 changesets with 20 changes to 20 files
110 added 21 changesets with 20 changes to 20 files
111 new changesets *:* (glob)
111 new changesets *:* (glob)
112 $ cd narrowroot
112 $ cd narrowroot
113 $ hg tracked
113 $ hg tracked
114 I path:.
114 I path:.
115 X path:dir/tests
115 X path:dir/tests
116 $ hg tracked
116 $ hg tracked
117 I path:.
117 I path:.
118 X path:dir/tests
118 X path:dir/tests
119 $ hg update
119 $ hg update
120 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
121 $ find * | sort
121 $ find * | sort
122 dir
122 dir
123 dir/src
123 dir/src
124 dir/src/f1
124 dir/src/f1
125 dir/src/f10
125 dir/src/f10
126 dir/src/f11
126 dir/src/f11
127 dir/src/f12
127 dir/src/f12
128 dir/src/f13
128 dir/src/f13
129 dir/src/f14
129 dir/src/f14
130 dir/src/f15
130 dir/src/f15
131 dir/src/f16
131 dir/src/f16
132 dir/src/f17
132 dir/src/f17
133 dir/src/f18
133 dir/src/f18
134 dir/src/f19
134 dir/src/f19
135 dir/src/f2
135 dir/src/f2
136 dir/src/f20
136 dir/src/f20
137 dir/src/f3
137 dir/src/f3
138 dir/src/f4
138 dir/src/f4
139 dir/src/f5
139 dir/src/f5
140 dir/src/f6
140 dir/src/f6
141 dir/src/f7
141 dir/src/f7
142 dir/src/f8
142 dir/src/f8
143 dir/src/f9
143 dir/src/f9
144
144
145 $ cd ..
145 $ cd ..
146
146
147 narrow clone no paths at all
147 narrow clone no paths at all
148
148
149 $ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
149 $ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
150 requesting all changes
150 requesting all changes
151 adding changesets
151 adding changesets
152 adding manifests
152 adding manifests
153 adding file changes
153 adding file changes
154 added 1 changesets with 0 changes to 0 files
154 added 1 changesets with 0 changes to 0 files
155 new changesets * (glob)
155 new changesets * (glob)
156 $ cd narrowempty
156 $ cd narrowempty
157 $ hg tracked
157 $ hg tracked
158 $ hg update
158 $ hg update
159 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 $ ls
160 $ ls
161
161
162 $ cd ..
162 $ cd ..
163
163
164 simple clone
164 simple clone
165 $ hg clone ssh://user@dummy/master simpleclone
165 $ hg clone ssh://user@dummy/master simpleclone
166 requesting all changes
166 requesting all changes
167 adding changesets
167 adding changesets
168 adding manifests
168 adding manifests
169 adding file changes
169 adding file changes
170 added 40 changesets with 40 changes to 40 files
170 added 40 changesets with 40 changes to 40 files
171 new changesets * (glob)
171 new changesets * (glob)
172 updating to branch default
172 updating to branch default
173 40 files updated, 0 files merged, 0 files removed, 0 files unresolved
173 40 files updated, 0 files merged, 0 files removed, 0 files unresolved
174 $ cd simpleclone
174 $ cd simpleclone
175 $ find * | sort
175 $ find * | sort
176 dir
176 dir
177 dir/src
177 dir/src
178 dir/src/f1
178 dir/src/f1
179 dir/src/f10
179 dir/src/f10
180 dir/src/f11
180 dir/src/f11
181 dir/src/f12
181 dir/src/f12
182 dir/src/f13
182 dir/src/f13
183 dir/src/f14
183 dir/src/f14
184 dir/src/f15
184 dir/src/f15
185 dir/src/f16
185 dir/src/f16
186 dir/src/f17
186 dir/src/f17
187 dir/src/f18
187 dir/src/f18
188 dir/src/f19
188 dir/src/f19
189 dir/src/f2
189 dir/src/f2
190 dir/src/f20
190 dir/src/f20
191 dir/src/f3
191 dir/src/f3
192 dir/src/f4
192 dir/src/f4
193 dir/src/f5
193 dir/src/f5
194 dir/src/f6
194 dir/src/f6
195 dir/src/f7
195 dir/src/f7
196 dir/src/f8
196 dir/src/f8
197 dir/src/f9
197 dir/src/f9
198 dir/tests
198 dir/tests
199 dir/tests/t1
199 dir/tests/t1
200 dir/tests/t10
200 dir/tests/t10
201 dir/tests/t11
201 dir/tests/t11
202 dir/tests/t12
202 dir/tests/t12
203 dir/tests/t13
203 dir/tests/t13
204 dir/tests/t14
204 dir/tests/t14
205 dir/tests/t15
205 dir/tests/t15
206 dir/tests/t16
206 dir/tests/t16
207 dir/tests/t17
207 dir/tests/t17
208 dir/tests/t18
208 dir/tests/t18
209 dir/tests/t19
209 dir/tests/t19
210 dir/tests/t2
210 dir/tests/t2
211 dir/tests/t20
211 dir/tests/t20
212 dir/tests/t3
212 dir/tests/t3
213 dir/tests/t4
213 dir/tests/t4
214 dir/tests/t5
214 dir/tests/t5
215 dir/tests/t6
215 dir/tests/t6
216 dir/tests/t7
216 dir/tests/t7
217 dir/tests/t8
217 dir/tests/t8
218 dir/tests/t9
218 dir/tests/t9
219
219
220 $ cd ..
220 $ cd ..
221
222 Testing the --narrowspec flag to clone
223
224 $ cat >> narrowspecs <<EOF
225 > %include foo
226 > [include]
227 > path:dir/tests/
228 > dir/src/f12
229 > EOF
230
231 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
232 reading narrowspec from '$TESTTMP/narrowspecs'
233 abort: cannot specify other files using '%include' in narrowspec
234 [255]
235
236 $ cat > narrowspecs <<EOF
237 > [include]
238 > path:dir/tests/
239 > file:dir/src/f12
240 > EOF
241
242 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
243 reading narrowspec from '$TESTTMP/narrowspecs'
244 requesting all changes
245 adding changesets
246 adding manifests
247 adding file changes
248 added 21 changesets with 20 changes to 20 files
249 new changesets f93383bb3e99:26ce255d5b5d
250 updating to branch default
251 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
252 $ cd specfile
253 $ hg tracked
254 I path:dir/tests
255 I path:file:dir/src/f12
256 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now