Patchwork [2,of,2] bundlerepo: add support for treemanifests in cg3 bundles

login
register
mail settings
Submitter Augie Fackler
Date Aug. 4, 2016, 6:17 p.m.
Message ID <781e56c61c17a07164cd.1470334666@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/16093/
State Changes Requested
Headers show

Comments

Augie Fackler - Aug. 4, 2016, 6:17 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1470334433 14400
#      Thu Aug 04 14:13:53 2016 -0400
# Node ID 781e56c61c17a07164cd7cbcd4b319ce2ded511f
# Parent  c6da11db73e97aceabcc85c9f5bb893643bf01a7
bundlerepo: add support for treemanifests in cg3 bundles
via Mercurial-devel - Aug. 4, 2016, 6:39 p.m.
On Thu, Aug 4, 2016 at 11:17 AM, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1470334433 14400
> #      Thu Aug 04 14:13:53 2016 -0400
> # Node ID 781e56c61c17a07164cd7cbcd4b319ce2ded511f
> # Parent  c6da11db73e97aceabcc85c9f5bb893643bf01a7
> bundlerepo: add support for treemanifests in cg3 bundles
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -190,8 +190,8 @@ class bundlechangelog(bundlerevlog, chan
>              self.filteredrevs = oldfilter
>
>  class bundlemanifest(bundlerevlog, manifest.manifest):
> -    def __init__(self, opener, bundle, linkmapper):
> -        manifest.manifest.__init__(self, opener)
> +    def __init__(self, opener, bundle, linkmapper, dir=''):
> +        manifest.manifest.__init__(self, opener, dir=dir)
>          bundlerevlog.__init__(self, opener, self.indexfile, bundle,
>                                linkmapper)
>
> @@ -332,7 +332,12 @@ class bundlerepository(localrepo.localre
>          # XXX: hack to work with changegroup3, but we still don't handle
>          # tree manifests correctly

No longer valid, right?

>          if self.bundle.version == "03":
> -            self.bundle.filelogheader()
> +            dirheader = self.bundle.filelogheader()
> +            while dirheader:
> +                d = dirheader["filename"]
> +                self.bundledirlogs = bundlemanifest(
> +                    self.svfs, self.bundle, linkmapper, dir=d)
> +                dirheader = self.bundle.filelogheader()
>          self.filestart = self.bundle.tell()
>          return m
>
> diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
> --- a/tests/test-treemanifest.t
> +++ b/tests/test-treemanifest.t
> @@ -313,6 +313,15 @@ Stripping and recovering changes should
>       rev    offset  length  delta linkrev nodeid       p1           p2
>         0         0     127     -1       4 064927a0648a 000000000000 000000000000
>         1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
> +  $ hg incoming --traceback .hg/strip-backup/*

I suspect --traceback was there while you were debugging, but I think
we usually leave it from out tests.

> +  comparing with .hg/strip-backup/*-backup.hg (glob)
> +  searching for changes
> +  changeset:   6:51cfd7b1e13b
> +  tag:         tip
> +  user:        test
> +  date:        Thu Jan 01 00:00:00 1970 +0000
> +  summary:     modify dir1/a
> +

Should also be able to pull from the bundle, right? Can you add a test
for that too?

>    $ hg unbundle -q .hg/strip-backup/*
>    $ hg debugindex --dir dir1
>       rev    offset  length  delta linkrev nodeid       p1           p2
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Aug. 4, 2016, 6:42 p.m.
Good catches, v2 forthcoming.

On Thu, Aug 4, 2016 at 2:39 PM, Martin von Zweigbergk
<martinvonz@google.com> wrote:
> On Thu, Aug 4, 2016 at 11:17 AM, Augie Fackler <raf@durin42.com> wrote:
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1470334433 14400
>> #      Thu Aug 04 14:13:53 2016 -0400
>> # Node ID 781e56c61c17a07164cd7cbcd4b319ce2ded511f
>> # Parent  c6da11db73e97aceabcc85c9f5bb893643bf01a7
>> bundlerepo: add support for treemanifests in cg3 bundles
>>
>> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
>> --- a/mercurial/bundlerepo.py
>> +++ b/mercurial/bundlerepo.py
>> @@ -190,8 +190,8 @@ class bundlechangelog(bundlerevlog, chan
>>              self.filteredrevs = oldfilter
>>
>>  class bundlemanifest(bundlerevlog, manifest.manifest):
>> -    def __init__(self, opener, bundle, linkmapper):
>> -        manifest.manifest.__init__(self, opener)
>> +    def __init__(self, opener, bundle, linkmapper, dir=''):
>> +        manifest.manifest.__init__(self, opener, dir=dir)
>>          bundlerevlog.__init__(self, opener, self.indexfile, bundle,
>>                                linkmapper)
>>
>> @@ -332,7 +332,12 @@ class bundlerepository(localrepo.localre
>>          # XXX: hack to work with changegroup3, but we still don't handle
>>          # tree manifests correctly
>
> No longer valid, right?
>
>>          if self.bundle.version == "03":
>> -            self.bundle.filelogheader()
>> +            dirheader = self.bundle.filelogheader()
>> +            while dirheader:
>> +                d = dirheader["filename"]
>> +                self.bundledirlogs = bundlemanifest(
>> +                    self.svfs, self.bundle, linkmapper, dir=d)
>> +                dirheader = self.bundle.filelogheader()
>>          self.filestart = self.bundle.tell()
>>          return m
>>
>> diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
>> --- a/tests/test-treemanifest.t
>> +++ b/tests/test-treemanifest.t
>> @@ -313,6 +313,15 @@ Stripping and recovering changes should
>>       rev    offset  length  delta linkrev nodeid       p1           p2
>>         0         0     127     -1       4 064927a0648a 000000000000 000000000000
>>         1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
>> +  $ hg incoming --traceback .hg/strip-backup/*
>
> I suspect --traceback was there while you were debugging, but I think
> we usually leave it from out tests.
>
>> +  comparing with .hg/strip-backup/*-backup.hg (glob)
>> +  searching for changes
>> +  changeset:   6:51cfd7b1e13b
>> +  tag:         tip
>> +  user:        test
>> +  date:        Thu Jan 01 00:00:00 1970 +0000
>> +  summary:     modify dir1/a
>> +
>
> Should also be able to pull from the bundle, right? Can you add a test
> for that too?
>
>>    $ hg unbundle -q .hg/strip-backup/*
>>    $ hg debugindex --dir dir1
>>       rev    offset  length  delta linkrev nodeid       p1           p2
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -190,8 +190,8 @@  class bundlechangelog(bundlerevlog, chan
             self.filteredrevs = oldfilter
 
 class bundlemanifest(bundlerevlog, manifest.manifest):
-    def __init__(self, opener, bundle, linkmapper):
-        manifest.manifest.__init__(self, opener)
+    def __init__(self, opener, bundle, linkmapper, dir=''):
+        manifest.manifest.__init__(self, opener, dir=dir)
         bundlerevlog.__init__(self, opener, self.indexfile, bundle,
                               linkmapper)
 
@@ -332,7 +332,12 @@  class bundlerepository(localrepo.localre
         # XXX: hack to work with changegroup3, but we still don't handle
         # tree manifests correctly
         if self.bundle.version == "03":
-            self.bundle.filelogheader()
+            dirheader = self.bundle.filelogheader()
+            while dirheader:
+                d = dirheader["filename"]
+                self.bundledirlogs = bundlemanifest(
+                    self.svfs, self.bundle, linkmapper, dir=d)
+                dirheader = self.bundle.filelogheader()
         self.filestart = self.bundle.tell()
         return m
 
diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -313,6 +313,15 @@  Stripping and recovering changes should 
      rev    offset  length  delta linkrev nodeid       p1           p2
        0         0     127     -1       4 064927a0648a 000000000000 000000000000
        1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
+  $ hg incoming --traceback .hg/strip-backup/*
+  comparing with .hg/strip-backup/*-backup.hg (glob)
+  searching for changes
+  changeset:   6:51cfd7b1e13b
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     modify dir1/a
+  
   $ hg unbundle -q .hg/strip-backup/*
   $ hg debugindex --dir dir1
      rev    offset  length  delta linkrev nodeid       p1           p2