comparison mercurial/sparse.py @ 41039:54c3b4bd01f2

merge: extract helper for creating empty "actions" dict Replicating the set of actions in multiple places is bad. Differential Revision: https://phab.mercurial-scm.org/D5472
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 21 Dec 2018 09:48:30 -0800
parents 9db856446298
children 0bd56c291359
comparison
equal deleted inserted replaced
41038:3913223417ea 41039:54c3b4bd01f2
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 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import collections
11 import hashlib 10 import hashlib
12 import os 11 import os
13 12
14 from .i18n import _ 13 from .i18n import _
15 from .node import ( 14 from .node import (
245 if file in dirstate and not sparsematch(file): 244 if file in dirstate and not sparsematch(file):
246 message = _('dropping temporarily included sparse files') 245 message = _('dropping temporarily included sparse files')
247 actions.append((file, None, message)) 246 actions.append((file, None, message))
248 dropped.append(file) 247 dropped.append(file)
249 248
250 typeactions = collections.defaultdict(list) 249 typeactions = mergemod.emptyactions()
251 typeactions['r'] = actions 250 typeactions['r'] = actions
252 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False) 251 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)
253 252
254 # Fix dirstate 253 # Fix dirstate
255 for file in dropped: 254 for file in dropped:
378 for file in temporaryfiles: 377 for file in temporaryfiles:
379 if file in wctxmanifest: 378 if file in wctxmanifest:
380 fctx = repo[None][file] 379 fctx = repo[None][file]
381 actions.append((file, (fctx.flags(), False), message)) 380 actions.append((file, (fctx.flags(), False), message))
382 381
383 typeactions = collections.defaultdict(list) 382 typeactions = mergemod.emptyactions()
384 typeactions['g'] = actions 383 typeactions['g'] = actions
385 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], 384 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'],
386 False) 385 False)
387 386
388 dirstate = repo.dirstate 387 dirstate = repo.dirstate
481 new = sparsematch(file) 480 new = sparsematch(file)
482 if old and not new: 481 if old and not new:
483 dropped.append(file) 482 dropped.append(file)
484 483
485 # Apply changes to disk 484 # Apply changes to disk
486 typeactions = dict((m, []) 485 typeactions = mergemod.emptyactions()
487 for m in 'a f g am cd dc r dm dg m e k p pr'.split())
488 for f, (m, args, msg) in actions.iteritems(): 486 for f, (m, args, msg) in actions.iteritems():
489 if m not in typeactions:
490 typeactions[m] = []
491 typeactions[m].append((f, args, msg)) 487 typeactions[m].append((f, args, msg))
492 488
493 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False) 489 mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)
494 490
495 # Fix dirstate 491 # Fix dirstate