[Updated] D8830: mergeresult: introduce action -> (filename, data, msg) mapping and related API
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sun Aug 2 17:46:22 UTC 2020
Closed by commit rHG69691c5b8ce4: mergeresult: introduce action -> (filename, data, msg) mapping and related API (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8830?vs=22117&id=22213
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8830/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8830
AFFECTED FILES
mercurial/merge.py
CHANGE DETAILS
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -7,6 +7,7 @@
from __future__ import absolute_import
+import collections
import errno
import stat
import struct
@@ -564,11 +565,14 @@
deleted on one side and renamed on other.
commitinfo: dict containing data which should be used on commit
contains a filename -> info mapping
+ actionmapping: dict of action names as keys and list of files and
+ related data as values
"""
self._filemapping = {}
self._diverge = {}
self._renamedelete = {}
self._commitinfo = {}
+ self._actionmapping = collections.defaultdict(list)
def updatevalues(self, diverge, renamedelete, commitinfo):
self._diverge = diverge
@@ -583,12 +587,33 @@
data: a tuple of information like fctx and ctx related to this merge
message: a message about the merge
"""
+ # if the file already existed, we need to delete it's old
+ # entry form _actionmapping too
+ if filename in self._filemapping:
+ # TODO: this is inefficient
+ a, d, m = self._filemapping[filename]
+ self._actionmapping[a].remove((filename, d, m))
+
self._filemapping[filename] = (action, data, message)
+ self._actionmapping[action].append((filename, data, message))
def removefile(self, filename):
""" removes a file from the mergeresult object as the file might
not merging anymore """
+ action, data, message = self._filemapping[filename]
del self._filemapping[filename]
+ # TODO: this is inefficient
+ self._actionmapping[action].remove((filename, data, message))
+
+ def getactions(self, actions):
+ """ get list of files which are marked with these actions
+
+ Returns a list of tuple of form (filename, data, message)
+ """
+ res = []
+ for a in actions:
+ res.extend(self._actionmapping[a])
+ return res
@property
def actions(self):
@@ -610,20 +635,17 @@
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 """
- # Convert to dictionary-of-lists format
- actions = emptyactions()
- for f, (m, args, msg) in pycompat.iteritems(self._filemapping):
- if m not in actions:
- actions[m] = []
- actions[m].append((f, args, msg))
-
- return actions
+ return self._actionmapping
def setactions(self, actions):
self._filemapping = actions
+ self._actionmapping = collections.defaultdict(list)
+ for f, (act, data, msg) in pycompat.iteritems(self._filemapping):
+ self._actionmapping[act].append((f, data, msg))
def updateactions(self, updates):
- self._filemapping.update(updates)
+ for f, (a, data, msg) in pycompat.iteritems(updates):
+ self.addfile(f, a, data, msg)
def hasconflicts(self):
""" tells whether this merge resulted in some actions which can
To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200802/22ae8c5c/attachment-0002.html>
More information about the Mercurial-patches
mailing list