##// END OF EJS Templates
narrow: fix typo "respositories"...
Martin von Zweigbergk -
r43075:383fdfa6 default
parent child Browse files
Show More
@@ -1,478 +1,478 b''
1 1 # narrowcommands.py - command modifications for narrowhg extension
2 2 #
3 3 # Copyright 2017 Google, Inc.
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7 from __future__ import absolute_import
8 8
9 9 import itertools
10 10 import os
11 11
12 12 from mercurial.i18n import _
13 13 from mercurial import (
14 14 bundle2,
15 15 cmdutil,
16 16 commands,
17 17 discovery,
18 18 encoding,
19 19 error,
20 20 exchange,
21 21 extensions,
22 22 hg,
23 23 narrowspec,
24 24 node,
25 25 pycompat,
26 26 registrar,
27 27 repair,
28 28 repository,
29 29 repoview,
30 30 sparse,
31 31 util,
32 32 wireprototypes,
33 33 )
34 34
35 35 table = {}
36 36 command = registrar.command(table)
37 37
38 38 def setup():
39 39 """Wraps user-facing mercurial commands with narrow-aware versions."""
40 40
41 41 entry = extensions.wrapcommand(commands.table, 'clone', clonenarrowcmd)
42 42 entry[1].append(('', 'narrow', None,
43 43 _("create a narrow clone of select files")))
44 44 entry[1].append(('', 'depth', '',
45 45 _("limit the history fetched by distance from heads")))
46 46 entry[1].append(('', 'narrowspec', '',
47 47 _("read narrowspecs from file")))
48 48 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
49 49 if 'sparse' not in extensions.enabled():
50 50 entry[1].append(('', 'include', [],
51 51 _("specifically fetch this file/directory")))
52 52 entry[1].append(
53 53 ('', 'exclude', [],
54 54 _("do not fetch this file/directory, even if included")))
55 55
56 56 entry = extensions.wrapcommand(commands.table, 'pull', pullnarrowcmd)
57 57 entry[1].append(('', 'depth', '',
58 58 _("limit the history fetched by distance from heads")))
59 59
60 60 extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
61 61
62 62 def clonenarrowcmd(orig, ui, repo, *args, **opts):
63 63 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
64 64 opts = pycompat.byteskwargs(opts)
65 65 wrappedextraprepare = util.nullcontextmanager()
66 66 narrowspecfile = opts['narrowspec']
67 67
68 68 if narrowspecfile:
69 69 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
70 70 ui.status(_("reading narrowspec from '%s'\n") % filepath)
71 71 try:
72 72 fdata = util.readfile(filepath)
73 73 except IOError as inst:
74 74 raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
75 75 (filepath, encoding.strtolocal(inst.strerror)))
76 76
77 77 includes, excludes, profiles = sparse.parseconfig(ui, fdata, 'narrow')
78 78 if profiles:
79 79 raise error.Abort(_("cannot specify other files using '%include' in"
80 80 " narrowspec"))
81 81
82 82 narrowspec.validatepatterns(includes)
83 83 narrowspec.validatepatterns(excludes)
84 84
85 85 # narrowspec is passed so we should assume that user wants narrow clone
86 86 opts['narrow'] = True
87 87 opts['include'].extend(includes)
88 88 opts['exclude'].extend(excludes)
89 89
90 90 if opts['narrow']:
91 91 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
92 92 orig(pullop, kwargs)
93 93
94 94 if opts.get('depth'):
95 95 kwargs['depth'] = opts['depth']
96 96 wrappedextraprepare = extensions.wrappedfunction(exchange,
97 97 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
98 98
99 99 with wrappedextraprepare:
100 100 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
101 101
102 102 def pullnarrowcmd(orig, ui, repo, *args, **opts):
103 103 """Wraps pull command to allow modifying narrow spec."""
104 104 wrappedextraprepare = util.nullcontextmanager()
105 105 if repository.NARROW_REQUIREMENT in repo.requirements:
106 106
107 107 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
108 108 orig(pullop, kwargs)
109 109 if opts.get(r'depth'):
110 110 kwargs['depth'] = opts[r'depth']
111 111 wrappedextraprepare = extensions.wrappedfunction(exchange,
112 112 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
113 113
114 114 with wrappedextraprepare:
115 115 return orig(ui, repo, *args, **opts)
116 116
117 117 def archivenarrowcmd(orig, ui, repo, *args, **opts):
118 118 """Wraps archive command to narrow the default includes."""
119 119 if repository.NARROW_REQUIREMENT in repo.requirements:
120 120 repo_includes, repo_excludes = repo.narrowpats
121 121 includes = set(opts.get(r'include', []))
122 122 excludes = set(opts.get(r'exclude', []))
123 123 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
124 124 includes, excludes, repo_includes, repo_excludes)
125 125 if includes:
126 126 opts[r'include'] = includes
127 127 if excludes:
128 128 opts[r'exclude'] = excludes
129 129 return orig(ui, repo, *args, **opts)
130 130
131 131 def pullbundle2extraprepare(orig, pullop, kwargs):
132 132 repo = pullop.repo
133 133 if repository.NARROW_REQUIREMENT not in repo.requirements:
134 134 return orig(pullop, kwargs)
135 135
136 136 if wireprototypes.NARROWCAP not in pullop.remote.capabilities():
137 137 raise error.Abort(_("server does not support narrow clones"))
138 138 orig(pullop, kwargs)
139 139 kwargs['narrow'] = True
140 140 include, exclude = repo.narrowpats
141 141 kwargs['oldincludepats'] = include
142 142 kwargs['oldexcludepats'] = exclude
143 143 if include:
144 144 kwargs['includepats'] = include
145 145 if exclude:
146 146 kwargs['excludepats'] = exclude
147 147 # calculate known nodes only in ellipses cases because in non-ellipses cases
148 148 # we have all the nodes
149 149 if wireprototypes.ELLIPSESCAP1 in pullop.remote.capabilities():
150 150 kwargs['known'] = [node.hex(ctx.node()) for ctx in
151 151 repo.set('::%ln', pullop.common)
152 152 if ctx.node() != node.nullid]
153 153 if not kwargs['known']:
154 154 # Mercurial serializes an empty list as '' and deserializes it as
155 155 # [''], so delete it instead to avoid handling the empty string on
156 156 # the server.
157 157 del kwargs['known']
158 158
159 159 extensions.wrapfunction(exchange,'_pullbundle2extraprepare',
160 160 pullbundle2extraprepare)
161 161
162 162 def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
163 163 newincludes, newexcludes, force):
164 164 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
165 165 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
166 166
167 167 # This is essentially doing "hg outgoing" to find all local-only
168 168 # commits. We will then check that the local-only commits don't
169 169 # have any changes to files that will be untracked.
170 170 unfi = repo.unfiltered()
171 171 outgoing = discovery.findcommonoutgoing(unfi, remote,
172 172 commoninc=commoninc)
173 173 ui.status(_('looking for local changes to affected paths\n'))
174 174 localnodes = []
175 175 for n in itertools.chain(outgoing.missing, outgoing.excluded):
176 176 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
177 177 localnodes.append(n)
178 178 revstostrip = unfi.revs('descendants(%ln)', localnodes)
179 179 hiddenrevs = repoview.filterrevs(repo, 'visible')
180 180 visibletostrip = list(repo.changelog.node(r)
181 181 for r in (revstostrip - hiddenrevs))
182 182 if visibletostrip:
183 183 ui.status(_('The following changeset(s) or their ancestors have '
184 184 'local changes not on the remote:\n'))
185 185 maxnodes = 10
186 186 if ui.verbose or len(visibletostrip) <= maxnodes:
187 187 for n in visibletostrip:
188 188 ui.status('%s\n' % node.short(n))
189 189 else:
190 190 for n in visibletostrip[:maxnodes]:
191 191 ui.status('%s\n' % node.short(n))
192 192 ui.status(_('...and %d more, use --verbose to list all\n') %
193 193 (len(visibletostrip) - maxnodes))
194 194 if not force:
195 195 raise error.Abort(_('local changes found'),
196 196 hint=_('use --force-delete-local-changes to '
197 197 'ignore'))
198 198
199 199 with ui.uninterruptible():
200 200 if revstostrip:
201 201 tostrip = [unfi.changelog.node(r) for r in revstostrip]
202 202 if repo['.'].node() in tostrip:
203 203 # stripping working copy, so move to a different commit first
204 204 urev = max(repo.revs('(::%n) - %ln + null',
205 205 repo['.'].node(), visibletostrip))
206 206 hg.clean(repo, urev)
207 207 overrides = {('devel', 'strip-obsmarkers'): False}
208 208 with ui.configoverride(overrides, 'narrow'):
209 209 repair.strip(ui, unfi, tostrip, topic='narrow')
210 210
211 211 todelete = []
212 212 for f, f2, size in repo.store.datafiles():
213 213 if f.startswith('data/'):
214 214 file = f[5:-2]
215 215 if not newmatch(file):
216 216 todelete.append(f)
217 217 elif f.startswith('meta/'):
218 218 dir = f[5:-13]
219 219 dirs = sorted(util.dirs({dir})) + [dir]
220 220 include = True
221 221 for d in dirs:
222 222 visit = newmatch.visitdir(d)
223 223 if not visit:
224 224 include = False
225 225 break
226 226 if visit == 'all':
227 227 break
228 228 if not include:
229 229 todelete.append(f)
230 230
231 231 repo.destroying()
232 232
233 233 with repo.transaction('narrowing'):
234 234 # Update narrowspec before removing revlogs, so repo won't be
235 235 # corrupt in case of crash
236 236 repo.setnarrowpats(newincludes, newexcludes)
237 237
238 238 for f in todelete:
239 239 ui.status(_('deleting %s\n') % f)
240 240 util.unlinkpath(repo.svfs.join(f))
241 241 repo.store.markremoved(f)
242 242
243 243 narrowspec.updateworkingcopy(repo, assumeclean=True)
244 244 narrowspec.copytoworkingcopy(repo)
245 245
246 246 repo.destroyed()
247 247
248 248 def _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
249 249 newincludes, newexcludes):
250 250 # for now we assume that if a server has ellipses enabled, we will be
251 251 # exchanging ellipses nodes. In future we should add ellipses as a client
252 252 # side requirement (maybe) to distinguish a client is shallow or not and
253 253 # then send that information to server whether we want ellipses or not.
254 254 # Theoretically a non-ellipses repo should be able to use narrow
255 255 # functionality from an ellipses enabled server
256 256 remotecap = remote.capabilities()
257 257 ellipsesremote = any(cap in remotecap
258 258 for cap in wireprototypes.SUPPORTED_ELLIPSESCAP)
259 259
260 260 # check whether we are talking to a server which supports old version of
261 261 # ellipses capabilities
262 262 isoldellipses = (ellipsesremote and wireprototypes.ELLIPSESCAP1 in
263 263 remotecap and wireprototypes.ELLIPSESCAP not in remotecap)
264 264
265 265 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
266 266 orig(pullop, kwargs)
267 267 # The old{in,ex}cludepats have already been set by orig()
268 268 kwargs['includepats'] = newincludes
269 269 kwargs['excludepats'] = newexcludes
270 270 wrappedextraprepare = extensions.wrappedfunction(exchange,
271 271 '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
272 272
273 273 # define a function that narrowbundle2 can call after creating the
274 274 # backup bundle, but before applying the bundle from the server
275 275 def setnewnarrowpats():
276 276 repo.setnarrowpats(newincludes, newexcludes)
277 277 repo.setnewnarrowpats = setnewnarrowpats
278 278 # silence the devel-warning of applying an empty changegroup
279 279 overrides = {('devel', 'all-warnings'): False}
280 280
281 281 common = commoninc[0]
282 282 with ui.uninterruptible():
283 283 if ellipsesremote:
284 284 ds = repo.dirstate
285 285 p1, p2 = ds.p1(), ds.p2()
286 286 with ds.parentchange():
287 287 ds.setparents(node.nullid, node.nullid)
288 288 if isoldellipses:
289 289 with wrappedextraprepare:
290 290 exchange.pull(repo, remote, heads=common)
291 291 else:
292 292 known = []
293 293 if ellipsesremote:
294 294 known = [node.hex(ctx.node()) for ctx in
295 295 repo.set('::%ln', common)
296 296 if ctx.node() != node.nullid]
297 297 with remote.commandexecutor() as e:
298 298 bundle = e.callcommand('narrow_widen', {
299 299 'oldincludes': oldincludes,
300 300 'oldexcludes': oldexcludes,
301 301 'newincludes': newincludes,
302 302 'newexcludes': newexcludes,
303 303 'cgversion': '03',
304 304 'commonheads': common,
305 305 'known': known,
306 306 'ellipses': ellipsesremote,
307 307 }).result()
308 308
309 309 trmanager = exchange.transactionmanager(repo, 'widen', remote.url())
310 310 with trmanager, repo.ui.configoverride(overrides, 'widen'):
311 311 op = bundle2.bundleoperation(repo, trmanager.transaction,
312 312 source='widen')
313 313 # TODO: we should catch error.Abort here
314 314 bundle2.processbundle(repo, bundle, op=op)
315 315
316 316 if ellipsesremote:
317 317 with ds.parentchange():
318 318 ds.setparents(p1, p2)
319 319
320 320 with repo.transaction('widening'):
321 321 repo.setnewnarrowpats()
322 322 narrowspec.updateworkingcopy(repo)
323 323 narrowspec.copytoworkingcopy(repo)
324 324
325 325 # TODO(rdamazio): Make new matcher format and update description
326 326 @command('tracked',
327 327 [('', 'addinclude', [], _('new paths to include')),
328 328 ('', 'removeinclude', [], _('old paths to no longer include')),
329 329 ('', 'addexclude', [], _('new paths to exclude')),
330 330 ('', 'import-rules', '', _('import narrowspecs from a file')),
331 331 ('', 'removeexclude', [], _('old paths to no longer exclude')),
332 332 ('', 'clear', False, _('whether to replace the existing narrowspec')),
333 333 ('', 'force-delete-local-changes', False,
334 334 _('forces deletion of local changes when narrowing')),
335 335 ('', 'update-working-copy', False,
336 336 _('update working copy when the store has changed')),
337 337 ] + commands.remoteopts,
338 338 _('[OPTIONS]... [REMOTE]'),
339 339 inferrepo=True)
340 340 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
341 341 """show or change the current narrowspec
342 342
343 343 With no argument, shows the current narrowspec entries, one per line. Each
344 344 line will be prefixed with 'I' or 'X' for included or excluded patterns,
345 345 respectively.
346 346
347 347 The narrowspec is comprised of expressions to match remote files and/or
348 348 directories that should be pulled into your client.
349 349 The narrowspec has *include* and *exclude* expressions, with excludes always
350 350 trumping includes: that is, if a file matches an exclude expression, it will
351 351 be excluded even if it also matches an include expression.
352 352 Excluding files that were never included has no effect.
353 353
354 354 Each included or excluded entry is in the format described by
355 355 'hg help patterns'.
356 356
357 357 The options allow you to add or remove included and excluded expressions.
358 358
359 359 If --clear is specified, then all previous includes and excludes are DROPPED
360 360 and replaced by the new ones specified to --addinclude and --addexclude.
361 361 If --clear is specified without any further options, the narrowspec will be
362 362 empty and will not match any files.
363 363
364 364 --import-rules accepts a path to a file containing rules, allowing you to
365 365 add --addinclude, --addexclude rules in bulk. Like the other include and
366 366 exclude switches, the changes are applied immediately.
367 367 """
368 368 opts = pycompat.byteskwargs(opts)
369 369 if repository.NARROW_REQUIREMENT not in repo.requirements:
370 370 raise error.Abort(_('the tracked command is only supported on '
371 'respositories cloned with --narrow'))
371 'repositories cloned with --narrow'))
372 372
373 373 # Before supporting, decide whether it "hg tracked --clear" should mean
374 374 # tracking no paths or all paths.
375 375 if opts['clear']:
376 376 raise error.Abort(_('the --clear option is not yet supported'))
377 377
378 378 # import rules from a file
379 379 newrules = opts.get('import_rules')
380 380 if newrules:
381 381 try:
382 382 filepath = os.path.join(encoding.getcwd(), newrules)
383 383 fdata = util.readfile(filepath)
384 384 except IOError as inst:
385 385 raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
386 386 (filepath, encoding.strtolocal(inst.strerror)))
387 387 includepats, excludepats, profiles = sparse.parseconfig(ui, fdata,
388 388 'narrow')
389 389 if profiles:
390 390 raise error.Abort(_("including other spec files using '%include' "
391 391 "is not supported in narrowspec"))
392 392 opts['addinclude'].extend(includepats)
393 393 opts['addexclude'].extend(excludepats)
394 394
395 395 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
396 396 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
397 397 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
398 398 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
399 399
400 400 update_working_copy = opts['update_working_copy']
401 401 only_show = not (addedincludes or removedincludes or addedexcludes or
402 402 removedexcludes or newrules or update_working_copy)
403 403
404 404 oldincludes, oldexcludes = repo.narrowpats
405 405
406 406 # filter the user passed additions and deletions into actual additions and
407 407 # deletions of excludes and includes
408 408 addedincludes -= oldincludes
409 409 removedincludes &= oldincludes
410 410 addedexcludes -= oldexcludes
411 411 removedexcludes &= oldexcludes
412 412
413 413 widening = addedincludes or removedexcludes
414 414 narrowing = removedincludes or addedexcludes
415 415
416 416 # Only print the current narrowspec.
417 417 if only_show:
418 418 ui.pager('tracked')
419 419 fm = ui.formatter('narrow', opts)
420 420 for i in sorted(oldincludes):
421 421 fm.startitem()
422 422 fm.write('status', '%s ', 'I', label='narrow.included')
423 423 fm.write('pat', '%s\n', i, label='narrow.included')
424 424 for i in sorted(oldexcludes):
425 425 fm.startitem()
426 426 fm.write('status', '%s ', 'X', label='narrow.excluded')
427 427 fm.write('pat', '%s\n', i, label='narrow.excluded')
428 428 fm.end()
429 429 return 0
430 430
431 431 if update_working_copy:
432 432 with repo.wlock(), repo.lock(), repo.transaction('narrow-wc'):
433 433 narrowspec.updateworkingcopy(repo)
434 434 narrowspec.copytoworkingcopy(repo)
435 435 return 0
436 436
437 437 if not widening and not narrowing:
438 438 ui.status(_("nothing to widen or narrow\n"))
439 439 return 0
440 440
441 441 with repo.wlock(), repo.lock():
442 442 cmdutil.bailifchanged(repo)
443 443
444 444 # Find the revisions we have in common with the remote. These will
445 445 # be used for finding local-only changes for narrowing. They will
446 446 # also define the set of revisions to update for widening.
447 447 remotepath = ui.expandpath(remotepath or 'default')
448 448 url, branches = hg.parseurl(remotepath)
449 449 ui.status(_('comparing with %s\n') % util.hidepassword(url))
450 450 remote = hg.peer(repo, opts, url)
451 451
452 452 # check narrow support before doing anything if widening needs to be
453 453 # performed. In future we should also abort if client is ellipses and
454 454 # server does not support ellipses
455 455 if widening and wireprototypes.NARROWCAP not in remote.capabilities():
456 456 raise error.Abort(_("server does not support narrow clones"))
457 457
458 458 commoninc = discovery.findcommonincoming(repo, remote)
459 459
460 460 if narrowing:
461 461 newincludes = oldincludes - removedincludes
462 462 newexcludes = oldexcludes | addedexcludes
463 463 _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
464 464 newincludes, newexcludes,
465 465 opts['force_delete_local_changes'])
466 466 # _narrow() updated the narrowspec and _widen() below needs to
467 467 # use the updated values as its base (otherwise removed includes
468 468 # and addedexcludes will be lost in the resulting narrowspec)
469 469 oldincludes = newincludes
470 470 oldexcludes = newexcludes
471 471
472 472 if widening:
473 473 newincludes = oldincludes | addedincludes
474 474 newexcludes = oldexcludes - removedexcludes
475 475 _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
476 476 newincludes, newexcludes)
477 477
478 478 return 0
@@ -1,224 +1,224 b''
1 1 #testcases flat tree
2 2 $ . "$TESTDIR/narrow-library.sh"
3 3
4 4 #if tree
5 5 $ cat << EOF >> $HGRCPATH
6 6 > [experimental]
7 7 > treemanifest = 1
8 8 > EOF
9 9 #endif
10 10
11 11 $ hg init master
12 12 $ cd master
13 13 $ cat >> .hg/hgrc <<EOF
14 14 > [narrow]
15 15 > serveellipses=True
16 16 > EOF
17 17
18 18 $ mkdir inside
19 19 $ echo 'inside' > inside/f
20 20 $ hg add inside/f
21 21 $ hg commit -m 'add inside'
22 22
23 23 $ mkdir widest
24 24 $ echo 'widest' > widest/f
25 25 $ hg add widest/f
26 26 $ hg commit -m 'add widest'
27 27
28 28 $ mkdir outside
29 29 $ echo 'outside' > outside/f
30 30 $ hg add outside/f
31 31 $ hg commit -m 'add outside'
32 32
33 33 $ cd ..
34 34
35 35 narrow clone the inside file
36 36
37 37 $ hg clone --narrow ssh://user@dummy/master narrow --include inside
38 38 requesting all changes
39 39 adding changesets
40 40 adding manifests
41 41 adding file changes
42 42 added 2 changesets with 1 changes to 1 files
43 43 new changesets *:* (glob)
44 44 updating to branch default
45 45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 46 $ cd narrow
47 47 $ hg tracked
48 48 I path:inside
49 49 $ ls
50 50 inside
51 51 $ cat inside/f
52 52 inside
53 53 $ cd ..
54 54
55 55 add more upstream files which we will include in a wider narrow spec
56 56
57 57 $ cd master
58 58
59 59 $ mkdir wider
60 60 $ echo 'wider' > wider/f
61 61 $ hg add wider/f
62 62 $ echo 'widest v2' > widest/f
63 63 $ hg commit -m 'add wider, update widest'
64 64
65 65 $ echo 'widest v3' > widest/f
66 66 $ hg commit -m 'update widest v3'
67 67
68 68 $ echo 'inside v2' > inside/f
69 69 $ hg commit -m 'update inside'
70 70
71 71 $ mkdir outside2
72 72 $ echo 'outside2' > outside2/f
73 73 $ hg add outside2/f
74 74 $ hg commit -m 'add outside2'
75 75
76 76 $ echo 'widest v4' > widest/f
77 77 $ hg commit -m 'update widest v4'
78 78
79 79 $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n"
80 80 7: update widest v4
81 81 6: add outside2
82 82 5: update inside
83 83 4: update widest v3
84 84 3: add wider, update widest
85 85 2: add outside
86 86 1: add widest
87 87 0: add inside
88 88
89 89 $ cd ..
90 90
91 91 Testing the --import-rules flag of `hg tracked` command
92 92
93 93 $ cd narrow
94 94 $ hg tracked --import-rules
95 95 hg tracked: option --import-rules requires argument
96 96 hg tracked [OPTIONS]... [REMOTE]
97 97
98 98 show or change the current narrowspec
99 99
100 100 options ([+] can be repeated):
101 101
102 102 --addinclude VALUE [+] new paths to include
103 103 --removeinclude VALUE [+] old paths to no longer include
104 104 --addexclude VALUE [+] new paths to exclude
105 105 --import-rules VALUE import narrowspecs from a file
106 106 --removeexclude VALUE [+] old paths to no longer exclude
107 107 --clear whether to replace the existing narrowspec
108 108 --force-delete-local-changes forces deletion of local changes when
109 109 narrowing
110 110 --update-working-copy update working copy when the store has
111 111 changed
112 112 -e --ssh CMD specify ssh command to use
113 113 --remotecmd CMD specify hg command to run on the remote side
114 114 --insecure do not verify server certificate (ignoring
115 115 web.cacerts config)
116 116
117 117 (use 'hg tracked -h' to show more help)
118 118 [255]
119 119 $ hg tracked --import-rules doesnotexist
120 120 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
121 121 [255]
122 122
123 123 $ cat > specs <<EOF
124 124 > %include foo
125 125 > [include]
126 126 > path:widest/
127 127 > [exclude]
128 128 > path:inside/
129 129 > EOF
130 130
131 131 $ hg tracked --import-rules specs
132 132 abort: including other spec files using '%include' is not supported in narrowspec
133 133 [255]
134 134
135 135 $ cat > specs <<EOF
136 136 > [include]
137 137 > outisde
138 138 > [exclude]
139 139 > inside
140 140 > EOF
141 141
142 142 $ hg tracked --import-rules specs
143 143 comparing with ssh://user@dummy/master
144 144 searching for changes
145 145 looking for local changes to affected paths
146 146 deleting data/inside/f.i
147 147 deleting meta/inside/00manifest.i (tree !)
148 148 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
149 149 adding changesets
150 150 adding manifests
151 151 adding file changes
152 152 added 2 changesets with 0 changes to 0 files
153 153 $ hg tracked
154 154 I path:outisde
155 155 X path:inside
156 156
157 157 Testing the --import-rules flag with --addinclude and --addexclude
158 158
159 159 $ cat > specs <<EOF
160 160 > [include]
161 161 > widest
162 162 > EOF
163 163
164 164 $ hg tracked --import-rules specs --addinclude 'wider/'
165 165 comparing with ssh://user@dummy/master
166 166 searching for changes
167 167 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
168 168 adding changesets
169 169 adding manifests
170 170 adding file changes
171 171 added 3 changesets with 1 changes to 1 files
172 172 $ hg tracked
173 173 I path:outisde
174 174 I path:wider
175 175 I path:widest
176 176 X path:inside
177 177
178 178 $ cat > specs <<EOF
179 179 > [exclude]
180 180 > outside2
181 181 > EOF
182 182
183 183 $ hg tracked --import-rules specs --addexclude 'widest'
184 184 comparing with ssh://user@dummy/master
185 185 searching for changes
186 186 looking for local changes to affected paths
187 187 deleting data/widest/f.i
188 188 deleting meta/widest/00manifest.i (tree !)
189 189 $ hg tracked
190 190 I path:outisde
191 191 I path:wider
192 192 X path:inside
193 193 X path:outside2
194 194 X path:widest
195 195
196 196 $ hg tracked --import-rules specs --clear
197 197 abort: the --clear option is not yet supported
198 198 [255]
199 199
200 200 Testing with passing a out of wdir file
201 201
202 202 $ cat > ../nspecs <<EOF
203 203 > [include]
204 204 > widest
205 205 > EOF
206 206
207 207 $ hg tracked --import-rules ../nspecs
208 208 comparing with ssh://user@dummy/master
209 209 searching for changes
210 210 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
211 211 adding changesets
212 212 adding manifests
213 213 adding file changes
214 214 added 3 changesets with 0 changes to 0 files
215 215
216 216 $ cd ..
217 217
218 218 Testing tracked command on a non-narrow repo
219 219
220 220 $ hg init non-narrow
221 221 $ cd non-narrow
222 222 $ hg tracked --addinclude foobar
223 abort: the tracked command is only supported on respositories cloned with --narrow
223 abort: the tracked command is only supported on repositories cloned with --narrow
224 224 [255]
General Comments 0
You need to be logged in to leave comments. Login now