Patchwork [3,of,3] shelve: bundle using bundle2 if repository is general delta

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 2, 2015, 2:44 a.m.
Message ID <16416ec34180cfaf51e1.1443753878@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10726/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 2, 2015, 2:44 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443737280 25200
#      Thu Oct 01 15:08:00 2015 -0700
# Node ID 16416ec34180cfaf51e17b88bd63c4fa55263f77
# Parent  4e7207b283fe09b167d1c8ac0403e5e724963522
shelve: bundle using bundle2 if repository is general delta

This will prevent expensive delta computation on bundling and is similar to what we do
for strip backup. This was tracked as issue4862.
Augie Fackler - Oct. 7, 2015, 5:34 p.m.
On Thu, Oct 01, 2015 at 07:44:38PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1443737280 25200
> #      Thu Oct 01 15:08:00 2015 -0700
> # Node ID 16416ec34180cfaf51e17b88bd63c4fa55263f77
> # Parent  4e7207b283fe09b167d1c8ac0403e5e724963522
> shelve: bundle using bundle2 if repository is general delta

queued these, thanks

>
> This will prevent expensive delta computation on bundling and is similar to what we do
> for strip backup. This was tracked as issue4862.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -104,12 +104,22 @@ class shelvedfile(object):
>
>      def bundlerepo(self):
>          return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
>                                             self.vfs.join(self.fname))
>      def writebundle(self, bases, node):
> -        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve')
> -        changegroup.writebundle(self.ui, cg, self.fname, 'HG10BZ', self.vfs)
> +        btype = 'HG10BZ'
> +        cgversion = '01'
> +        compression = None
> +        if 'generaldelta' in self.repo.requirements:
> +            btype = 'HG20'
> +            cgversion = '02'
> +            compression = 'BZ'
> +
> +        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve',
> +                                           version=cgversion)
> +        changegroup.writebundle(self.ui, cg, self.fname, btype, self.vfs,
> +                                compression=compression)
>
>  class shelvedstate(object):
>      """Handle persistence during unshelving operations.
>
>      Handles saving and restoring a shelved state. Ensures that different
> diff --git a/tests/test-shelve.t b/tests/test-shelve.t
> --- a/tests/test-shelve.t
> +++ b/tests/test-shelve.t
> @@ -952,5 +952,51 @@ shelve --patch and shelve --stat should
>    [255]
>    $ hg shelve --stat nonexistentshelf
>    abort: cannot find shelf nonexistentshelf
>    [255]
>
> +  $ cd ..
> +
> +Shelve from general delta repo use bundle2 on disk
> +--------------------------------------------------
> +
> +no general delta
> +
> +  $ hg clone --pull repo bundle1 --config format.generaldelta=0
> +  requesting all changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 5 changesets with 8 changes to 6 files
> +  updating to branch default
> +  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ cd bundle1
> +  $ echo babar > jungle
> +  $ hg add jungle
> +  $ hg shelve
> +  shelved as default
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ hg debugbundle .hg/shelved/*.hg
> +  7e30d8ac6f23cfc84330fd7e698730374615d21a
> +  $ cd ..
> +
> +with general delta
> +
> +  $ hg clone --pull repo bundle2 --config format.generaldelta=1
> +  requesting all changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 5 changesets with 8 changes to 6 files
> +  updating to branch default
> +  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ cd bundle2
> +  $ echo babar > jungle
> +  $ hg add jungle
> +  $ hg shelve
> +  shelved as default
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ hg debugbundle .hg/shelved/*.hg
> +  Stream params: {'Compression': 'BZ'}
> +  changegroup -- "{'version': '02'}"
> +      7e30d8ac6f23cfc84330fd7e698730374615d21a
> +  $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -104,12 +104,22 @@  class shelvedfile(object):
 
     def bundlerepo(self):
         return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
                                            self.vfs.join(self.fname))
     def writebundle(self, bases, node):
-        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve')
-        changegroup.writebundle(self.ui, cg, self.fname, 'HG10BZ', self.vfs)
+        btype = 'HG10BZ'
+        cgversion = '01'
+        compression = None
+        if 'generaldelta' in self.repo.requirements:
+            btype = 'HG20'
+            cgversion = '02'
+            compression = 'BZ'
+
+        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve',
+                                           version=cgversion)
+        changegroup.writebundle(self.ui, cg, self.fname, btype, self.vfs,
+                                compression=compression)
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
 
     Handles saving and restoring a shelved state. Ensures that different
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -952,5 +952,51 @@  shelve --patch and shelve --stat should 
   [255]
   $ hg shelve --stat nonexistentshelf
   abort: cannot find shelf nonexistentshelf
   [255]
 
+  $ cd ..
+
+Shelve from general delta repo use bundle2 on disk
+--------------------------------------------------
+
+no general delta
+
+  $ hg clone --pull repo bundle1 --config format.generaldelta=0
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 5 changesets with 8 changes to 6 files
+  updating to branch default
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd bundle1
+  $ echo babar > jungle
+  $ hg add jungle
+  $ hg shelve
+  shelved as default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg debugbundle .hg/shelved/*.hg
+  7e30d8ac6f23cfc84330fd7e698730374615d21a
+  $ cd ..
+
+with general delta
+
+  $ hg clone --pull repo bundle2 --config format.generaldelta=1
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 5 changesets with 8 changes to 6 files
+  updating to branch default
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd bundle2
+  $ echo babar > jungle
+  $ hg add jungle
+  $ hg shelve
+  shelved as default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg debugbundle .hg/shelved/*.hg
+  Stream params: {'Compression': 'BZ'}
+  changegroup -- "{'version': '02'}"
+      7e30d8ac6f23cfc84330fd7e698730374615d21a
+  $ cd ..