From patchwork Fri Apr 11 22:05:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,8] bundle2: add replies awareness to unbundlerecords From: Pierre-Yves David X-Patchwork-Id: 4285 Message-Id: <45371a6d56d2fe379693.1397253959@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Fri, 11 Apr 2014 18:05:59 -0400 # HG changeset patch # User Pierre-Yves David # 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):