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