Show More
@@ -0,0 +1,218 b'' | |||
|
1 | #testcases flat tree | |
|
2 | $ . "$TESTDIR/narrow-library.sh" | |
|
3 | ||
|
4 | #if tree | |
|
5 | $ cat << EOF >> $HGRCPATH | |
|
6 | > [experimental] | |
|
7 | > treemanifest = 1 | |
|
8 | > EOF | |
|
9 | #endif | |
|
10 | ||
|
11 | $ hg init master | |
|
12 | $ cd master | |
|
13 | $ cat >> .hg/hgrc <<EOF | |
|
14 | > [narrow] | |
|
15 | > serveellipses=True | |
|
16 | > EOF | |
|
17 | ||
|
18 | $ mkdir inside | |
|
19 | $ echo 'inside' > inside/f | |
|
20 | $ hg add inside/f | |
|
21 | $ hg commit -m 'add inside' | |
|
22 | ||
|
23 | $ mkdir widest | |
|
24 | $ echo 'widest' > widest/f | |
|
25 | $ hg add widest/f | |
|
26 | $ hg commit -m 'add widest' | |
|
27 | ||
|
28 | $ mkdir outside | |
|
29 | $ echo 'outside' > outside/f | |
|
30 | $ hg add outside/f | |
|
31 | $ hg commit -m 'add outside' | |
|
32 | ||
|
33 | $ cd .. | |
|
34 | ||
|
35 | narrow clone the inside file | |
|
36 | ||
|
37 | $ hg clone --narrow ssh://user@dummy/master narrow --include inside | |
|
38 | requesting all changes | |
|
39 | adding changesets | |
|
40 | adding manifests | |
|
41 | adding file changes | |
|
42 | added 2 changesets with 1 changes to 1 files | |
|
43 | new changesets *:* (glob) | |
|
44 | updating to branch default | |
|
45 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
46 | $ cd narrow | |
|
47 | $ hg tracked | |
|
48 | I path:inside | |
|
49 | $ ls | |
|
50 | inside | |
|
51 | $ cat inside/f | |
|
52 | inside | |
|
53 | $ cd .. | |
|
54 | ||
|
55 | add more upstream files which we will include in a wider narrow spec | |
|
56 | ||
|
57 | $ cd master | |
|
58 | ||
|
59 | $ mkdir wider | |
|
60 | $ echo 'wider' > wider/f | |
|
61 | $ hg add wider/f | |
|
62 | $ echo 'widest v2' > widest/f | |
|
63 | $ hg commit -m 'add wider, update widest' | |
|
64 | ||
|
65 | $ echo 'widest v3' > widest/f | |
|
66 | $ hg commit -m 'update widest v3' | |
|
67 | ||
|
68 | $ echo 'inside v2' > inside/f | |
|
69 | $ hg commit -m 'update inside' | |
|
70 | ||
|
71 | $ mkdir outside2 | |
|
72 | $ echo 'outside2' > outside2/f | |
|
73 | $ hg add outside2/f | |
|
74 | $ hg commit -m 'add outside2' | |
|
75 | ||
|
76 | $ echo 'widest v4' > widest/f | |
|
77 | $ hg commit -m 'update widest v4' | |
|
78 | ||
|
79 | $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n" | |
|
80 | 7: update widest v4 | |
|
81 | 6: add outside2 | |
|
82 | 5: update inside | |
|
83 | 4: update widest v3 | |
|
84 | 3: add wider, update widest | |
|
85 | 2: add outside | |
|
86 | 1: add widest | |
|
87 | 0: add inside | |
|
88 | ||
|
89 | $ cd .. | |
|
90 | ||
|
91 | Testing the --import-rules flag of `hg tracked` command | |
|
92 | ||
|
93 | $ cd narrow | |
|
94 | $ hg tracked --import-rules | |
|
95 | hg tracked: option --import-rules requires argument | |
|
96 | hg tracked [OPTIONS]... [REMOTE] | |
|
97 | ||
|
98 | show or change the current narrowspec | |
|
99 | ||
|
100 | options ([+] can be repeated): | |
|
101 | ||
|
102 | --addinclude VALUE [+] new paths to include | |
|
103 | --removeinclude VALUE [+] old paths to no longer include | |
|
104 | --addexclude VALUE [+] new paths to exclude | |
|
105 | --import-rules VALUE import narrowspecs from a file | |
|
106 | --removeexclude VALUE [+] old paths to no longer exclude | |
|
107 | --clear whether to replace the existing narrowspec | |
|
108 | --force-delete-local-changes forces deletion of local changes when | |
|
109 | narrowing | |
|
110 | -e --ssh CMD specify ssh command to use | |
|
111 | --remotecmd CMD specify hg command to run on the remote side | |
|
112 | --insecure do not verify server certificate (ignoring | |
|
113 | web.cacerts config) | |
|
114 | ||
|
115 | (use 'hg tracked -h' to show more help) | |
|
116 | [255] | |
|
117 | $ hg tracked --import-rules doesnotexist | |
|
118 | abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$ | |
|
119 | [255] | |
|
120 | ||
|
121 | $ cat > specs <<EOF | |
|
122 | > %include foo | |
|
123 | > [include] | |
|
124 | > path:widest/ | |
|
125 | > [exclude] | |
|
126 | > path:inside/ | |
|
127 | > EOF | |
|
128 | ||
|
129 | $ hg tracked --import-rules specs | |
|
130 | abort: including other spec files using '%include' is not supported in narrowspec | |
|
131 | [255] | |
|
132 | ||
|
133 | $ cat > specs <<EOF | |
|
134 | > [include] | |
|
135 | > outisde | |
|
136 | > [exclude] | |
|
137 | > inside | |
|
138 | > EOF | |
|
139 | ||
|
140 | $ hg tracked --import-rules specs | |
|
141 | comparing with ssh://user@dummy/master | |
|
142 | searching for changes | |
|
143 | looking for local changes to affected paths | |
|
144 | deleting data/inside/f.i | |
|
145 | deleting meta/inside/00manifest.i (tree !) | |
|
146 | no changes found | |
|
147 | saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
|
148 | adding changesets | |
|
149 | adding manifests | |
|
150 | adding file changes | |
|
151 | added 2 changesets with 0 changes to 0 files | |
|
152 | new changesets *:* (glob) | |
|
153 | $ hg tracked | |
|
154 | I path:outisde | |
|
155 | X path:inside | |
|
156 | ||
|
157 | Testing the --import-rules flag with --addinclude and --addexclude | |
|
158 | ||
|
159 | $ cat > specs <<EOF | |
|
160 | > [include] | |
|
161 | > widest | |
|
162 | > EOF | |
|
163 | ||
|
164 | $ hg tracked --import-rules specs --addinclude 'wider/' | |
|
165 | comparing with ssh://user@dummy/master | |
|
166 | searching for changes | |
|
167 | no changes found | |
|
168 | saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
|
169 | adding changesets | |
|
170 | adding manifests | |
|
171 | adding file changes | |
|
172 | added 3 changesets with 1 changes to 1 files | |
|
173 | new changesets *:* (glob) | |
|
174 | $ hg tracked | |
|
175 | I path:outisde | |
|
176 | I path:wider | |
|
177 | I path:widest | |
|
178 | X path:inside | |
|
179 | ||
|
180 | $ cat > specs <<EOF | |
|
181 | > [exclude] | |
|
182 | > outside2 | |
|
183 | > EOF | |
|
184 | ||
|
185 | $ hg tracked --import-rules specs --addexclude 'widest' | |
|
186 | comparing with ssh://user@dummy/master | |
|
187 | searching for changes | |
|
188 | looking for local changes to affected paths | |
|
189 | deleting data/widest/f.i | |
|
190 | deleting meta/widest/00manifest.i (tree !) | |
|
191 | $ hg tracked | |
|
192 | I path:outisde | |
|
193 | I path:wider | |
|
194 | X path:inside | |
|
195 | X path:outside2 | |
|
196 | X path:widest | |
|
197 | ||
|
198 | $ hg tracked --import-rules specs --clear | |
|
199 | The --clear option is not yet supported. | |
|
200 | [1] | |
|
201 | ||
|
202 | Testing with passing a out of wdir file | |
|
203 | ||
|
204 | $ cat > ../nspecs <<EOF | |
|
205 | > [include] | |
|
206 | > widest | |
|
207 | > EOF | |
|
208 | ||
|
209 | $ hg tracked --import-rules ../nspecs | |
|
210 | comparing with ssh://user@dummy/master | |
|
211 | searching for changes | |
|
212 | no changes found | |
|
213 | saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
|
214 | adding changesets | |
|
215 | adding manifests | |
|
216 | adding file changes | |
|
217 | added 3 changesets with 0 changes to 0 files | |
|
218 | new changesets *:* (glob) |
@@ -14,6 +14,7 b' from mercurial import (' | |||
|
14 | 14 | cmdutil, |
|
15 | 15 | commands, |
|
16 | 16 | discovery, |
|
17 | encoding, | |
|
17 | 18 | error, |
|
18 | 19 | exchange, |
|
19 | 20 | extensions, |
@@ -326,6 +327,7 b' def _widen(ui, repo, remote, commoninc, ' | |||
|
326 | 327 | [('', 'addinclude', [], _('new paths to include')), |
|
327 | 328 | ('', 'removeinclude', [], _('old paths to no longer include')), |
|
328 | 329 | ('', 'addexclude', [], _('new paths to exclude')), |
|
330 | ('', 'import-rules', '', _('import narrowspecs from a file')), | |
|
329 | 331 | ('', 'removeexclude', [], _('old paths to no longer exclude')), |
|
330 | 332 | ('', 'clear', False, _('whether to replace the existing narrowspec')), |
|
331 | 333 | ('', 'force-delete-local-changes', False, |
@@ -369,6 +371,23 b' def trackedcmd(ui, repo, remotepath=None' | |||
|
369 | 371 | ui.warn(_('The --clear option is not yet supported.\n')) |
|
370 | 372 | return 1 |
|
371 | 373 | |
|
374 | # import rules from a file | |
|
375 | newrules = opts.get('import_rules') | |
|
376 | if newrules: | |
|
377 | try: | |
|
378 | filepath = os.path.join(pycompat.getcwd(), newrules) | |
|
379 | fdata = util.readfile(filepath) | |
|
380 | except IOError as inst: | |
|
381 | raise error.Abort(_("cannot read narrowspecs from '%s': %s") % | |
|
382 | (filepath, encoding.strtolocal(inst.strerror))) | |
|
383 | includepats, excludepats, profiles = sparse.parseconfig(ui, fdata, | |
|
384 | 'narrow') | |
|
385 | if profiles: | |
|
386 | raise error.Abort(_("including other spec files using '%include' " | |
|
387 | "is not supported in narrowspec")) | |
|
388 | opts['addinclude'].extend(includepats) | |
|
389 | opts['addexclude'].extend(excludepats) | |
|
390 | ||
|
372 | 391 | if narrowspec.needsexpansion(opts['addinclude'] + opts['addexclude']): |
|
373 | 392 | raise error.Abort('Expansion not yet supported on widen/narrow') |
|
374 | 393 |
General Comments 0
You need to be logged in to leave comments.
Login now