From 4849fabbc81a4055aa39d629ff6081465763aac8 Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Aug 20 2018 20:42:15 +0000 Subject: Rebase to v0.4 Compatible with Mercurial v4.6 Remove patches applied in upstream --- diff --git a/.gitignore b/.gitignore index 259966f..1701816 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /git-remote-hg-0.2.tar.gz /git-remote-hg-0.3.tar.gz +/git-remote-hg-0.4.tar.gz diff --git a/0001-Avoid-deprecated-bookmarks.write.patch b/0001-Avoid-deprecated-bookmarks.write.patch deleted file mode 100644 index 68d45a3..0000000 --- a/0001-Avoid-deprecated-bookmarks.write.patch +++ /dev/null @@ -1,44 +0,0 @@ -From dff7c6f3be09c01197cc90e5a6e5589b1565ff12 Mon Sep 17 00:00:00 2001 -From: Petr Stodulka -Date: Mon, 28 Nov 2016 22:59:55 +0100 -Subject: [PATCH 1/2] Avoid deprecated bookmarks.write() - -The method has been deprecated and removed in mercurial v3.6. ---- - git-remote-hg | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/git-remote-hg b/git-remote-hg -index 87dc8f3..1749d43 100755 ---- a/git-remote-hg -+++ b/git-remote-hg -@@ -373,10 +373,23 @@ def updatebookmarks(repo, peer): - for k, v in remotemarks.iteritems(): - localmarks[k] = hgbin(v) - -- if hasattr(localmarks, 'write'): -- localmarks.write() -+ if check_version(3, 6): -+ lock = tr = None -+ try: -+ lock = repo.lock() -+ tr = repo.transaction('bookmark') -+ localmarks.recordchange(tr) -+ tr.close() -+ finally: -+ if tr is not None: -+ tr.release() -+ if lock is not None: -+ lock.release() - else: -- bookmarks.write(repo) -+ if hasattr(localmarks, 'write'): -+ localmarks.write() -+ else: -+ bookmarks.write(repo) - - def get_repo(url, alias): - global peer --- -2.5.5 - diff --git a/0002-Fix-remote-push-error-because-of-incompatibility-wit.patch b/0002-Fix-remote-push-error-because-of-incompatibility-wit.patch deleted file mode 100644 index 8c74e04..0000000 --- a/0002-Fix-remote-push-error-because-of-incompatibility-wit.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/git-remote-hg b/git-remote-hg -index 87dc8f3..39f1f6f 100755 ---- a/git-remote-hg -+++ b/git-remote-hg -@@ -1064,11 +1064,19 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): - fci = discovery.findcommonincoming - commoninc = fci(repo, remote, force=force) - common, _, remoteheads = commoninc -+ fco = discovery.findcommonoutgoing -+ outgoing = fco(repo, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force) - - if not checkheads(repo, remote, p_revs): - return None - -- if check_version(3, 2): -+ if check_version(4, 0): -+ if hasattr(changegroup, 'getlocalchangegroup'): -+ cg = changegroup.getlocalchangegroup(repo, 'push', outgoing) -+ else: -+ # as of about version 4.4 -+ cg = changegroup.makechangegroup(repo, outgoing, '01', 'push') -+ elif check_version(3, 2): - cg = changegroup.getchangegroup(repo, 'push', heads=list(p_revs), common=common) - elif check_version(3, 0): - cg = changegroup.getbundle(repo, 'push', heads=list(p_revs), common=common) diff --git a/0003-Fix-compatibility-with-mercurial4.5.patch b/0003-Fix-compatibility-with-mercurial4.5.patch deleted file mode 100644 index 3b93185..0000000 --- a/0003-Fix-compatibility-with-mercurial4.5.patch +++ /dev/null @@ -1,58 +0,0 @@ -diff --git a/git-remote-hg b/git-remote-hg -index 39f1f6f..8e1c321 100755 ---- a/git-remote-hg -+++ b/git-remote-hg -@@ -771,6 +771,15 @@ def c_style_unescape(string): - return string.decode('string-escape')[1:-1] - return string - -+# sigh; handle context creation for various (incompatible) versions -+def make_memfilectx(repo, memctx, path, data, is_link, is_exec, *args): -+ if check_version(4, 5): -+ return context.memfilectx(repo, memctx, path, data, is_link, is_exec, *args) -+ if check_version(3, 1): -+ return context.memfilectx(repo, path, data, is_link, is_exec, *args) -+ else: -+ return context.memfilectx(path, data, is_link, is_exec, *args) -+ - def parse_commit(parser): - from_mark = merge_mark = None - -@@ -830,23 +839,13 @@ def parse_commit(parser): - ctx = of['ctx'] - is_exec = ctx.isexec() - is_link = ctx.islink() -- if check_version(3, 1): -- return context.memfilectx(repo, f, ctx.data(), -- is_link, is_exec) -- else: -- return context.memfilectx(f, ctx.data(), -- is_link, is_exec) -+ return make_memfilectx(repo, memctx, f, ctx.data(), is_link, is_exec) - else: - return of['ctx'] - is_exec = of['mode'] == 'x' - is_link = of['mode'] == 'l' - rename = of.get('rename', None) -- if check_version(3, 1): -- return context.memfilectx(repo, f, of['data'], -- is_link, is_exec, rename) -- else: -- return context.memfilectx(f, of['data'], -- is_link, is_exec, rename) -+ return make_memfilectx(repo, memctx, f, of['data'], is_link, is_exec, rename) - - repo = parser.repo - -@@ -949,10 +948,7 @@ def write_tag(repo, tag, node, msg, author): - except error.ManifestLookupError: - data = "" - content = data + "%s %s\n" % (node, tag) -- if check_version(3, 1): -- return context.memfilectx(repo, f, content, False, False, None) -- else: -- return context.memfilectx(f, content, False, False, None) -+ return make_memfilectx(repo, memctx, f, content, False, False, None) - - p1 = tip.hex() - p2 = '0' * 40 diff --git a/0004-Optionally-ignore-remote-mercurial-revision-names.patch b/0004-Optionally-ignore-remote-mercurial-revision-names.patch deleted file mode 100644 index e85d048..0000000 --- a/0004-Optionally-ignore-remote-mercurial-revision-names.patch +++ /dev/null @@ -1,84 +0,0 @@ -commit e2627129b1f6ebc6ad4bdd695f708195d85bcb6a -Author: TomasKorbar -Date: Sat Apr 28 19:23:07 2018 +0200 - - ignore some mercurial remote revision names - -diff --git a/git-remote-hg b/git-remote-hg -index 8e1c321..e9dac14 100755 ---- a/git-remote-hg -+++ b/git-remote-hg -@@ -95,8 +95,8 @@ def check_version(*check): - return True - return hg_version >= check - --def get_config(config): -- cmd = ['git', 'config', '--get', config] -+def get_config(config, getall=False): -+ cmd = ['git', 'config', '--get' if not getall else '--get-all', config] - process = subprocess.Popen(cmd, stdout=subprocess.PIPE) - output, _ = process.communicate() - return output -@@ -696,20 +696,41 @@ def do_list(parser): - - list_head(repo, cur) - -+ ignore_ref = get_config('remote-hg.ignore-name', True) -+ ignore_re = [] -+ for exp in ignore_ref.splitlines(): -+ if exp: -+ try: -+ #warn("checking %s" % ( -+ ignore_re.append(re.compile(exp.strip())) -+ except: -+ warn("Invalid regular expression '%s'" % (exp)) -+ def ignore(kind, name): -+ for r in ignore_re: -+ if r.search(name): -+ warn("Ignoring matched %s %s" % (kind, name)) -+ return True -+ return False -+ -+ for_push = (parser.line.find('for-push') >= 0) -+ sha1 = 'f' * 40 if (capability_push and for_push) else '?' -+ - if track_branches: - for branch in branches: -- print "? refs/heads/branches/%s" % gitref(branch) -+ if not ignore('branch', branch): -+ print "%s refs/heads/branches/%s" % (sha1, gitref(branch)) - - for bmark in bmarks: - if bmarks[bmark].hex() == '0' * 40: - warn("Ignoring invalid bookmark '%s'", bmark) -- else: -- print "? refs/heads/%s" % gitref(bmark) -+ elif not ignore('bookmark', bmark): -+ print "%s refs/heads/%s" % (sha1, gitref(bmark)) - - for tag, node in repo.tagslist(): - if tag == 'tip': - continue -- print "? refs/tags/%s" % gitref(tag) -+ if not ignore('tag', tag): -+ print "%s refs/tags/%s" % (sha1, gitref(tag)) - - print - -@@ -1270,6 +1291,7 @@ def main(args): - global fake_bmark, hg_version - global dry_run - global notes, alias -+ global capability_push - - marks = None - is_tmp = False -@@ -1287,6 +1309,8 @@ def main(args): - - hg_git_compat = get_config_bool('remote-hg.hg-git-compat') - track_branches = get_config_bool('remote-hg.track-branches', True) -+ capability_push = get_config_bool('remote-hg.capability-push', True) -+ - force_push = False - - if hg_git_compat: diff --git a/0005-Push-bookmarks-without-changesets.patch b/0005-Push-bookmarks-without-changesets.patch deleted file mode 100644 index 3bb78fa..0000000 --- a/0005-Push-bookmarks-without-changesets.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/git-remote-hg b/git-remote-hg -index 5030f15..5fa02e6 100755 ---- a/git-remote-hg -+++ b/git-remote-hg -@@ -1085,6 +1085,11 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): - outgoing = fco(repo, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force) - - if not checkheads(repo, remote, p_revs): -+ return False -+ -+ # nice to know about this rather than assume a bogus error -+ # also, some remote peertypes might otherwise be surprised further down -+ if not outgoing.missing: - return None - - if check_version(4, 0): -@@ -1241,7 +1246,9 @@ def do_export(parser): - return - - if peer: -- if not push(parser.repo, peer, parsed_refs, p_revs): -+ ret = push(parser.repo, peer, parsed_refs, p_revs) -+ # None ok: nothing to push -+ if ret != None and not ret: - # do not update bookmarks - print - return diff --git a/git-remote-hg.spec b/git-remote-hg.spec index 1c9dc54..38a197b 100644 --- a/git-remote-hg.spec +++ b/git-remote-hg.spec @@ -1,7 +1,7 @@ %global debug_package %{nil} Name: git-remote-hg -Version: 0.3 -Release: 9%{?dist} +Version: 0.4 +Release: 1%{?dist} BuildArch: noarch Summary: Mercurial wrapper for git License: GPLv2+ @@ -13,15 +13,6 @@ Source0: https://github.com/mnauw/%{name}/archive/v%{version}.tar.gz#/%{n # Makes it work with Mercurial 3.2 # The second commit (to the tests) isn't needed against 0.2 -Patch1: 0001-Avoid-deprecated-bookmarks.write.patch -Patch2: 0002-Fix-remote-push-error-because-of-incompatibility-wit.patch -#https://github.com/mnauw/git-remote-hg/issues/12 -Patch3: 0003-Fix-compatibility-with-mercurial4.5.patch -#https://github.com/mnauw/git-remote-hg/issues/10 -Patch4: 0004-Optionally-ignore-remote-mercurial-revision-names.patch -#https://github.com/felipec/git-remote-hg/issues/32 -Patch5: 0005-Push-bookmarks-without-changesets.patch - BuildRequires: asciidoc >= 8.4.1 BuildRequires: hg-git BuildRequires: python2-devel @@ -37,11 +28,7 @@ repositories as if they were Git ones. %prep %setup -q -%patch01 -p1 -%patch02 -p1 -%patch03 -p1 -%patch04 -p1 -%patch05 -p1 +#%patch01 -p1 sed -i -e "1 s|^#!.*|#!%{__python2}|" git-remote-hg sed -i -e 's|\tinstall|\tinstall -p|' Makefile @@ -63,6 +50,11 @@ make install-doc %{_mandir}/man1/* %changelog +* Mon Aug 20 2018 Petr Stodulka - 0.4-1 +- Rebase to v0.4 +- Compatible with Mercurial v4.6 +- Remove patches applied in upstream + * Fri Jul 13 2018 Fedora Release Engineering - 0.3-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild diff --git a/sources b/sources index 8322eff..b74efd9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -40346d361c41c2cef02dae2eed7a86d9 git-remote-hg-0.3.tar.gz +SHA512 (git-remote-hg-0.4.tar.gz) = 25b6d9c50ca0b5694a1782c19a62b965a44446795531c7fcd3da4eb1d80e1739efc32a7ffaf7297bed9c56b7902e665a81e95b7c116cbe73e3ae28c5473e5054