##// END OF EJS Templates
errors: raise more specifc errors from narrowcommands...
Martin von Zweigbergk -
r46733:6cc269bd default
parent child Browse files
Show More
@@ -1,663 +1,663
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 import os
11
11
12 from mercurial.i18n import _
12 from mercurial.i18n import _
13 from mercurial.node import (
13 from mercurial.node import (
14 hex,
14 hex,
15 nullid,
15 nullid,
16 short,
16 short,
17 )
17 )
18 from mercurial import (
18 from mercurial import (
19 bundle2,
19 bundle2,
20 cmdutil,
20 cmdutil,
21 commands,
21 commands,
22 discovery,
22 discovery,
23 encoding,
23 encoding,
24 error,
24 error,
25 exchange,
25 exchange,
26 extensions,
26 extensions,
27 hg,
27 hg,
28 narrowspec,
28 narrowspec,
29 pathutil,
29 pathutil,
30 pycompat,
30 pycompat,
31 registrar,
31 registrar,
32 repair,
32 repair,
33 repoview,
33 repoview,
34 requirements,
34 requirements,
35 sparse,
35 sparse,
36 util,
36 util,
37 wireprototypes,
37 wireprototypes,
38 )
38 )
39
39
40 table = {}
40 table = {}
41 command = registrar.command(table)
41 command = registrar.command(table)
42
42
43
43
44 def setup():
44 def setup():
45 """Wraps user-facing mercurial commands with narrow-aware versions."""
45 """Wraps user-facing mercurial commands with narrow-aware versions."""
46
46
47 entry = extensions.wrapcommand(commands.table, b'clone', clonenarrowcmd)
47 entry = extensions.wrapcommand(commands.table, b'clone', clonenarrowcmd)
48 entry[1].append(
48 entry[1].append(
49 (b'', b'narrow', None, _(b"create a narrow clone of select files"))
49 (b'', b'narrow', None, _(b"create a narrow clone of select files"))
50 )
50 )
51 entry[1].append(
51 entry[1].append(
52 (
52 (
53 b'',
53 b'',
54 b'depth',
54 b'depth',
55 b'',
55 b'',
56 _(b"limit the history fetched by distance from heads"),
56 _(b"limit the history fetched by distance from heads"),
57 )
57 )
58 )
58 )
59 entry[1].append((b'', b'narrowspec', b'', _(b"read narrowspecs from file")))
59 entry[1].append((b'', b'narrowspec', b'', _(b"read narrowspecs from file")))
60 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
60 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
61 if b'sparse' not in extensions.enabled():
61 if b'sparse' not in extensions.enabled():
62 entry[1].append(
62 entry[1].append(
63 (b'', b'include', [], _(b"specifically fetch this file/directory"))
63 (b'', b'include', [], _(b"specifically fetch this file/directory"))
64 )
64 )
65 entry[1].append(
65 entry[1].append(
66 (
66 (
67 b'',
67 b'',
68 b'exclude',
68 b'exclude',
69 [],
69 [],
70 _(b"do not fetch this file/directory, even if included"),
70 _(b"do not fetch this file/directory, even if included"),
71 )
71 )
72 )
72 )
73
73
74 entry = extensions.wrapcommand(commands.table, b'pull', pullnarrowcmd)
74 entry = extensions.wrapcommand(commands.table, b'pull', pullnarrowcmd)
75 entry[1].append(
75 entry[1].append(
76 (
76 (
77 b'',
77 b'',
78 b'depth',
78 b'depth',
79 b'',
79 b'',
80 _(b"limit the history fetched by distance from heads"),
80 _(b"limit the history fetched by distance from heads"),
81 )
81 )
82 )
82 )
83
83
84 extensions.wrapcommand(commands.table, b'archive', archivenarrowcmd)
84 extensions.wrapcommand(commands.table, b'archive', archivenarrowcmd)
85
85
86
86
87 def clonenarrowcmd(orig, ui, repo, *args, **opts):
87 def clonenarrowcmd(orig, ui, repo, *args, **opts):
88 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
88 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
89 opts = pycompat.byteskwargs(opts)
89 opts = pycompat.byteskwargs(opts)
90 wrappedextraprepare = util.nullcontextmanager()
90 wrappedextraprepare = util.nullcontextmanager()
91 narrowspecfile = opts[b'narrowspec']
91 narrowspecfile = opts[b'narrowspec']
92
92
93 if narrowspecfile:
93 if narrowspecfile:
94 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
94 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
95 ui.status(_(b"reading narrowspec from '%s'\n") % filepath)
95 ui.status(_(b"reading narrowspec from '%s'\n") % filepath)
96 try:
96 try:
97 fdata = util.readfile(filepath)
97 fdata = util.readfile(filepath)
98 except IOError as inst:
98 except IOError as inst:
99 raise error.Abort(
99 raise error.Abort(
100 _(b"cannot read narrowspecs from '%s': %s")
100 _(b"cannot read narrowspecs from '%s': %s")
101 % (filepath, encoding.strtolocal(inst.strerror))
101 % (filepath, encoding.strtolocal(inst.strerror))
102 )
102 )
103
103
104 includes, excludes, profiles = sparse.parseconfig(ui, fdata, b'narrow')
104 includes, excludes, profiles = sparse.parseconfig(ui, fdata, b'narrow')
105 if profiles:
105 if profiles:
106 raise error.Abort(
106 raise error.ConfigError(
107 _(
107 _(
108 b"cannot specify other files using '%include' in"
108 b"cannot specify other files using '%include' in"
109 b" narrowspec"
109 b" narrowspec"
110 )
110 )
111 )
111 )
112
112
113 narrowspec.validatepatterns(includes)
113 narrowspec.validatepatterns(includes)
114 narrowspec.validatepatterns(excludes)
114 narrowspec.validatepatterns(excludes)
115
115
116 # narrowspec is passed so we should assume that user wants narrow clone
116 # narrowspec is passed so we should assume that user wants narrow clone
117 opts[b'narrow'] = True
117 opts[b'narrow'] = True
118 opts[b'include'].extend(includes)
118 opts[b'include'].extend(includes)
119 opts[b'exclude'].extend(excludes)
119 opts[b'exclude'].extend(excludes)
120
120
121 if opts[b'narrow']:
121 if opts[b'narrow']:
122
122
123 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
123 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
124 orig(pullop, kwargs)
124 orig(pullop, kwargs)
125
125
126 if opts.get(b'depth'):
126 if opts.get(b'depth'):
127 kwargs[b'depth'] = opts[b'depth']
127 kwargs[b'depth'] = opts[b'depth']
128
128
129 wrappedextraprepare = extensions.wrappedfunction(
129 wrappedextraprepare = extensions.wrappedfunction(
130 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
130 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
131 )
131 )
132
132
133 with wrappedextraprepare:
133 with wrappedextraprepare:
134 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
134 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
135
135
136
136
137 def pullnarrowcmd(orig, ui, repo, *args, **opts):
137 def pullnarrowcmd(orig, ui, repo, *args, **opts):
138 """Wraps pull command to allow modifying narrow spec."""
138 """Wraps pull command to allow modifying narrow spec."""
139 wrappedextraprepare = util.nullcontextmanager()
139 wrappedextraprepare = util.nullcontextmanager()
140 if requirements.NARROW_REQUIREMENT in repo.requirements:
140 if requirements.NARROW_REQUIREMENT in repo.requirements:
141
141
142 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
142 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
143 orig(pullop, kwargs)
143 orig(pullop, kwargs)
144 if opts.get('depth'):
144 if opts.get('depth'):
145 kwargs[b'depth'] = opts['depth']
145 kwargs[b'depth'] = opts['depth']
146
146
147 wrappedextraprepare = extensions.wrappedfunction(
147 wrappedextraprepare = extensions.wrappedfunction(
148 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
148 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
149 )
149 )
150
150
151 with wrappedextraprepare:
151 with wrappedextraprepare:
152 return orig(ui, repo, *args, **opts)
152 return orig(ui, repo, *args, **opts)
153
153
154
154
155 def archivenarrowcmd(orig, ui, repo, *args, **opts):
155 def archivenarrowcmd(orig, ui, repo, *args, **opts):
156 """Wraps archive command to narrow the default includes."""
156 """Wraps archive command to narrow the default includes."""
157 if requirements.NARROW_REQUIREMENT in repo.requirements:
157 if requirements.NARROW_REQUIREMENT in repo.requirements:
158 repo_includes, repo_excludes = repo.narrowpats
158 repo_includes, repo_excludes = repo.narrowpats
159 includes = set(opts.get('include', []))
159 includes = set(opts.get('include', []))
160 excludes = set(opts.get('exclude', []))
160 excludes = set(opts.get('exclude', []))
161 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
161 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
162 includes, excludes, repo_includes, repo_excludes
162 includes, excludes, repo_includes, repo_excludes
163 )
163 )
164 if includes:
164 if includes:
165 opts['include'] = includes
165 opts['include'] = includes
166 if excludes:
166 if excludes:
167 opts['exclude'] = excludes
167 opts['exclude'] = excludes
168 return orig(ui, repo, *args, **opts)
168 return orig(ui, repo, *args, **opts)
169
169
170
170
171 def pullbundle2extraprepare(orig, pullop, kwargs):
171 def pullbundle2extraprepare(orig, pullop, kwargs):
172 repo = pullop.repo
172 repo = pullop.repo
173 if requirements.NARROW_REQUIREMENT not in repo.requirements:
173 if requirements.NARROW_REQUIREMENT not in repo.requirements:
174 return orig(pullop, kwargs)
174 return orig(pullop, kwargs)
175
175
176 if wireprototypes.NARROWCAP not in pullop.remote.capabilities():
176 if wireprototypes.NARROWCAP not in pullop.remote.capabilities():
177 raise error.Abort(_(b"server does not support narrow clones"))
177 raise error.Abort(_(b"server does not support narrow clones"))
178 orig(pullop, kwargs)
178 orig(pullop, kwargs)
179 kwargs[b'narrow'] = True
179 kwargs[b'narrow'] = True
180 include, exclude = repo.narrowpats
180 include, exclude = repo.narrowpats
181 kwargs[b'oldincludepats'] = include
181 kwargs[b'oldincludepats'] = include
182 kwargs[b'oldexcludepats'] = exclude
182 kwargs[b'oldexcludepats'] = exclude
183 if include:
183 if include:
184 kwargs[b'includepats'] = include
184 kwargs[b'includepats'] = include
185 if exclude:
185 if exclude:
186 kwargs[b'excludepats'] = exclude
186 kwargs[b'excludepats'] = exclude
187 # calculate known nodes only in ellipses cases because in non-ellipses cases
187 # calculate known nodes only in ellipses cases because in non-ellipses cases
188 # we have all the nodes
188 # we have all the nodes
189 if wireprototypes.ELLIPSESCAP1 in pullop.remote.capabilities():
189 if wireprototypes.ELLIPSESCAP1 in pullop.remote.capabilities():
190 kwargs[b'known'] = [
190 kwargs[b'known'] = [
191 hex(ctx.node())
191 hex(ctx.node())
192 for ctx in repo.set(b'::%ln', pullop.common)
192 for ctx in repo.set(b'::%ln', pullop.common)
193 if ctx.node() != nullid
193 if ctx.node() != nullid
194 ]
194 ]
195 if not kwargs[b'known']:
195 if not kwargs[b'known']:
196 # Mercurial serializes an empty list as '' and deserializes it as
196 # Mercurial serializes an empty list as '' and deserializes it as
197 # [''], so delete it instead to avoid handling the empty string on
197 # [''], so delete it instead to avoid handling the empty string on
198 # the server.
198 # the server.
199 del kwargs[b'known']
199 del kwargs[b'known']
200
200
201
201
202 extensions.wrapfunction(
202 extensions.wrapfunction(
203 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare
203 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare
204 )
204 )
205
205
206
206
207 def _narrow(
207 def _narrow(
208 ui,
208 ui,
209 repo,
209 repo,
210 remote,
210 remote,
211 commoninc,
211 commoninc,
212 oldincludes,
212 oldincludes,
213 oldexcludes,
213 oldexcludes,
214 newincludes,
214 newincludes,
215 newexcludes,
215 newexcludes,
216 force,
216 force,
217 ):
217 ):
218 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
218 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
219 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
219 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
220
220
221 # This is essentially doing "hg outgoing" to find all local-only
221 # This is essentially doing "hg outgoing" to find all local-only
222 # commits. We will then check that the local-only commits don't
222 # commits. We will then check that the local-only commits don't
223 # have any changes to files that will be untracked.
223 # have any changes to files that will be untracked.
224 unfi = repo.unfiltered()
224 unfi = repo.unfiltered()
225 outgoing = discovery.findcommonoutgoing(unfi, remote, commoninc=commoninc)
225 outgoing = discovery.findcommonoutgoing(unfi, remote, commoninc=commoninc)
226 ui.status(_(b'looking for local changes to affected paths\n'))
226 ui.status(_(b'looking for local changes to affected paths\n'))
227 localnodes = []
227 localnodes = []
228 for n in itertools.chain(outgoing.missing, outgoing.excluded):
228 for n in itertools.chain(outgoing.missing, outgoing.excluded):
229 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
229 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
230 localnodes.append(n)
230 localnodes.append(n)
231 revstostrip = unfi.revs(b'descendants(%ln)', localnodes)
231 revstostrip = unfi.revs(b'descendants(%ln)', localnodes)
232 hiddenrevs = repoview.filterrevs(repo, b'visible')
232 hiddenrevs = repoview.filterrevs(repo, b'visible')
233 visibletostrip = list(
233 visibletostrip = list(
234 repo.changelog.node(r) for r in (revstostrip - hiddenrevs)
234 repo.changelog.node(r) for r in (revstostrip - hiddenrevs)
235 )
235 )
236 if visibletostrip:
236 if visibletostrip:
237 ui.status(
237 ui.status(
238 _(
238 _(
239 b'The following changeset(s) or their ancestors have '
239 b'The following changeset(s) or their ancestors have '
240 b'local changes not on the remote:\n'
240 b'local changes not on the remote:\n'
241 )
241 )
242 )
242 )
243 maxnodes = 10
243 maxnodes = 10
244 if ui.verbose or len(visibletostrip) <= maxnodes:
244 if ui.verbose or len(visibletostrip) <= maxnodes:
245 for n in visibletostrip:
245 for n in visibletostrip:
246 ui.status(b'%s\n' % short(n))
246 ui.status(b'%s\n' % short(n))
247 else:
247 else:
248 for n in visibletostrip[:maxnodes]:
248 for n in visibletostrip[:maxnodes]:
249 ui.status(b'%s\n' % short(n))
249 ui.status(b'%s\n' % short(n))
250 ui.status(
250 ui.status(
251 _(b'...and %d more, use --verbose to list all\n')
251 _(b'...and %d more, use --verbose to list all\n')
252 % (len(visibletostrip) - maxnodes)
252 % (len(visibletostrip) - maxnodes)
253 )
253 )
254 if not force:
254 if not force:
255 raise error.Abort(
255 raise error.StateError(
256 _(b'local changes found'),
256 _(b'local changes found'),
257 hint=_(b'use --force-delete-local-changes to ignore'),
257 hint=_(b'use --force-delete-local-changes to ignore'),
258 )
258 )
259
259
260 with ui.uninterruptible():
260 with ui.uninterruptible():
261 if revstostrip:
261 if revstostrip:
262 tostrip = [unfi.changelog.node(r) for r in revstostrip]
262 tostrip = [unfi.changelog.node(r) for r in revstostrip]
263 if repo[b'.'].node() in tostrip:
263 if repo[b'.'].node() in tostrip:
264 # stripping working copy, so move to a different commit first
264 # stripping working copy, so move to a different commit first
265 urev = max(
265 urev = max(
266 repo.revs(
266 repo.revs(
267 b'(::%n) - %ln + null',
267 b'(::%n) - %ln + null',
268 repo[b'.'].node(),
268 repo[b'.'].node(),
269 visibletostrip,
269 visibletostrip,
270 )
270 )
271 )
271 )
272 hg.clean(repo, urev)
272 hg.clean(repo, urev)
273 overrides = {(b'devel', b'strip-obsmarkers'): False}
273 overrides = {(b'devel', b'strip-obsmarkers'): False}
274 with ui.configoverride(overrides, b'narrow'):
274 with ui.configoverride(overrides, b'narrow'):
275 repair.strip(ui, unfi, tostrip, topic=b'narrow')
275 repair.strip(ui, unfi, tostrip, topic=b'narrow')
276
276
277 todelete = []
277 todelete = []
278 for f, f2, size in repo.store.datafiles():
278 for f, f2, size in repo.store.datafiles():
279 if f.startswith(b'data/'):
279 if f.startswith(b'data/'):
280 file = f[5:-2]
280 file = f[5:-2]
281 if not newmatch(file):
281 if not newmatch(file):
282 todelete.append(f)
282 todelete.append(f)
283 elif f.startswith(b'meta/'):
283 elif f.startswith(b'meta/'):
284 dir = f[5:-13]
284 dir = f[5:-13]
285 dirs = sorted(pathutil.dirs({dir})) + [dir]
285 dirs = sorted(pathutil.dirs({dir})) + [dir]
286 include = True
286 include = True
287 for d in dirs:
287 for d in dirs:
288 visit = newmatch.visitdir(d)
288 visit = newmatch.visitdir(d)
289 if not visit:
289 if not visit:
290 include = False
290 include = False
291 break
291 break
292 if visit == b'all':
292 if visit == b'all':
293 break
293 break
294 if not include:
294 if not include:
295 todelete.append(f)
295 todelete.append(f)
296
296
297 repo.destroying()
297 repo.destroying()
298
298
299 with repo.transaction(b'narrowing'):
299 with repo.transaction(b'narrowing'):
300 # Update narrowspec before removing revlogs, so repo won't be
300 # Update narrowspec before removing revlogs, so repo won't be
301 # corrupt in case of crash
301 # corrupt in case of crash
302 repo.setnarrowpats(newincludes, newexcludes)
302 repo.setnarrowpats(newincludes, newexcludes)
303
303
304 for f in todelete:
304 for f in todelete:
305 ui.status(_(b'deleting %s\n') % f)
305 ui.status(_(b'deleting %s\n') % f)
306 util.unlinkpath(repo.svfs.join(f))
306 util.unlinkpath(repo.svfs.join(f))
307 repo.store.markremoved(f)
307 repo.store.markremoved(f)
308
308
309 narrowspec.updateworkingcopy(repo, assumeclean=True)
309 narrowspec.updateworkingcopy(repo, assumeclean=True)
310 narrowspec.copytoworkingcopy(repo)
310 narrowspec.copytoworkingcopy(repo)
311
311
312 repo.destroyed()
312 repo.destroyed()
313
313
314
314
315 def _widen(
315 def _widen(
316 ui,
316 ui,
317 repo,
317 repo,
318 remote,
318 remote,
319 commoninc,
319 commoninc,
320 oldincludes,
320 oldincludes,
321 oldexcludes,
321 oldexcludes,
322 newincludes,
322 newincludes,
323 newexcludes,
323 newexcludes,
324 ):
324 ):
325 # for now we assume that if a server has ellipses enabled, we will be
325 # for now we assume that if a server has ellipses enabled, we will be
326 # exchanging ellipses nodes. In future we should add ellipses as a client
326 # exchanging ellipses nodes. In future we should add ellipses as a client
327 # side requirement (maybe) to distinguish a client is shallow or not and
327 # side requirement (maybe) to distinguish a client is shallow or not and
328 # then send that information to server whether we want ellipses or not.
328 # then send that information to server whether we want ellipses or not.
329 # Theoretically a non-ellipses repo should be able to use narrow
329 # Theoretically a non-ellipses repo should be able to use narrow
330 # functionality from an ellipses enabled server
330 # functionality from an ellipses enabled server
331 remotecap = remote.capabilities()
331 remotecap = remote.capabilities()
332 ellipsesremote = any(
332 ellipsesremote = any(
333 cap in remotecap for cap in wireprototypes.SUPPORTED_ELLIPSESCAP
333 cap in remotecap for cap in wireprototypes.SUPPORTED_ELLIPSESCAP
334 )
334 )
335
335
336 # check whether we are talking to a server which supports old version of
336 # check whether we are talking to a server which supports old version of
337 # ellipses capabilities
337 # ellipses capabilities
338 isoldellipses = (
338 isoldellipses = (
339 ellipsesremote
339 ellipsesremote
340 and wireprototypes.ELLIPSESCAP1 in remotecap
340 and wireprototypes.ELLIPSESCAP1 in remotecap
341 and wireprototypes.ELLIPSESCAP not in remotecap
341 and wireprototypes.ELLIPSESCAP not in remotecap
342 )
342 )
343
343
344 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
344 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
345 orig(pullop, kwargs)
345 orig(pullop, kwargs)
346 # The old{in,ex}cludepats have already been set by orig()
346 # The old{in,ex}cludepats have already been set by orig()
347 kwargs[b'includepats'] = newincludes
347 kwargs[b'includepats'] = newincludes
348 kwargs[b'excludepats'] = newexcludes
348 kwargs[b'excludepats'] = newexcludes
349
349
350 wrappedextraprepare = extensions.wrappedfunction(
350 wrappedextraprepare = extensions.wrappedfunction(
351 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
351 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
352 )
352 )
353
353
354 # define a function that narrowbundle2 can call after creating the
354 # define a function that narrowbundle2 can call after creating the
355 # backup bundle, but before applying the bundle from the server
355 # backup bundle, but before applying the bundle from the server
356 def setnewnarrowpats():
356 def setnewnarrowpats():
357 repo.setnarrowpats(newincludes, newexcludes)
357 repo.setnarrowpats(newincludes, newexcludes)
358
358
359 repo.setnewnarrowpats = setnewnarrowpats
359 repo.setnewnarrowpats = setnewnarrowpats
360 # silence the devel-warning of applying an empty changegroup
360 # silence the devel-warning of applying an empty changegroup
361 overrides = {(b'devel', b'all-warnings'): False}
361 overrides = {(b'devel', b'all-warnings'): False}
362
362
363 common = commoninc[0]
363 common = commoninc[0]
364 with ui.uninterruptible():
364 with ui.uninterruptible():
365 if ellipsesremote:
365 if ellipsesremote:
366 ds = repo.dirstate
366 ds = repo.dirstate
367 p1, p2 = ds.p1(), ds.p2()
367 p1, p2 = ds.p1(), ds.p2()
368 with ds.parentchange():
368 with ds.parentchange():
369 ds.setparents(nullid, nullid)
369 ds.setparents(nullid, nullid)
370 if isoldellipses:
370 if isoldellipses:
371 with wrappedextraprepare:
371 with wrappedextraprepare:
372 exchange.pull(repo, remote, heads=common)
372 exchange.pull(repo, remote, heads=common)
373 else:
373 else:
374 known = []
374 known = []
375 if ellipsesremote:
375 if ellipsesremote:
376 known = [
376 known = [
377 ctx.node()
377 ctx.node()
378 for ctx in repo.set(b'::%ln', common)
378 for ctx in repo.set(b'::%ln', common)
379 if ctx.node() != nullid
379 if ctx.node() != nullid
380 ]
380 ]
381 with remote.commandexecutor() as e:
381 with remote.commandexecutor() as e:
382 bundle = e.callcommand(
382 bundle = e.callcommand(
383 b'narrow_widen',
383 b'narrow_widen',
384 {
384 {
385 b'oldincludes': oldincludes,
385 b'oldincludes': oldincludes,
386 b'oldexcludes': oldexcludes,
386 b'oldexcludes': oldexcludes,
387 b'newincludes': newincludes,
387 b'newincludes': newincludes,
388 b'newexcludes': newexcludes,
388 b'newexcludes': newexcludes,
389 b'cgversion': b'03',
389 b'cgversion': b'03',
390 b'commonheads': common,
390 b'commonheads': common,
391 b'known': known,
391 b'known': known,
392 b'ellipses': ellipsesremote,
392 b'ellipses': ellipsesremote,
393 },
393 },
394 ).result()
394 ).result()
395
395
396 trmanager = exchange.transactionmanager(
396 trmanager = exchange.transactionmanager(
397 repo, b'widen', remote.url()
397 repo, b'widen', remote.url()
398 )
398 )
399 with trmanager, repo.ui.configoverride(overrides, b'widen'):
399 with trmanager, repo.ui.configoverride(overrides, b'widen'):
400 op = bundle2.bundleoperation(
400 op = bundle2.bundleoperation(
401 repo, trmanager.transaction, source=b'widen'
401 repo, trmanager.transaction, source=b'widen'
402 )
402 )
403 # TODO: we should catch error.Abort here
403 # TODO: we should catch error.Abort here
404 bundle2.processbundle(repo, bundle, op=op)
404 bundle2.processbundle(repo, bundle, op=op)
405
405
406 if ellipsesremote:
406 if ellipsesremote:
407 with ds.parentchange():
407 with ds.parentchange():
408 ds.setparents(p1, p2)
408 ds.setparents(p1, p2)
409
409
410 with repo.transaction(b'widening'):
410 with repo.transaction(b'widening'):
411 repo.setnewnarrowpats()
411 repo.setnewnarrowpats()
412 narrowspec.updateworkingcopy(repo)
412 narrowspec.updateworkingcopy(repo)
413 narrowspec.copytoworkingcopy(repo)
413 narrowspec.copytoworkingcopy(repo)
414
414
415
415
416 # TODO(rdamazio): Make new matcher format and update description
416 # TODO(rdamazio): Make new matcher format and update description
417 @command(
417 @command(
418 b'tracked',
418 b'tracked',
419 [
419 [
420 (b'', b'addinclude', [], _(b'new paths to include')),
420 (b'', b'addinclude', [], _(b'new paths to include')),
421 (b'', b'removeinclude', [], _(b'old paths to no longer include')),
421 (b'', b'removeinclude', [], _(b'old paths to no longer include')),
422 (
422 (
423 b'',
423 b'',
424 b'auto-remove-includes',
424 b'auto-remove-includes',
425 False,
425 False,
426 _(b'automatically choose unused includes to remove'),
426 _(b'automatically choose unused includes to remove'),
427 ),
427 ),
428 (b'', b'addexclude', [], _(b'new paths to exclude')),
428 (b'', b'addexclude', [], _(b'new paths to exclude')),
429 (b'', b'import-rules', b'', _(b'import narrowspecs from a file')),
429 (b'', b'import-rules', b'', _(b'import narrowspecs from a file')),
430 (b'', b'removeexclude', [], _(b'old paths to no longer exclude')),
430 (b'', b'removeexclude', [], _(b'old paths to no longer exclude')),
431 (
431 (
432 b'',
432 b'',
433 b'clear',
433 b'clear',
434 False,
434 False,
435 _(b'whether to replace the existing narrowspec'),
435 _(b'whether to replace the existing narrowspec'),
436 ),
436 ),
437 (
437 (
438 b'',
438 b'',
439 b'force-delete-local-changes',
439 b'force-delete-local-changes',
440 False,
440 False,
441 _(b'forces deletion of local changes when narrowing'),
441 _(b'forces deletion of local changes when narrowing'),
442 ),
442 ),
443 (
443 (
444 b'',
444 b'',
445 b'update-working-copy',
445 b'update-working-copy',
446 False,
446 False,
447 _(b'update working copy when the store has changed'),
447 _(b'update working copy when the store has changed'),
448 ),
448 ),
449 ]
449 ]
450 + commands.remoteopts,
450 + commands.remoteopts,
451 _(b'[OPTIONS]... [REMOTE]'),
451 _(b'[OPTIONS]... [REMOTE]'),
452 inferrepo=True,
452 inferrepo=True,
453 helpcategory=command.CATEGORY_MAINTENANCE,
453 helpcategory=command.CATEGORY_MAINTENANCE,
454 )
454 )
455 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
455 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
456 """show or change the current narrowspec
456 """show or change the current narrowspec
457
457
458 With no argument, shows the current narrowspec entries, one per line. Each
458 With no argument, shows the current narrowspec entries, one per line. Each
459 line will be prefixed with 'I' or 'X' for included or excluded patterns,
459 line will be prefixed with 'I' or 'X' for included or excluded patterns,
460 respectively.
460 respectively.
461
461
462 The narrowspec is comprised of expressions to match remote files and/or
462 The narrowspec is comprised of expressions to match remote files and/or
463 directories that should be pulled into your client.
463 directories that should be pulled into your client.
464 The narrowspec has *include* and *exclude* expressions, with excludes always
464 The narrowspec has *include* and *exclude* expressions, with excludes always
465 trumping includes: that is, if a file matches an exclude expression, it will
465 trumping includes: that is, if a file matches an exclude expression, it will
466 be excluded even if it also matches an include expression.
466 be excluded even if it also matches an include expression.
467 Excluding files that were never included has no effect.
467 Excluding files that were never included has no effect.
468
468
469 Each included or excluded entry is in the format described by
469 Each included or excluded entry is in the format described by
470 'hg help patterns'.
470 'hg help patterns'.
471
471
472 The options allow you to add or remove included and excluded expressions.
472 The options allow you to add or remove included and excluded expressions.
473
473
474 If --clear is specified, then all previous includes and excludes are DROPPED
474 If --clear is specified, then all previous includes and excludes are DROPPED
475 and replaced by the new ones specified to --addinclude and --addexclude.
475 and replaced by the new ones specified to --addinclude and --addexclude.
476 If --clear is specified without any further options, the narrowspec will be
476 If --clear is specified without any further options, the narrowspec will be
477 empty and will not match any files.
477 empty and will not match any files.
478
478
479 If --auto-remove-includes is specified, then those includes that don't match
479 If --auto-remove-includes is specified, then those includes that don't match
480 any files modified by currently visible local commits (those not shared by
480 any files modified by currently visible local commits (those not shared by
481 the remote) will be added to the set of explicitly specified includes to
481 the remote) will be added to the set of explicitly specified includes to
482 remove.
482 remove.
483
483
484 --import-rules accepts a path to a file containing rules, allowing you to
484 --import-rules accepts a path to a file containing rules, allowing you to
485 add --addinclude, --addexclude rules in bulk. Like the other include and
485 add --addinclude, --addexclude rules in bulk. Like the other include and
486 exclude switches, the changes are applied immediately.
486 exclude switches, the changes are applied immediately.
487 """
487 """
488 opts = pycompat.byteskwargs(opts)
488 opts = pycompat.byteskwargs(opts)
489 if requirements.NARROW_REQUIREMENT not in repo.requirements:
489 if requirements.NARROW_REQUIREMENT not in repo.requirements:
490 raise error.Abort(
490 raise error.InputError(
491 _(
491 _(
492 b'the tracked command is only supported on '
492 b'the tracked command is only supported on '
493 b'repositories cloned with --narrow'
493 b'repositories cloned with --narrow'
494 )
494 )
495 )
495 )
496
496
497 # Before supporting, decide whether it "hg tracked --clear" should mean
497 # Before supporting, decide whether it "hg tracked --clear" should mean
498 # tracking no paths or all paths.
498 # tracking no paths or all paths.
499 if opts[b'clear']:
499 if opts[b'clear']:
500 raise error.Abort(_(b'the --clear option is not yet supported'))
500 raise error.InputError(_(b'the --clear option is not yet supported'))
501
501
502 # import rules from a file
502 # import rules from a file
503 newrules = opts.get(b'import_rules')
503 newrules = opts.get(b'import_rules')
504 if newrules:
504 if newrules:
505 try:
505 try:
506 filepath = os.path.join(encoding.getcwd(), newrules)
506 filepath = os.path.join(encoding.getcwd(), newrules)
507 fdata = util.readfile(filepath)
507 fdata = util.readfile(filepath)
508 except IOError as inst:
508 except IOError as inst:
509 raise error.Abort(
509 raise error.StorageError(
510 _(b"cannot read narrowspecs from '%s': %s")
510 _(b"cannot read narrowspecs from '%s': %s")
511 % (filepath, encoding.strtolocal(inst.strerror))
511 % (filepath, encoding.strtolocal(inst.strerror))
512 )
512 )
513 includepats, excludepats, profiles = sparse.parseconfig(
513 includepats, excludepats, profiles = sparse.parseconfig(
514 ui, fdata, b'narrow'
514 ui, fdata, b'narrow'
515 )
515 )
516 if profiles:
516 if profiles:
517 raise error.Abort(
517 raise error.InputError(
518 _(
518 _(
519 b"including other spec files using '%include' "
519 b"including other spec files using '%include' "
520 b"is not supported in narrowspec"
520 b"is not supported in narrowspec"
521 )
521 )
522 )
522 )
523 opts[b'addinclude'].extend(includepats)
523 opts[b'addinclude'].extend(includepats)
524 opts[b'addexclude'].extend(excludepats)
524 opts[b'addexclude'].extend(excludepats)
525
525
526 addedincludes = narrowspec.parsepatterns(opts[b'addinclude'])
526 addedincludes = narrowspec.parsepatterns(opts[b'addinclude'])
527 removedincludes = narrowspec.parsepatterns(opts[b'removeinclude'])
527 removedincludes = narrowspec.parsepatterns(opts[b'removeinclude'])
528 addedexcludes = narrowspec.parsepatterns(opts[b'addexclude'])
528 addedexcludes = narrowspec.parsepatterns(opts[b'addexclude'])
529 removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude'])
529 removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude'])
530 autoremoveincludes = opts[b'auto_remove_includes']
530 autoremoveincludes = opts[b'auto_remove_includes']
531
531
532 update_working_copy = opts[b'update_working_copy']
532 update_working_copy = opts[b'update_working_copy']
533 only_show = not (
533 only_show = not (
534 addedincludes
534 addedincludes
535 or removedincludes
535 or removedincludes
536 or addedexcludes
536 or addedexcludes
537 or removedexcludes
537 or removedexcludes
538 or newrules
538 or newrules
539 or autoremoveincludes
539 or autoremoveincludes
540 or update_working_copy
540 or update_working_copy
541 )
541 )
542
542
543 oldincludes, oldexcludes = repo.narrowpats
543 oldincludes, oldexcludes = repo.narrowpats
544
544
545 # filter the user passed additions and deletions into actual additions and
545 # filter the user passed additions and deletions into actual additions and
546 # deletions of excludes and includes
546 # deletions of excludes and includes
547 addedincludes -= oldincludes
547 addedincludes -= oldincludes
548 removedincludes &= oldincludes
548 removedincludes &= oldincludes
549 addedexcludes -= oldexcludes
549 addedexcludes -= oldexcludes
550 removedexcludes &= oldexcludes
550 removedexcludes &= oldexcludes
551
551
552 widening = addedincludes or removedexcludes
552 widening = addedincludes or removedexcludes
553 narrowing = removedincludes or addedexcludes
553 narrowing = removedincludes or addedexcludes
554
554
555 # Only print the current narrowspec.
555 # Only print the current narrowspec.
556 if only_show:
556 if only_show:
557 ui.pager(b'tracked')
557 ui.pager(b'tracked')
558 fm = ui.formatter(b'narrow', opts)
558 fm = ui.formatter(b'narrow', opts)
559 for i in sorted(oldincludes):
559 for i in sorted(oldincludes):
560 fm.startitem()
560 fm.startitem()
561 fm.write(b'status', b'%s ', b'I', label=b'narrow.included')
561 fm.write(b'status', b'%s ', b'I', label=b'narrow.included')
562 fm.write(b'pat', b'%s\n', i, label=b'narrow.included')
562 fm.write(b'pat', b'%s\n', i, label=b'narrow.included')
563 for i in sorted(oldexcludes):
563 for i in sorted(oldexcludes):
564 fm.startitem()
564 fm.startitem()
565 fm.write(b'status', b'%s ', b'X', label=b'narrow.excluded')
565 fm.write(b'status', b'%s ', b'X', label=b'narrow.excluded')
566 fm.write(b'pat', b'%s\n', i, label=b'narrow.excluded')
566 fm.write(b'pat', b'%s\n', i, label=b'narrow.excluded')
567 fm.end()
567 fm.end()
568 return 0
568 return 0
569
569
570 if update_working_copy:
570 if update_working_copy:
571 with repo.wlock(), repo.lock(), repo.transaction(b'narrow-wc'):
571 with repo.wlock(), repo.lock(), repo.transaction(b'narrow-wc'):
572 narrowspec.updateworkingcopy(repo)
572 narrowspec.updateworkingcopy(repo)
573 narrowspec.copytoworkingcopy(repo)
573 narrowspec.copytoworkingcopy(repo)
574 return 0
574 return 0
575
575
576 if not (widening or narrowing or autoremoveincludes):
576 if not (widening or narrowing or autoremoveincludes):
577 ui.status(_(b"nothing to widen or narrow\n"))
577 ui.status(_(b"nothing to widen or narrow\n"))
578 return 0
578 return 0
579
579
580 with repo.wlock(), repo.lock():
580 with repo.wlock(), repo.lock():
581 cmdutil.bailifchanged(repo)
581 cmdutil.bailifchanged(repo)
582
582
583 # Find the revisions we have in common with the remote. These will
583 # Find the revisions we have in common with the remote. These will
584 # be used for finding local-only changes for narrowing. They will
584 # be used for finding local-only changes for narrowing. They will
585 # also define the set of revisions to update for widening.
585 # also define the set of revisions to update for widening.
586 remotepath = ui.expandpath(remotepath or b'default')
586 remotepath = ui.expandpath(remotepath or b'default')
587 url, branches = hg.parseurl(remotepath)
587 url, branches = hg.parseurl(remotepath)
588 ui.status(_(b'comparing with %s\n') % util.hidepassword(url))
588 ui.status(_(b'comparing with %s\n') % util.hidepassword(url))
589 remote = hg.peer(repo, opts, url)
589 remote = hg.peer(repo, opts, url)
590
590
591 # check narrow support before doing anything if widening needs to be
591 # check narrow support before doing anything if widening needs to be
592 # performed. In future we should also abort if client is ellipses and
592 # performed. In future we should also abort if client is ellipses and
593 # server does not support ellipses
593 # server does not support ellipses
594 if widening and wireprototypes.NARROWCAP not in remote.capabilities():
594 if widening and wireprototypes.NARROWCAP not in remote.capabilities():
595 raise error.Abort(_(b"server does not support narrow clones"))
595 raise error.Abort(_(b"server does not support narrow clones"))
596
596
597 commoninc = discovery.findcommonincoming(repo, remote)
597 commoninc = discovery.findcommonincoming(repo, remote)
598
598
599 if autoremoveincludes:
599 if autoremoveincludes:
600 outgoing = discovery.findcommonoutgoing(
600 outgoing = discovery.findcommonoutgoing(
601 repo, remote, commoninc=commoninc
601 repo, remote, commoninc=commoninc
602 )
602 )
603 ui.status(_(b'looking for unused includes to remove\n'))
603 ui.status(_(b'looking for unused includes to remove\n'))
604 localfiles = set()
604 localfiles = set()
605 for n in itertools.chain(outgoing.missing, outgoing.excluded):
605 for n in itertools.chain(outgoing.missing, outgoing.excluded):
606 localfiles.update(repo[n].files())
606 localfiles.update(repo[n].files())
607 suggestedremovals = []
607 suggestedremovals = []
608 for include in sorted(oldincludes):
608 for include in sorted(oldincludes):
609 match = narrowspec.match(repo.root, [include], oldexcludes)
609 match = narrowspec.match(repo.root, [include], oldexcludes)
610 if not any(match(f) for f in localfiles):
610 if not any(match(f) for f in localfiles):
611 suggestedremovals.append(include)
611 suggestedremovals.append(include)
612 if suggestedremovals:
612 if suggestedremovals:
613 for s in suggestedremovals:
613 for s in suggestedremovals:
614 ui.status(b'%s\n' % s)
614 ui.status(b'%s\n' % s)
615 if (
615 if (
616 ui.promptchoice(
616 ui.promptchoice(
617 _(
617 _(
618 b'remove these unused includes (yn)?'
618 b'remove these unused includes (yn)?'
619 b'$$ &Yes $$ &No'
619 b'$$ &Yes $$ &No'
620 )
620 )
621 )
621 )
622 == 0
622 == 0
623 ):
623 ):
624 removedincludes.update(suggestedremovals)
624 removedincludes.update(suggestedremovals)
625 narrowing = True
625 narrowing = True
626 else:
626 else:
627 ui.status(_(b'found no unused includes\n'))
627 ui.status(_(b'found no unused includes\n'))
628
628
629 if narrowing:
629 if narrowing:
630 newincludes = oldincludes - removedincludes
630 newincludes = oldincludes - removedincludes
631 newexcludes = oldexcludes | addedexcludes
631 newexcludes = oldexcludes | addedexcludes
632 _narrow(
632 _narrow(
633 ui,
633 ui,
634 repo,
634 repo,
635 remote,
635 remote,
636 commoninc,
636 commoninc,
637 oldincludes,
637 oldincludes,
638 oldexcludes,
638 oldexcludes,
639 newincludes,
639 newincludes,
640 newexcludes,
640 newexcludes,
641 opts[b'force_delete_local_changes'],
641 opts[b'force_delete_local_changes'],
642 )
642 )
643 # _narrow() updated the narrowspec and _widen() below needs to
643 # _narrow() updated the narrowspec and _widen() below needs to
644 # use the updated values as its base (otherwise removed includes
644 # use the updated values as its base (otherwise removed includes
645 # and addedexcludes will be lost in the resulting narrowspec)
645 # and addedexcludes will be lost in the resulting narrowspec)
646 oldincludes = newincludes
646 oldincludes = newincludes
647 oldexcludes = newexcludes
647 oldexcludes = newexcludes
648
648
649 if widening:
649 if widening:
650 newincludes = oldincludes | addedincludes
650 newincludes = oldincludes | addedincludes
651 newexcludes = oldexcludes - removedexcludes
651 newexcludes = oldexcludes - removedexcludes
652 _widen(
652 _widen(
653 ui,
653 ui,
654 repo,
654 repo,
655 remote,
655 remote,
656 commoninc,
656 commoninc,
657 oldincludes,
657 oldincludes,
658 oldexcludes,
658 oldexcludes,
659 newincludes,
659 newincludes,
660 newexcludes,
660 newexcludes,
661 )
661 )
662
662
663 return 0
663 return 0
@@ -1,162 +1,162
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 sparserevlog
30 sparserevlog
31 store
31 store
32 testonly-simplestore (reposimplestore !)
32 testonly-simplestore (reposimplestore !)
33
33
34 $ hg tracked
34 $ hg tracked
35 I path:dir/src/f10
35 I path:dir/src/f10
36 $ hg update
36 $ hg update
37 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 $ find * | sort
38 $ find * | sort
39 dir
39 dir
40 dir/src
40 dir/src
41 dir/src/f10
41 dir/src/f10
42 $ cat dir/src/f10
42 $ cat dir/src/f10
43 10
43 10
44
44
45 $ cd ..
45 $ cd ..
46
46
47 narrow clone a directory, tests/, except tests/t19
47 narrow clone a directory, tests/, except tests/t19
48
48
49 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
49 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
50 requesting all changes
50 requesting all changes
51 adding changesets
51 adding changesets
52 adding manifests
52 adding manifests
53 adding file changes
53 adding file changes
54 added 40 changesets with 19 changes to 19 files
54 added 40 changesets with 19 changes to 19 files
55 new changesets *:* (glob)
55 new changesets *:* (glob)
56 $ cd narrowdir
56 $ cd narrowdir
57 $ hg tracked
57 $ hg tracked
58 I path:dir/tests
58 I path:dir/tests
59 X path:dir/tests/t19
59 X path:dir/tests/t19
60 $ hg update
60 $ hg update
61 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 $ find * | sort
62 $ find * | sort
63 dir
63 dir
64 dir/tests
64 dir/tests
65 dir/tests/t1
65 dir/tests/t1
66 dir/tests/t10
66 dir/tests/t10
67 dir/tests/t11
67 dir/tests/t11
68 dir/tests/t12
68 dir/tests/t12
69 dir/tests/t13
69 dir/tests/t13
70 dir/tests/t14
70 dir/tests/t14
71 dir/tests/t15
71 dir/tests/t15
72 dir/tests/t16
72 dir/tests/t16
73 dir/tests/t17
73 dir/tests/t17
74 dir/tests/t18
74 dir/tests/t18
75 dir/tests/t2
75 dir/tests/t2
76 dir/tests/t20
76 dir/tests/t20
77 dir/tests/t3
77 dir/tests/t3
78 dir/tests/t4
78 dir/tests/t4
79 dir/tests/t5
79 dir/tests/t5
80 dir/tests/t6
80 dir/tests/t6
81 dir/tests/t7
81 dir/tests/t7
82 dir/tests/t8
82 dir/tests/t8
83 dir/tests/t9
83 dir/tests/t9
84
84
85 $ cd ..
85 $ cd ..
86
86
87 narrow clone everything but a directory (tests/)
87 narrow clone everything but a directory (tests/)
88
88
89 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
89 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
90 requesting all changes
90 requesting all changes
91 adding changesets
91 adding changesets
92 adding manifests
92 adding manifests
93 adding file changes
93 adding file changes
94 added 40 changesets with 20 changes to 20 files
94 added 40 changesets with 20 changes to 20 files
95 new changesets *:* (glob)
95 new changesets *:* (glob)
96 $ cd narrowroot
96 $ cd narrowroot
97 $ hg tracked
97 $ hg tracked
98 I path:.
98 I path:.
99 X path:dir/tests
99 X path:dir/tests
100 $ hg update
100 $ hg update
101 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 $ find * | sort
102 $ find * | sort
103 dir
103 dir
104 dir/src
104 dir/src
105 dir/src/f1
105 dir/src/f1
106 dir/src/f10
106 dir/src/f10
107 dir/src/f11
107 dir/src/f11
108 dir/src/f12
108 dir/src/f12
109 dir/src/f13
109 dir/src/f13
110 dir/src/f14
110 dir/src/f14
111 dir/src/f15
111 dir/src/f15
112 dir/src/f16
112 dir/src/f16
113 dir/src/f17
113 dir/src/f17
114 dir/src/f18
114 dir/src/f18
115 dir/src/f19
115 dir/src/f19
116 dir/src/f2
116 dir/src/f2
117 dir/src/f20
117 dir/src/f20
118 dir/src/f3
118 dir/src/f3
119 dir/src/f4
119 dir/src/f4
120 dir/src/f5
120 dir/src/f5
121 dir/src/f6
121 dir/src/f6
122 dir/src/f7
122 dir/src/f7
123 dir/src/f8
123 dir/src/f8
124 dir/src/f9
124 dir/src/f9
125
125
126 $ cd ..
126 $ cd ..
127
127
128 Testing the --narrowspec flag to clone
128 Testing the --narrowspec flag to clone
129
129
130 $ cat >> narrowspecs <<EOF
130 $ cat >> narrowspecs <<EOF
131 > %include foo
131 > %include foo
132 > [include]
132 > [include]
133 > path:dir/tests/
133 > path:dir/tests/
134 > path:dir/src/f12
134 > path:dir/src/f12
135 > EOF
135 > EOF
136
136
137 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
137 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
138 reading narrowspec from '$TESTTMP/narrowspecs'
138 reading narrowspec from '$TESTTMP/narrowspecs'
139 abort: cannot specify other files using '%include' in narrowspec
139 config error: cannot specify other files using '%include' in narrowspec
140 [255]
140 [30]
141
141
142 $ cat > narrowspecs <<EOF
142 $ cat > narrowspecs <<EOF
143 > [include]
143 > [include]
144 > path:dir/tests/
144 > path:dir/tests/
145 > path:dir/src/f12
145 > path:dir/src/f12
146 > EOF
146 > EOF
147
147
148 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
148 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
149 reading narrowspec from '$TESTTMP/narrowspecs'
149 reading narrowspec from '$TESTTMP/narrowspecs'
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 40 changesets with 21 changes to 21 files
154 added 40 changesets with 21 changes to 21 files
155 new changesets 681085829a73:26ce255d5b5d
155 new changesets 681085829a73:26ce255d5b5d
156 updating to branch default
156 updating to branch default
157 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 $ cd specfile
158 $ cd specfile
159 $ hg tracked
159 $ hg tracked
160 I path:dir/src/f12
160 I path:dir/src/f12
161 I path:dir/tests
161 I path:dir/tests
162 $ cd ..
162 $ cd ..
@@ -1,293 +1,293
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 Only path: and rootfilesin: pattern prefixes are allowed
19 Only path: and rootfilesin: pattern prefixes are allowed
20
20
21 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**'
21 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**'
22 abort: invalid prefix on narrow pattern: glob:**
22 abort: invalid prefix on narrow pattern: glob:**
23 (narrow patterns must begin with one of the following: path:, rootfilesin:)
23 (narrow patterns must begin with one of the following: path:, rootfilesin:)
24 [255]
24 [255]
25
25
26 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored'
26 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored'
27 abort: invalid prefix on narrow pattern: set:ignored
27 abort: invalid prefix on narrow pattern: set:ignored
28 (narrow patterns must begin with one of the following: path:, rootfilesin:)
28 (narrow patterns must begin with one of the following: path:, rootfilesin:)
29 [255]
29 [255]
30
30
31 narrow clone a file, f10
31 narrow clone a file, f10
32
32
33 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
33 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
34 requesting all changes
34 requesting all changes
35 adding changesets
35 adding changesets
36 adding manifests
36 adding manifests
37 adding file changes
37 adding file changes
38 added 3 changesets with 1 changes to 1 files
38 added 3 changesets with 1 changes to 1 files
39 new changesets *:* (glob)
39 new changesets *:* (glob)
40 $ cd narrow
40 $ cd narrow
41 $ cat .hg/requires | grep -v generaldelta
41 $ cat .hg/requires | grep -v generaldelta
42 dotencode
42 dotencode
43 fncache
43 fncache
44 narrowhg-experimental
44 narrowhg-experimental
45 revlogv1
45 revlogv1
46 sparserevlog
46 sparserevlog
47 store
47 store
48 testonly-simplestore (reposimplestore !)
48 testonly-simplestore (reposimplestore !)
49
49
50 $ hg tracked
50 $ hg tracked
51 I path:dir/src/f10
51 I path:dir/src/f10
52 $ hg tracked
52 $ hg tracked
53 I path:dir/src/f10
53 I path:dir/src/f10
54 $ hg update
54 $ hg update
55 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
56 $ find * | sort
56 $ find * | sort
57 dir
57 dir
58 dir/src
58 dir/src
59 dir/src/f10
59 dir/src/f10
60 $ cat dir/src/f10
60 $ cat dir/src/f10
61 10
61 10
62
62
63 $ cd ..
63 $ cd ..
64
64
65 BUG: local-to-local narrow clones should work, but don't.
65 BUG: local-to-local narrow clones should work, but don't.
66
66
67 $ hg clone --narrow master narrow-via-localpeer --noupdate --include "dir/src/f10"
67 $ hg clone --narrow master narrow-via-localpeer --noupdate --include "dir/src/f10"
68 requesting all changes
68 requesting all changes
69 abort: server does not support narrow clones
69 abort: server does not support narrow clones
70 [255]
70 [255]
71 $ hg tracked -R narrow-via-localpeer
71 $ hg tracked -R narrow-via-localpeer
72 abort: repository narrow-via-localpeer not found
72 abort: repository narrow-via-localpeer not found
73 [255]
73 [255]
74 $ rm -Rf narrow-via-localpeer
74 $ rm -Rf narrow-via-localpeer
75
75
76 narrow clone with a newline should fail
76 narrow clone with a newline should fail
77
77
78 $ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
78 $ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
79 > '
79 > '
80 abort: newlines are not allowed in narrowspec paths
80 abort: newlines are not allowed in narrowspec paths
81 [255]
81 [255]
82
82
83 narrow clone a directory, tests/, except tests/t19
83 narrow clone a directory, tests/, except tests/t19
84
84
85 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
85 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
86 requesting all changes
86 requesting all changes
87 adding changesets
87 adding changesets
88 adding manifests
88 adding manifests
89 adding file changes
89 adding file changes
90 added 21 changesets with 19 changes to 19 files
90 added 21 changesets with 19 changes to 19 files
91 new changesets *:* (glob)
91 new changesets *:* (glob)
92 $ cd narrowdir
92 $ cd narrowdir
93 $ hg tracked
93 $ hg tracked
94 I path:dir/tests
94 I path:dir/tests
95 X path:dir/tests/t19
95 X path:dir/tests/t19
96 $ hg tracked
96 $ hg tracked
97 I path:dir/tests
97 I path:dir/tests
98 X path:dir/tests/t19
98 X path:dir/tests/t19
99 $ hg update
99 $ hg update
100 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 $ find * | sort
101 $ find * | sort
102 dir
102 dir
103 dir/tests
103 dir/tests
104 dir/tests/t1
104 dir/tests/t1
105 dir/tests/t10
105 dir/tests/t10
106 dir/tests/t11
106 dir/tests/t11
107 dir/tests/t12
107 dir/tests/t12
108 dir/tests/t13
108 dir/tests/t13
109 dir/tests/t14
109 dir/tests/t14
110 dir/tests/t15
110 dir/tests/t15
111 dir/tests/t16
111 dir/tests/t16
112 dir/tests/t17
112 dir/tests/t17
113 dir/tests/t18
113 dir/tests/t18
114 dir/tests/t2
114 dir/tests/t2
115 dir/tests/t20
115 dir/tests/t20
116 dir/tests/t3
116 dir/tests/t3
117 dir/tests/t4
117 dir/tests/t4
118 dir/tests/t5
118 dir/tests/t5
119 dir/tests/t6
119 dir/tests/t6
120 dir/tests/t7
120 dir/tests/t7
121 dir/tests/t8
121 dir/tests/t8
122 dir/tests/t9
122 dir/tests/t9
123
123
124 $ cd ..
124 $ cd ..
125
125
126 narrow clone everything but a directory (tests/)
126 narrow clone everything but a directory (tests/)
127
127
128 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
128 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
129 requesting all changes
129 requesting all changes
130 adding changesets
130 adding changesets
131 adding manifests
131 adding manifests
132 adding file changes
132 adding file changes
133 added 21 changesets with 20 changes to 20 files
133 added 21 changesets with 20 changes to 20 files
134 new changesets *:* (glob)
134 new changesets *:* (glob)
135 $ cd narrowroot
135 $ cd narrowroot
136 $ hg tracked
136 $ hg tracked
137 I path:.
137 I path:.
138 X path:dir/tests
138 X path:dir/tests
139 $ hg tracked
139 $ hg tracked
140 I path:.
140 I path:.
141 X path:dir/tests
141 X path:dir/tests
142 $ hg update
142 $ hg update
143 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
143 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
144 $ find * | sort
144 $ find * | sort
145 dir
145 dir
146 dir/src
146 dir/src
147 dir/src/f1
147 dir/src/f1
148 dir/src/f10
148 dir/src/f10
149 dir/src/f11
149 dir/src/f11
150 dir/src/f12
150 dir/src/f12
151 dir/src/f13
151 dir/src/f13
152 dir/src/f14
152 dir/src/f14
153 dir/src/f15
153 dir/src/f15
154 dir/src/f16
154 dir/src/f16
155 dir/src/f17
155 dir/src/f17
156 dir/src/f18
156 dir/src/f18
157 dir/src/f19
157 dir/src/f19
158 dir/src/f2
158 dir/src/f2
159 dir/src/f20
159 dir/src/f20
160 dir/src/f3
160 dir/src/f3
161 dir/src/f4
161 dir/src/f4
162 dir/src/f5
162 dir/src/f5
163 dir/src/f6
163 dir/src/f6
164 dir/src/f7
164 dir/src/f7
165 dir/src/f8
165 dir/src/f8
166 dir/src/f9
166 dir/src/f9
167
167
168 $ cd ..
168 $ cd ..
169
169
170 narrow clone no paths at all
170 narrow clone no paths at all
171
171
172 $ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
172 $ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
173 requesting all changes
173 requesting all changes
174 adding changesets
174 adding changesets
175 adding manifests
175 adding manifests
176 adding file changes
176 adding file changes
177 added 1 changesets with 0 changes to 0 files
177 added 1 changesets with 0 changes to 0 files
178 new changesets * (glob)
178 new changesets * (glob)
179 $ cd narrowempty
179 $ cd narrowempty
180 $ hg tracked
180 $ hg tracked
181 $ hg update
181 $ hg update
182 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
182 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
183 $ ls -A
183 $ ls -A
184 .hg
184 .hg
185
185
186 $ cd ..
186 $ cd ..
187
187
188 simple clone
188 simple clone
189 $ hg clone ssh://user@dummy/master simpleclone
189 $ hg clone ssh://user@dummy/master simpleclone
190 requesting all changes
190 requesting all changes
191 adding changesets
191 adding changesets
192 adding manifests
192 adding manifests
193 adding file changes
193 adding file changes
194 added 40 changesets with 40 changes to 40 files
194 added 40 changesets with 40 changes to 40 files
195 new changesets * (glob)
195 new changesets * (glob)
196 updating to branch default
196 updating to branch default
197 40 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 40 files updated, 0 files merged, 0 files removed, 0 files unresolved
198 $ cd simpleclone
198 $ cd simpleclone
199 $ find * | sort
199 $ find * | sort
200 dir
200 dir
201 dir/src
201 dir/src
202 dir/src/f1
202 dir/src/f1
203 dir/src/f10
203 dir/src/f10
204 dir/src/f11
204 dir/src/f11
205 dir/src/f12
205 dir/src/f12
206 dir/src/f13
206 dir/src/f13
207 dir/src/f14
207 dir/src/f14
208 dir/src/f15
208 dir/src/f15
209 dir/src/f16
209 dir/src/f16
210 dir/src/f17
210 dir/src/f17
211 dir/src/f18
211 dir/src/f18
212 dir/src/f19
212 dir/src/f19
213 dir/src/f2
213 dir/src/f2
214 dir/src/f20
214 dir/src/f20
215 dir/src/f3
215 dir/src/f3
216 dir/src/f4
216 dir/src/f4
217 dir/src/f5
217 dir/src/f5
218 dir/src/f6
218 dir/src/f6
219 dir/src/f7
219 dir/src/f7
220 dir/src/f8
220 dir/src/f8
221 dir/src/f9
221 dir/src/f9
222 dir/tests
222 dir/tests
223 dir/tests/t1
223 dir/tests/t1
224 dir/tests/t10
224 dir/tests/t10
225 dir/tests/t11
225 dir/tests/t11
226 dir/tests/t12
226 dir/tests/t12
227 dir/tests/t13
227 dir/tests/t13
228 dir/tests/t14
228 dir/tests/t14
229 dir/tests/t15
229 dir/tests/t15
230 dir/tests/t16
230 dir/tests/t16
231 dir/tests/t17
231 dir/tests/t17
232 dir/tests/t18
232 dir/tests/t18
233 dir/tests/t19
233 dir/tests/t19
234 dir/tests/t2
234 dir/tests/t2
235 dir/tests/t20
235 dir/tests/t20
236 dir/tests/t3
236 dir/tests/t3
237 dir/tests/t4
237 dir/tests/t4
238 dir/tests/t5
238 dir/tests/t5
239 dir/tests/t6
239 dir/tests/t6
240 dir/tests/t7
240 dir/tests/t7
241 dir/tests/t8
241 dir/tests/t8
242 dir/tests/t9
242 dir/tests/t9
243
243
244 $ cd ..
244 $ cd ..
245
245
246 Testing the --narrowspec flag to clone
246 Testing the --narrowspec flag to clone
247
247
248 $ cat >> narrowspecs <<EOF
248 $ cat >> narrowspecs <<EOF
249 > %include foo
249 > %include foo
250 > [include]
250 > [include]
251 > path:dir/tests/
251 > path:dir/tests/
252 > path:dir/src/f12
252 > path:dir/src/f12
253 > EOF
253 > EOF
254
254
255 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
255 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
256 reading narrowspec from '$TESTTMP/narrowspecs'
256 reading narrowspec from '$TESTTMP/narrowspecs'
257 abort: cannot specify other files using '%include' in narrowspec
257 config error: cannot specify other files using '%include' in narrowspec
258 [255]
258 [30]
259
259
260 $ cat > narrowspecs <<EOF
260 $ cat > narrowspecs <<EOF
261 > [include]
261 > [include]
262 > path:dir/tests/
262 > path:dir/tests/
263 > path:dir/src/f12
263 > path:dir/src/f12
264 > EOF
264 > EOF
265
265
266 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
266 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
267 reading narrowspec from '$TESTTMP/narrowspecs'
267 reading narrowspec from '$TESTTMP/narrowspecs'
268 requesting all changes
268 requesting all changes
269 adding changesets
269 adding changesets
270 adding manifests
270 adding manifests
271 adding file changes
271 adding file changes
272 added 23 changesets with 21 changes to 21 files
272 added 23 changesets with 21 changes to 21 files
273 new changesets c13e3773edb4:26ce255d5b5d
273 new changesets c13e3773edb4:26ce255d5b5d
274 updating to branch default
274 updating to branch default
275 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
276 $ cd specfile
276 $ cd specfile
277 $ hg tracked
277 $ hg tracked
278 I path:dir/src/f12
278 I path:dir/src/f12
279 I path:dir/tests
279 I path:dir/tests
280 $ cd ..
280 $ cd ..
281
281
282 Narrow spec with invalid patterns is rejected
282 Narrow spec with invalid patterns is rejected
283
283
284 $ cat > narrowspecs <<EOF
284 $ cat > narrowspecs <<EOF
285 > [include]
285 > [include]
286 > glob:**
286 > glob:**
287 > EOF
287 > EOF
288
288
289 $ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs
289 $ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs
290 reading narrowspec from '$TESTTMP/narrowspecs'
290 reading narrowspec from '$TESTTMP/narrowspecs'
291 abort: invalid prefix on narrow pattern: glob:**
291 abort: invalid prefix on narrow pattern: glob:**
292 (narrow patterns must begin with one of the following: path:, rootfilesin:)
292 (narrow patterns must begin with one of the following: path:, rootfilesin:)
293 [255]
293 [255]
@@ -1,227 +1,227
1 #testcases flat tree
1 #testcases flat tree
2 $ . "$TESTDIR/narrow-library.sh"
2 $ . "$TESTDIR/narrow-library.sh"
3
3
4 #if tree
4 #if tree
5 $ cat << EOF >> $HGRCPATH
5 $ cat << EOF >> $HGRCPATH
6 > [experimental]
6 > [experimental]
7 > treemanifest = 1
7 > treemanifest = 1
8 > EOF
8 > EOF
9 #endif
9 #endif
10
10
11 $ hg init master
11 $ hg init master
12 $ cd master
12 $ cd master
13 $ cat >> .hg/hgrc <<EOF
13 $ cat >> .hg/hgrc <<EOF
14 > [narrow]
14 > [narrow]
15 > serveellipses=True
15 > serveellipses=True
16 > EOF
16 > EOF
17
17
18 $ mkdir inside
18 $ mkdir inside
19 $ echo 'inside' > inside/f
19 $ echo 'inside' > inside/f
20 $ hg add inside/f
20 $ hg add inside/f
21 $ hg commit -m 'add inside'
21 $ hg commit -m 'add inside'
22
22
23 $ mkdir widest
23 $ mkdir widest
24 $ echo 'widest' > widest/f
24 $ echo 'widest' > widest/f
25 $ hg add widest/f
25 $ hg add widest/f
26 $ hg commit -m 'add widest'
26 $ hg commit -m 'add widest'
27
27
28 $ mkdir outside
28 $ mkdir outside
29 $ echo 'outside' > outside/f
29 $ echo 'outside' > outside/f
30 $ hg add outside/f
30 $ hg add outside/f
31 $ hg commit -m 'add outside'
31 $ hg commit -m 'add outside'
32
32
33 $ cd ..
33 $ cd ..
34
34
35 narrow clone the inside file
35 narrow clone the inside file
36
36
37 $ hg clone --narrow ssh://user@dummy/master narrow --include inside
37 $ hg clone --narrow ssh://user@dummy/master narrow --include inside
38 requesting all changes
38 requesting all changes
39 adding changesets
39 adding changesets
40 adding manifests
40 adding manifests
41 adding file changes
41 adding file changes
42 added 2 changesets with 1 changes to 1 files
42 added 2 changesets with 1 changes to 1 files
43 new changesets *:* (glob)
43 new changesets *:* (glob)
44 updating to branch default
44 updating to branch default
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 $ cd narrow
46 $ cd narrow
47 $ hg tracked
47 $ hg tracked
48 I path:inside
48 I path:inside
49 $ ls -A
49 $ ls -A
50 .hg
50 .hg
51 inside
51 inside
52 $ cat inside/f
52 $ cat inside/f
53 inside
53 inside
54 $ cd ..
54 $ cd ..
55
55
56 add more upstream files which we will include in a wider narrow spec
56 add more upstream files which we will include in a wider narrow spec
57
57
58 $ cd master
58 $ cd master
59
59
60 $ mkdir wider
60 $ mkdir wider
61 $ echo 'wider' > wider/f
61 $ echo 'wider' > wider/f
62 $ hg add wider/f
62 $ hg add wider/f
63 $ echo 'widest v2' > widest/f
63 $ echo 'widest v2' > widest/f
64 $ hg commit -m 'add wider, update widest'
64 $ hg commit -m 'add wider, update widest'
65
65
66 $ echo 'widest v3' > widest/f
66 $ echo 'widest v3' > widest/f
67 $ hg commit -m 'update widest v3'
67 $ hg commit -m 'update widest v3'
68
68
69 $ echo 'inside v2' > inside/f
69 $ echo 'inside v2' > inside/f
70 $ hg commit -m 'update inside'
70 $ hg commit -m 'update inside'
71
71
72 $ mkdir outside2
72 $ mkdir outside2
73 $ echo 'outside2' > outside2/f
73 $ echo 'outside2' > outside2/f
74 $ hg add outside2/f
74 $ hg add outside2/f
75 $ hg commit -m 'add outside2'
75 $ hg commit -m 'add outside2'
76
76
77 $ echo 'widest v4' > widest/f
77 $ echo 'widest v4' > widest/f
78 $ hg commit -m 'update widest v4'
78 $ hg commit -m 'update widest v4'
79
79
80 $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n"
80 $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n"
81 7: update widest v4
81 7: update widest v4
82 6: add outside2
82 6: add outside2
83 5: update inside
83 5: update inside
84 4: update widest v3
84 4: update widest v3
85 3: add wider, update widest
85 3: add wider, update widest
86 2: add outside
86 2: add outside
87 1: add widest
87 1: add widest
88 0: add inside
88 0: add inside
89
89
90 $ cd ..
90 $ cd ..
91
91
92 Testing the --import-rules flag of `hg tracked` command
92 Testing the --import-rules flag of `hg tracked` command
93
93
94 $ cd narrow
94 $ cd narrow
95 $ hg tracked --import-rules
95 $ hg tracked --import-rules
96 hg tracked: option --import-rules requires argument
96 hg tracked: option --import-rules requires argument
97 hg tracked [OPTIONS]... [REMOTE]
97 hg tracked [OPTIONS]... [REMOTE]
98
98
99 show or change the current narrowspec
99 show or change the current narrowspec
100
100
101 options ([+] can be repeated):
101 options ([+] can be repeated):
102
102
103 --addinclude VALUE [+] new paths to include
103 --addinclude VALUE [+] new paths to include
104 --removeinclude VALUE [+] old paths to no longer include
104 --removeinclude VALUE [+] old paths to no longer include
105 --auto-remove-includes automatically choose unused includes to
105 --auto-remove-includes automatically choose unused includes to
106 remove
106 remove
107 --addexclude VALUE [+] new paths to exclude
107 --addexclude VALUE [+] new paths to exclude
108 --import-rules VALUE import narrowspecs from a file
108 --import-rules VALUE import narrowspecs from a file
109 --removeexclude VALUE [+] old paths to no longer exclude
109 --removeexclude VALUE [+] old paths to no longer exclude
110 --clear whether to replace the existing narrowspec
110 --clear whether to replace the existing narrowspec
111 --force-delete-local-changes forces deletion of local changes when
111 --force-delete-local-changes forces deletion of local changes when
112 narrowing
112 narrowing
113 --update-working-copy update working copy when the store has
113 --update-working-copy update working copy when the store has
114 changed
114 changed
115 -e --ssh CMD specify ssh command to use
115 -e --ssh CMD specify ssh command to use
116 --remotecmd CMD specify hg command to run on the remote side
116 --remotecmd CMD specify hg command to run on the remote side
117 --insecure do not verify server certificate (ignoring
117 --insecure do not verify server certificate (ignoring
118 web.cacerts config)
118 web.cacerts config)
119
119
120 (use 'hg tracked -h' to show more help)
120 (use 'hg tracked -h' to show more help)
121 [255]
121 [255]
122 $ hg tracked --import-rules doesnotexist
122 $ hg tracked --import-rules doesnotexist
123 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
123 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
124 [255]
124 [50]
125
125
126 $ cat > specs <<EOF
126 $ cat > specs <<EOF
127 > %include foo
127 > %include foo
128 > [include]
128 > [include]
129 > path:widest/
129 > path:widest/
130 > [exclude]
130 > [exclude]
131 > path:inside/
131 > path:inside/
132 > EOF
132 > EOF
133
133
134 $ hg tracked --import-rules specs
134 $ hg tracked --import-rules specs
135 abort: including other spec files using '%include' is not supported in narrowspec
135 abort: including other spec files using '%include' is not supported in narrowspec
136 [255]
136 [10]
137
137
138 $ cat > specs <<EOF
138 $ cat > specs <<EOF
139 > [include]
139 > [include]
140 > outisde
140 > outisde
141 > [exclude]
141 > [exclude]
142 > inside
142 > inside
143 > EOF
143 > EOF
144
144
145 $ hg tracked --import-rules specs
145 $ hg tracked --import-rules specs
146 comparing with ssh://user@dummy/master
146 comparing with ssh://user@dummy/master
147 searching for changes
147 searching for changes
148 looking for local changes to affected paths
148 looking for local changes to affected paths
149 deleting data/inside/f.i
149 deleting data/inside/f.i
150 deleting meta/inside/00manifest.i (tree !)
150 deleting meta/inside/00manifest.i (tree !)
151 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
151 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
152 adding changesets
152 adding changesets
153 adding manifests
153 adding manifests
154 adding file changes
154 adding file changes
155 added 2 changesets with 0 changes to 0 files
155 added 2 changesets with 0 changes to 0 files
156 $ hg tracked
156 $ hg tracked
157 I path:outisde
157 I path:outisde
158 X path:inside
158 X path:inside
159
159
160 Testing the --import-rules flag with --addinclude and --addexclude
160 Testing the --import-rules flag with --addinclude and --addexclude
161
161
162 $ cat > specs <<EOF
162 $ cat > specs <<EOF
163 > [include]
163 > [include]
164 > widest
164 > widest
165 > EOF
165 > EOF
166
166
167 $ hg tracked --import-rules specs --addinclude 'wider/'
167 $ hg tracked --import-rules specs --addinclude 'wider/'
168 comparing with ssh://user@dummy/master
168 comparing with ssh://user@dummy/master
169 searching for changes
169 searching for changes
170 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
170 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
171 adding changesets
171 adding changesets
172 adding manifests
172 adding manifests
173 adding file changes
173 adding file changes
174 added 3 changesets with 1 changes to 1 files
174 added 3 changesets with 1 changes to 1 files
175 $ hg tracked
175 $ hg tracked
176 I path:outisde
176 I path:outisde
177 I path:wider
177 I path:wider
178 I path:widest
178 I path:widest
179 X path:inside
179 X path:inside
180
180
181 $ cat > specs <<EOF
181 $ cat > specs <<EOF
182 > [exclude]
182 > [exclude]
183 > outside2
183 > outside2
184 > EOF
184 > EOF
185
185
186 $ hg tracked --import-rules specs --addexclude 'widest'
186 $ hg tracked --import-rules specs --addexclude 'widest'
187 comparing with ssh://user@dummy/master
187 comparing with ssh://user@dummy/master
188 searching for changes
188 searching for changes
189 looking for local changes to affected paths
189 looking for local changes to affected paths
190 deleting data/widest/f.i
190 deleting data/widest/f.i
191 deleting meta/widest/00manifest.i (tree !)
191 deleting meta/widest/00manifest.i (tree !)
192 $ hg tracked
192 $ hg tracked
193 I path:outisde
193 I path:outisde
194 I path:wider
194 I path:wider
195 X path:inside
195 X path:inside
196 X path:outside2
196 X path:outside2
197 X path:widest
197 X path:widest
198
198
199 $ hg tracked --import-rules specs --clear
199 $ hg tracked --import-rules specs --clear
200 abort: the --clear option is not yet supported
200 abort: the --clear option is not yet supported
201 [255]
201 [10]
202
202
203 Testing with passing a out of wdir file
203 Testing with passing a out of wdir file
204
204
205 $ cat > ../nspecs <<EOF
205 $ cat > ../nspecs <<EOF
206 > [include]
206 > [include]
207 > widest
207 > widest
208 > EOF
208 > EOF
209
209
210 $ hg tracked --import-rules ../nspecs
210 $ hg tracked --import-rules ../nspecs
211 comparing with ssh://user@dummy/master
211 comparing with ssh://user@dummy/master
212 searching for changes
212 searching for changes
213 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
213 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
214 adding changesets
214 adding changesets
215 adding manifests
215 adding manifests
216 adding file changes
216 adding file changes
217 added 3 changesets with 0 changes to 0 files
217 added 3 changesets with 0 changes to 0 files
218
218
219 $ cd ..
219 $ cd ..
220
220
221 Testing tracked command on a non-narrow repo
221 Testing tracked command on a non-narrow repo
222
222
223 $ hg init non-narrow
223 $ hg init non-narrow
224 $ cd non-narrow
224 $ cd non-narrow
225 $ hg tracked --addinclude foobar
225 $ hg tracked --addinclude foobar
226 abort: the tracked command is only supported on repositories cloned with --narrow
226 abort: the tracked command is only supported on repositories cloned with --narrow
227 [255]
227 [10]
@@ -1,494 +1,494
1 #testcases flat tree
1 #testcases flat tree
2 #testcases lfs-on lfs-off
2 #testcases lfs-on lfs-off
3
3
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [experimental]
5 > [experimental]
6 > evolution=createmarkers
6 > evolution=createmarkers
7 > EOF
7 > EOF
8
8
9 #if lfs-on
9 #if lfs-on
10 $ cat >> $HGRCPATH <<EOF
10 $ cat >> $HGRCPATH <<EOF
11 > [extensions]
11 > [extensions]
12 > lfs =
12 > lfs =
13 > EOF
13 > EOF
14 #endif
14 #endif
15
15
16 $ . "$TESTDIR/narrow-library.sh"
16 $ . "$TESTDIR/narrow-library.sh"
17
17
18 #if tree
18 #if tree
19 $ cat << EOF >> $HGRCPATH
19 $ cat << EOF >> $HGRCPATH
20 > [experimental]
20 > [experimental]
21 > treemanifest = 1
21 > treemanifest = 1
22 > EOF
22 > EOF
23 #endif
23 #endif
24
24
25 $ hg init master
25 $ hg init master
26 $ cd master
26 $ cd master
27 $ cat >> .hg/hgrc <<EOF
27 $ cat >> .hg/hgrc <<EOF
28 > [narrow]
28 > [narrow]
29 > serveellipses=True
29 > serveellipses=True
30 > EOF
30 > EOF
31 $ for x in `$TESTDIR/seq.py 0 10`
31 $ for x in `$TESTDIR/seq.py 0 10`
32 > do
32 > do
33 > mkdir d$x
33 > mkdir d$x
34 > echo $x > d$x/f
34 > echo $x > d$x/f
35 > hg add d$x/f
35 > hg add d$x/f
36 > hg commit -m "add d$x/f"
36 > hg commit -m "add d$x/f"
37 > done
37 > done
38 $ hg log -T "{rev}: {desc}\n"
38 $ hg log -T "{rev}: {desc}\n"
39 10: add d10/f
39 10: add d10/f
40 9: add d9/f
40 9: add d9/f
41 8: add d8/f
41 8: add d8/f
42 7: add d7/f
42 7: add d7/f
43 6: add d6/f
43 6: add d6/f
44 5: add d5/f
44 5: add d5/f
45 4: add d4/f
45 4: add d4/f
46 3: add d3/f
46 3: add d3/f
47 2: add d2/f
47 2: add d2/f
48 1: add d1/f
48 1: add d1/f
49 0: add d0/f
49 0: add d0/f
50 $ cd ..
50 $ cd ..
51
51
52 Error if '.' or '..' are in the directory to track.
52 Error if '.' or '..' are in the directory to track.
53 $ hg clone --narrow ssh://user@dummy/master foo --include ./asdf
53 $ hg clone --narrow ssh://user@dummy/master foo --include ./asdf
54 abort: "." and ".." are not allowed in narrowspec paths
54 abort: "." and ".." are not allowed in narrowspec paths
55 [255]
55 [255]
56 $ hg clone --narrow ssh://user@dummy/master foo --include asdf/..
56 $ hg clone --narrow ssh://user@dummy/master foo --include asdf/..
57 abort: "." and ".." are not allowed in narrowspec paths
57 abort: "." and ".." are not allowed in narrowspec paths
58 [255]
58 [255]
59 $ hg clone --narrow ssh://user@dummy/master foo --include a/./c
59 $ hg clone --narrow ssh://user@dummy/master foo --include a/./c
60 abort: "." and ".." are not allowed in narrowspec paths
60 abort: "." and ".." are not allowed in narrowspec paths
61 [255]
61 [255]
62
62
63 Names with '.' in them are OK.
63 Names with '.' in them are OK.
64 $ hg clone --narrow ssh://user@dummy/master should-work --include a/.b/c
64 $ hg clone --narrow ssh://user@dummy/master should-work --include a/.b/c
65 requesting all changes
65 requesting all changes
66 adding changesets
66 adding changesets
67 adding manifests
67 adding manifests
68 adding file changes
68 adding file changes
69 added 1 changesets with 0 changes to 0 files
69 added 1 changesets with 0 changes to 0 files
70 new changesets * (glob)
70 new changesets * (glob)
71 updating to branch default
71 updating to branch default
72 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
73
73
74 Test repo with local changes
74 Test repo with local changes
75 $ hg clone --narrow ssh://user@dummy/master narrow-local-changes --include d0 --include d3 --include d6
75 $ hg clone --narrow ssh://user@dummy/master narrow-local-changes --include d0 --include d3 --include d6
76 requesting all changes
76 requesting all changes
77 adding changesets
77 adding changesets
78 adding manifests
78 adding manifests
79 adding file changes
79 adding file changes
80 added 6 changesets with 3 changes to 3 files
80 added 6 changesets with 3 changes to 3 files
81 new changesets *:* (glob)
81 new changesets *:* (glob)
82 updating to branch default
82 updating to branch default
83 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 $ cd narrow-local-changes
84 $ cd narrow-local-changes
85 $ echo local change >> d0/f
85 $ echo local change >> d0/f
86 $ hg ci -m 'local change to d0'
86 $ hg ci -m 'local change to d0'
87 $ hg co '.^'
87 $ hg co '.^'
88 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
88 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 $ echo local change >> d3/f
89 $ echo local change >> d3/f
90 $ hg ci -m 'local hidden change to d3'
90 $ hg ci -m 'local hidden change to d3'
91 created new head
91 created new head
92 $ hg ci --amend -m 'local change to d3'
92 $ hg ci --amend -m 'local change to d3'
93 $ hg tracked --removeinclude d0
93 $ hg tracked --removeinclude d0
94 comparing with ssh://user@dummy/master
94 comparing with ssh://user@dummy/master
95 searching for changes
95 searching for changes
96 looking for local changes to affected paths
96 looking for local changes to affected paths
97 The following changeset(s) or their ancestors have local changes not on the remote:
97 The following changeset(s) or their ancestors have local changes not on the remote:
98 * (glob)
98 * (glob)
99 abort: local changes found
99 abort: local changes found
100 (use --force-delete-local-changes to ignore)
100 (use --force-delete-local-changes to ignore)
101 [255]
101 [20]
102 Check that nothing was removed by the failed attempts
102 Check that nothing was removed by the failed attempts
103 $ hg tracked
103 $ hg tracked
104 I path:d0
104 I path:d0
105 I path:d3
105 I path:d3
106 I path:d6
106 I path:d6
107 $ hg files
107 $ hg files
108 d0/f
108 d0/f
109 d3/f
109 d3/f
110 d6/f
110 d6/f
111 $ find *
111 $ find *
112 d0
112 d0
113 d0/f
113 d0/f
114 d3
114 d3
115 d3/f
115 d3/f
116 d6
116 d6
117 d6/f
117 d6/f
118 $ hg verify -q
118 $ hg verify -q
119 Force deletion of local changes
119 Force deletion of local changes
120 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
120 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
121 8: local change to d3
121 8: local change to d3
122 6: local change to d0
122 6: local change to d0
123 5: add d10/f outsidenarrow
123 5: add d10/f outsidenarrow
124 4: add d6/f
124 4: add d6/f
125 3: add d5/f outsidenarrow
125 3: add d5/f outsidenarrow
126 2: add d3/f
126 2: add d3/f
127 1: add d2/f outsidenarrow
127 1: add d2/f outsidenarrow
128 0: add d0/f
128 0: add d0/f
129 $ hg tracked --removeinclude d0 --force-delete-local-changes
129 $ hg tracked --removeinclude d0 --force-delete-local-changes
130 comparing with ssh://user@dummy/master
130 comparing with ssh://user@dummy/master
131 searching for changes
131 searching for changes
132 looking for local changes to affected paths
132 looking for local changes to affected paths
133 The following changeset(s) or their ancestors have local changes not on the remote:
133 The following changeset(s) or their ancestors have local changes not on the remote:
134 * (glob)
134 * (glob)
135 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
135 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
136 deleting data/d0/f.i (reporevlogstore !)
136 deleting data/d0/f.i (reporevlogstore !)
137 deleting meta/d0/00manifest.i (tree !)
137 deleting meta/d0/00manifest.i (tree !)
138 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
138 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
139 deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore !)
139 deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore !)
140 deleting data/d0/f/index (reposimplestore !)
140 deleting data/d0/f/index (reposimplestore !)
141
141
142 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
142 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
143 7: local change to d3
143 7: local change to d3
144 5: add d10/f outsidenarrow
144 5: add d10/f outsidenarrow
145 4: add d6/f
145 4: add d6/f
146 3: add d5/f outsidenarrow
146 3: add d5/f outsidenarrow
147 2: add d3/f
147 2: add d3/f
148 1: add d2/f outsidenarrow
148 1: add d2/f outsidenarrow
149 0: add d0/f outsidenarrow
149 0: add d0/f outsidenarrow
150 Can restore stripped local changes after widening
150 Can restore stripped local changes after widening
151 $ hg tracked --addinclude d0 -q
151 $ hg tracked --addinclude d0 -q
152 $ hg unbundle .hg/strip-backup/*-narrow.hg -q
152 $ hg unbundle .hg/strip-backup/*-narrow.hg -q
153 $ hg --hidden co -r 'desc("local change to d0")' -q
153 $ hg --hidden co -r 'desc("local change to d0")' -q
154 $ cat d0/f
154 $ cat d0/f
155 0
155 0
156 local change
156 local change
157 Pruned commits affecting removed paths should not prevent narrowing
157 Pruned commits affecting removed paths should not prevent narrowing
158 $ hg co '.^'
158 $ hg co '.^'
159 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 $ hg debugobsolete `hg log -T '{node}' -r 'desc("local change to d0")'`
160 $ hg debugobsolete `hg log -T '{node}' -r 'desc("local change to d0")'`
161 1 new obsolescence markers
161 1 new obsolescence markers
162 obsoleted 1 changesets
162 obsoleted 1 changesets
163 $ hg tracked --removeinclude d0
163 $ hg tracked --removeinclude d0
164 comparing with ssh://user@dummy/master
164 comparing with ssh://user@dummy/master
165 searching for changes
165 searching for changes
166 looking for local changes to affected paths
166 looking for local changes to affected paths
167 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
167 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
168 deleting data/d0/f.i (reporevlogstore !)
168 deleting data/d0/f.i (reporevlogstore !)
169 deleting meta/d0/00manifest.i (tree !)
169 deleting meta/d0/00manifest.i (tree !)
170 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
170 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
171 deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore !)
171 deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore !)
172 deleting data/d0/f/index (reposimplestore !)
172 deleting data/d0/f/index (reposimplestore !)
173
173
174 Updates off of stripped commit if necessary
174 Updates off of stripped commit if necessary
175 $ hg co -r 'desc("local change to d3")' -q
175 $ hg co -r 'desc("local change to d3")' -q
176 $ echo local change >> d6/f
176 $ echo local change >> d6/f
177 $ hg ci -m 'local change to d6'
177 $ hg ci -m 'local change to d6'
178 $ hg tracked --removeinclude d3 --force-delete-local-changes
178 $ hg tracked --removeinclude d3 --force-delete-local-changes
179 comparing with ssh://user@dummy/master
179 comparing with ssh://user@dummy/master
180 searching for changes
180 searching for changes
181 looking for local changes to affected paths
181 looking for local changes to affected paths
182 The following changeset(s) or their ancestors have local changes not on the remote:
182 The following changeset(s) or their ancestors have local changes not on the remote:
183 * (glob)
183 * (glob)
184 * (glob)
184 * (glob)
185 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
185 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
186 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
186 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
187 deleting data/d3/f.i (reporevlogstore !)
187 deleting data/d3/f.i (reporevlogstore !)
188 deleting meta/d3/00manifest.i (tree !)
188 deleting meta/d3/00manifest.i (tree !)
189 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
189 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
190 deleting data/d3/f/99fa7136105a15e2045ce3d9152e4837c5349e4d (reposimplestore !)
190 deleting data/d3/f/99fa7136105a15e2045ce3d9152e4837c5349e4d (reposimplestore !)
191 deleting data/d3/f/index (reposimplestore !)
191 deleting data/d3/f/index (reposimplestore !)
192 $ hg log -T '{desc}\n' -r .
192 $ hg log -T '{desc}\n' -r .
193 add d10/f
193 add d10/f
194 Updates to nullid if necessary
194 Updates to nullid if necessary
195 $ hg tracked --addinclude d3 -q
195 $ hg tracked --addinclude d3 -q
196 $ hg co null -q
196 $ hg co null -q
197 $ mkdir d3
197 $ mkdir d3
198 $ echo local change > d3/f
198 $ echo local change > d3/f
199 $ hg add d3/f
199 $ hg add d3/f
200 $ hg ci -m 'local change to d3'
200 $ hg ci -m 'local change to d3'
201 created new head
201 created new head
202 $ hg tracked --removeinclude d3 --force-delete-local-changes
202 $ hg tracked --removeinclude d3 --force-delete-local-changes
203 comparing with ssh://user@dummy/master
203 comparing with ssh://user@dummy/master
204 searching for changes
204 searching for changes
205 looking for local changes to affected paths
205 looking for local changes to affected paths
206 The following changeset(s) or their ancestors have local changes not on the remote:
206 The following changeset(s) or their ancestors have local changes not on the remote:
207 * (glob)
207 * (glob)
208 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
208 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
209 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
209 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
210 deleting data/d3/f.i (reporevlogstore !)
210 deleting data/d3/f.i (reporevlogstore !)
211 deleting meta/d3/00manifest.i (tree !)
211 deleting meta/d3/00manifest.i (tree !)
212 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
212 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
213 deleting data/d3/f/5ce0767945cbdbca3b924bb9fbf5143f72ab40ac (reposimplestore !)
213 deleting data/d3/f/5ce0767945cbdbca3b924bb9fbf5143f72ab40ac (reposimplestore !)
214 deleting data/d3/f/index (reposimplestore !)
214 deleting data/d3/f/index (reposimplestore !)
215 $ hg id
215 $ hg id
216 000000000000
216 000000000000
217 $ cd ..
217 $ cd ..
218
218
219 Narrowing doesn't resurrect old commits (unlike what regular `hg strip` does)
219 Narrowing doesn't resurrect old commits (unlike what regular `hg strip` does)
220 $ hg clone --narrow ssh://user@dummy/master narrow-obsmarkers --include d0 --include d3 -q
220 $ hg clone --narrow ssh://user@dummy/master narrow-obsmarkers --include d0 --include d3 -q
221 $ cd narrow-obsmarkers
221 $ cd narrow-obsmarkers
222 $ echo a >> d0/f2
222 $ echo a >> d0/f2
223 $ hg add d0/f2
223 $ hg add d0/f2
224 $ hg ci -m 'modify d0/'
224 $ hg ci -m 'modify d0/'
225 $ echo a >> d3/f2
225 $ echo a >> d3/f2
226 $ hg add d3/f2
226 $ hg add d3/f2
227 $ hg commit --amend -m 'modify d0/ and d3/'
227 $ hg commit --amend -m 'modify d0/ and d3/'
228 $ hg log -T "{rev}: {desc}\n"
228 $ hg log -T "{rev}: {desc}\n"
229 5: modify d0/ and d3/
229 5: modify d0/ and d3/
230 3: add d10/f
230 3: add d10/f
231 2: add d3/f
231 2: add d3/f
232 1: add d2/f
232 1: add d2/f
233 0: add d0/f
233 0: add d0/f
234 $ hg tracked --removeinclude d3 --force-delete-local-changes -q
234 $ hg tracked --removeinclude d3 --force-delete-local-changes -q
235 $ hg log -T "{rev}: {desc}\n"
235 $ hg log -T "{rev}: {desc}\n"
236 3: add d10/f
236 3: add d10/f
237 2: add d3/f
237 2: add d3/f
238 1: add d2/f
238 1: add d2/f
239 0: add d0/f
239 0: add d0/f
240 $ cd ..
240 $ cd ..
241
241
242 Widening doesn't lose bookmarks
242 Widening doesn't lose bookmarks
243 $ hg clone --narrow ssh://user@dummy/master widen-bookmarks --include d0 -q
243 $ hg clone --narrow ssh://user@dummy/master widen-bookmarks --include d0 -q
244 $ cd widen-bookmarks
244 $ cd widen-bookmarks
245 $ hg bookmark my-bookmark
245 $ hg bookmark my-bookmark
246 $ hg log -T "{rev}: {desc} {bookmarks}\n"
246 $ hg log -T "{rev}: {desc} {bookmarks}\n"
247 1: add d10/f my-bookmark
247 1: add d10/f my-bookmark
248 0: add d0/f
248 0: add d0/f
249 $ hg tracked --addinclude d3 -q
249 $ hg tracked --addinclude d3 -q
250 $ hg log -T "{rev}: {desc} {bookmarks}\n"
250 $ hg log -T "{rev}: {desc} {bookmarks}\n"
251 3: add d10/f my-bookmark
251 3: add d10/f my-bookmark
252 2: add d3/f
252 2: add d3/f
253 1: add d2/f
253 1: add d2/f
254 0: add d0/f
254 0: add d0/f
255 $ cd ..
255 $ cd ..
256
256
257 Can remove last include, making repo empty
257 Can remove last include, making repo empty
258 $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5
258 $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5
259 adding changesets
259 adding changesets
260 adding manifests
260 adding manifests
261 adding file changes
261 adding file changes
262 added 2 changesets with 1 changes to 1 files
262 added 2 changesets with 1 changes to 1 files
263 new changesets *:* (glob)
263 new changesets *:* (glob)
264 updating to branch default
264 updating to branch default
265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
266 $ cd narrow-empty
266 $ cd narrow-empty
267 $ hg tracked --removeinclude d0
267 $ hg tracked --removeinclude d0
268 comparing with ssh://user@dummy/master
268 comparing with ssh://user@dummy/master
269 searching for changes
269 searching for changes
270 looking for local changes to affected paths
270 looking for local changes to affected paths
271 deleting data/d0/f.i (reporevlogstore !)
271 deleting data/d0/f.i (reporevlogstore !)
272 deleting meta/d0/00manifest.i (tree !)
272 deleting meta/d0/00manifest.i (tree !)
273 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
273 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
274 deleting data/d0/f/index (reposimplestore !)
274 deleting data/d0/f/index (reposimplestore !)
275 $ hg tracked
275 $ hg tracked
276 $ hg files
276 $ hg files
277 [1]
277 [1]
278 $ test -d d0
278 $ test -d d0
279 [1]
279 [1]
280 Do some work in the empty clone
280 Do some work in the empty clone
281 $ hg diff --change .
281 $ hg diff --change .
282 $ hg branch foo
282 $ hg branch foo
283 marked working directory as branch foo
283 marked working directory as branch foo
284 (branches are permanent and global, did you want a bookmark?)
284 (branches are permanent and global, did you want a bookmark?)
285 $ hg ci -m empty
285 $ hg ci -m empty
286 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
286 $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
287 2: empty
287 2: empty
288 1: add d5/f outsidenarrow
288 1: add d5/f outsidenarrow
289 0: add d0/f outsidenarrow
289 0: add d0/f outsidenarrow
290 $ hg pull -q
290 $ hg pull -q
291 Can widen the empty clone
291 Can widen the empty clone
292 $ hg tracked --addinclude d0
292 $ hg tracked --addinclude d0
293 comparing with ssh://user@dummy/master
293 comparing with ssh://user@dummy/master
294 searching for changes
294 searching for changes
295 saved backup bundle to $TESTTMP/narrow-empty/.hg/strip-backup/*-widen.hg (glob)
295 saved backup bundle to $TESTTMP/narrow-empty/.hg/strip-backup/*-widen.hg (glob)
296 adding changesets
296 adding changesets
297 adding manifests
297 adding manifests
298 adding file changes
298 adding file changes
299 added 3 changesets with 1 changes to 1 files
299 added 3 changesets with 1 changes to 1 files
300 $ hg tracked
300 $ hg tracked
301 I path:d0
301 I path:d0
302 $ hg files
302 $ hg files
303 d0/f
303 d0/f
304 $ find *
304 $ find *
305 d0
305 d0
306 d0/f
306 d0/f
307 $ cd ..
307 $ cd ..
308
308
309 TODO(martinvonz): test including e.g. d3/g and then removing it once
309 TODO(martinvonz): test including e.g. d3/g and then removing it once
310 https://bitbucket.org/Google/narrowhg/issues/6 is fixed
310 https://bitbucket.org/Google/narrowhg/issues/6 is fixed
311
311
312 $ hg clone --narrow ssh://user@dummy/master narrow --include d0 --include d3 --include d6 --include d9
312 $ hg clone --narrow ssh://user@dummy/master narrow --include d0 --include d3 --include d6 --include d9
313 requesting all changes
313 requesting all changes
314 adding changesets
314 adding changesets
315 adding manifests
315 adding manifests
316 adding file changes
316 adding file changes
317 added 8 changesets with 4 changes to 4 files
317 added 8 changesets with 4 changes to 4 files
318 new changesets *:* (glob)
318 new changesets *:* (glob)
319 updating to branch default
319 updating to branch default
320 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
320 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
321 $ cd narrow
321 $ cd narrow
322 $ hg tracked
322 $ hg tracked
323 I path:d0
323 I path:d0
324 I path:d3
324 I path:d3
325 I path:d6
325 I path:d6
326 I path:d9
326 I path:d9
327 $ hg tracked --removeinclude d6
327 $ hg tracked --removeinclude d6
328 comparing with ssh://user@dummy/master
328 comparing with ssh://user@dummy/master
329 searching for changes
329 searching for changes
330 looking for local changes to affected paths
330 looking for local changes to affected paths
331 deleting data/d6/f.i (reporevlogstore !)
331 deleting data/d6/f.i (reporevlogstore !)
332 deleting meta/d6/00manifest.i (tree !)
332 deleting meta/d6/00manifest.i (tree !)
333 deleting data/d6/f/7339d30678f451ac8c3f38753beeb4cf2e1655c7 (reposimplestore !)
333 deleting data/d6/f/7339d30678f451ac8c3f38753beeb4cf2e1655c7 (reposimplestore !)
334 deleting data/d6/f/index (reposimplestore !)
334 deleting data/d6/f/index (reposimplestore !)
335 $ hg tracked
335 $ hg tracked
336 I path:d0
336 I path:d0
337 I path:d3
337 I path:d3
338 I path:d9
338 I path:d9
339 #if repofncache
339 #if repofncache
340 $ hg debugrebuildfncache
340 $ hg debugrebuildfncache
341 fncache already up to date
341 fncache already up to date
342 #endif
342 #endif
343 $ find *
343 $ find *
344 d0
344 d0
345 d0/f
345 d0/f
346 d3
346 d3
347 d3/f
347 d3/f
348 d9
348 d9
349 d9/f
349 d9/f
350 $ hg verify -q
350 $ hg verify -q
351 $ hg tracked --addexclude d3/f
351 $ hg tracked --addexclude d3/f
352 comparing with ssh://user@dummy/master
352 comparing with ssh://user@dummy/master
353 searching for changes
353 searching for changes
354 looking for local changes to affected paths
354 looking for local changes to affected paths
355 deleting data/d3/f.i (reporevlogstore !)
355 deleting data/d3/f.i (reporevlogstore !)
356 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
356 deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore !)
357 deleting data/d3/f/index (reposimplestore !)
357 deleting data/d3/f/index (reposimplestore !)
358 $ hg tracked
358 $ hg tracked
359 I path:d0
359 I path:d0
360 I path:d3
360 I path:d3
361 I path:d9
361 I path:d9
362 X path:d3/f
362 X path:d3/f
363 #if repofncache
363 #if repofncache
364 $ hg debugrebuildfncache
364 $ hg debugrebuildfncache
365 fncache already up to date
365 fncache already up to date
366 #endif
366 #endif
367 $ find *
367 $ find *
368 d0
368 d0
369 d0/f
369 d0/f
370 d9
370 d9
371 d9/f
371 d9/f
372 $ hg verify -q
372 $ hg verify -q
373 $ hg tracked --addexclude d0
373 $ hg tracked --addexclude d0
374 comparing with ssh://user@dummy/master
374 comparing with ssh://user@dummy/master
375 searching for changes
375 searching for changes
376 looking for local changes to affected paths
376 looking for local changes to affected paths
377 deleting data/d0/f.i (reporevlogstore !)
377 deleting data/d0/f.i (reporevlogstore !)
378 deleting meta/d0/00manifest.i (tree !)
378 deleting meta/d0/00manifest.i (tree !)
379 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
379 deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore !)
380 deleting data/d0/f/index (reposimplestore !)
380 deleting data/d0/f/index (reposimplestore !)
381 $ hg tracked
381 $ hg tracked
382 I path:d3
382 I path:d3
383 I path:d9
383 I path:d9
384 X path:d0
384 X path:d0
385 X path:d3/f
385 X path:d3/f
386 #if repofncache
386 #if repofncache
387 $ hg debugrebuildfncache
387 $ hg debugrebuildfncache
388 fncache already up to date
388 fncache already up to date
389 #endif
389 #endif
390 $ find *
390 $ find *
391 d9
391 d9
392 d9/f
392 d9/f
393
393
394 Make a 15 of changes to d9 to test the path without --verbose
394 Make a 15 of changes to d9 to test the path without --verbose
395 (Note: using regexes instead of "* (glob)" because if the test fails, it
395 (Note: using regexes instead of "* (glob)" because if the test fails, it
396 produces more sensible diffs)
396 produces more sensible diffs)
397 $ hg tracked
397 $ hg tracked
398 I path:d3
398 I path:d3
399 I path:d9
399 I path:d9
400 X path:d0
400 X path:d0
401 X path:d3/f
401 X path:d3/f
402 $ for x in `$TESTDIR/seq.py 1 15`
402 $ for x in `$TESTDIR/seq.py 1 15`
403 > do
403 > do
404 > echo local change >> d9/f
404 > echo local change >> d9/f
405 > hg commit -m "change $x to d9/f"
405 > hg commit -m "change $x to d9/f"
406 > done
406 > done
407 $ hg tracked --removeinclude d9
407 $ hg tracked --removeinclude d9
408 comparing with ssh://user@dummy/master
408 comparing with ssh://user@dummy/master
409 searching for changes
409 searching for changes
410 looking for local changes to affected paths
410 looking for local changes to affected paths
411 The following changeset(s) or their ancestors have local changes not on the remote:
411 The following changeset(s) or their ancestors have local changes not on the remote:
412 ^[0-9a-f]{12}$ (re)
412 ^[0-9a-f]{12}$ (re)
413 ^[0-9a-f]{12}$ (re)
413 ^[0-9a-f]{12}$ (re)
414 ^[0-9a-f]{12}$ (re)
414 ^[0-9a-f]{12}$ (re)
415 ^[0-9a-f]{12}$ (re)
415 ^[0-9a-f]{12}$ (re)
416 ^[0-9a-f]{12}$ (re)
416 ^[0-9a-f]{12}$ (re)
417 ^[0-9a-f]{12}$ (re)
417 ^[0-9a-f]{12}$ (re)
418 ^[0-9a-f]{12}$ (re)
418 ^[0-9a-f]{12}$ (re)
419 ^[0-9a-f]{12}$ (re)
419 ^[0-9a-f]{12}$ (re)
420 ^[0-9a-f]{12}$ (re)
420 ^[0-9a-f]{12}$ (re)
421 ^[0-9a-f]{12}$ (re)
421 ^[0-9a-f]{12}$ (re)
422 ...and 5 more, use --verbose to list all
422 ...and 5 more, use --verbose to list all
423 abort: local changes found
423 abort: local changes found
424 (use --force-delete-local-changes to ignore)
424 (use --force-delete-local-changes to ignore)
425 [255]
425 [20]
426 Now test it *with* verbose.
426 Now test it *with* verbose.
427 $ hg tracked --removeinclude d9 --verbose
427 $ hg tracked --removeinclude d9 --verbose
428 comparing with ssh://user@dummy/master
428 comparing with ssh://user@dummy/master
429 searching for changes
429 searching for changes
430 looking for local changes to affected paths
430 looking for local changes to affected paths
431 The following changeset(s) or their ancestors have local changes not on the remote:
431 The following changeset(s) or their ancestors have local changes not on the remote:
432 ^[0-9a-f]{12}$ (re)
432 ^[0-9a-f]{12}$ (re)
433 ^[0-9a-f]{12}$ (re)
433 ^[0-9a-f]{12}$ (re)
434 ^[0-9a-f]{12}$ (re)
434 ^[0-9a-f]{12}$ (re)
435 ^[0-9a-f]{12}$ (re)
435 ^[0-9a-f]{12}$ (re)
436 ^[0-9a-f]{12}$ (re)
436 ^[0-9a-f]{12}$ (re)
437 ^[0-9a-f]{12}$ (re)
437 ^[0-9a-f]{12}$ (re)
438 ^[0-9a-f]{12}$ (re)
438 ^[0-9a-f]{12}$ (re)
439 ^[0-9a-f]{12}$ (re)
439 ^[0-9a-f]{12}$ (re)
440 ^[0-9a-f]{12}$ (re)
440 ^[0-9a-f]{12}$ (re)
441 ^[0-9a-f]{12}$ (re)
441 ^[0-9a-f]{12}$ (re)
442 ^[0-9a-f]{12}$ (re)
442 ^[0-9a-f]{12}$ (re)
443 ^[0-9a-f]{12}$ (re)
443 ^[0-9a-f]{12}$ (re)
444 ^[0-9a-f]{12}$ (re)
444 ^[0-9a-f]{12}$ (re)
445 ^[0-9a-f]{12}$ (re)
445 ^[0-9a-f]{12}$ (re)
446 ^[0-9a-f]{12}$ (re)
446 ^[0-9a-f]{12}$ (re)
447 abort: local changes found
447 abort: local changes found
448 (use --force-delete-local-changes to ignore)
448 (use --force-delete-local-changes to ignore)
449 [255]
449 [20]
450 $ cd ..
450 $ cd ..
451
451
452 Test --auto-remove-includes
452 Test --auto-remove-includes
453 $ hg clone --narrow ssh://user@dummy/master narrow-auto-remove -q \
453 $ hg clone --narrow ssh://user@dummy/master narrow-auto-remove -q \
454 > --include d0 --include d1 --include d2
454 > --include d0 --include d1 --include d2
455 $ cd narrow-auto-remove
455 $ cd narrow-auto-remove
456 $ echo a >> d0/f
456 $ echo a >> d0/f
457 $ hg ci -m 'local change to d0'
457 $ hg ci -m 'local change to d0'
458 $ hg co '.^'
458 $ hg co '.^'
459 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
459 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
460 $ echo a >> d1/f
460 $ echo a >> d1/f
461 $ hg ci -m 'local change to d1'
461 $ hg ci -m 'local change to d1'
462 created new head
462 created new head
463 $ hg debugobsolete $(hg log -T '{node}' -r 'desc("local change to d0")')
463 $ hg debugobsolete $(hg log -T '{node}' -r 'desc("local change to d0")')
464 1 new obsolescence markers
464 1 new obsolescence markers
465 obsoleted 1 changesets
465 obsoleted 1 changesets
466 $ echo n | hg tracked --auto-remove-includes --config ui.interactive=yes
466 $ echo n | hg tracked --auto-remove-includes --config ui.interactive=yes
467 comparing with ssh://user@dummy/master
467 comparing with ssh://user@dummy/master
468 searching for changes
468 searching for changes
469 looking for unused includes to remove
469 looking for unused includes to remove
470 path:d0
470 path:d0
471 path:d2
471 path:d2
472 remove these unused includes (yn)? n
472 remove these unused includes (yn)? n
473 $ hg tracked --auto-remove-includes
473 $ hg tracked --auto-remove-includes
474 comparing with ssh://user@dummy/master
474 comparing with ssh://user@dummy/master
475 searching for changes
475 searching for changes
476 looking for unused includes to remove
476 looking for unused includes to remove
477 path:d0
477 path:d0
478 path:d2
478 path:d2
479 remove these unused includes (yn)? y
479 remove these unused includes (yn)? y
480 looking for local changes to affected paths
480 looking for local changes to affected paths
481 saved backup bundle to $TESTTMP/narrow-auto-remove/.hg/strip-backup/*-narrow.hg (glob)
481 saved backup bundle to $TESTTMP/narrow-auto-remove/.hg/strip-backup/*-narrow.hg (glob)
482 deleting data/d0/f.i
482 deleting data/d0/f.i
483 deleting data/d2/f.i
483 deleting data/d2/f.i
484 deleting meta/d0/00manifest.i (tree !)
484 deleting meta/d0/00manifest.i (tree !)
485 deleting meta/d2/00manifest.i (tree !)
485 deleting meta/d2/00manifest.i (tree !)
486 $ hg tracked
486 $ hg tracked
487 I path:d1
487 I path:d1
488 $ hg files
488 $ hg files
489 d1/f
489 d1/f
490 $ hg tracked --auto-remove-includes
490 $ hg tracked --auto-remove-includes
491 comparing with ssh://user@dummy/master
491 comparing with ssh://user@dummy/master
492 searching for changes
492 searching for changes
493 looking for unused includes to remove
493 looking for unused includes to remove
494 found no unused includes
494 found no unused includes
General Comments 0
You need to be logged in to leave comments. Login now