Notification time stamped 2020-12-01 00:37:59 UTC
From e5a8c2419ba5932d1012b4186468eabce6189bbc Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk(a)redhat.com>
Date: Dec 01 2020 00:37:19 +0000
Subject: Apply url encoding for additional refname sanitizing
Resolves: #1893525
---
diff --git a/0001-Apply-url-encoding-for-additional-refname-sanitizing.patch
b/0001-Apply-url-encoding-for-additional-refname-sanitizing.patch
new file mode 100644
index 0000000..4c5f5c9
--- /dev/null
+++ b/0001-Apply-url-encoding-for-additional-refname-sanitizing.patch
@@ -0,0 +1,65 @@
+From 05d230688462ada50ab275a4c8e674688426694f Mon Sep 17 00:00:00 2001
+From: Mark Nauwelaerts <mnauw(a)users.sourceforge.net>
+Date: Mon, 1 Jun 2020 16:22:01 +0200
+Subject: [PATCH] Apply url encoding for additional refname sanitizing
+
+Fixes mnauw/git-remote-hg#33
+
+@pstodulk note: Backported for v1.0.0
+---
+ README.asciidoc | 8 +++++---
+ git-remote-hg | 10 ++++++++--
+ 2 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/README.asciidoc b/README.asciidoc
+index d0cdbe2..5015e7e 100644
+--- a/README.asciidoc
++++ b/README.asciidoc
+@@ -247,9 +247,11 @@ to fully complete the conversion (prior to subsequent pushing).
+ Some Mercurial names (of branches, bookmarks, tags) may not be a valid git
+ refname. See e.g. `man git-check-ref-format` for a rather involved set of rules.
+ Moreover, while a slash `/` is allowed, it is not supported to have both a `parent`
+-and `parent/child` branch (though only the latter is allowed). So, pending some
+-"nice" bidirectional encoding (not even e.g. URL encoding is safe actually),
it is more
+-likely that only a few instances (out of a whole Mercurial repo) are
++and `parent/child` branch (though only the latter is allowed). Even though
++it is not quite (bidirectionally) safe, a (percentage) URL encoding
++(with some additional twist) is performed to obtain sane git refnames, at least
++so for most cases. If some nasty cases still slip through, then likely only
++a few instances (out of a whole Mercurial repo) are
+ problematic. This could be handled by a single-branch clone and/or configuring
+ a suitable refspec. However, it might be more convenient to simply filter out a
+ few unimportant pesky cases, which can be done by configuring a regural
+diff --git a/git-remote-hg b/git-remote-hg
+index 2c07917..cb8582d 100755
+--- a/git-remote-hg
++++ b/git-remote-hg
+@@ -29,6 +29,9 @@ import urlparse
+ import hashlib
+ import time as ptime
+
++urlquote = urllib.quote
++urlunquote = urllib.unquote
++
+ #
+ # If you want to see Mercurial revisions as Git commit notes:
+ # git config core.notesRef refs/notes/hg
+@@ -86,10 +89,13 @@ def hgbin(n):
+ return node.bin(n)
+
+ def hgref(ref):
+- return ref.replace('___', ' ')
++ return urlunquote(ref.replace('___',
'%20').replace('%5F%5F%5F', '___'))
+
+ def gitref(ref):
+- return ref.replace(' ', '___')
++ # standard url percentage encoding with a (legacy) twist:
++ # ' ' -> '___'
++ # '___' also percentage encoded
++ return urlquote(ref).replace('___',
'%5F%5F%5F').replace('%20', '___')
+
+ def check_version(*check):
+ if not hg_version:
+--
+2.26.2
+
diff --git a/git-remote-hg.spec b/git-remote-hg.spec
index 47be216..4730173 100644
--- a/git-remote-hg.spec
+++ b/git-remote-hg.spec
@@ -1,7 +1,7 @@
%global debug_package %{nil}
Name: git-remote-hg
Version: 1.0.0
-Release: 6%{?dist}
+Release: 7%{?dist}
BuildArch: noarch
Summary: Mercurial wrapper for git
License: GPLv2+
@@ -11,6 +11,7 @@ Source0:
https://github.com/mnauw/%{name}/archive/v%{version}.tar.gz#/%{n
#
https://github.com/felipec/git-remote-hg/pull/28
# Makes it work with Mercurial 3.2
# The second commit (to the tests) isn't needed against 0.2
+Patch01: 0001-Apply-url-encoding-for-additional-refname-sanitizing.patch
BuildRequires: asciidoc >= 8.4.1
BuildRequires: python2-devel
@@ -26,7 +27,7 @@ repositories as if they were Git ones.
%prep
%setup -q
-#%patch01 -p1
+%patch01 -p1
sed -i -e "1 s|^#!.*|#!%{__python2}|" git-remote-hg
sed -i -e 's|\tinstall|\tinstall -p|' Makefile
@@ -48,6 +49,10 @@ make install-doc
%{_mandir}/man1/*
%changelog
+* Tue Dec 01 2020 Petr Stodulka <pstodulk(a)redhat.com> - 1.0.0-7
+- Apply url encoding for additional refname sanitizing
+- Resolves: #1893525
+
* Mon Jul 27 2020 Fedora Release Engineering <releng(a)fedoraproject.org> - 1.0.0-6
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
https://src.fedoraproject.org/rpms/git-remote-hg/c/e5a8c2419ba5932d1012b4...