Patchwork archive: add XZ support if built with Python 3

login
register
mail settings
Submitter David Demelier
Date Sept. 17, 2019, 10:48 a.m.
Message ID <c0398aef7f0977b5f076.1568717304@ns3138881.ip-37-59-60.eu>
Download mbox | patch
Permalink /patch/41689/
State Accepted
Headers show

Comments

David Demelier - Sept. 17, 2019, 10:48 a.m.
# HG changeset patch
# User David Demelier <markand@malikania.fr>
# Date 1568717251 0
#      Tue Sep 17 10:47:31 2019 +0000
# Node ID c0398aef7f0977b5f076b15638762773dde7d5b6
# Parent  181ee2118a96c4b52bbd6d7b5a47e87f2e1d77e9
archive: add XZ support if built with Python 3
Augie Fackler - Sept. 17, 2019, 2:02 p.m.
> On Sep 17, 2019, at 06:48, David Demelier <markand@malikania.fr> wrote:
> 
> # HG changeset patch
> # User David Demelier <markand@malikania.fr>
> # Date 1568717251 0
> #      Tue Sep 17 10:47:31 2019 +0000
> # Node ID c0398aef7f0977b5f076b15638762773dde7d5b6
> # Parent  181ee2118a96c4b52bbd6d7b5a47e87f2e1d77e9
> archive: add XZ support if built with Python 3

queued, thanks

> 
> diff -r 181ee2118a96 -r c0398aef7f09 mercurial/archival.py
> --- a/mercurial/archival.py	Wed Sep 11 15:03:08 2019 -0700
> +++ b/mercurial/archival.py	Tue Sep 17 10:47:31 2019 +0000
> @@ -67,6 +67,7 @@
>     'tbz2': ['.tbz2', '.tar.bz2'],
>     'tgz': ['.tgz', '.tar.gz'],
>     'zip': ['.zip'],
> +    'txz': ['.txz', '.tar.xz']
>     }
> 
> def guesskind(dest):
> @@ -270,6 +271,7 @@
>     'tar': tarit,
>     'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'),
>     'tgz': lambda name, mtime: tarit(name, mtime, 'gz'),
> +    'txz': lambda name, mtime: tarit(name, mtime, 'xz'),
>     'uzip': lambda name, mtime: zipit(name, mtime, False),
>     'zip': zipit,
>     }
> @@ -295,6 +297,9 @@
>     subrepos tells whether to include subrepos.
>     '''
> 
> +    if kind == 'txz' and not pycompat.ispy3:
> +        raise error.Abort(_('xz compression is only available in Python 3'))
> +
>     if kind == 'files':
>         if prefix:
>             raise error.Abort(_('cannot give prefix when archiving to files'))
> diff -r 181ee2118a96 -r c0398aef7f09 mercurial/commands.py
> --- a/mercurial/commands.py	Wed Sep 11 15:03:08 2019 -0700
> +++ b/mercurial/commands.py	Tue Sep 17 10:47:31 2019 +0000
> @@ -514,6 +514,7 @@
>     :``tar``:   tar archive, uncompressed
>     :``tbz2``:  tar archive, compressed using bzip2
>     :``tgz``:   tar archive, compressed using gzip
> +    :``txz``:   tar archive, compressed using lzma (only in Python 3)
>     :``uzip``:  zip archive, uncompressed
>     :``zip``:   zip archive, compressed using deflate
> 
> diff -r 181ee2118a96 -r c0398aef7f09 tests/test-archive.t
> --- a/tests/test-archive.t	Wed Sep 11 15:03:08 2019 -0700
> +++ b/tests/test-archive.t	Tue Sep 17 10:47:31 2019 +0000
> @@ -566,6 +566,21 @@
>   *172*80*00:00*old/.hg_archival.txt (glob)
>   *0*80*00:00*old/old (glob)
> 
> +test xz support only available in Python 3.4
> +
> +#if py3
> +  $ hg archive ../archive.txz
> +  $ xz -l ../archive.txz | head -n1
> +  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename (py3 !)
> +  $ rm -f ../archive.txz
> +#endif
> +
> +#if no-py3
> +  $ hg archive ../archive.txz
> +  abort: xz compression is only available in Python 3
> +  [255]
> +#endif
> +
> show an error when a provided pattern matches no files
> 
>   $ hg archive -I file_that_does_not_exist.foo ../empty.zip
> @@ -607,3 +622,4 @@
>   456789012
> 
>   $ cd ..
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
via Mercurial-devel - Sept. 17, 2019, 5:18 p.m.
On Tue, Sep 17, 2019 at 7:16 AM Augie Fackler <raf@durin42.com> wrote:

>
>
> > On Sep 17, 2019, at 06:48, David Demelier <markand@malikania.fr> wrote:
> >
> > # HG changeset patch
> > # User David Demelier <markand@malikania.fr>
> > # Date 1568717251 0
> > #      Tue Sep 17 10:47:31 2019 +0000
> > # Node ID c0398aef7f0977b5f076b15638762773dde7d5b6
> > # Parent  181ee2118a96c4b52bbd6d7b5a47e87f2e1d77e9
> > archive: add XZ support if built with Python 3
>
> queued, thanks
>
> >
> > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/archival.py
> > --- a/mercurial/archival.py   Wed Sep 11 15:03:08 2019 -0700
> > +++ b/mercurial/archival.py   Tue Sep 17 10:47:31 2019 +0000
> > @@ -67,6 +67,7 @@
> >     'tbz2': ['.tbz2', '.tar.bz2'],
> >     'tgz': ['.tgz', '.tar.gz'],
> >     'zip': ['.zip'],
> > +    'txz': ['.txz', '.tar.xz']
> >     }
> >
> > def guesskind(dest):
> > @@ -270,6 +271,7 @@
> >     'tar': tarit,
> >     'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'),
> >     'tgz': lambda name, mtime: tarit(name, mtime, 'gz'),
> > +    'txz': lambda name, mtime: tarit(name, mtime, 'xz'),
> >     'uzip': lambda name, mtime: zipit(name, mtime, False),
> >     'zip': zipit,
> >     }
> > @@ -295,6 +297,9 @@
> >     subrepos tells whether to include subrepos.
> >     '''
> >
> > +    if kind == 'txz' and not pycompat.ispy3:
> > +        raise error.Abort(_('xz compression is only available in Python
> 3'))
> > +
> >     if kind == 'files':
> >         if prefix:
> >             raise error.Abort(_('cannot give prefix when archiving to
> files'))
> > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/commands.py
> > --- a/mercurial/commands.py   Wed Sep 11 15:03:08 2019 -0700
> > +++ b/mercurial/commands.py   Tue Sep 17 10:47:31 2019 +0000
> > @@ -514,6 +514,7 @@
> >     :``tar``:   tar archive, uncompressed
> >     :``tbz2``:  tar archive, compressed using bzip2
> >     :``tgz``:   tar archive, compressed using gzip
> > +    :``txz``:   tar archive, compressed using lzma (only in Python 3)
> >     :``uzip``:  zip archive, uncompressed
> >     :``zip``:   zip archive, compressed using deflate
> >
> > diff -r 181ee2118a96 -r c0398aef7f09 tests/test-archive.t
> > --- a/tests/test-archive.t    Wed Sep 11 15:03:08 2019 -0700
> > +++ b/tests/test-archive.t    Tue Sep 17 10:47:31 2019 +0000
> > @@ -566,6 +566,21 @@
> >   *172*80*00:00*old/.hg_archival.txt (glob)
> >   *0*80*00:00*old/old (glob)
> >
> > +test xz support only available in Python 3.4
> > +
> > +#if py3
> > +  $ hg archive ../archive.txz
> > +  $ xz -l ../archive.txz | head -n1
> > +  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename (py3
> !)
>

I'll drop the "(py3 !)" here.


> > +  $ rm -f ../archive.txz
> > +#endif
> > +
> > +#if no-py3
>

And I'll replace these three lines by "#else"


> > +  $ hg archive ../archive.txz
> > +  abort: xz compression is only available in Python 3
> > +  [255]
> > +#endif
> > +
> > show an error when a provided pattern matches no files
> >
> >   $ hg archive -I file_that_does_not_exist.foo ../empty.zip
> > @@ -607,3 +622,4 @@
> >   456789012
> >
> >   $ cd ..
> > +
>

And I'll drop this unrelated change.


> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
David Demelier - Sept. 18, 2019, 7:18 a.m.
Le 17/09/2019 à 19:18, Martin von Zweigbergk a écrit :
> 
> 
> On Tue, Sep 17, 2019 at 7:16 AM Augie Fackler <raf@durin42.com 
> <mailto:raf@durin42.com>> wrote:
> 
> 
> 
>      > On Sep 17, 2019, at 06:48, David Demelier <markand@malikania.fr
>     <mailto:markand@malikania.fr>> wrote:
>      >
>      > # HG changeset patch
>      > # User David Demelier <markand@malikania.fr
>     <mailto:markand@malikania.fr>>
>      > # Date 1568717251 0
>      > #      Tue Sep 17 10:47:31 2019 +0000
>      > # Node ID c0398aef7f0977b5f076b15638762773dde7d5b6
>      > # Parent  181ee2118a96c4b52bbd6d7b5a47e87f2e1d77e9
>      > archive: add XZ support if built with Python 3
> 
>     queued, thanks
> 
>      >
>      > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/archival.py
>      > --- a/mercurial/archival.py   Wed Sep 11 15:03:08 2019 -0700
>      > +++ b/mercurial/archival.py   Tue Sep 17 10:47:31 2019 +0000
>      > @@ -67,6 +67,7 @@
>      >     'tbz2': ['.tbz2', '.tar.bz2'],
>      >     'tgz': ['.tgz', '.tar.gz'],
>      >     'zip': ['.zip'],
>      > +    'txz': ['.txz', '.tar.xz']
>      >     }
>      >
>      > def guesskind(dest):
>      > @@ -270,6 +271,7 @@
>      >     'tar': tarit,
>      >     'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'),
>      >     'tgz': lambda name, mtime: tarit(name, mtime, 'gz'),
>      > +    'txz': lambda name, mtime: tarit(name, mtime, 'xz'),
>      >     'uzip': lambda name, mtime: zipit(name, mtime, False),
>      >     'zip': zipit,
>      >     }
>      > @@ -295,6 +297,9 @@
>      >     subrepos tells whether to include subrepos.
>      >     '''
>      >
>      > +    if kind == 'txz' and not pycompat.ispy3:
>      > +        raise error.Abort(_('xz compression is only available in
>     Python 3'))
>      > +
>      >     if kind == 'files':
>      >         if prefix:
>      >             raise error.Abort(_('cannot give prefix when
>     archiving to files'))
>      > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/commands.py
>      > --- a/mercurial/commands.py   Wed Sep 11 15:03:08 2019 -0700
>      > +++ b/mercurial/commands.py   Tue Sep 17 10:47:31 2019 +0000
>      > @@ -514,6 +514,7 @@
>      >     :``tar``:   tar archive, uncompressed
>      >     :``tbz2``:  tar archive, compressed using bzip2
>      >     :``tgz``:   tar archive, compressed using gzip
>      > +    :``txz``:   tar archive, compressed using lzma (only in
>     Python 3)
>      >     :``uzip``:  zip archive, uncompressed
>      >     :``zip``:   zip archive, compressed using deflate
>      >
>      > diff -r 181ee2118a96 -r c0398aef7f09 tests/test-archive.t
>      > --- a/tests/test-archive.t    Wed Sep 11 15:03:08 2019 -0700
>      > +++ b/tests/test-archive.t    Tue Sep 17 10:47:31 2019 +0000
>      > @@ -566,6 +566,21 @@
>      >   *172*80*00:00*old/.hg_archival.txt (glob)
>      >   *0*80*00:00*old/old (glob)
>      >
>      > +test xz support only available in Python 3.4
>      > +
>      > +#if py3
>      > +  $ hg archive ../archive.txz
>      > +  $ xz -l ../archive.txz | head -n1
>      > +  Strms  Blocks   Compressed Uncompressed  Ratio  Check 
>       Filename (py3 !)
> 
> 
> I'll drop the "(py3 !)" here.
> 

Yes, sorry I first wrote the block in one test rather than using 
#if/#endif, then I forgot to remove the (py3 !) selectors.

Augie, is the patch already in place?

Otherwise I'll just send a new revision which cleans up this.

Regards,
via Mercurial-devel - Sept. 18, 2019, 7:26 a.m.
Yes, it's already accepted. I meant that I fixed those things in flight. So
no follow-up needed.

On Wed, Sep 18, 2019, 00:22 David Demelier <markand@malikania.fr> wrote:

> Le 17/09/2019 à 19:18, Martin von Zweigbergk a écrit :
> >
> >
> > On Tue, Sep 17, 2019 at 7:16 AM Augie Fackler <raf@durin42.com
> > <mailto:raf@durin42.com>> wrote:
> >
> >
> >
> >      > On Sep 17, 2019, at 06:48, David Demelier <markand@malikania.fr
> >     <mailto:markand@malikania.fr>> wrote:
> >      >
> >      > # HG changeset patch
> >      > # User David Demelier <markand@malikania.fr
> >     <mailto:markand@malikania.fr>>
> >      > # Date 1568717251 0
> >      > #      Tue Sep 17 10:47:31 2019 +0000
> >      > # Node ID c0398aef7f0977b5f076b15638762773dde7d5b6
> >      > # Parent  181ee2118a96c4b52bbd6d7b5a47e87f2e1d77e9
> >      > archive: add XZ support if built with Python 3
> >
> >     queued, thanks
> >
> >      >
> >      > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/archival.py
> >      > --- a/mercurial/archival.py   Wed Sep 11 15:03:08 2019 -0700
> >      > +++ b/mercurial/archival.py   Tue Sep 17 10:47:31 2019 +0000
> >      > @@ -67,6 +67,7 @@
> >      >     'tbz2': ['.tbz2', '.tar.bz2'],
> >      >     'tgz': ['.tgz', '.tar.gz'],
> >      >     'zip': ['.zip'],
> >      > +    'txz': ['.txz', '.tar.xz']
> >      >     }
> >      >
> >      > def guesskind(dest):
> >      > @@ -270,6 +271,7 @@
> >      >     'tar': tarit,
> >      >     'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'),
> >      >     'tgz': lambda name, mtime: tarit(name, mtime, 'gz'),
> >      > +    'txz': lambda name, mtime: tarit(name, mtime, 'xz'),
> >      >     'uzip': lambda name, mtime: zipit(name, mtime, False),
> >      >     'zip': zipit,
> >      >     }
> >      > @@ -295,6 +297,9 @@
> >      >     subrepos tells whether to include subrepos.
> >      >     '''
> >      >
> >      > +    if kind == 'txz' and not pycompat.ispy3:
> >      > +        raise error.Abort(_('xz compression is only available in
> >     Python 3'))
> >      > +
> >      >     if kind == 'files':
> >      >         if prefix:
> >      >             raise error.Abort(_('cannot give prefix when
> >     archiving to files'))
> >      > diff -r 181ee2118a96 -r c0398aef7f09 mercurial/commands.py
> >      > --- a/mercurial/commands.py   Wed Sep 11 15:03:08 2019 -0700
> >      > +++ b/mercurial/commands.py   Tue Sep 17 10:47:31 2019 +0000
> >      > @@ -514,6 +514,7 @@
> >      >     :``tar``:   tar archive, uncompressed
> >      >     :``tbz2``:  tar archive, compressed using bzip2
> >      >     :``tgz``:   tar archive, compressed using gzip
> >      > +    :``txz``:   tar archive, compressed using lzma (only in
> >     Python 3)
> >      >     :``uzip``:  zip archive, uncompressed
> >      >     :``zip``:   zip archive, compressed using deflate
> >      >
> >      > diff -r 181ee2118a96 -r c0398aef7f09 tests/test-archive.t
> >      > --- a/tests/test-archive.t    Wed Sep 11 15:03:08 2019 -0700
> >      > +++ b/tests/test-archive.t    Tue Sep 17 10:47:31 2019 +0000
> >      > @@ -566,6 +566,21 @@
> >      >   *172*80*00:00*old/.hg_archival.txt (glob)
> >      >   *0*80*00:00*old/old (glob)
> >      >
> >      > +test xz support only available in Python 3.4
> >      > +
> >      > +#if py3
> >      > +  $ hg archive ../archive.txz
> >      > +  $ xz -l ../archive.txz | head -n1
> >      > +  Strms  Blocks   Compressed Uncompressed  Ratio  Check
> >       Filename (py3 !)
> >
> >
> > I'll drop the "(py3 !)" here.
> >
>
> Yes, sorry I first wrote the block in one test rather than using
> #if/#endif, then I forgot to remove the (py3 !) selectors.
>
> Augie, is the patch already in place?
>
> Otherwise I'll just send a new revision which cleans up this.
>
> Regards,
>
> --
> David
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
David Demelier - Sept. 18, 2019, 7:34 a.m.
Le 18/09/2019 à 09:26, Martin von Zweigbergk a écrit :
> Yes, it's already accepted. I meant that I fixed those things in flight. 
> So no follow-up needed.

Ok, thanks :-)

Patch

diff -r 181ee2118a96 -r c0398aef7f09 mercurial/archival.py
--- a/mercurial/archival.py	Wed Sep 11 15:03:08 2019 -0700
+++ b/mercurial/archival.py	Tue Sep 17 10:47:31 2019 +0000
@@ -67,6 +67,7 @@ 
     'tbz2': ['.tbz2', '.tar.bz2'],
     'tgz': ['.tgz', '.tar.gz'],
     'zip': ['.zip'],
+    'txz': ['.txz', '.tar.xz']
     }
 
 def guesskind(dest):
@@ -270,6 +271,7 @@ 
     'tar': tarit,
     'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'),
     'tgz': lambda name, mtime: tarit(name, mtime, 'gz'),
+    'txz': lambda name, mtime: tarit(name, mtime, 'xz'),
     'uzip': lambda name, mtime: zipit(name, mtime, False),
     'zip': zipit,
     }
@@ -295,6 +297,9 @@ 
     subrepos tells whether to include subrepos.
     '''
 
+    if kind == 'txz' and not pycompat.ispy3:
+        raise error.Abort(_('xz compression is only available in Python 3'))
+
     if kind == 'files':
         if prefix:
             raise error.Abort(_('cannot give prefix when archiving to files'))
diff -r 181ee2118a96 -r c0398aef7f09 mercurial/commands.py
--- a/mercurial/commands.py	Wed Sep 11 15:03:08 2019 -0700
+++ b/mercurial/commands.py	Tue Sep 17 10:47:31 2019 +0000
@@ -514,6 +514,7 @@ 
     :``tar``:   tar archive, uncompressed
     :``tbz2``:  tar archive, compressed using bzip2
     :``tgz``:   tar archive, compressed using gzip
+    :``txz``:   tar archive, compressed using lzma (only in Python 3)
     :``uzip``:  zip archive, uncompressed
     :``zip``:   zip archive, compressed using deflate
 
diff -r 181ee2118a96 -r c0398aef7f09 tests/test-archive.t
--- a/tests/test-archive.t	Wed Sep 11 15:03:08 2019 -0700
+++ b/tests/test-archive.t	Tue Sep 17 10:47:31 2019 +0000
@@ -566,6 +566,21 @@ 
   *172*80*00:00*old/.hg_archival.txt (glob)
   *0*80*00:00*old/old (glob)
 
+test xz support only available in Python 3.4
+
+#if py3
+  $ hg archive ../archive.txz
+  $ xz -l ../archive.txz | head -n1
+  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename (py3 !)
+  $ rm -f ../archive.txz
+#endif
+
+#if no-py3
+  $ hg archive ../archive.txz
+  abort: xz compression is only available in Python 3
+  [255]
+#endif
+
 show an error when a provided pattern matches no files
 
   $ hg archive -I file_that_does_not_exist.foo ../empty.zip
@@ -607,3 +622,4 @@ 
   456789012
 
   $ cd ..
+