Patchwork changegroup: don't send empty subdirectory manifest groups

login
register
mail settings
Submitter via Mercurial-devel
Date June 16, 2016, 11:21 p.m.
Message ID <70dd155d8fc45406d15a.1466119312@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/15531/
State Accepted
Headers show

Comments

via Mercurial-devel - June 16, 2016, 11:21 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1466115333 25200
#      Thu Jun 16 15:15:33 2016 -0700
# Node ID 70dd155d8fc45406d15a281c8bb5212cd7d2095b
# Parent  f652e84f23f2ea6fa6464d6a4782bf58b502d38a
changegroup: don't send empty subdirectory manifest groups

When grafting/rebasing, it is common for multiple changesets to make
the same change to a subdirectory. When writing the revlog for the
directory, the revlog code already takes care of not writing the entry
again. In 0c2a088ffcc5 (changegroup: prune subdirectory dirlogs too,
2016-02-12), I added the corresponding code in changegroup (not
sending entries the client already has), but I forgot to avoid sending
the entire changegroup if no nodes remained in the pruned
set. Although that's harmless besides the wasted network traffic, the
receiving side was checking for it (copied from the changegroup code
for handling files). This resulted in the client crashing with:

  abort: received dir revlog group is empty

Fix by simply not emitting a changegroup for the directory if there
were no changes is it. This matches how files are handled.
Matt Mackall - June 17, 2016, 9:50 p.m.
On Thu, 2016-06-16 at 16:21 -0700, Martin von Zweigbergk via Mercurial-devel
wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1466115333 25200
> #      Thu Jun 16 15:15:33 2016 -0700
> # Node ID 70dd155d8fc45406d15a281c8bb5212cd7d2095b
> # Parent  f652e84f23f2ea6fa6464d6a4782bf58b502d38a
> changegroup: don't send empty subdirectory manifest groups

Queued for default, thanks.
-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff -r f652e84f23f2 -r 70dd155d8fc4 mercurial/changegroup.py
--- a/mercurial/changegroup.py	Sat Jun 11 10:17:49 2016 +0900
+++ b/mercurial/changegroup.py	Thu Jun 16 15:15:33 2016 -0700
@@ -728,10 +728,11 @@ 
             dir = min(tmfnodes)
             nodes = tmfnodes[dir]
             prunednodes = self.prune(dirlog(dir), nodes, commonrevs)
-            for x in self._packmanifests(dir, prunednodes,
-                                         makelookupmflinknode(dir)):
-                size += len(x)
-                yield x
+            if not dir or prunednodes:
+                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()
diff -r f652e84f23f2 -r 70dd155d8fc4 tests/test-treemanifest.t
--- a/tests/test-treemanifest.t	Sat Jun 11 10:17:49 2016 +0900
+++ b/tests/test-treemanifest.t	Thu Jun 16 15:15:33 2016 -0700
@@ -742,3 +742,45 @@ 
   $ hg -R deeprepo bundle --all -t v2 deeprepo.bundle
   abort: repository does not support bundle version 02
   [255]
+
+Pull does not include changegroup for manifest the client already has from
+other branch
+
+  $ mkdir grafted-dir-repo
+  $ cd grafted-dir-repo
+  $ hg --config experimental.treemanifest=1 init
+  $ mkdir dir
+  $ echo a > dir/file
+  $ echo a > file
+  $ hg ci -Am initial
+  adding dir/file
+  adding file
+  $ echo b > dir/file
+  $ hg ci -m updated
+  $ hg co '.^'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg revert -r tip dir/
+  reverting dir/file (glob)
+  $ echo b > file # to make sure root manifest is sent
+  $ hg ci -m grafted
+  created new head
+  $ cd ..
+
+  $ hg --config experimental.treemanifest=1 clone --pull -r 1 \
+  >   grafted-dir-repo grafted-dir-repo-clone
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 3 changes to 2 files
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd grafted-dir-repo-clone
+  $ hg pull -r 2
+  pulling from $TESTTMP/grafted-dir-repo (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+