Show More
@@ -74,8 +74,6 b' certain files::' | |||||
74 |
|
74 | |||
75 | from __future__ import absolute_import |
|
75 | from __future__ import absolute_import | |
76 |
|
76 | |||
77 | import collections |
|
|||
78 |
|
||||
79 | from mercurial.i18n import _ |
|
77 | from mercurial.i18n import _ | |
80 | from mercurial.node import nullid |
|
78 | from mercurial.node import nullid | |
81 | from mercurial import ( |
|
79 | from mercurial import ( | |
@@ -139,91 +137,8 b' def replacefilecache(cls, propname, repl' | |||||
139 | propname)) |
|
137 | propname)) | |
140 |
|
138 | |||
141 | def _setupupdates(ui): |
|
139 | def _setupupdates(ui): | |
142 | def _calculateupdates(orig, repo, wctx, mctx, ancestors, branchmerge, *arg, |
|
140 | extensions.wrapfunction(mergemod, 'calculateupdates', | |
143 |
|
|
141 | sparse.calculateupdates) | |
144 | """Filter updates to only lay out files that match the sparse rules. |
|
|||
145 | """ |
|
|||
146 | actions, diverge, renamedelete = orig(repo, wctx, mctx, ancestors, |
|
|||
147 | branchmerge, *arg, **kwargs) |
|
|||
148 |
|
||||
149 | oldrevs = [pctx.rev() for pctx in wctx.parents()] |
|
|||
150 | oldsparsematch = sparse.matcher(repo, oldrevs) |
|
|||
151 |
|
||||
152 | if oldsparsematch.always(): |
|
|||
153 | return actions, diverge, renamedelete |
|
|||
154 |
|
||||
155 | files = set() |
|
|||
156 | prunedactions = {} |
|
|||
157 |
|
||||
158 | if branchmerge: |
|
|||
159 | # If we're merging, use the wctx filter, since we're merging into |
|
|||
160 | # the wctx. |
|
|||
161 | sparsematch = sparse.matcher(repo, [wctx.parents()[0].rev()]) |
|
|||
162 | else: |
|
|||
163 | # If we're updating, use the target context's filter, since we're |
|
|||
164 | # moving to the target context. |
|
|||
165 | sparsematch = sparse.matcher(repo, [mctx.rev()]) |
|
|||
166 |
|
||||
167 | temporaryfiles = [] |
|
|||
168 | for file, action in actions.iteritems(): |
|
|||
169 | type, args, msg = action |
|
|||
170 | files.add(file) |
|
|||
171 | if sparsematch(file): |
|
|||
172 | prunedactions[file] = action |
|
|||
173 | elif type == 'm': |
|
|||
174 | temporaryfiles.append(file) |
|
|||
175 | prunedactions[file] = action |
|
|||
176 | elif branchmerge: |
|
|||
177 | if type != 'k': |
|
|||
178 | temporaryfiles.append(file) |
|
|||
179 | prunedactions[file] = action |
|
|||
180 | elif type == 'f': |
|
|||
181 | prunedactions[file] = action |
|
|||
182 | elif file in wctx: |
|
|||
183 | prunedactions[file] = ('r', args, msg) |
|
|||
184 |
|
||||
185 | if len(temporaryfiles) > 0: |
|
|||
186 | ui.status(_("temporarily included %d file(s) in the sparse checkout" |
|
|||
187 | " for merging\n") % len(temporaryfiles)) |
|
|||
188 | sparse.addtemporaryincludes(repo, temporaryfiles) |
|
|||
189 |
|
||||
190 | # Add the new files to the working copy so they can be merged, etc |
|
|||
191 | actions = [] |
|
|||
192 | message = 'temporarily adding to sparse checkout' |
|
|||
193 | wctxmanifest = repo[None].manifest() |
|
|||
194 | for file in temporaryfiles: |
|
|||
195 | if file in wctxmanifest: |
|
|||
196 | fctx = repo[None][file] |
|
|||
197 | actions.append((file, (fctx.flags(), False), message)) |
|
|||
198 |
|
||||
199 | typeactions = collections.defaultdict(list) |
|
|||
200 | typeactions['g'] = actions |
|
|||
201 | mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], |
|
|||
202 | False) |
|
|||
203 |
|
||||
204 | dirstate = repo.dirstate |
|
|||
205 | for file, flags, msg in actions: |
|
|||
206 | dirstate.normal(file) |
|
|||
207 |
|
||||
208 | profiles = sparse.activeprofiles(repo) |
|
|||
209 | changedprofiles = profiles & files |
|
|||
210 | # If an active profile changed during the update, refresh the checkout. |
|
|||
211 | # Don't do this during a branch merge, since all incoming changes should |
|
|||
212 | # have been handled by the temporary includes above. |
|
|||
213 | if changedprofiles and not branchmerge: |
|
|||
214 | mf = mctx.manifest() |
|
|||
215 | for file in mf: |
|
|||
216 | old = oldsparsematch(file) |
|
|||
217 | new = sparsematch(file) |
|
|||
218 | if not old and new: |
|
|||
219 | flags = mf.flags(file) |
|
|||
220 | prunedactions[file] = ('g', (flags, False), '') |
|
|||
221 | elif old and not new: |
|
|||
222 | prunedactions[file] = ('r', [], '') |
|
|||
223 |
|
||||
224 | return prunedactions, diverge, renamedelete |
|
|||
225 |
|
||||
226 | extensions.wrapfunction(mergemod, 'calculateupdates', _calculateupdates) |
|
|||
227 |
|
142 | |||
228 | def _setupcommit(ui): |
|
143 | def _setupcommit(ui): | |
229 | def _refreshoncommit(orig, self, node): |
|
144 | def _refreshoncommit(orig, self, node): |
@@ -300,3 +300,87 b' def matcher(repo, revs=None, includetemp' | |||||
300 | repo._sparsematchercache[key] = result |
|
300 | repo._sparsematchercache[key] = result | |
301 |
|
301 | |||
302 | return result |
|
302 | return result | |
|
303 | ||||
|
304 | def calculateupdates(orig, repo, wctx, mctx, ancestors, branchmerge, *arg, | |||
|
305 | **kwargs): | |||
|
306 | """Filter updates to only lay out files that match the sparse rules. | |||
|
307 | """ | |||
|
308 | actions, diverge, renamedelete = orig(repo, wctx, mctx, ancestors, | |||
|
309 | branchmerge, *arg, **kwargs) | |||
|
310 | ||||
|
311 | oldrevs = [pctx.rev() for pctx in wctx.parents()] | |||
|
312 | oldsparsematch = matcher(repo, oldrevs) | |||
|
313 | ||||
|
314 | if oldsparsematch.always(): | |||
|
315 | return actions, diverge, renamedelete | |||
|
316 | ||||
|
317 | files = set() | |||
|
318 | prunedactions = {} | |||
|
319 | ||||
|
320 | if branchmerge: | |||
|
321 | # If we're merging, use the wctx filter, since we're merging into | |||
|
322 | # the wctx. | |||
|
323 | sparsematch = matcher(repo, [wctx.parents()[0].rev()]) | |||
|
324 | else: | |||
|
325 | # If we're updating, use the target context's filter, since we're | |||
|
326 | # moving to the target context. | |||
|
327 | sparsematch = matcher(repo, [mctx.rev()]) | |||
|
328 | ||||
|
329 | temporaryfiles = [] | |||
|
330 | for file, action in actions.iteritems(): | |||
|
331 | type, args, msg = action | |||
|
332 | files.add(file) | |||
|
333 | if sparsematch(file): | |||
|
334 | prunedactions[file] = action | |||
|
335 | elif type == 'm': | |||
|
336 | temporaryfiles.append(file) | |||
|
337 | prunedactions[file] = action | |||
|
338 | elif branchmerge: | |||
|
339 | if type != 'k': | |||
|
340 | temporaryfiles.append(file) | |||
|
341 | prunedactions[file] = action | |||
|
342 | elif type == 'f': | |||
|
343 | prunedactions[file] = action | |||
|
344 | elif file in wctx: | |||
|
345 | prunedactions[file] = ('r', args, msg) | |||
|
346 | ||||
|
347 | if len(temporaryfiles) > 0: | |||
|
348 | repo.ui.status(_('temporarily included %d file(s) in the sparse ' | |||
|
349 | 'checkout for merging\n') % len(temporaryfiles)) | |||
|
350 | addtemporaryincludes(repo, temporaryfiles) | |||
|
351 | ||||
|
352 | # Add the new files to the working copy so they can be merged, etc | |||
|
353 | actions = [] | |||
|
354 | message = 'temporarily adding to sparse checkout' | |||
|
355 | wctxmanifest = repo[None].manifest() | |||
|
356 | for file in temporaryfiles: | |||
|
357 | if file in wctxmanifest: | |||
|
358 | fctx = repo[None][file] | |||
|
359 | actions.append((file, (fctx.flags(), False), message)) | |||
|
360 | ||||
|
361 | typeactions = collections.defaultdict(list) | |||
|
362 | typeactions['g'] = actions | |||
|
363 | mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], | |||
|
364 | False) | |||
|
365 | ||||
|
366 | dirstate = repo.dirstate | |||
|
367 | for file, flags, msg in actions: | |||
|
368 | dirstate.normal(file) | |||
|
369 | ||||
|
370 | profiles = activeprofiles(repo) | |||
|
371 | changedprofiles = profiles & files | |||
|
372 | # If an active profile changed during the update, refresh the checkout. | |||
|
373 | # Don't do this during a branch merge, since all incoming changes should | |||
|
374 | # have been handled by the temporary includes above. | |||
|
375 | if changedprofiles and not branchmerge: | |||
|
376 | mf = mctx.manifest() | |||
|
377 | for file in mf: | |||
|
378 | old = oldsparsematch(file) | |||
|
379 | new = sparsematch(file) | |||
|
380 | if not old and new: | |||
|
381 | flags = mf.flags(file) | |||
|
382 | prunedactions[file] = ('g', (flags, False), '') | |||
|
383 | elif old and not new: | |||
|
384 | prunedactions[file] = ('r', [], '') | |||
|
385 | ||||
|
386 | return prunedactions, diverge, renamedelete |
General Comments 0
You need to be logged in to leave comments.
Login now