Patchwork [5,of,9,V3] mergestate: update _stateextras instead of reassinging

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 28, 2020, 6:29 a.m.
Message ID <f8e3bc0c10b22350994a.1601274557@workspace>
Download mbox | patch
Permalink /patch/47302/
State Accepted
Headers show

Comments

Pulkit Goyal - Sept. 28, 2020, 6:29 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1601022485 -19800
#      Fri Sep 25 13:58:05 2020 +0530
# Node ID f8e3bc0c10b22350994af28e86b11ae34ff04fc4
# Parent  b3bee7c363ff2c24ad2bf48359f300c7e9026aca
# EXP-Topic merge-newnode-final
mergestate: update _stateextras instead of reassinging

`merge.applyupdates()` can store extras for a file and _stateextras may not be
empty always. Hence reassigning loses the old values.

We can directly update like this because we switched to using
`collections.defaultdict` for `_stateextras` sometime ago.

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -261,7 +261,7 @@  class _mergestate_base(object):
             hex(fco.filenode()),
             fcl.flags(),
         ]
-        self._stateextras[fd] = {b'ancestorlinknode': hex(fca.node())}
+        self._stateextras[fd][b'ancestorlinknode'] = hex(fca.node())
         self._dirty = True
 
     def addpathconflict(self, path, frename, forigin):