Subject: [PATCH] Add hotfix for running `hg archive` with gzip files on python 3.8.2+

From: Ludovic Chabant <[email-masked]>
Date: Tue, 10 Mar 2020 20:47:48 +0000

---
 main/mercurial/APKBUILD           |  7 ++++---
 main/mercurial/archive_gzip.patch | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 main/mercurial/archive_gzip.patch

diff --git a/main/mercurial/APKBUILD b/main/mercurial/APKBUILD
index 7932977c84..9c53e77fd3 100644
--- a/main/mercurial/APKBUILD
+++ b/main/mercurial/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=mercurial
 pkgver=5.3.1
-pkgrel=0
+pkgrel=1
 pkgdesc="Scalable distributed SCM tool"
 url="https://www.mercurial-scm.org"
 arch="all"
@@ -15,7 +15,7 @@ subpackages="
 	$pkgname-zsh-completion:zshcomp:noarch
 	$pkgname-bash-completion:bashcomp:noarch
 	"
-source="https://www.mercurial-scm.org/release/mercurial-$pkgver.tar.gz"
+source="https://www.mercurial-scm.org/release/mercurial-$pkgver.tar.gz archive_gzip.patch"
 
 # secfixes:
 #   4.9-r0:
@@ -65,4 +65,5 @@ bashcomp() {
 		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
 }
 
-sha512sums="3bc49ea96cb4ac0e777f667a3243917af495a001534b6b91141fc93b5c47a8eddc84331e1cb0b981fac1bf451dcfc91b8c538134983733466248fdc20afd39c6  mercurial-5.3.1.tar.gz"
+sha512sums="3bc49ea96cb4ac0e777f667a3243917af495a001534b6b91141fc93b5c47a8eddc84331e1cb0b981fac1bf451dcfc91b8c538134983733466248fdc20afd39c6  mercurial-5.3.1.tar.gz
+42974b580e5dafc562fdce9728b90f882a2cfb10c3c0adbd50d41382bd6bcf3a430be6fc81c52a3baa3955677999bf4662c5e5b5bc90891ba9c862ec27c448a2  archive_gzip.patch"
diff --git a/main/mercurial/archive_gzip.patch b/main/mercurial/archive_gzip.patch
new file mode 100644
index 0000000000..5f4f81ecff
--- /dev/null
+++ b/main/mercurial/archive_gzip.patch
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User Ludovic Chabant <[email-masked]>
+# Date 1583871438 0
+#      Tue Mar 10 20:17:18 2020 +0000
+# Node ID 70878db5d0ede9c39128328cfa8cb6ee758d5374
+# Parent  a08bbdf839ae08ff69c6f99a289ee85b3a012f03
+archive: fix crash when archiving to gzip file with Python 3.8.2+
+
+Differential Revision: https://phab.mercurial-scm.org/D8272
+
+diff --git a/mercurial/archival.py b/mercurial/archival.py
+--- a/mercurial/archival.py
++++ b/mercurial/archival.py
+@@ -146,7 +146,7 @@
+                 self.timestamp = timestamp
+             gzip.GzipFile.__init__(self, *args, **kw)
+ 
+-        def _write_gzip_header(self):
++        def _write_gzip_header(self, *args, **kwargs):
+             self.fileobj.write(b'\037\213')  # magic header
+             self.fileobj.write(b'\010')  # compression method
+             fname = self.name
-- 
2.24.1

---

From: "Ludovic Chabant" <[email-masked]>
Date: Fri, 03 Apr 2020 09:42:14 -0700

Hey Natanael, this is a gentle ping about this patch.

The  `hg archive` command is currently broken on Alpine edge without
this fix (or until the next Mercurial release). It's blocking us on
sourcehut at the moment because our deployments rely on that command.

Thanks!

---

From: Natanael Copa <[email-masked]>
Date: Fri, 3 Apr 2020 18:53:52 +0200

Hi!

On Fri, 03 Apr 2020 09:42:14 -0700

> sourcehut at the moment because our deployments rely on that command.

Sorry, the patch drowned in my inbox and I missed it completely.

The commit message should be something like:

  main/mercurial: hotfix for running `hg archive` with gzip files on python 3.8.2+

It would also be good with a reference to upstream bug report or
upstream commit in the commit message.

I can clean up the message this time (but for the future to minimize
risk that I confuse it with other mailing lists).

Second, the patch needs to be rebased since mercurial was updated to
5.3.2 - unless this fixes the issue ofc.

Thanks!

---

From: "Ludovic Chabant" <[email-masked]>
Date: Fri, 03 Apr 2020 10:23:47 -0700

> 5.3.2 - unless this fixes the issue ofc.

A glance at the 5.3.2 branch seems to indicate it actually contains the
proper fix... we're still pulling mercurial 5.3.1 on our servers though
so I'll have to investigate that. But this means this patch hotfix isn't
needed anymore.

Cheers!

---

From: "Ludovic Chabant" <[email-masked]>
Date: Mon, 06 Apr 2020 10:23:27 -0700

Hi again,
Can the new package (mercurial 5.3.2) be backported to Alpine stable so we can pull the latest mercurial there?
Thanks!

---

From: Leo <[email-masked]>
Date: Mon, 6 Apr 2020 14:27:42 -0300

On Mon, 06 Apr 2020 10:23:27 -0700
"Ludovic Chabant" <[email-masked]> wrote:

> Hi again,
> Can the new package (mercurial 5.3.2) be backported to Alpine stable
> so we can pull the latest mercurial there? Thanks!

See: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/6394