From patchwork Tue Feb 23 19:52:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 8] changegroup: write root manifests and subdir manifests in a single loop From: Martin von Zweigbergk X-Patchwork-Id: 13329 Message-Id: <54d19d993e13b9edabba.1456257151@martinvonz.mtv.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Tue, 23 Feb 2016 11:52:31 -0800 # HG changeset patch # User Martin von Zweigbergk # Date 1455348618 28800 # Fri Feb 12 23:30:18 2016 -0800 # Node ID 54d19d993e13b9edabbabc518a99c47d75c85f76 # Parent 85c69fa32772e880d3a682e9cc031feaefc2963a changegroup: write root manifests and subdir manifests in a single loop This is another step towards making the manifest generation recurse along the directory trees. The loop over 'tmfnodes' now takes the form of a queue. At this point, we only add to the queue twice: we add the root manifests, and, while visiting the root manifest revisions, we add all subdirectory revisions (for treemanifest repos). Thus, any iterations over 'tmfnodes' after the first will not add any items and the "queue" will just keep shrinking. diff -r 85c69fa32772 -r 54d19d993e13 mercurial/changegroup.py --- a/mercurial/changegroup.py Fri Feb 12 23:26:15 2016 -0800 +++ b/mercurial/changegroup.py Fri Feb 12 23:30:18 2016 -0800 @@ -756,7 +756,7 @@ mfchangedfiles, fnodes): repo = self._repo ml = repo.manifest - tmfnodes = {} + tmfnodes = {'': mfs} # Callback for the manifest, used to collect linkrevs for filelog # revisions. @@ -825,17 +825,16 @@ return clnode return lookupmflinknode - mfnodes = self.prune(ml, mfs, commonrevs) size = 0 - for x in self._packmanifests('', mfnodes, makelookupmflinknode('')): - size += len(x) - yield x - for dir, nodes in tmfnodes.iteritems(): + while tmfnodes: + dir = min(tmfnodes) + nodes = tmfnodes[dir] prunednodes = self.prune(ml.dirlog(dir), nodes, commonrevs) for x in self._packmanifests(dir, prunednodes, makelookupmflinknode(dir)): size += len(x) yield x + del tmfnodes[dir] self._verbosenote(_('%8.i (manifests)\n') % size) yield self._manifestsdone()