changeset 20996:ed3c5e18a047

bundle2: add reply awareness to unbundlerecords We need an efficient way to handle bundle replies. The unbundle records class is extended to carry such data.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 11 Apr 2014 08:24:59 -0700
parents e995d104c87f
children d7df4b7378ae
files mercurial/bundle2.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Tue Apr 01 00:07:17 2014 -0700
+++ b/mercurial/bundle2.py	Fri Apr 11 08:24:59 2014 -0700
@@ -205,14 +205,21 @@
     def __init__(self):
         self._categories = {}
         self._sequences = []
+        self._replies = {}
 
-    def add(self, category, entry):
+    def add(self, category, entry, inreplyto=None):
         """add a new record of a given category.
 
         The entry can then be retrieved in the list returned by
         self['category']."""
         self._categories.setdefault(category, []).append(entry)
         self._sequences.append((category, entry))
+        if inreplyto is not None:
+            self.getreplies(inreplyto).add(category, entry)
+
+    def getreplies(self, partid):
+        """get the subrecords that replies to a specific part"""
+        return self._replies.setdefault(partid, unbundlerecords())
 
     def __getitem__(self, cat):
         return tuple(self._categories.get(cat, ()))