[PATCH 4 of 4 RFC stream clone bundles] commands.unbundle: support consuming streaming clone bundles

Gregory Szorc gregory.szorc at gmail.com
Wed Oct 14 17:34:03 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1444861540 25200
#      Wed Oct 14 15:25:40 2015 -0700
# Node ID c927f2b34d0a420d074152464e854901c746527a
# Parent  e577b42c94d917eb3fbbe866bf66e455a251bb1b
commands.unbundle: support consuming streaming clone bundles

Now that we can produce streaming clone bundles `hg bundle`, it makes
sense to support consuming them with `hg unbundle` too.

We don't need to perform any sanity checking in the command because the
application code in clonebundles.py does this. So the integration here
is pretty simple.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6530,8 +6530,11 @@ def unbundle(ui, repo, fname1, *fnames, 
                         tr.release()
                 changes = [r.get('return', 0)
                            for r in op.records['changegroup']]
                 modheads = changegroup.combineresults(changes)
+            elif isinstance(gen, streamclone.unbundler):
+                gen.apply(repo)
+                modheads = len(repo.heads())
             else:
                 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
                                                       'bundle:' + fname)
     finally:
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -277,8 +277,22 @@ packed1 is produced properly
   0010: 00 00 00 00 0a 30 00 09 72 65 76 6c 6f 67 76 31 |.....0..revlogv1|
   0020: 00 64 61 74 61 2f 61 64 69 66 66 65 72 65 6e 74 |.data/adifferent|
   0030: 66 69 6c 65 2e 69 00 31 33 39 0a 00 01 00 01 00 |file.i.139......|
 
+We can unpack packed1 bundles
+
+  $ hg init packed
+  $ hg -R packed unbundle packed.hg
+  6 files to transfer, 2.55 KB of data
+  transferred 2.55 KB in *.* seconds (*/sec) (glob)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+
+We can't unpack packed1 bundles on non-empty repos
+
+  $ hg -R packed unbundle packed.hg
+  abort: cannot apply stream clone bundle on non-empty repo
+  [255]
+
 Create partial clones
 
   $ rm -r empty
   $ hg init empty


More information about the Mercurial-devel mailing list