##// END OF EJS Templates
merge: extract helper for creating empty "actions" dict...
Martin von Zweigbergk -
r41068:54c3b4bd default
parent child Browse files
Show More
@@ -316,7 +316,7 b' def _widen(ui, repo, remote, commoninc, '
316 transactiongetter=tgetter)
316 transactiongetter=tgetter)
317
317
318 repo.setnewnarrowpats()
318 repo.setnewnarrowpats()
319 actions = {k: [] for k in 'a am f g cd dc r dm dg m e k p pr'.split()}
319 actions = merge.emptyactions()
320 addgaction = actions['g'].append
320 addgaction = actions['g'].append
321
321
322 mf = repo['.'].manifest().matches(newmatch)
322 mf = repo['.'].manifest().matches(newmatch)
@@ -1541,6 +1541,25 b' class updateresult(object):'
1541 return (not self.updatedcount and not self.mergedcount
1541 return (not self.updatedcount and not self.mergedcount
1542 and not self.removedcount and not self.unresolvedcount)
1542 and not self.removedcount and not self.unresolvedcount)
1543
1543
1544 def emptyactions():
1545 """create an actions dict, to be populated and passed to applyupdates()"""
1546 return dict((m, [])
1547 for m in (
1548 ACTION_ADD,
1549 ACTION_ADD_MODIFIED,
1550 ACTION_FORGET,
1551 ACTION_GET,
1552 ACTION_CHANGED_DELETED,
1553 ACTION_DELETED_CHANGED,
1554 ACTION_REMOVE,
1555 ACTION_DIR_RENAME_MOVE_LOCAL,
1556 ACTION_LOCAL_DIR_RENAME_GET,
1557 ACTION_MERGE,
1558 ACTION_EXEC,
1559 ACTION_KEEP,
1560 ACTION_PATH_CONFLICT,
1561 ACTION_PATH_CONFLICT_RESOLVE))
1562
1544 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
1563 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
1545 """apply the merge action list to the working directory
1564 """apply the merge action list to the working directory
1546
1565
@@ -2090,22 +2109,7 b' def update(repo, node, branchmerge, forc'
2090 del actionbyfile[f]
2109 del actionbyfile[f]
2091
2110
2092 # Convert to dictionary-of-lists format
2111 # Convert to dictionary-of-lists format
2093 actions = dict((m, [])
2112 actions = emptyactions()
2094 for m in (
2095 ACTION_ADD,
2096 ACTION_ADD_MODIFIED,
2097 ACTION_FORGET,
2098 ACTION_GET,
2099 ACTION_CHANGED_DELETED,
2100 ACTION_DELETED_CHANGED,
2101 ACTION_REMOVE,
2102 ACTION_DIR_RENAME_MOVE_LOCAL,
2103 ACTION_LOCAL_DIR_RENAME_GET,
2104 ACTION_MERGE,
2105 ACTION_EXEC,
2106 ACTION_KEEP,
2107 ACTION_PATH_CONFLICT,
2108 ACTION_PATH_CONFLICT_RESOLVE))
2109 for f, (m, args, msg) in actionbyfile.iteritems():
2113 for f, (m, args, msg) in actionbyfile.iteritems():
2110 if m not in actions:
2114 if m not in actions:
2111 actions[m] = []
2115 actions[m] = []
@@ -7,7 +7,6 b''
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
@@ -247,7 +246,7 b' def prunetemporaryincludes(repo):'
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
@@ -380,7 +379,7 b' def filterupdatesactions(repo, wctx, mct'
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)
@@ -483,11 +482,8 b' def refreshwdir(repo, origstatus, origsp'
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)
General Comments 0
You need to be logged in to leave comments. Login now