Patchwork [1,of,2,V2] streamclone: include obsstore file into stream bundle if client can read it

login
register
mail settings
Submitter Anton Shestakov
Date Oct. 18, 2018, 1:49 p.m.
Message ID <212b1f69138c7d1fa166.1539870559@neuro>
Download mbox | patch
Permalink /patch/36145/
State New
Headers show

Comments

Anton Shestakov - Oct. 18, 2018, 1:49 p.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1538753237 -28800
#      Fri Oct 05 23:27:17 2018 +0800
# Node ID 212b1f69138c7d1fa166356448305219259f34f9
# Parent  89cba88e95ed84b6e5e49ecc51ebf7119cfaa6b4
# EXP-Topic stream-obsmarkers
streamclone: include obsstore file into stream bundle if client can read it
Gregory Szorc - Oct. 31, 2018, 7:46 p.m.
On Thu, Oct 18, 2018 at 6:51 AM Anton Shestakov <av6@dwimlabs.net> wrote:

> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1538753237 -28800
> #      Fri Oct 05 23:27:17 2018 +0800
> # Node ID 212b1f69138c7d1fa166356448305219259f34f9
> # Parent  89cba88e95ed84b6e5e49ecc51ebf7119cfaa6b4
> # EXP-Topic stream-obsmarkers
> streamclone: include obsstore file into stream bundle if client can read it
>

I attempted to look at this patch but it didn't apply.

Could you please rebase?


>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -1697,8 +1697,15 @@ def addpartbundlestream2(bundler, repo,
>      if (includepats or excludepats) and not narrowstream:
>          raise error.Abort(_('server does not support narrow stream
> clones'))
>
> +    includeobsmarkers = False
> +    if repo.obsstore:
> +        remoteversions = obsmarkersversion(bundler.capabilities)
> +        if repo.obsstore._version in remoteversions:
> +            includeobsmarkers = True
> +
>      filecount, bytecount, it = streamclone.generatev2(repo, includepats,
> -                                                      excludepats)
> +                                                      excludepats,
> +                                                      includeobsmarkers)
>      requirements = _formatrequirementsspec(repo.requirements)
>      part = bundler.newpart('stream2', data=it)
>      part.addparam('bytecount', '%d' % bytecount, mandatory=True)
> diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
> --- a/mercurial/streamclone.py
> +++ b/mercurial/streamclone.py
> @@ -532,7 +532,7 @@ def _emit2(repo, entries, totalfilesize)
>              finally:
>                  fp.close()
>
> -def generatev2(repo, includes, excludes):
> +def generatev2(repo, includes, excludes, includeobsmarkers):
>      """Emit content for version 2 of a streaming clone.
>
>      the data stream consists the following entries:
> @@ -567,6 +567,9 @@ def generatev2(repo, includes, excludes)
>              if repo.svfs.exists(name):
>                  totalfilesize += repo.svfs.lstat(name).st_size
>                  entries.append((_srcstore, name, _filefull, None))
> +        if includeobsmarkers and repo.svfs.exists('obsstore'):
> +            totalfilesize += repo.svfs.lstat('obsstore').st_size
> +            entries.append((_srcstore, 'obsstore', _filefull, None))
>          for name in cacheutil.cachetocopy(repo):
>              if repo.cachevfs.exists(name):
>                  totalfilesize += repo.cachevfs.lstat(name).st_size
> diff --git a/tests/test-clone-uncompressed.t
> b/tests/test-clone-uncompressed.t
> --- a/tests/test-clone-uncompressed.t
> +++ b/tests/test-clone-uncompressed.t
> @@ -514,3 +514,48 @@ stream v1 unsuitable for non-publishing
>  #endif
>
>    $ killdaemons.py
> +
> +#if stream-legacy
> +
> +With v1 of the stream protocol, changeset are always cloned as public.
> There's
> +no obsolescence markers exchange in stream v1.
> +
> +#endif
> +#if stream-bundle2
> +
> +Stream repository with obsolescence
> +-----------------------------------
> +
> +Clone non-publishing with obsolescence
> +
> +  $ cat >> $HGRCPATH << EOF
> +  > [experimental]
> +  > evolution=all
> +  > EOF
> +
> +  $ cd server
> +  $ echo foo > foo
> +  $ hg -q commit -m 'about to be pruned'
> +  $ hg debugobsolete `hg log -r . -T '{node}'` -d '0 0' -u test
> --record-parents
> +  obsoleted 1 changesets
> +  $ hg up null -q
> +  $ hg log -T '{rev}: {phase}\n'
> +  1: draft
> +  0: draft
> +  $ hg serve -p $HGPORT -d --pid-file=hg.pid
> +  $ cat hg.pid > $DAEMON_PIDS
> +  $ cd ..
> +
> +  $ hg clone -U --stream http://localhost:$HGPORT with-obsolescence
> +  streaming all changes
> +  1035 files to transfer, 97.1 KB of data
> +  transferred 97.1 KB in * seconds (* */sec) (glob)
> +  $ hg -R with-obsolescence log -T '{rev}: {phase}\n'
> +  1: draft
> +  0: draft
> +  $ hg debugobsolete -R with-obsolescence
> +  50382b884f66690b7045cac93a540cba4d4c906f 0
> {c17445101a72edac06facd130d14808dfbd5c7c2} (Thu Jan 01 00:00:00 1970 +0000)
> {'user': 'test'}
> +
> +  $ killdaemons.py
> +
> +#endif
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1697,8 +1697,15 @@  def addpartbundlestream2(bundler, repo, 
     if (includepats or excludepats) and not narrowstream:
         raise error.Abort(_('server does not support narrow stream clones'))
 
+    includeobsmarkers = False
+    if repo.obsstore:
+        remoteversions = obsmarkersversion(bundler.capabilities)
+        if repo.obsstore._version in remoteversions:
+            includeobsmarkers = True
+
     filecount, bytecount, it = streamclone.generatev2(repo, includepats,
-                                                      excludepats)
+                                                      excludepats,
+                                                      includeobsmarkers)
     requirements = _formatrequirementsspec(repo.requirements)
     part = bundler.newpart('stream2', data=it)
     part.addparam('bytecount', '%d' % bytecount, mandatory=True)
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -532,7 +532,7 @@  def _emit2(repo, entries, totalfilesize)
             finally:
                 fp.close()
 
-def generatev2(repo, includes, excludes):
+def generatev2(repo, includes, excludes, includeobsmarkers):
     """Emit content for version 2 of a streaming clone.
 
     the data stream consists the following entries:
@@ -567,6 +567,9 @@  def generatev2(repo, includes, excludes)
             if repo.svfs.exists(name):
                 totalfilesize += repo.svfs.lstat(name).st_size
                 entries.append((_srcstore, name, _filefull, None))
+        if includeobsmarkers and repo.svfs.exists('obsstore'):
+            totalfilesize += repo.svfs.lstat('obsstore').st_size
+            entries.append((_srcstore, 'obsstore', _filefull, None))
         for name in cacheutil.cachetocopy(repo):
             if repo.cachevfs.exists(name):
                 totalfilesize += repo.cachevfs.lstat(name).st_size
diff --git a/tests/test-clone-uncompressed.t b/tests/test-clone-uncompressed.t
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -514,3 +514,48 @@  stream v1 unsuitable for non-publishing 
 #endif
 
   $ killdaemons.py
+
+#if stream-legacy
+
+With v1 of the stream protocol, changeset are always cloned as public. There's
+no obsolescence markers exchange in stream v1.
+
+#endif
+#if stream-bundle2
+
+Stream repository with obsolescence
+-----------------------------------
+
+Clone non-publishing with obsolescence
+
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution=all
+  > EOF
+
+  $ cd server
+  $ echo foo > foo
+  $ hg -q commit -m 'about to be pruned'
+  $ hg debugobsolete `hg log -r . -T '{node}'` -d '0 0' -u test --record-parents
+  obsoleted 1 changesets
+  $ hg up null -q
+  $ hg log -T '{rev}: {phase}\n'
+  1: draft
+  0: draft
+  $ hg serve -p $HGPORT -d --pid-file=hg.pid
+  $ cat hg.pid > $DAEMON_PIDS
+  $ cd ..
+
+  $ hg clone -U --stream http://localhost:$HGPORT with-obsolescence
+  streaming all changes
+  1035 files to transfer, 97.1 KB of data
+  transferred 97.1 KB in * seconds (* */sec) (glob)
+  $ hg -R with-obsolescence log -T '{rev}: {phase}\n'
+  1: draft
+  0: draft
+  $ hg debugobsolete -R with-obsolescence
+  50382b884f66690b7045cac93a540cba4d4c906f 0 {c17445101a72edac06facd130d14808dfbd5c7c2} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+
+  $ killdaemons.py
+
+#endif