diff 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
line wrap: on
line diff
--- a/mercurial/sparse.py	Mon Dec 03 22:22:23 2018 -0800
+++ b/mercurial/sparse.py	Fri Dec 21 09:48:30 2018 -0800
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import
 
-import collections
 import hashlib
 import os
 
@@ -247,7 +246,7 @@
             actions.append((file, None, message))
             dropped.append(file)
 
-    typeactions = collections.defaultdict(list)
+    typeactions = mergemod.emptyactions()
     typeactions['r'] = actions
     mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)
 
@@ -380,7 +379,7 @@
                 fctx = repo[None][file]
                 actions.append((file, (fctx.flags(), False), message))
 
-        typeactions = collections.defaultdict(list)
+        typeactions = mergemod.emptyactions()
         typeactions['g'] = actions
         mergemod.applyupdates(repo, typeactions, repo[None], repo['.'],
                               False)
@@ -483,11 +482,8 @@
                 dropped.append(file)
 
     # Apply changes to disk
-    typeactions = dict((m, [])
-                       for m in 'a f g am cd dc r dm dg m e k p pr'.split())
+    typeactions = mergemod.emptyactions()
     for f, (m, args, msg) in actions.iteritems():
-        if m not in typeactions:
-            typeactions[m] = []
         typeactions[m].append((f, args, msg))
 
     mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)