[PATCH 2 of 8] bundle2: add replies awareness to unbundlerecords
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Fri Apr 11 22:05:59 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1397229899 25200
# Fri Apr 11 08:24:59 2014 -0700
# Node ID 45371a6d56d2fe379693c898d0f5374cd7a00f2b
# Parent e5ac0c58e81ac8fc28a8a69ae0bc96b33acde5f4
bundle2: add replies awareness to unbundlerecords
We need an efficient was to handle bundle replies. The unbundle records class is
extended to carry such data.
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -203,18 +203,25 @@ class unbundlerecords(object):
"""
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, ()))
def __iter__(self):
More information about the Mercurial-devel
mailing list