Patchwork [04,of,11] debugbundle: display the content of obsmarkers parts

login
register
mail settings
Submitter Pierre-Yves David
Date May 28, 2017, 4:32 p.m.
Message ID <a4da14c3c095bf4f566c.1495989125@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20989/
State Accepted
Headers show

Comments

Pierre-Yves David - May 28, 2017, 4:32 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1495723846 -7200
#      Thu May 25 16:50:46 2017 +0200
# Node ID a4da14c3c095bf4f566c655cb4a82dc3b1ccd5e9
# Parent  b97c492388f6b14c346600e1c1ed4e400f6b47ca
# EXP-Topic obsstrip
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a4da14c3c095
debugbundle: display the content of obsmarkers parts

We parse and display the markers in the part when possible.
Gregory Szorc - May 28, 2017, 7:05 p.m.
On Sun, May 28, 2017 at 9:32 AM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1495723846 -7200
> #      Thu May 25 16:50:46 2017 +0200
> # Node ID a4da14c3c095bf4f566c655cb4a82dc3b1ccd5e9
> # Parent  b97c492388f6b14c346600e1c1ed4e400f6b47ca
> # EXP-Topic obsstrip
> # Available At https://www.mercurial-scm.org/
> repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/
> repo/users/marmoute/mercurial/ -r a4da14c3c095
> debugbundle: display the content of obsmarkers parts
>

Also queued this one.


>
> We parse and display the markers in the part when possible.
>
> diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py
> +++ b/mercurial/debugcommands.py
> @@ -288,6 +288,27 @@ def _debugchangegroup(ui, gen, all=None,
>              ui.write("%s%s\n" % (indent_string, hex(node)))
>              chain = node
>
> +def _debugobsmarkers(ui, data, all=None, indent=0, **opts):
> +    """display version and markers contained in 'data'"""
> +    indent_string = ' ' * indent
> +    try:
> +        version, markers = obsolete._readmarkers(data)
> +    except error.UnknownVersion as exc:
> +        msg = "%sunsupported version: %s (%d bytes)\n"
> +        msg %= indent_string, exc.version, len(data)
> +        ui.write(msg)
> +    else:
> +        msg = "%sversion: %s (%d bytes)\n"
> +        msg %= indent_string, version, len(data)
> +        ui.write(msg)
> +        fm = ui.formatter('debugobsolete', opts)
> +        for rawmarker in sorted(markers):
> +            m = obsolete.marker(None, rawmarker)
> +            fm.startitem()
> +            fm.plain(indent_string)
> +            cmdutil.showmarker(fm, m)
> +        fm.end()
> +
>  def _debugbundle2(ui, gen, all=None, **opts):
>      """lists the contents of a bundle2"""
>      if not isinstance(gen, bundle2.unbundle20):
> @@ -299,6 +320,8 @@ def _debugbundle2(ui, gen, all=None, **o
>              version = part.params.get('version', '01')
>              cg = changegroup.getunbundler(version, part, 'UN')
>              _debugchangegroup(ui, cg, all=all, indent=4, **opts)
> +        if part.type == 'obsmarkers':
> +            _debugobsmarkers(ui, part.read(), all=all, indent=4, **opts)
>
>  @command('debugbundle',
>          [('a', 'all', None, _('show all details')),
> diff --git a/tests/test-obsolete-changeset-exchange.t
> b/tests/test-obsolete-changeset-exchange.t
> --- a/tests/test-obsolete-changeset-exchange.t
> +++ b/tests/test-obsolete-changeset-exchange.t
> @@ -97,6 +97,8 @@ check-that bundle can contains markers:
>    changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])"
>        f89bcc95eba5174b1ccc3e33a82e84c96e8338ee
>    obsmarkers -- 'sortdict()'
> +      version: 1 (70 bytes)
> +      9d73aac1b2ed7d53835eaeec212ed41ea47da53a
> f89bcc95eba5174b1ccc3e33a82e84c96e8338ee 0 (Thu Jan 01 00:00:00 1970
> +0000) {'user': 'test'}
>
>    $ cd ..
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - May 28, 2017, 10:46 p.m.
On 05/28/2017 09:05 PM, Gregory Szorc wrote:
> On Sun, May 28, 2017 at 9:32 AM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org <mailto:pierre-yves.david@ens-lyon.org>>
> wrote:
>
>     # HG changeset patch
>     # User Pierre-Yves David <pierre-yves.david@octobus.net
>     <mailto:pierre-yves.david@octobus.net>>
>     # Date 1495723846 -7200
>     #      Thu May 25 16:50:46 2017 +0200
>     # Node ID a4da14c3c095bf4f566c655cb4a82dc3b1ccd5e9
>     # Parent  b97c492388f6b14c346600e1c1ed4e400f6b47ca
>     # EXP-Topic obsstrip
>     # Available At
>     https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>     <https://www.mercurial-scm.org/repo/users/marmoute/mercurial/>
>     #              hg pull
>     https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>     <https://www.mercurial-scm.org/repo/users/marmoute/mercurial/> -r
>     a4da14c3c095
>     debugbundle: display the content of obsmarkers parts
>
>
> Also queued this one.

Thanks for the queuing.

I do not think patch 4 can be queued without patch 3 since 
error.UnknownVersion will not be defined.

Patch 5-11 seems to have been dropped from patchwork. What about them ?

Cheers,

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -288,6 +288,27 @@  def _debugchangegroup(ui, gen, all=None,
             ui.write("%s%s\n" % (indent_string, hex(node)))
             chain = node
 
+def _debugobsmarkers(ui, data, all=None, indent=0, **opts):
+    """display version and markers contained in 'data'"""
+    indent_string = ' ' * indent
+    try:
+        version, markers = obsolete._readmarkers(data)
+    except error.UnknownVersion as exc:
+        msg = "%sunsupported version: %s (%d bytes)\n"
+        msg %= indent_string, exc.version, len(data)
+        ui.write(msg)
+    else:
+        msg = "%sversion: %s (%d bytes)\n"
+        msg %= indent_string, version, len(data)
+        ui.write(msg)
+        fm = ui.formatter('debugobsolete', opts)
+        for rawmarker in sorted(markers):
+            m = obsolete.marker(None, rawmarker)
+            fm.startitem()
+            fm.plain(indent_string)
+            cmdutil.showmarker(fm, m)
+        fm.end()
+
 def _debugbundle2(ui, gen, all=None, **opts):
     """lists the contents of a bundle2"""
     if not isinstance(gen, bundle2.unbundle20):
@@ -299,6 +320,8 @@  def _debugbundle2(ui, gen, all=None, **o
             version = part.params.get('version', '01')
             cg = changegroup.getunbundler(version, part, 'UN')
             _debugchangegroup(ui, cg, all=all, indent=4, **opts)
+        if part.type == 'obsmarkers':
+            _debugobsmarkers(ui, part.read(), all=all, indent=4, **opts)
 
 @command('debugbundle',
         [('a', 'all', None, _('show all details')),
diff --git a/tests/test-obsolete-changeset-exchange.t b/tests/test-obsolete-changeset-exchange.t
--- a/tests/test-obsolete-changeset-exchange.t
+++ b/tests/test-obsolete-changeset-exchange.t
@@ -97,6 +97,8 @@  check-that bundle can contains markers:
   changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])"
       f89bcc95eba5174b1ccc3e33a82e84c96e8338ee
   obsmarkers -- 'sortdict()'
+      version: 1 (70 bytes)
+      9d73aac1b2ed7d53835eaeec212ed41ea47da53a f89bcc95eba5174b1ccc3e33a82e84c96e8338ee 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
 
   $ cd ..