Show More
@@ -510,14 +510,6 b' def _wraprepo(ui, repo):' | |||||
510 |
|
510 | |||
511 | return result |
|
511 | return result | |
512 |
|
512 | |||
513 | def writesparseconfig(self, include, exclude, profiles): |
|
|||
514 | raw = '%s[include]\n%s\n[exclude]\n%s\n' % ( |
|
|||
515 | ''.join(['%%include %s\n' % p for p in sorted(profiles)]), |
|
|||
516 | '\n'.join(sorted(include)), |
|
|||
517 | '\n'.join(sorted(exclude))) |
|
|||
518 | self.vfs.write("sparse", raw) |
|
|||
519 | sparse.invalidatesignaturecache(self) |
|
|||
520 |
|
||||
521 | def addtemporaryincludes(self, files): |
|
513 | def addtemporaryincludes(self, files): | |
522 | includes = self.gettemporaryincludes() |
|
514 | includes = self.gettemporaryincludes() | |
523 | for file in files: |
|
515 | for file in files: | |
@@ -722,7 +714,8 b' def _config(ui, repo, pats, opts, includ' | |||||
722 | newinclude.difference_update(pats) |
|
714 | newinclude.difference_update(pats) | |
723 | newexclude.difference_update(pats) |
|
715 | newexclude.difference_update(pats) | |
724 |
|
716 | |||
725 |
repo |
|
717 | sparse.writeconfig(repo, newinclude, newexclude, newprofiles) | |
|
718 | ||||
726 | fcounts = map( |
|
719 | fcounts = map( | |
727 | len, _refresh(ui, repo, oldstatus, oldsparsematch, force)) |
|
720 | len, _refresh(ui, repo, oldstatus, oldsparsematch, force)) | |
728 |
|
721 | |||
@@ -735,7 +728,7 b' def _config(ui, repo, pats, opts, includ' | |||||
735 | _verbose_output( |
|
728 | _verbose_output( | |
736 | ui, opts, profilecount, includecount, excludecount, *fcounts) |
|
729 | ui, opts, profilecount, includecount, excludecount, *fcounts) | |
737 | except Exception: |
|
730 | except Exception: | |
738 |
repo |
|
731 | sparse.writeconfig(repo, oldinclude, oldexclude, oldprofiles) | |
739 | raise |
|
732 | raise | |
740 | finally: |
|
733 | finally: | |
741 | wlock.release() |
|
734 | wlock.release() | |
@@ -784,13 +777,13 b' def _import(ui, repo, files, opts, force' | |||||
784 |
|
777 | |||
785 | oldstatus = repo.status() |
|
778 | oldstatus = repo.status() | |
786 | oldsparsematch = repo.sparsematch() |
|
779 | oldsparsematch = repo.sparsematch() | |
787 |
repo |
|
780 | sparse.writeconfig(repo, includes, excludes, profiles) | |
788 |
|
781 | |||
789 | try: |
|
782 | try: | |
790 | fcounts = map( |
|
783 | fcounts = map( | |
791 | len, _refresh(ui, repo, oldstatus, oldsparsematch, force)) |
|
784 | len, _refresh(ui, repo, oldstatus, oldsparsematch, force)) | |
792 | except Exception: |
|
785 | except Exception: | |
793 |
repo |
|
786 | sparse.writeconfig(repo, oincludes, oexcludes, oprofiles) | |
794 | raise |
|
787 | raise | |
795 |
|
788 | |||
796 | _verbose_output(ui, opts, profilecount, includecount, excludecount, |
|
789 | _verbose_output(ui, opts, profilecount, includecount, excludecount, | |
@@ -804,7 +797,7 b' def _clear(ui, repo, files, force=False)' | |||||
804 | if includes or excludes: |
|
797 | if includes or excludes: | |
805 | oldstatus = repo.status() |
|
798 | oldstatus = repo.status() | |
806 | oldsparsematch = repo.sparsematch() |
|
799 | oldsparsematch = repo.sparsematch() | |
807 |
repo |
|
800 | sparse.writeconfig(repo, set(), set(), profiles) | |
808 | _refresh(ui, repo, oldstatus, oldsparsematch, force) |
|
801 | _refresh(ui, repo, oldstatus, oldsparsematch, force) | |
809 |
|
802 | |||
810 | def _refresh(ui, repo, origstatus, origsparsematch, force): |
|
803 | def _refresh(ui, repo, origstatus, origsparsematch, force): |
@@ -129,3 +129,23 b' def activeprofiles(repo):' | |||||
129 |
|
129 | |||
130 | def invalidatesignaturecache(repo): |
|
130 | def invalidatesignaturecache(repo): | |
131 | repo._sparsesignaturecache.clear() |
|
131 | repo._sparsesignaturecache.clear() | |
|
132 | ||||
|
133 | def writeconfig(repo, includes, excludes, profiles): | |||
|
134 | """Write the sparse config file given a sparse configuration.""" | |||
|
135 | with repo.vfs('sparse', 'wb') as fh: | |||
|
136 | for p in sorted(profiles): | |||
|
137 | fh.write('%%include %s\n' % p) | |||
|
138 | ||||
|
139 | if includes: | |||
|
140 | fh.write('[include]\n') | |||
|
141 | for i in sorted(includes): | |||
|
142 | fh.write(i) | |||
|
143 | fh.write('\n') | |||
|
144 | ||||
|
145 | if excludes: | |||
|
146 | fh.write('[exclude]\n') | |||
|
147 | for e in sorted(excludes): | |||
|
148 | fh.write(e) | |||
|
149 | fh.write('\n') | |||
|
150 | ||||
|
151 | invalidatesignaturecache(repo) |
@@ -63,8 +63,6 b" Verify 'hg debugsparse' default output" | |||||
63 | $ hg debugsparse |
|
63 | $ hg debugsparse | |
64 | [include] |
|
64 | [include] | |
65 | show* |
|
65 | show* | |
66 | [exclude] |
|
|||
67 |
|
||||
68 |
|
66 | |||
69 | Verify update only writes included files |
|
67 | Verify update only writes included files | |
70 |
|
68 | |||
@@ -150,8 +148,6 b' Verify rebase temporarily includes exclu' | |||||
150 | [1] |
|
148 | [1] | |
151 |
|
149 | |||
152 | $ hg debugsparse |
|
150 | $ hg debugsparse | |
153 | [include] |
|
|||
154 |
|
||||
155 | [exclude] |
|
151 | [exclude] | |
156 | hide* |
|
152 | hide* | |
157 |
|
153 | |||
@@ -187,8 +183,6 b' Verify merge fails if merging excluded f' | |||||
187 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
183 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
188 | [1] |
|
184 | [1] | |
189 | $ hg debugsparse |
|
185 | $ hg debugsparse | |
190 | [include] |
|
|||
191 |
|
||||
192 | [exclude] |
|
186 | [exclude] | |
193 | hide* |
|
187 | hide* | |
194 |
|
188 | |||
@@ -199,8 +193,6 b' Verify merge fails if merging excluded f' | |||||
199 | cleaned up 1 temporarily added file(s) from the sparse checkout |
|
193 | cleaned up 1 temporarily added file(s) from the sparse checkout | |
200 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
194 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
201 | $ hg debugsparse |
|
195 | $ hg debugsparse | |
202 | [include] |
|
|||
203 |
|
||||
204 | [exclude] |
|
196 | [exclude] | |
205 | hide* |
|
197 | hide* | |
206 |
|
198 | |||
@@ -209,8 +201,6 b' Verify strip -k resets dirstate correctl' | |||||
209 |
|
201 | |||
210 | $ hg status |
|
202 | $ hg status | |
211 | $ hg debugsparse |
|
203 | $ hg debugsparse | |
212 | [include] |
|
|||
213 |
|
||||
214 | [exclude] |
|
204 | [exclude] | |
215 | hide* |
|
205 | hide* | |
216 |
|
206 | |||
@@ -257,8 +247,6 b' Test that add -s adds dirs to sparse pro' | |||||
257 | $ hg debugsparse |
|
247 | $ hg debugsparse | |
258 | [include] |
|
248 | [include] | |
259 | empty |
|
249 | empty | |
260 | [exclude] |
|
|||
261 |
|
||||
262 |
|
250 | |||
263 |
|
251 | |||
264 | $ mkdir add |
|
252 | $ mkdir add | |
@@ -276,8 +264,6 b' Test that add -s adds dirs to sparse pro' | |||||
276 | [include] |
|
264 | [include] | |
277 | add |
|
265 | add | |
278 | empty |
|
266 | empty | |
279 | [exclude] |
|
|||
280 |
|
||||
281 |
|
267 | |||
282 | $ hg add -s add/* |
|
268 | $ hg add -s add/* | |
283 | add/foo already tracked! |
|
269 | add/foo already tracked! | |
@@ -288,8 +274,6 b' Test that add -s adds dirs to sparse pro' | |||||
288 | [include] |
|
274 | [include] | |
289 | add |
|
275 | add | |
290 | empty |
|
276 | empty | |
291 | [exclude] |
|
|||
292 |
|
||||
293 |
|
277 | |||
294 |
|
278 | |||
295 | $ cd .. |
|
279 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now