Patchwork [1,of,5,mergedriver] merge.recordactions: don't require action keys to be present in dict

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 23, 2015, 6 a.m.
Message ID <27d5817b6f00bf4e5035.1448258447@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11593/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 23, 2015, 6 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447653346 28800
#      Sun Nov 15 21:55:46 2015 -0800
# Node ID 27d5817b6f00bf4e50351586c78809a9a8eed00a
# Parent  324708162fef045b07f36ea675848cebe707c5e2
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 27d5817b6f00
merge.recordactions: don't require action keys to be present in dict

We're going to use this function for a much smaller set of actions in the next
patch. It's easier to do this than to backfill the dict we pass in.
Martin von Zweigbergk - Nov. 23, 2015, 6:06 p.m.
On Sun, Nov 22, 2015 at 10:02 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447653346 28800
> #      Sun Nov 15 21:55:46 2015 -0800
> # Node ID 27d5817b6f00bf4e50351586c78809a9a8eed00a
> # Parent  324708162fef045b07f36ea675848cebe707c5e2
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 27d5817b6f00
> merge.recordactions: don't require action keys to be present in dict
>

I'm assuming s/recordactions/recordupates/. Fixing in flight.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1131,38 +1131,38 @@  def applyupdates(repo, actions, wctx, mc
 def recordupdates(repo, actions, branchmerge):
     "record merge actions to the dirstate"
     # remove (must come first)
-    for f, args, msg in actions['r']:
+    for f, args, msg in actions.get('r', []):
         if branchmerge:
             repo.dirstate.remove(f)
         else:
             repo.dirstate.drop(f)
 
     # forget (must come first)
-    for f, args, msg in actions['f']:
+    for f, args, msg in actions.get('f', []):
         repo.dirstate.drop(f)
 
     # re-add
-    for f, args, msg in actions['a']:
+    for f, args, msg in actions.get('a', []):
         if not branchmerge:
             repo.dirstate.add(f)
 
     # exec change
-    for f, args, msg in actions['e']:
+    for f, args, msg in actions.get('e', []):
         repo.dirstate.normallookup(f)
 
     # keep
-    for f, args, msg in actions['k']:
+    for f, args, msg in actions.get('k', []):
         pass
 
     # get
-    for f, args, msg in actions['g']:
+    for f, args, msg in actions.get('g', []):
         if branchmerge:
             repo.dirstate.otherparent(f)
         else:
             repo.dirstate.normal(f)
 
     # merge
-    for f, args, msg in actions['m']:
+    for f, args, msg in actions.get('m', []):
         f1, f2, fa, move, anc = args
         if branchmerge:
             # We've done a branch merge, mark this file as merged
@@ -1187,7 +1187,7 @@  def recordupdates(repo, actions, branchm
                 repo.dirstate.drop(f1)
 
     # directory rename, move local
-    for f, args, msg in actions['dm']:
+    for f, args, msg in actions.get('dm', []):
         f0, flag = args
         if branchmerge:
             repo.dirstate.add(f)
@@ -1198,7 +1198,7 @@  def recordupdates(repo, actions, branchm
             repo.dirstate.drop(f0)
 
     # directory rename, get
-    for f, args, msg in actions['dg']:
+    for f, args, msg in actions.get('dg', []):
         f0, flag = args
         if branchmerge:
             repo.dirstate.add(f)