Patchwork [2,of,2] unbundle: support bundle2 files

login
register
mail settings
Submitter Eric Sumner
Date Jan. 16, 2015, 9:06 p.m.
Message ID <3ecd9bb7ceb56001d4f7.1421442366@dev911.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7496/
State Superseded
Headers show

Comments

Eric Sumner - Jan. 16, 2015, 9:06 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@fb.com>
# Date 1421284195 28800
#      Wed Jan 14 17:09:55 2015 -0800
# Node ID 3ecd9bb7ceb56001d4f71f30480576ea086b38ee
# Parent  27a61fc3498b0bae606cbc92801a9103015090d4
unbundle: support bundle2 files

This adds support for bundle2 files to the unbundle command.
Eric Sumner - Jan. 16, 2015, 9:07 p.m.
Sorry; these should have been tagged v2

  -- Eric

On 1/16/15, 1:06 PM, "Eric Sumner" <ericsumner@fb.com> wrote:

># HG changeset patch
># User Eric Sumner <ericsumner@fb.com>
># Date 1421284195 28800
>#      Wed Jan 14 17:09:55 2015 -0800
># Node ID 3ecd9bb7ceb56001d4f71f30480576ea086b38ee
># Parent  27a61fc3498b0bae606cbc92801a9103015090d4
>unbundle: support bundle2 files
>
>This adds support for bundle2 files to the unbundle command.
>
>diff --git a/mercurial/commands.py b/mercurial/commands.py
>--- a/mercurial/commands.py
>+++ b/mercurial/commands.py
>@@ -6143,8 +6143,20 @@
>         for fname in fnames:
>             f = hg.openpath(ui, fname)
>             gen = exchange.readbundle(ui, f, fname)
>-            modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
>-                                                  'bundle:' + fname)
>+            if isinstance(gen, bundle2.unbundle20):
>+                tr = repo.transaction('unbundle')
>+                try:
>+                    op = bundle2.processbundle(repo, gen, lambda: tr)
>+                    tr.close()
>+                finally:
>+                    if tr:
>+                        tr.release()
>+                changes = [r.get('result', 0)
>+                           for r in op.records['changegroup']]
>+                modheads = changegroup.combineresults(changes)
>+            else:
>+                modheads = changegroup.addchangegroup(repo, gen,
>'unbundle',
>+                                                      'bundle:' + fname)
>     finally:
>         lock.release()
> 
>diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
>--- a/tests/test-bundle2-format.t
>+++ b/tests/test-bundle2-format.t
>@@ -762,13 +762,11 @@
>       9520eea781bcca16c1e15acc0ba14335a0e8e5ba
>       eea13746799a9e0bfd88f29d3c2e9dc9389f524f
>       02de42196ebee42ef284b6780a87cdc96e8eaab6
>-  $ hg unbundle2 < ../rev.hg2
>+  $ hg unbundle ../rev.hg2
>   adding changesets
>   adding manifests
>   adding file changes
>   added 0 changesets with 0 changes to 3 files
>-  0 unread bytes
>-  addchangegroup return: 1
> 
> with reply
> 
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel@selenic.com
>http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6143,8 +6143,20 @@ 
         for fname in fnames:
             f = hg.openpath(ui, fname)
             gen = exchange.readbundle(ui, f, fname)
-            modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
-                                                  'bundle:' + fname)
+            if isinstance(gen, bundle2.unbundle20):
+                tr = repo.transaction('unbundle')
+                try:
+                    op = bundle2.processbundle(repo, gen, lambda: tr)
+                    tr.close()
+                finally:
+                    if tr:
+                        tr.release()
+                changes = [r.get('result', 0)
+                           for r in op.records['changegroup']]
+                modheads = changegroup.combineresults(changes)
+            else:
+                modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
+                                                      'bundle:' + fname)
     finally:
         lock.release()
 
diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -762,13 +762,11 @@ 
       9520eea781bcca16c1e15acc0ba14335a0e8e5ba
       eea13746799a9e0bfd88f29d3c2e9dc9389f524f
       02de42196ebee42ef284b6780a87cdc96e8eaab6
-  $ hg unbundle2 < ../rev.hg2
+  $ hg unbundle ../rev.hg2
   adding changesets
   adding manifests
   adding file changes
   added 0 changesets with 0 changes to 3 files
-  0 unread bytes
-  addchangegroup return: 1
 
 with reply