Patchwork D8903: merge: remove emptyactions() and use collections.defaultdict(list) instead

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2020, 11:18 a.m.
Message ID <differential-rev-PHID-DREV-ghgix5jxyxcisdk3b4w5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47002/
State Superseded
Headers show

Comments

phabricator - Aug. 6, 2020, 11:18 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  emptyactions() used to return a dict which was populated and passed into
  applyupdates(). However, with recent changes, we no longer pass a plain dict,
  instead we pass the mergeresult object.
  
  There was only one usage of emptyactions and that too inside mergeresult object.
  That usage is replaced with collections.defaultdict(list) instead.
  
  Not sure why we were not using collections.defaultdict(list) from the beginning.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8903

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/merge.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -687,7 +687,7 @@ 
     def actionsdict(self):
         """ returns a dictionary of actions to be perfomed with action as key
         and a list of files and related arguments as values """
-        res = emptyactions()
+        res = collections.defaultdict(list)
         for a, d in pycompat.iteritems(self._actionmapping):
             for f, (args, msg) in pycompat.iteritems(d):
                 res[a].append((f, args, msg))
@@ -1338,29 +1338,6 @@ 
         )
 
 
-def emptyactions():
-    """create an actions dict, to be populated and passed to applyupdates()"""
-    return {
-        m: []
-        for m in (
-            mergestatemod.ACTION_ADD,
-            mergestatemod.ACTION_ADD_MODIFIED,
-            mergestatemod.ACTION_FORGET,
-            mergestatemod.ACTION_GET,
-            mergestatemod.ACTION_CHANGED_DELETED,
-            mergestatemod.ACTION_DELETED_CHANGED,
-            mergestatemod.ACTION_REMOVE,
-            mergestatemod.ACTION_DIR_RENAME_MOVE_LOCAL,
-            mergestatemod.ACTION_LOCAL_DIR_RENAME_GET,
-            mergestatemod.ACTION_MERGE,
-            mergestatemod.ACTION_EXEC,
-            mergestatemod.ACTION_KEEP,
-            mergestatemod.ACTION_PATH_CONFLICT,
-            mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
-        )
-    }
-
-
 def applyupdates(
     repo,
     mresult,
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -497,14 +497,6 @@ 
         orig(ui, repo, *pats, **opts)
 
 
-# Register the MERGE_ACTION_LARGEFILE_MARK_REMOVED in emptyactions() return type
-@eh.wrapfunction(merge, b'emptyactions')
-def overrideemptyactions(origfn):
-    ret = origfn()
-    ret[MERGE_ACTION_LARGEFILE_MARK_REMOVED] = []
-    return ret
-
-
 # Before starting the manifest merge, merge.updates will call
 # _checkunknownfile to check if there are any files in the merged-in
 # changeset that collide with unknown files in the working copy.