From 1442c29d39a5b711a4883235e0280483d6169e65 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:19:01 -0500 Subject: [PATCH 001/109] check-versions: fix variable Signed-off-by: Felipe Contreras --- tools/check-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check-versions b/tools/check-versions index 95b891b..872140f 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -274,7 +274,7 @@ elsif not $versions.empty? # mode 2 $verbosity = HIGH - exit check(versions) ? 0 : 1 + exit check($versions) ? 0 : 1 else # mode 3 $verbosity = QUIET From 0c8f8571c71eefb282c45b8ee96c435872c49a6a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:11:33 -0500 Subject: [PATCH 002/109] check-versions: update hggit url Signed-off-by: Felipe Contreras --- tools/check-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check-versions b/tools/check-versions index 872140f..ebca2d7 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -222,7 +222,7 @@ hggit_checkout_fix = lambda do |version| run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.8.0.patch], fatal: false end -add_component(:hggit, 'https://bitbucket.org/durin42/hg-git', checkout_fix: hggit_checkout_fix) +add_component(:hggit, 'https://foss.heptapod.net/mercurial/hg-git', checkout_fix: hggit_checkout_fix) add_component(:dulwich, 'https://github.com/dulwich/dulwich.git', version_format: 'dulwich-%s', kind: :git) From 237ff083af90a4ce04bbc6a1ab85edbfdd3e1e72 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:12:45 -0500 Subject: [PATCH 003/109] check-versions: update versions These combinations seem to work. Signed-off-by: Felipe Contreras --- tools/versions.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/versions.txt b/tools/versions.txt index d410ac9..1b2a008 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -26,8 +26,8 @@ hg:4.3 hggit:0.8.10 dulwich:0.18.0 # 2017_11 hg:4.4 hggit:0.8.10 dulwich:0.18.0 # 2017_11 hg:4.5 hggit:0.8.11 dulwich:0.18.0 # 2018_02 -hg:4.6 hggit:0.8.12 dulwich:0.19.7 # 2018_10 -hg:4.7 hggit:0.8.12 dulwich:0.19.7 # 2018_10 -hg:4.8 hggit:@ dulwich:0.19.11 -hg:4.9 hggit:@ dulwich:0.19.11 -hg:5.0 hggit:@ dulwich:0.19.11 +hg:4.6 hggit:0.8.13 dulwich:0.19.7 # 2018_10 +hg:4.7 hggit:0.8.13 dulwich:0.19.7 # 2018_10 +hg:4.8 hggit:0.8.13 dulwich:0.19.7 # 2018_10 +hg:4.9 hggit:0.8.13 dulwich:0.19.7 # 2019_01 +hg:5.0 hggit:0.8.13 dulwich:0.19.7 # 2019_04 From 6d6504d1fd3741eb48bfd03e957b4666962dc160 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:36:06 -0500 Subject: [PATCH 004/109] test: fix for latest versions of git Since git 2.34 the big push with force test is broken thanks to: 726a228dfb (fast-export: fix surprising behavior with --first-parent, 2021-12-16) Since this only affects pushing multiple heads to the same branch, it probably is not that important. Signed-off-by: Felipe Contreras --- test/main.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.t b/test/main.t index 888d420..7c12c4d 100755 --- a/test/main.t +++ b/test/main.t @@ -682,7 +682,7 @@ test_expect_success 'remote big push force' ' EOF ) && - check_branch hgrepo default six && + check_branch hgrepo default four && check_branch hgrepo good_branch eight && check_branch hgrepo bad_branch nine && check_branch hgrepo new_branch ten && From 0a1e8ecbc78b1ff1706e85682baca56837161d08 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:23:23 -0500 Subject: [PATCH 005/109] github: add simple workflow Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..52024d8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,15 @@ +on: + push: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v4 + with: + python-version: '2.7' + - name: Install python-dev + run: sudo apt-get install -y python2.7-dev + - run: ./tools/check-versions hg:5.0 From ed80437db48592f955a742b62a12fe29925bc0a9 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:48:57 -0500 Subject: [PATCH 006/109] github: use a matrix of hg versions Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 52024d8..ba14dc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,11 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + hg: [ '4.5', '4.6', '4.7', '4.8', '4.9', '5.0' ] + env: + HG_VERSION: ${{ matrix.hg }} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 @@ -12,4 +17,4 @@ jobs: python-version: '2.7' - name: Install python-dev run: sudo apt-get install -y python2.7-dev - - run: ./tools/check-versions hg:5.0 + - run: ./tools/check-versions hg:$HG_VERSION From 5dcd6df3c8898a903c607541337260bf70edd3bf Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 00:59:58 -0500 Subject: [PATCH 007/109] github: cache check-versions stuff Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba14dc1..0341179 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,4 +17,10 @@ jobs: python-version: '2.7' - name: Install python-dev run: sudo apt-get install -y python2.7-dev + - name: Cache check-versions script + id: cache-check-versions + uses: actions/cache@v3 + with: + path: ~/.cache/git-remote-hg + key: check-versions - run: ./tools/check-versions hg:$HG_VERSION From ad77f125b7a62cd3ff64a67b9049f6e1512f6638 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 01:24:33 -0500 Subject: [PATCH 008/109] travis: remove crap No longer open. Signed-off-by: Felipe Contreras --- .travis.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be08357..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -dist: xenial -language: minimal - -cache: - directories: - - $HOME/.cache/git-remote-hg - -script: - - ./tools/check-versions hg:$HG_VERSION - -matrix: - include: - - env: - - env: HG_VERSION=@ - - env: HG_VERSION=5.0 - - env: HG_VERSION=4.9 - - env: HG_VERSION=4.8 - - env: HG_VERSION=4.7 - - env: HG_VERSION=4.6 - - env: HG_VERSION=4.5 From 970883c46c11aac3336e2f1d7096850dc03cf2cc Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 01:16:55 -0500 Subject: [PATCH 009/109] check-versions: add more versions Signed-off-by: Felipe Contreras --- tools/versions.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/versions.txt b/tools/versions.txt index 1b2a008..eaebf0e 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -31,3 +31,5 @@ hg:4.7 hggit:0.8.13 dulwich:0.19.7 # 2018_10 hg:4.8 hggit:0.8.13 dulwich:0.19.7 # 2018_10 hg:4.9 hggit:0.8.13 dulwich:0.19.7 # 2019_01 hg:5.0 hggit:0.8.13 dulwich:0.19.7 # 2019_04 +hg:5.1 hggit:0.8.13 dulwich:0.19.7 # 2019_07 +hg:5.2 hggit:0.8.13 dulwich:0.19.7 # 2019_11 From 85293dcf69060f07c343f7726db559f28644c634 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 01:21:52 -0500 Subject: [PATCH 010/109] check-versions: add 2020 versions Also, update the hggit patch for 0.9.0. Signed-off-by: Felipe Contreras --- tools/check-versions | 6 +++++- tools/hggit_rename_fix_0.9.0.patch | 22 ++++++++++++++++++++++ tools/versions.txt | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tools/hggit_rename_fix_0.9.0.patch diff --git a/tools/check-versions b/tools/check-versions index ebca2d7..d1d52d9 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -219,7 +219,11 @@ add_component(:hg, 'https://www.mercurial-scm.org/repo/hg', checkout_fix: hg_che hggit_checkout_fix = lambda do |version| return unless check_version(version, '0.8.0') - run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.8.0.patch], fatal: false + if check_version(version, '0.9.0') + run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.9.0.patch], fatal: false + else + run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.8.0.patch], fatal: false + end end add_component(:hggit, 'https://foss.heptapod.net/mercurial/hg-git', checkout_fix: hggit_checkout_fix) diff --git a/tools/hggit_rename_fix_0.9.0.patch b/tools/hggit_rename_fix_0.9.0.patch new file mode 100644 index 0000000..fd4a206 --- /dev/null +++ b/tools/hggit_rename_fix_0.9.0.patch @@ -0,0 +1,22 @@ +diff --git a/hggit/git_handler.py b/hggit/git_handler.py +--- a/hggit/git_handler.py ++++ b/hggit/git_handler.py +@@ -829,6 +829,8 @@ + def import_git_commit(self, commit): + self.ui.debug(_(b"importing: %s\n") % commit.id) + ++ extra_in_message = self.ui.configbool(b'git', b'debugextrainmessage', False) ++ + detect_renames = False + (strip_message, hg_renames, + hg_branch, extra) = git2hg.extract_hg_metadata( +@@ -839,7 +841,8 @@ + # renames detected from Git. This is because we export an extra + # 'HG:rename-source' Git parameter when this isn't set, which will + # break bidirectionality. +- extra[b'hg-git-rename-source'] = b'git' ++ if not extra_in_message: ++ extra[b'hg-git-rename-source'] = b'git' + else: + renames = hg_renames + diff --git a/tools/versions.txt b/tools/versions.txt index eaebf0e..7f85138 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -33,3 +33,8 @@ hg:4.9 hggit:0.8.13 dulwich:0.19.7 # 2019_01 hg:5.0 hggit:0.8.13 dulwich:0.19.7 # 2019_04 hg:5.1 hggit:0.8.13 dulwich:0.19.7 # 2019_07 hg:5.2 hggit:0.8.13 dulwich:0.19.7 # 2019_11 + +hg:5.3 hggit:0.9.0 dulwich:0.19.15 # 2020_01 +hg:5.4 hggit:0.9.0 dulwich:0.19.15 # 2020_04 +hg:5.5 hggit:0.9.0 dulwich:0.19.15 # 2020_08 +hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 From 98c1c9263ebdfeb7a393c30b966d60787e518de5 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 01:24:00 -0500 Subject: [PATCH 011/109] github: update hg versions Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0341179..3a02c1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '4.5', '4.6', '4.7', '4.8', '4.9', '5.0' ] + hg: [ '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6' ] env: HG_VERSION: ${{ matrix.hg }} steps: From 122b7f5da2b76e0603116a79a1caa71f193a5ead Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 30 Jul 2022 05:16:36 -0500 Subject: [PATCH 012/109] Remove annoying warning Signed-off-by: Felipe Contreras --- git-remote-hg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index c273c95..51b44ab 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -720,9 +720,7 @@ def do_list(parser): print "? refs/heads/branches/%s" % gitref(branch) for bmark in bmarks: - if bmarks[bmark].hex() == '0' * 40: - warn("Ignoring invalid bookmark '%s'", bmark) - else: + if bmarks[bmark].hex() != '0' * 40: print "? refs/heads/%s" % gitref(bmark) for tag, node in repo.tagslist(): From e24a713dc9068963e47e20cfceae8b4114a81bef Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 Aug 2022 23:03:01 -0500 Subject: [PATCH 013/109] check-versions: add hack for hg 5.7 Signed-off-by: Felipe Contreras --- tools/check-versions | 4 ++++ tools/hg_revert_5.7.patch | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools/hg_revert_5.7.patch diff --git a/tools/check-versions b/tools/check-versions index d1d52d9..e553643 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -203,6 +203,10 @@ def add_component(id, url, **args) end hg_checkout_fix = lambda do |version| + if check_version(version, '5.7') + run_cmd %W[hg import -q --no-commit #{__dir__}/hg_revert_5.7.patch] + end + FileUtils.cp('hg', "#{$builddir}/bin/") return if check_version(version, '4.3') diff --git a/tools/hg_revert_5.7.patch b/tools/hg_revert_5.7.patch new file mode 100644 index 0000000..71dd115 --- /dev/null +++ b/tools/hg_revert_5.7.patch @@ -0,0 +1,24 @@ +diff --git a/hg b/hg +index 4ec2b6140b..a3e61ad39c 100755 +--- a/hg ++++ b/hg +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python3 ++#!/usr/bin/env python + # + # mercurial - scalable distributed SCM + # +diff --git a/mercurial/hg.py b/mercurial/hg.py +index 1a7a281e30..bf75f15ac1 100644 +--- a/mercurial/hg.py ++++ b/mercurial/hg.py +@@ -1013,7 +1013,7 @@ def clone( + pass + if uprev is None: + try: +- if destrepo._activebookmark: ++ if False: + uprev = destrepo.lookup(destrepo._activebookmark) + update = destrepo._activebookmark + else: + From 0e52a6c883bf69dbc02944c590a44128276d768c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 01:24:47 -0500 Subject: [PATCH 014/109] check-versions: add last python2 combination Mercurial 5.8 does keep working with python 2.7, but hggit 0.10.1 doesn't, and neither does dulwich 0.20.0. Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- tools/versions.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a02c1b..84dd14f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6' ] + hg: [ '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7' ] env: HG_VERSION: ${{ matrix.hg }} steps: diff --git a/tools/versions.txt b/tools/versions.txt index 7f85138..839bbab 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -38,3 +38,5 @@ hg:5.3 hggit:0.9.0 dulwich:0.19.15 # 2020_01 hg:5.4 hggit:0.9.0 dulwich:0.19.15 # 2020_04 hg:5.5 hggit:0.9.0 dulwich:0.19.15 # 2020_08 hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 + +hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01 From 2313dc2ca085eeb5fb5d50c564dfe07ecfa6af92 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 02:57:23 -0500 Subject: [PATCH 015/109] readme: update [no ci] Signed-off-by: Felipe Contreras --- README.asciidoc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 6c16893..b96d2f5 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -50,8 +50,10 @@ If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly Remember to run `git gc --aggressive` after cloning a repository, specially if it's a big one. Otherwise lots of space will be wasted. -The oldest version of mercurial supported is 1.9. For the most part 1.8 works, -but you might experience some issues. +The newest supported version of Mercurial is 6.1 but only through Python 2. The +oldest one is 2.4. + +Support for Python 3 is on the way. === Pushing branches === @@ -111,11 +113,14 @@ Limitations of the remote-helpers' framework apply. == Other projects == -There are other 'git-remote-hg' projects out there, do not confuse this one, -this is the one distributed officially by the Git project: +There are other 'git-remote-hg' projects out there, this is the original, which +was distributed officially the Git project. -* https://github.com/msysgit/msysgit/wiki/Guide-to-git-remote-hg[msysgit's git-remote-hg] -* https://github.com/rfk/git-remote-hg[rfk's git-remote-hg] +Over the years many similar tools have died out, the only actively maintained +altnernative is mnauw's fork of this project: +https://github.com/mnauw/git-remote-hg[mnauw/git-remote-hg]. I've merged some of +his patches, and he has merged some of my patches, so the projects are mostly in +sync, but not quite. For a comparison between these and other projects go https://github.com/felipec/git/wiki/Comparison-of-git-remote-hg-alternatives[here]. From 1f5134062ee2f3a039f48a1d6e5c91f19860886a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 16:59:15 -0500 Subject: [PATCH 016/109] Add debug helper It's kind of tedious to always add something like this. [no ci] Signed-off-by: Felipe Contreras --- git-remote-hg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-remote-hg b/git-remote-hg index 51b44ab..1cce32c 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -61,6 +61,9 @@ RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') VERSION = 2 +def debug(*args): + sys.stderr.write('DEBUG: %s\n' % repr(args)) + def die(msg, *args): sys.stderr.write('ERROR: %s\n' % (msg % args)) sys.exit(1) From 20366b4b204c6f97ab0dd3fa389db99ff8ed9706 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:46:39 -0500 Subject: [PATCH 017/109] Trivial cleanup rev_marks and tips are already strings. Signed-off-by: Felipe Contreras --- git-remote-hg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 1cce32c..c10f481 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -185,7 +185,7 @@ class Marks: return self.marks[rev] def to_rev(self, mark): - return str(self.rev_marks[mark]) + return self.rev_marks[mark] def next_mark(self): self.last_mark += 1 @@ -205,7 +205,7 @@ class Marks: return rev in self.marks def get_tip(self, branch): - return str(self.tips[branch]) + return self.tips[branch] def set_tip(self, branch, tip): self.tips[branch] = tip From 795b88e16c1b2780a14ec6ade949c3309fa68586 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 23:22:48 -0500 Subject: [PATCH 018/109] readme: minor improvements [no ci] Signed-off-by: Felipe Contreras --- README.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index b96d2f5..56733a0 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -102,10 +102,10 @@ Mercurial branches and bookmarks have some limitations of Git branches: you can't have both 'dev/feature' and 'dev' (as Git uses files and directories to store them). -Multiple anonymous heads (which are useless anyway) are not supported; you +Multiple anonymous heads (which are useless anyway) are not supported: you would only see the latest head. -Closed branches are not supported; they are not shown and you can't close or +Closed branches are not supported: they are not shown and you can't close or reopen. Additionally in certain rare situations a synchronization issue can occur (https://github.com/felipec/git/issues/65[Bug #65]). @@ -113,8 +113,8 @@ Limitations of the remote-helpers' framework apply. == Other projects == -There are other 'git-remote-hg' projects out there, this is the original, which -was distributed officially the Git project. +There are other 'git-remote-hg' projects out there, but this is the original, +which was distributed officially in the Git project. Over the years many similar tools have died out, the only actively maintained altnernative is mnauw's fork of this project: From dcf96f31dbdba10104913f4e3439dbba35ef0f58 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 23:25:21 -0500 Subject: [PATCH 019/109] readme: more description about mnauw's fork [no ci] Signed-off-by: Felipe Contreras --- README.asciidoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 56733a0..fdb977a 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -120,7 +120,9 @@ Over the years many similar tools have died out, the only actively maintained altnernative is mnauw's fork of this project: https://github.com/mnauw/git-remote-hg[mnauw/git-remote-hg]. I've merged some of his patches, and he has merged some of my patches, so the projects are mostly in -sync, but not quite. +sync, but not quite. In particular Nauwelaerts' fork has many administrative +extensions, which although useful to some people, I don't believe they belong +in the core. For a comparison between these and other projects go https://github.com/felipec/git/wiki/Comparison-of-git-remote-hg-alternatives[here]. From bd3f404d3473e155ff430e8e14799e3da9b28c11 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 7 Aug 2022 22:33:10 -0500 Subject: [PATCH 020/109] readme: python3 support is ready [no ci] Signed-off-by: Felipe Contreras --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index fdb977a..ebcaed5 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -53,7 +53,7 @@ it's a big one. Otherwise lots of space will be wasted. The newest supported version of Mercurial is 6.1 but only through Python 2. The oldest one is 2.4. -Support for Python 3 is on the way. +Support for Python 3 is ready, but will be released in the next version soon. === Pushing branches === From d1f60c445ec1bc5be3aaea8fc6463a92bc9f1b80 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 7 Aug 2022 23:18:16 -0500 Subject: [PATCH 021/109] readme: general updates [no ci] Signed-off-by: Felipe Contreras --- README.asciidoc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index ebcaed5..08f5d3b 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -1,4 +1,4 @@ -'git-remote-hg' is the semi-official Mercurial bridge from Git project, once +`git-remote-hg` is the semi-official Mercurial bridge from the Git project, once installed, it allows you to clone, fetch and push to and from Mercurial repositories as if they were Git ones: @@ -6,10 +6,10 @@ repositories as if they were Git ones: git clone "hg::http://selenic.com/repo/hello" -------------------------------------- -To enable this, simply add the 'git-remote-hg' script anywhere in your `$PATH`: +To enable this, simply add the `git-remote-hg` script anywhere in your `$PATH`: -------------------------------------- -wget https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg -O ~/bin/git-remote-hg +curl https://raw.githubusercontent.com/felipec/git-remote-hg/master/git-remote-hg -o ~/bin/git-remote-hg chmod +x ~/bin/git-remote-hg -------------------------------------- @@ -25,7 +25,8 @@ If you want to see Mercurial revisions as Git commit notes: % git config core.notesRef refs/notes/hg -------------------------------------- -If you are not interested in Mercurial permanent and global branches (aka. commit labels): +If you are not interested in Mercurial permanent and global branches (aka. +commit labels): -------------------------------------- % git config --global remote-hg.track-branches false @@ -33,13 +34,14 @@ If you are not interested in Mercurial permanent and global branches (aka. commi With this configuration, the 'branches/foo' refs won't appear. -If you want the equivalent of 'hg clone --insecure': +If you want the equivalent of `hg clone --insecure`: -------------------------------------- % git config --global remote-hg.insecure true -------------------------------------- -If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly the same commits: +If you want `git-remote-hg` to be compatible with `hg-git`, and generate exactly +the same commits: -------------------------------------- % git config --global remote-hg.hg-git-compat true @@ -47,7 +49,7 @@ If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly == Notes == -Remember to run `git gc --aggressive` after cloning a repository, specially if +Remember to run `git gc --aggressive` after cloning a repository, especially if it's a big one. Otherwise lots of space will be wasted. The newest supported version of Mercurial is 6.1 but only through Python 2. The @@ -57,7 +59,7 @@ Support for Python 3 is ready, but will be released in the next version soon. === Pushing branches === -To push a branch, you need to use the "branches/" prefix: +To push a branch, you need to use the 'branches/' prefix: -------------------------------------- % git checkout branches/next @@ -67,7 +69,7 @@ To push a branch, you need to use the "branches/" prefix: All the pushed commits will receive the "next" Mercurial named branch. -*Note*: Make sure you don't have +remote-hg.track-branches+ disabled. +*Note*: Make sure you don't have `remote-hg.track-branches` disabled. === Cloning HTTPS === @@ -77,7 +79,7 @@ The simplest way is to specify the user and password in the URL: git clone hg::https://user:password@bitbucket.org/user/repo -------------------------------------- -You can also use the http://mercurial.selenic.com/wiki/SchemesExtension[schemes extension]: +You can also use the https://mercurial-scm.org/wiki/SchemesExtension[schemes extension]: -------------------------------------- [auth] @@ -87,11 +89,7 @@ bb.password = password -------------------------------------- Finally, you can also use the -https://pypi.python.org/pypi/mercurial_keyring[keyring extension]. - -However, some of these features require very new versions of 'git-remote-hg', -so you might have better luck simply specifying the username and password in -the URL. +https://pypi.org/project/mercurial_keyring[keyring extension]. === Caveats === @@ -109,15 +107,16 @@ Closed branches are not supported: they are not shown and you can't close or reopen. Additionally in certain rare situations a synchronization issue can occur (https://github.com/felipec/git/issues/65[Bug #65]). -Limitations of the remote-helpers' framework apply. +Limitations of Git's https://git-scm.com/docs/gitremote-helpers[remote-helpers] +framework apply. == Other projects == -There are other 'git-remote-hg' projects out there, but this is the original, +There are other `git-remote-hg` projects out there, but this is the original, which was distributed officially in the Git project. Over the years many similar tools have died out, the only actively maintained -altnernative is mnauw's fork of this project: +alternative is mnauw's fork of this project: https://github.com/mnauw/git-remote-hg[mnauw/git-remote-hg]. I've merged some of his patches, and he has merged some of my patches, so the projects are mostly in sync, but not quite. In particular Nauwelaerts' fork has many administrative From 900a55e974db751b0e74c28616cb766966de3d19 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 15:16:22 -0500 Subject: [PATCH 022/109] Use more standard python3 idioms Signed-off-by: Felipe Contreras --- git-remote-hg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index c10f481..2d32f31 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -480,7 +480,7 @@ def gitrange(repo, a, b): return [] pfunc = repo.changelog.parentrevs - it = iter(xrange(b.rev(), -1, -1)) + it = iter(range(b.rev(), -1, -1)) positive = [] pending = set([b.rev()]) @@ -492,7 +492,7 @@ def gitrange(repo, a, b): yield p while pending: - cur = it.next() + cur = next(it) if cur in negative: negative.remove(cur) From 19633eaf36b7ba3b9c63d41060de8819e8a5dd7e Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 15:12:46 -0500 Subject: [PATCH 023/109] Improve urllib imports So it's more extensible for when we move to python3. Signed-off-by: Felipe Contreras --- git-remote-hg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 2d32f31..46fe805 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -22,12 +22,13 @@ import os import json import shutil import subprocess -import urllib import atexit -import urlparse import hashlib import time as ptime +from urlparse import urlparse, urljoin +from urllib import quote as urlquote, unquote as urlunquote + # # If you want to see Mercurial revisions as Git commit notes: # git config core.notesRef refs/notes/hg @@ -259,7 +260,7 @@ class Parser: m = re.match('^(.+?) ext:\((.+)\)$', name) if m: name = m.group(1) - ex = urllib.unquote(m.group(2)) + ex = urlunquote(m.group(2)) if email != bad_mail: if name: @@ -350,7 +351,7 @@ def fixup_user_hg(user): mail = sanitize(m.group(2)) ex = m.group(3) if ex: - name += ' ext:(' + urllib.quote(ex) + ')' + name += ' ext:(' + urlquote(ex) + ')' else: name = sanitize(user) if '@' in user: @@ -575,7 +576,7 @@ def export_ref(repo, name, kind, head): if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'): continue else: - extra_msg += "extra : %s : %s\n" % (key, urllib.quote(value)) + extra_msg += "extra : %s : %s\n" % (key, urlquote(value)) if extra_msg: desc += '\n--HG--\n' + extra_msg @@ -909,7 +910,7 @@ def parse_commit(parser): extra[k] = v elif k == 'extra': ek, ev = v.split(' : ', 1) - extra[ek] = urllib.unquote(ev) + extra[ek] = urlunquote(ev) data = data[:i] ctx = context.memctx(repo, (p1, p2), data, @@ -1294,10 +1295,10 @@ def do_option(parser): print 'unsupported' def fix_path(alias, repo, orig_url): - url = urlparse.urlparse(orig_url, 'file') + url = urlparse(orig_url, 'file') if url.scheme != 'file' or os.path.isabs(os.path.expanduser(url.path)): return - abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url) + abs_url = urljoin("%s/" % os.getcwd(), orig_url) cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url] subprocess.call(cmd) From cac075744d4d65a7458bfd9b2ed224c9e6250b6f Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 Aug 2022 20:48:58 -0500 Subject: [PATCH 024/109] Use python3 print syntax Signed-off-by: Felipe Contreras --- git-remote-hg | 140 +++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 46fe805..9acf710 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -293,10 +293,10 @@ def export_files(files): filenodes[fid] = mark d = f.data() - print "blob" - print "mark :%u" % mark - print "data %d" % len(d) - print d + print("blob") + print("mark :%u" % mark) + print("data %d" % len(d)) + print(d) path = fix_file_path(f.path()) final.append((gitmode(f.flags()), mark, path)) @@ -582,59 +582,59 @@ def export_ref(repo, name, kind, head): desc += '\n--HG--\n' + extra_msg if len(parents) == 0 and rev: - print 'reset %s/%s' % (prefix, ename) + print('reset %s/%s' % (prefix, ename)) modified_final = export_files(c.filectx(f) for f in modified) - print "commit %s/%s" % (prefix, ename) - print "mark :%d" % (marks.get_mark(c.hex())) - print "author %s" % (author) - print "committer %s" % (committer) - print "data %d" % (len(desc)) - print desc + print("commit %s/%s" % (prefix, ename)) + print("mark :%d" % (marks.get_mark(c.hex()))) + print("author %s" % (author)) + print("committer %s" % (committer)) + print("data %d" % (len(desc))) + print(desc) if len(parents) > 0: - print "from :%s" % (rev_to_mark(parents[0])) + print("from :%s" % (rev_to_mark(parents[0]))) if len(parents) > 1: - print "merge :%s" % (rev_to_mark(parents[1])) + print("merge :%s" % (rev_to_mark(parents[1]))) for f in removed: - print "D %s" % (fix_file_path(f)) + print("D %s" % (fix_file_path(f))) for f in modified_final: - print "M %s :%u %s" % f - print + print("M %s :%u %s" % f) + print("") progress = (rev - tip) if (progress % 100 == 0): - print "progress revision %d '%s' (%d/%d)" % (rev, name, progress, total) + print("progress revision %d '%s' (%d/%d)" % (rev, name, progress, total)) # make sure the ref is updated - print "reset %s/%s" % (prefix, ename) - print "from :%u" % rev_to_mark(head) - print + print("reset %s/%s" % (prefix, ename)) + print("from :%u" % rev_to_mark(head)) + print("") pending_revs = set(revs) - notes if pending_revs: note_mark = marks.next_mark() ref = "refs/notes/hg" - print "commit %s" % ref - print "mark :%d" % (note_mark) - print "committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone)) + print("commit %s" % ref) + print("mark :%d" % (note_mark)) + print("committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone))) desc = "Notes for %s\n" % (name) - print "data %d" % (len(desc)) - print desc + print("data %d" % (len(desc))) + print(desc) if marks.last_note: - print "from :%u" % marks.last_note + print("from :%u" % marks.last_note) for rev in pending_revs: notes.add(rev) c = repo[rev] - print "N inline :%u" % rev_to_mark(c) + print("N inline :%u" % rev_to_mark(c)) msg = c.hex() - print "data %d" % (len(msg)) - print msg - print + print(("data %d" % (len(msg)))) + print(msg) + print("") marks.last_note = note_mark @@ -657,20 +657,20 @@ def export_head(repo): export_ref(repo, g_head[0], 'bookmarks', g_head[1]) def do_capabilities(parser): - print "import" - print "export" - print "refspec refs/heads/branches/*:%s/branches/*" % prefix - print "refspec refs/heads/*:%s/bookmarks/*" % prefix - print "refspec refs/tags/*:%s/tags/*" % prefix + print("import") + print("export") + print("refspec refs/heads/branches/*:%s/branches/*" % prefix) + print("refspec refs/heads/*:%s/bookmarks/*" % prefix) + print("refspec refs/tags/*:%s/tags/*" % prefix) path = os.path.join(dirname, 'marks-git') if os.path.exists(path): - print "*import-marks %s" % path - print "*export-marks %s" % path - print "option" + print("*import-marks %s" % path) + print("*export-marks %s" % path) + print("option") - print + print("") def branch_tip(branch): return branches[branch][-1] @@ -700,7 +700,7 @@ def list_head(repo, cur): bmarks[head] = node head = gitref(head) - print "@refs/heads/%s HEAD" % head + print("@refs/heads/%s HEAD" % head) g_head = (head, node) def do_list(parser): @@ -721,29 +721,29 @@ def do_list(parser): if track_branches: for branch in branches: - print "? refs/heads/branches/%s" % gitref(branch) + print("? refs/heads/branches/%s" % gitref(branch)) for bmark in bmarks: if bmarks[bmark].hex() != '0' * 40: - print "? refs/heads/%s" % gitref(bmark) + print("? refs/heads/%s" % gitref(bmark)) for tag, node in repo.tagslist(): if tag == 'tip': continue - print "? refs/tags/%s" % gitref(tag) + print("? refs/tags/%s" % gitref(tag)) - print + print("") def do_import(parser): repo = parser.repo path = os.path.join(dirname, 'marks-git') - print "feature done" + print("feature done") if os.path.exists(path): - print "feature import-marks=%s" % path - print "feature export-marks=%s" % path - print "feature force" + print("feature import-marks=%s" % path) + print("feature export-marks=%s" % path) + print("feature force") sys.stdout.flush() tmp = encoding.encoding @@ -769,7 +769,7 @@ def do_import(parser): encoding.encoding = tmp - print 'done' + print('done') def parse_blob(parser): parser.next() @@ -1016,7 +1016,7 @@ def checkheads_bmark(repo, ref, ctx): ctx_new = ctx if not ctx.rev(): - print "error %s unknown" % ref + print("error %s unknown" % ref) return False if check_version(4, 7): @@ -1026,9 +1026,9 @@ def checkheads_bmark(repo, ref, ctx): if not isancestorrev(ctx_old.rev(), ctx_new.rev()): if force_push: - print "ok %s forced update" % ref + print("ok %s forced update" % ref) else: - print "error %s non-fast forward" % ref + print("error %s non-fast forward" % ref) return False return True @@ -1078,9 +1078,9 @@ def checkheads(repo, remote, p_revs): node = repo.changelog.node(rev) ref = p_revs[node] if force_push: - print "ok %s forced update" % ref + print("ok %s forced update" % ref) else: - print "error %s non-fast forward" % ref + print("error %s non-fast forward" % ref) ret = False return ret @@ -1132,7 +1132,7 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): def push(repo, remote, parsed_refs, p_revs): if hasattr(remote, 'canpush') and not remote.canpush(): - print "error cannot push" + print("error cannot push") if not p_revs: # nothing to push @@ -1198,12 +1198,12 @@ def do_export(parser): if remotemap and branch in remotemap: heads = [hghex(e) for e in remotemap[branch]] if not check_tip(ref, 'branches', branch, heads): - print "error %s fetch first" % ref + print("error %s fetch first" % ref) need_fetch = True continue p_revs[bnode] = ref - print "ok %s" % ref + print("ok %s" % ref) elif ref.startswith('refs/heads/'): bmark = ref[len('refs/heads/'):] new = node @@ -1212,7 +1212,7 @@ def do_export(parser): if old == new: continue - print "ok %s" % ref + print("ok %s" % ref) if not bookmark_is_fake(bmark, parser.repo._bookmarks): p_bmarks.append((ref, bmark, old, new)) @@ -1220,14 +1220,14 @@ def do_export(parser): remote_old = peer.listkeys('bookmarks').get(bmark) if remote_old: if not check_tip(ref, 'bookmarks', bmark, remote_old): - print "error %s fetch first" % ref + print("error %s fetch first" % ref) need_fetch = True continue p_revs[bnode] = ref elif ref.startswith('refs/tags/'): if dry_run: - print "ok %s" % ref + print("ok %s" % ref) continue tag = ref[len('refs/tags/'):] tag = hgref(tag) @@ -1246,25 +1246,25 @@ def do_export(parser): fp.write('%s %s\n' % (node, tag)) fp.close() p_revs[bnode] = ref - print "ok %s" % ref + print("ok %s" % ref) else: # transport-helper/fast-export bugs continue if need_fetch: - print + print("") return if dry_run: if peer: checkheads(parser.repo, peer, p_revs) - print + print("") return if peer: if not push(parser.repo, peer, parsed_refs, p_revs): # do not update bookmarks - print + print("") return # update remote bookmarks @@ -1273,26 +1273,26 @@ def do_export(parser): if force_push: old = remote_bmarks.get(bmark, '') if not peer.pushkey('bookmarks', bmark, old, new): - print "error %s" % ref + print("error %s" % ref) else: # update local bookmarks for ref, bmark, old, new in p_bmarks: if not bookmarks.pushbookmark(parser.repo, bmark, old, new): - print "error %s" % ref + print("error %s" % ref) - print + print("") def do_option(parser): global dry_run, force_push _, key, value = parser.line.split(' ') if key == 'dry-run': dry_run = (value == 'true') - print 'ok' + print('ok') elif key == 'force': force_push = (value == 'true') - print 'ok' + print('ok') else: - print 'unsupported' + print('unsupported') def fix_path(alias, repo, orig_url): url = urlparse(orig_url, 'file') From f6676e6d8675c6a4ef9d0bab2cfd214ff5d61972 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 Aug 2022 21:13:53 -0500 Subject: [PATCH 025/109] Avoid python2 iteritems() Signed-off-by: Felipe Contreras --- git-remote-hg | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 9acf710..7d11786 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -160,15 +160,15 @@ class Marks: self.version = tmp.get('version', 1) self.last_note = tmp.get('last-note', 0) - for rev, mark in self.marks.iteritems(): + for rev, mark in self.marks.items(): self.rev_marks[mark] = rev def upgrade_one(self): def get_id(rev): return hghex(self.repo.changelog.node(int(rev))) - self.tips = dict((name, get_id(rev)) for name, rev in self.tips.iteritems()) - self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.iteritems()) - self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.iteritems()) + self.tips = dict((name, get_id(rev)) for name, rev in self.tips.items()) + self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.items()) + self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.items()) self.version = 2 def dict(self): @@ -381,7 +381,7 @@ def updatebookmarks(repo, peer): if not remotemarks: return - changes = { k: hgbin(v) for k, v in remotemarks.iteritems() } + changes = { k: hgbin(v) for k, v in remotemarks.items() } wlock = tr = None try: @@ -572,7 +572,7 @@ def export_ref(repo, name, kind, head): for e in renames: extra_msg += "rename : %s => %s\n" % e - for key, value in extra.iteritems(): + for key, value in extra.items(): if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'): continue else: @@ -705,13 +705,18 @@ def list_head(repo, cur): def do_list(parser): repo = parser.repo - for bmark, node in bookmarks.listbookmarks(repo).iteritems(): + for bmark, node in bookmarks.listbookmarks(repo).items(): bmarks[bmark] = repo[node] cur = repo.dirstate.branch() orig = peer if peer else repo - for branch, heads in orig.branchmap().iteritems(): + if check_version(5, 1): + items = orig.branchmap().items() + else: + items = orig.branchmap().iteritems() + + for branch, heads in items: # only open heads heads = [h for h in heads if 'close' not in repo.changelog.read(h)[5]] if heads: @@ -1043,7 +1048,7 @@ def checkheads(repo, remote, p_revs): new = {} ret = True - for node, ref in p_revs.iteritems(): + for node, ref in p_revs.items(): ctx = repo[node] branch = ctx.branch() if branch not in remotemap: @@ -1058,7 +1063,7 @@ def checkheads(repo, remote, p_revs): continue new.setdefault(branch, []).append(ctx.rev()) - for branch, heads in new.iteritems(): + for branch, heads in new.items(): old = [repo.changelog.rev(x) for x in remotemap[branch]] for rev in heads: if check_version(2, 3): @@ -1185,7 +1190,7 @@ def do_export(parser): need_fetch = False - for ref, node in parsed_refs.iteritems(): + for ref, node in parsed_refs.items(): bnode = hgbin(node) if node else None if ref.startswith('refs/heads/branches'): branch = ref[len('refs/heads/branches/'):] From 7d50fa42c1407732aaf6c8bf27a1e563d06f625a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 17:01:55 -0500 Subject: [PATCH 026/109] Decode and encode parsed strings Signed-off-by: Felipe Contreras --- git-remote-hg | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 7d11786..cf300b3 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -29,6 +29,10 @@ import time as ptime from urlparse import urlparse, urljoin from urllib import quote as urlquote, unquote as urlunquote +# Hack to set default encoding +reload(sys) +sys.setdefaultencoding('utf-8') + # # If you want to see Mercurial revisions as Git commit notes: # git config core.notesRef refs/notes/hg @@ -218,7 +222,7 @@ class Parser: self.line = self.get_line() def get_line(self): - return sys.stdin.readline().strip() + return sys.stdin.readline().decode().strip() def __getitem__(self, i): return self.line.split()[i] @@ -793,6 +797,7 @@ def get_merge_files(repo, p1, p2, files): files[e] = f def c_style_unescape(string): + string = string.encode() if string[0] == string[-1] == '"': return string.decode('string-escape')[1:-1] return string @@ -879,7 +884,7 @@ def parse_commit(parser): extra = {} if committer != author: - extra['committer'] = "%s %u %u" % committer + extra['committer'] = ("%s %u %u" % committer).encode() if from_mark: p1 = mark_to_rev(from_mark) @@ -920,7 +925,7 @@ def parse_commit(parser): ctx = context.memctx(repo, (p1, p2), data, files.keys(), getfilectx, - user, (date, tz), extra) + user.encode(), (date, tz), extra) tmp = encoding.encoding encoding.encoding = 'utf-8' @@ -986,6 +991,7 @@ def write_tag(repo, tag, node, msg, author): p2 = '0' * 40 if author: user, date, tz = author + user = user.encode() date_tz = (date, tz) else: cmd = ['git', 'var', 'GIT_COMMITTER_IDENT'] From 055cec1aa7a94830d9c0ddf74f18de30b1a756c5 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 17:44:02 -0500 Subject: [PATCH 027/109] Encode hg bookmark stuff In preparation for python3. Signed-off-by: Felipe Contreras --- git-remote-hg | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index cf300b3..2465c3a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -649,7 +649,7 @@ def export_tag(repo, tag): export_ref(repo, tag, 'tags', repo[node]) def export_bookmark(repo, bmark): - head = bmarks[hgref(bmark)] + head = bmarks[hgref(bmark).encode()] export_ref(repo, bmark, 'bookmarks', head) def export_branch(repo, branch): @@ -734,7 +734,7 @@ def do_list(parser): for bmark in bmarks: if bmarks[bmark].hex() != '0' * 40: - print("? refs/heads/%s" % gitref(bmark)) + print("? refs/heads/%s" % gitref(bmark.decode())) for tag, node in repo.tagslist(): if tag == 'tip': @@ -1018,7 +1018,7 @@ def write_tag(repo, tag, node, msg, author): return (tagnode, branch) def checkheads_bmark(repo, ref, ctx): - bmark = ref[len('refs/heads/'):] + bmark = ref[len('refs/heads/'):].encode() if bmark not in bmarks: # new bmark return True @@ -1172,7 +1172,7 @@ def check_tip(ref, kind, name, heads): def bookmark_is_fake(bmark, real_bmarks): return bmark == fake_bmark or \ - (bmark == 'master' and bmark not in real_bmarks) + (bmark == b'master' and bmark not in real_bmarks) def do_export(parser): p_bmarks = [] @@ -1199,7 +1199,8 @@ def do_export(parser): for ref, node in parsed_refs.items(): bnode = hgbin(node) if node else None if ref.startswith('refs/heads/branches'): - branch = ref[len('refs/heads/branches/'):] + g_branch = ref[len('refs/heads/branches/'):] + branch = g_branch.encode() if branch in branches and bnode in branches[branch]: # up to date continue @@ -1208,7 +1209,7 @@ def do_export(parser): remotemap = peer.branchmap() if remotemap and branch in remotemap: heads = [hghex(e) for e in remotemap[branch]] - if not check_tip(ref, 'branches', branch, heads): + if not check_tip(ref, 'branches', g_branch, heads): print("error %s fetch first" % ref) need_fetch = True continue @@ -1216,9 +1217,10 @@ def do_export(parser): p_revs[bnode] = ref print("ok %s" % ref) elif ref.startswith('refs/heads/'): - bmark = ref[len('refs/heads/'):] + g_bmark = ref[len('refs/heads/'):] + bmark = g_bmark.encode() new = node - old = bmarks[bmark].hex() if bmark in bmarks else '' + old = bmarks[bmark].hex() if bmark in bmarks else b'' if old == new: continue @@ -1230,7 +1232,7 @@ def do_export(parser): if peer: remote_old = peer.listkeys('bookmarks').get(bmark) if remote_old: - if not check_tip(ref, 'bookmarks', bmark, remote_old): + if not check_tip(ref, 'bookmarks', g_bmark, remote_old): print("error %s fetch first" % ref) need_fetch = True continue From 9d45e70fce3042a105f66428e311c42f3c35a7be Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 17:51:30 -0500 Subject: [PATCH 028/109] Encode hg branch stuff In preparation for python3. Signed-off-by: Felipe Contreras --- git-remote-hg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 2465c3a..d3651ef 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -680,30 +680,30 @@ def branch_tip(branch): return branches[branch][-1] def get_branch_tip(repo, branch): - heads = branches.get(hgref(branch), None) + heads = branches.get(hgref(branch).encode(), None) if not heads: return None # verify there's only one head if (len(heads) > 1): warn("Branch '%s' has more than one head, consider merging" % branch) - return branch_tip(hgref(branch)) + return branch_tip(hgref(branch).encode()) return heads[0] def list_head(repo, cur): global g_head, fake_bmark - if 'default' not in branches: + if b'default' not in branches: # empty repo return - node = repo[branch_tip('default')] - head = 'master' if 'master' not in bmarks else 'default' + node = repo[branch_tip(b'default')] + head = b'master' if b'master' not in bmarks else b'default' fake_bmark = head bmarks[head] = node - head = gitref(head) + head = gitref(head.decode()) print("@refs/heads/%s HEAD" % head) g_head = (head, node) @@ -730,7 +730,7 @@ def do_list(parser): if track_branches: for branch in branches: - print("? refs/heads/branches/%s" % gitref(branch)) + print("? refs/heads/branches/%s" % gitref(branch.decode())) for bmark in bmarks: if bmarks[bmark].hex() != '0' * 40: @@ -1249,7 +1249,7 @@ def do_export(parser): if not msg: msg = 'Added tag %s for changeset %s' % (tag, node[:12]) tagnode, branch = write_tag(parser.repo, tag, node, msg, author) - p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch) + p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch.decode()) else: if check_version(2, 4): vfs = parser.repo.vfs From 01d619ad3cb0e2d2d0a368986eaf7d860d0fdfec Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 18:06:11 -0500 Subject: [PATCH 029/109] Encode hg tag stuff In preparation for python3. Signed-off-by: Felipe Contreras --- git-remote-hg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index d3651ef..d71a302 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -645,7 +645,7 @@ def export_ref(repo, name, kind, head): marks.set_tip(ename, head.hex()) def export_tag(repo, tag): - node = repo.tags().get(hgref(tag)) + node = repo.tags().get(hgref(tag).encode()) export_ref(repo, tag, 'tags', repo[node]) def export_bookmark(repo, bmark): @@ -737,9 +737,9 @@ def do_list(parser): print("? refs/heads/%s" % gitref(bmark.decode())) for tag, node in repo.tagslist(): - if tag == 'tip': + if tag == b'tip': continue - print("? refs/tags/%s" % gitref(tag)) + print("? refs/tags/%s" % gitref(tag.decode())) print("") @@ -971,7 +971,7 @@ def parse_tag(parser): rev = None parsed_refs['refs/tags/' + name] = rev - parsed_tags[name] = (tagger, data) + parsed_tags[name.encode()] = (tagger, data) def write_tag(repo, tag, node, msg, author): branch = repo[node].branch() @@ -1243,11 +1243,11 @@ def do_export(parser): print("ok %s" % ref) continue tag = ref[len('refs/tags/'):] - tag = hgref(tag) + tag = hgref(tag).encode() author, msg = parsed_tags.get(tag, (None, None)) if mode == 'git': if not msg: - msg = 'Added tag %s for changeset %s' % (tag, node[:12]) + msg = b'Added tag %s for changeset %s' % (tag, node[:12]) tagnode, branch = write_tag(parser.repo, tag, node, msg, author) p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch.decode()) else: From dd6b72df21eba0e0a9d6360bac710e398720cfa8 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 18:09:53 -0500 Subject: [PATCH 030/109] Encode and decode {hg,git}ref Signed-off-by: Felipe Contreras --- git-remote-hg | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index d71a302..c4f1877 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -102,10 +102,10 @@ def hgbin(n): return node.bin(n) def hgref(ref): - return ref.replace('___', ' ') + return ref.replace('___', ' ').encode() def gitref(ref): - return ref.replace(' ', '___') + return ref.decode().replace(' ', '___') def check_version(*check): if not hg_version: @@ -645,11 +645,11 @@ def export_ref(repo, name, kind, head): marks.set_tip(ename, head.hex()) def export_tag(repo, tag): - node = repo.tags().get(hgref(tag).encode()) + node = repo.tags().get(hgref(tag)) export_ref(repo, tag, 'tags', repo[node]) def export_bookmark(repo, bmark): - head = bmarks[hgref(bmark).encode()] + head = bmarks[hgref(bmark)] export_ref(repo, bmark, 'bookmarks', head) def export_branch(repo, branch): @@ -680,14 +680,14 @@ def branch_tip(branch): return branches[branch][-1] def get_branch_tip(repo, branch): - heads = branches.get(hgref(branch).encode(), None) + heads = branches.get(hgref(branch), None) if not heads: return None # verify there's only one head if (len(heads) > 1): warn("Branch '%s' has more than one head, consider merging" % branch) - return branch_tip(hgref(branch).encode()) + return branch_tip(hgref(branch)) return heads[0] @@ -703,7 +703,7 @@ def list_head(repo, cur): fake_bmark = head bmarks[head] = node - head = gitref(head.decode()) + head = gitref(head) print("@refs/heads/%s HEAD" % head) g_head = (head, node) @@ -730,16 +730,16 @@ def do_list(parser): if track_branches: for branch in branches: - print("? refs/heads/branches/%s" % gitref(branch.decode())) + print("? refs/heads/branches/%s" % gitref(branch)) for bmark in bmarks: if bmarks[bmark].hex() != '0' * 40: - print("? refs/heads/%s" % gitref(bmark.decode())) + print("? refs/heads/%s" % gitref(bmark)) for tag, node in repo.tagslist(): if tag == b'tip': continue - print("? refs/tags/%s" % gitref(tag.decode())) + print("? refs/tags/%s" % gitref(tag)) print("") @@ -906,7 +906,7 @@ def parse_commit(parser): # Check if the ref is supposed to be a named branch if ref.startswith('refs/heads/branches/'): branch = ref[len('refs/heads/branches/'):] - extra['branch'] = hgref(branch) + extra['branch'] = hgref(branch).decode() if mode == 'hg': i = data.find('\n--HG--\n') @@ -1243,13 +1243,13 @@ def do_export(parser): print("ok %s" % ref) continue tag = ref[len('refs/tags/'):] - tag = hgref(tag).encode() + tag = hgref(tag) author, msg = parsed_tags.get(tag, (None, None)) if mode == 'git': if not msg: msg = b'Added tag %s for changeset %s' % (tag, node[:12]) tagnode, branch = write_tag(parser.repo, tag, node, msg, author) - p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch.decode()) + p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch) else: if check_version(2, 4): vfs = parser.repo.vfs From ccee8909ffec1c9bce75ad6f40f29219dbb13eba Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 18:24:48 -0500 Subject: [PATCH 031/109] Encode hg rev and hex stuff Signed-off-by: Felipe Contreras --- git-remote-hg | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index c4f1877..4a44ee2 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -169,7 +169,7 @@ class Marks: def upgrade_one(self): def get_id(rev): - return hghex(self.repo.changelog.node(int(rev))) + return hghex(self.repo.changelog.node(int(rev))).decode() self.tips = dict((name, get_id(rev)) for name, rev in self.tips.items()) self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.items()) self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.items()) @@ -198,22 +198,23 @@ class Marks: def get_mark(self, rev): self.last_mark += 1 - self.marks[rev] = self.last_mark + self.marks[rev.decode()] = self.last_mark return self.last_mark def new_mark(self, rev, mark): + rev = rev.decode() self.marks[rev] = mark self.rev_marks[mark] = rev self.last_mark = mark def is_marked(self, rev): - return rev in self.marks + return rev.decode() in self.marks def get_tip(self, branch): - return self.tips[branch] + return self.tips[branch].encode() def set_tip(self, branch, tip): - self.tips[branch] = tip + self.tips[branch] = tip.decode() class Parser: @@ -474,10 +475,10 @@ def get_repo(url, alias): return repo def rev_to_mark(rev): - return marks.from_rev(rev.hex()) + return marks.from_rev(rev.hex().decode()) def mark_to_rev(mark): - return marks.to_rev(mark) + return marks.to_rev(mark).encode() # Get a range of revisions in the form of a..b (git committish) def gitrange(repo, a, b): @@ -733,7 +734,7 @@ def do_list(parser): print("? refs/heads/branches/%s" % gitref(branch)) for bmark in bmarks: - if bmarks[bmark].hex() != '0' * 40: + if bmarks[bmark].hex() != b'0' * 40: print("? refs/heads/%s" % gitref(bmark)) for tag, node in repo.tagslist(): @@ -889,12 +890,12 @@ def parse_commit(parser): if from_mark: p1 = mark_to_rev(from_mark) else: - p1 = '0' * 40 + p1 = b'0' * 40 if merge_mark: p2 = mark_to_rev(merge_mark) else: - p2 = '0' * 40 + p2 = b'0' * 40 # # If files changed from any of the parents, hg wants to know, but in git if @@ -988,7 +989,7 @@ def write_tag(repo, tag, node, msg, author): return make_memfilectx(repo, memctx, f, content) p1 = tip.hex() - p2 = '0' * 40 + p2 = b'0' * 40 if author: user, date, tz = author user = user.encode() From 8c3cde6be7fdc0bd77fa3d6715958d05072121d0 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 18:47:54 -0500 Subject: [PATCH 032/109] Encode hg urls Signed-off-by: Felipe Contreras --- git-remote-hg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 4a44ee2..79b8101 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -423,6 +423,8 @@ def get_repo(url, alias): extensions.loadall(myui) + url = url.encode() + if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'): repo = hg.repository(myui, url) if not os.path.exists(dirname): @@ -444,7 +446,7 @@ def get_repo(url, alias): # setup shared repo (if not there) try: - hg.peer(myui, {}, shared_path, create=True) + hg.peer(myui, {}, shared_path.encode(), create=True) except error.RepoError: pass @@ -453,12 +455,12 @@ def get_repo(url, alias): local_path = os.path.join(dirname, 'clone') if not os.path.exists(local_path): - hg.share(myui, shared_path, local_path, update=False) + hg.share(myui, shared_path.encode(), local_path.encode(), update=False) else: # make sure the shared path is always up-to-date - util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path) + util.writefile(os.path.join(local_path, '.hg', 'sharedpath').encode(), hg_path.encode()) - repo = hg.repository(myui, local_path) + repo = hg.repository(myui, local_path.encode()) try: peer = hg.peer(repo.ui, {}, url) except: From 0cf8b2c20adf25d4c0d8df6b5717a8548073bad7 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:09:00 -0500 Subject: [PATCH 033/109] Encode more hg stuff Signed-off-by: Felipe Contreras --- git-remote-hg | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 79b8101..3b4c8fa 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -281,7 +281,7 @@ class Parser: return (user, int(date), hgtz(tz)) def fix_file_path(path): - path = os.path.normpath(path) + path = os.path.normpath(path.decode()) if not os.path.isabs(path): return path return os.path.relpath(path, '/') @@ -539,15 +539,17 @@ def export_ref(repo, name, kind, head): continue (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node) - rev_branch = extra['branch'] + rev_branch = extra['branch'].decode() + + user = user.decode() author = "%s %d %s" % (fixup_user(user), time, gittz(tz)) if 'committer' in extra: try: - cuser, ctime, ctz = extra['committer'].rsplit(' ', 2) + cuser, ctime, ctz = extra['committer'].decode().rsplit(' ', 2) committer = "%s %s %s" % (fixup_user(cuser), ctime, gittz(int(ctz))) except ValueError: - cuser = extra['committer'] + cuser = extra['committer'].decode() committer = "%s %d %s" % (fixup_user(cuser), time, gittz(tz)) else: committer = author @@ -560,7 +562,7 @@ def export_ref(repo, name, kind, head): else: modified, removed = get_filechanges(repo, c, parents[0]) - desc += '\n' + desc += b'\n' if mode == 'hg': extra_msg = '' @@ -577,16 +579,17 @@ def export_ref(repo, name, kind, head): renames.append((rename[0], f)) for e in renames: - extra_msg += "rename : %s => %s\n" % e + extra_msg += (b"rename : %s => %s\n" % e).decode() for key, value in extra.items(): + key, value = key.decode(), value.decode() if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'): continue else: extra_msg += "extra : %s : %s\n" % (key, urlquote(value)) if extra_msg: - desc += '\n--HG--\n' + extra_msg + desc += b'\n--HG--\n' + extra_msg.encode() if len(parents) == 0 and rev: print('reset %s/%s' % (prefix, ename)) @@ -909,21 +912,21 @@ def parse_commit(parser): # Check if the ref is supposed to be a named branch if ref.startswith('refs/heads/branches/'): branch = ref[len('refs/heads/branches/'):] - extra['branch'] = hgref(branch).decode() + extra[b'branch'] = hgref(branch) if mode == 'hg': i = data.find('\n--HG--\n') if i >= 0: tmp = data[i + len('\n--HG--\n'):].strip() - for k, v in [e.split(' : ', 1) for e in tmp.split('\n')]: - if k == 'rename': - old, new = v.split(' => ', 1) + for k, v in [e.encode().split(b' : ', 1) for e in tmp.split('\n')]: + if k == b'rename': + old, new = v.split(b' => ', 1) files[new]['rename'] = old - elif k == 'branch': + elif k == b'branch': extra[k] = v - elif k == 'extra': - ek, ev = v.split(' : ', 1) - extra[ek] = urlunquote(ev) + elif k == b'extra': + ek, ev = v.split(b' : ', 1) + extra[ek] = urlunquote(ev).encode() data = data[:i] ctx = context.memctx(repo, (p1, p2), data, @@ -986,8 +989,8 @@ def write_tag(repo, tag, node, msg, author): fctx = tip.filectx(f) data = fctx.data() except error.LookupError: - data = "" - content = data + "%s %s\n" % (node, tag) + data = b"" + content = data + b"%s %s\n" % (node, tag) return make_memfilectx(repo, memctx, f, content) p1 = tip.hex() From b8c8b1fd0013703cf0fdec1a78fc9c61810618ca Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:17:46 -0500 Subject: [PATCH 034/109] Encode hg literals Signed-off-by: Felipe Contreras --- git-remote-hg | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 3b4c8fa..244273d 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -77,7 +77,7 @@ def warn(msg, *args): sys.stderr.write('WARNING: %s\n' % (msg % args)) def gitmode(flags): - return 'l' in flags and '120000' or 'x' in flags and '100755' or '100644' + return b'l' in flags and '120000' or b'x' in flags and '100755' or '100644' def gittz(tz): sign = 1 if tz >= 0 else -1 @@ -380,7 +380,7 @@ def fixup_user(user): return '%s <%s>' % (name, mail) def updatebookmarks(repo, peer): - remotemarks = peer.listkeys('bookmarks') + remotemarks = peer.listkeys(b'bookmarks') localmarks = repo._bookmarks if not remotemarks: @@ -391,7 +391,7 @@ def updatebookmarks(repo, peer): wlock = tr = None try: wlock = repo.wlock() - tr = repo.transaction('bookmark') + tr = repo.transaction(b'bookmark') if check_version(4, 3): localmarks.applychanges(repo, tr, changes.items()) else: @@ -415,11 +415,11 @@ def get_repo(url, alias): else: myui = ui.ui() - myui.setconfig('ui', 'interactive', 'off') + myui.setconfig(b'ui', b'interactive', b'off') myui.fout = sys.stderr if get_config_bool('remote-hg.insecure'): - myui.setconfig('web', 'cacerts', '') + myui.setconfig(b'web', b'cacerts', b'') extensions.loadall(myui) @@ -539,17 +539,17 @@ def export_ref(repo, name, kind, head): continue (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node) - rev_branch = extra['branch'].decode() + rev_branch = extra[b'branch'].decode() user = user.decode() author = "%s %d %s" % (fixup_user(user), time, gittz(tz)) - if 'committer' in extra: + if b'committer' in extra: try: - cuser, ctime, ctz = extra['committer'].decode().rsplit(' ', 2) + cuser, ctime, ctz = extra[b'committer'].decode().rsplit(' ', 2) committer = "%s %s %s" % (fixup_user(cuser), ctime, gittz(int(ctz))) except ValueError: - cuser = extra['committer'].decode() + cuser = extra[b'committer'].decode() committer = "%s %d %s" % (fixup_user(cuser), time, gittz(tz)) else: committer = author @@ -728,7 +728,7 @@ def do_list(parser): for branch, heads in items: # only open heads - heads = [h for h in heads if 'close' not in repo.changelog.read(h)[5]] + heads = [h for h in heads if b'close' not in repo.changelog.read(h)[5]] if heads: branches[branch] = heads @@ -890,7 +890,7 @@ def parse_commit(parser): extra = {} if committer != author: - extra['committer'] = ("%s %u %u" % committer).encode() + extra[b'committer'] = ("%s %u %u" % committer).encode() if from_mark: p1 = mark_to_rev(from_mark) @@ -1011,8 +1011,8 @@ def write_tag(repo, tag, node, msg, author): date_tz = None ctx = context.memctx(repo, (p1, p2), msg, - ['.hgtags'], getfilectx, - user, date_tz, {'branch': branch}) + [b'.hgtags'], getfilectx, + user, date_tz, {b'branch': branch}) tmp = encoding.encoding encoding.encoding = 'utf-8' @@ -1121,29 +1121,29 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): if check_version(4, 0): if check_version(4, 4): - cg = changegroup.makechangegroup(repo, outgoing, '01', 'push') + cg = changegroup.makechangegroup(repo, outgoing, b'01', b'push') else: - cg = changegroup.getchangegroup(repo, 'push', outgoing) + cg = changegroup.getchangegroup(repo, b'push', outgoing) elif check_version(3, 2): - cg = changegroup.getchangegroup(repo, 'push', heads=list(p_revs), common=common) + cg = changegroup.getchangegroup(repo, b'push', heads=list(p_revs), common=common) elif check_version(3, 0): - cg = changegroup.getbundle(repo, 'push', heads=list(p_revs), common=common) + cg = changegroup.getbundle(repo, b'push', heads=list(p_revs), common=common) else: - cg = repo.getbundle('push', heads=list(p_revs), common=common) + cg = repo.getbundle(b'push', heads=list(p_revs), common=common) - unbundle = remote.capable('unbundle') + unbundle = remote.capable(b'unbundle') if unbundle: if force: - remoteheads = ['force'] - ret = remote.unbundle(cg, remoteheads, 'push') + remoteheads = [b'force'] + ret = remote.unbundle(cg, remoteheads, b'push') else: - ret = remote.addchangegroup(cg, 'push', repo.url()) + ret = remote.addchangegroup(cg, b'push', repo.url()) - phases = remote.listkeys('phases') + phases = remote.listkeys(b'phases') if phases: for head in p_revs: # update to public - remote.pushkey('phases', hghex(head), '1', '0') + remote.pushkey(b'phases', hghex(head), b'1', b'0') return ret @@ -1156,7 +1156,7 @@ def push(repo, remote, parsed_refs, p_revs): return lock = None - unbundle = remote.capable('unbundle') + unbundle = remote.capable(b'unbundle') if not unbundle: lock = remote.lock() try: @@ -1236,7 +1236,7 @@ def do_export(parser): p_bmarks.append((ref, bmark, old, new)) if peer: - remote_old = peer.listkeys('bookmarks').get(bmark) + remote_old = peer.listkeys(b'bookmarks').get(bmark) if remote_old: if not check_tip(ref, 'bookmarks', g_bmark, remote_old): print("error %s fetch first" % ref) @@ -1261,8 +1261,8 @@ def do_export(parser): vfs = parser.repo.vfs else: vfs = parser.repo.opener - fp = vfs('localtags', 'a') - fp.write('%s %s\n' % (node, tag)) + fp = vfs(b'localtags', b'a') + fp.write(b'%s %s\n' % (node, tag)) fp.close() p_revs[bnode] = ref print("ok %s" % ref) @@ -1287,11 +1287,11 @@ def do_export(parser): return # update remote bookmarks - remote_bmarks = peer.listkeys('bookmarks') + remote_bmarks = peer.listkeys(b'bookmarks') for ref, bmark, old, new in p_bmarks: if force_push: - old = remote_bmarks.get(bmark, '') - if not peer.pushkey('bookmarks', bmark, old, new): + old = remote_bmarks.get(bmark, b'') + if not peer.pushkey(b'bookmarks', bmark, old, new): print("error %s" % ref) else: # update local bookmarks From 59ad50c6d07c02bbcda69a6884c6f3153bb2326c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:21:09 -0500 Subject: [PATCH 035/109] Encode more stuff Signed-off-by: Felipe Contreras --- git-remote-hg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 244273d..cc47044 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -116,7 +116,7 @@ def get_config(config): cmd = ['git', 'config', '--get', config] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) output, _ = process.communicate() - return output + return output.decode() def get_config_bool(config, default=False): value = get_config(config).rstrip('\n') @@ -1003,7 +1003,7 @@ def write_tag(repo, tag, node, msg, author): cmd = ['git', 'var', 'GIT_COMMITTER_IDENT'] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) output, _ = process.communicate() - m = re.match('^.* <.*>', output) + m = re.match(b'^.* <.*>', output) if m: user = m.group(0) else: @@ -1361,7 +1361,7 @@ def main(args): if alias[4:] == url: is_tmp = True - alias = hashlib.sha1(alias).hexdigest() + alias = hashlib.sha1(alias.encode()).hexdigest() dirname = os.path.join(gitdir, 'hg', alias) branches = {} From e892cb6ce3a1e8dfe6a14fdcff840cc7a0372f13 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:27:35 -0500 Subject: [PATCH 036/109] Decode commit data Signed-off-by: Felipe Contreras --- git-remote-hg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index cc47044..806044a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -828,7 +828,7 @@ def parse_commit(parser): parser.next() committer = parser.get_author() parser.next() - data = parser.get_data() + data = parser.get_data().decode() parser.next() if parser.check('from'): from_mark = parser.get_mark() @@ -929,7 +929,7 @@ def parse_commit(parser): extra[ek] = urlunquote(ev).encode() data = data[:i] - ctx = context.memctx(repo, (p1, p2), data, + ctx = context.memctx(repo, (p1, p2), data.encode(), files.keys(), getfilectx, user.encode(), (date, tz), extra) From 4aec2fe3cc45f329c9f93181af5aeb83c9d0b7a9 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:50:20 -0500 Subject: [PATCH 037/109] Properly print binary data Signed-off-by: Felipe Contreras --- git-remote-hg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 806044a..84e4484 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -301,7 +301,7 @@ def export_files(files): print("blob") print("mark :%u" % mark) print("data %d" % len(d)) - print(d) + print(d.decode()) path = fix_file_path(f.path()) final.append((gitmode(f.flags()), mark, path)) @@ -601,7 +601,7 @@ def export_ref(repo, name, kind, head): print("author %s" % (author)) print("committer %s" % (committer)) print("data %d" % (len(desc))) - print(desc) + print(desc.decode()) if len(parents) > 0: print("from :%s" % (rev_to_mark(parents[0]))) @@ -643,7 +643,7 @@ def export_ref(repo, name, kind, head): print("N inline :%u" % rev_to_mark(c)) msg = c.hex() print(("data %d" % (len(msg)))) - print(msg) + print(msg.decode()) print("") marks.last_note = note_mark From 34ba0878960308a71fc0b9f96457c9624262f439 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 17:24:41 -0500 Subject: [PATCH 038/109] Use unicode_escape Seems to work in both python2 and python3. Signed-off-by: Felipe Contreras --- git-remote-hg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 84e4484..72d8b8a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -803,10 +803,9 @@ def get_merge_files(repo, p1, p2, files): files[e] = f def c_style_unescape(string): - string = string.encode() if string[0] == string[-1] == '"': - return string.decode('string-escape')[1:-1] - return string + return string.encode().decode('unicode_escape').encode('latin-1')[1:-1] + return string.encode() def make_memfilectx(repo, changectx, path, data, islink=False, isexec=False, copied=None): if check_version(4, 5): From b3b9b5de39995a186861e2f0257e8216fe133b1d Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 Aug 2022 19:54:53 -0500 Subject: [PATCH 039/109] Enable python3 support Signed-off-by: Felipe Contreras --- README.asciidoc | 5 +---- git-remote-hg | 29 ++++++++++++++++++++--------- test/bidi.t | 2 +- test/hg-git.t | 6 +++--- test/main.t | 2 +- tools/check-versions | 2 +- tools/versions.txt | 2 ++ 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 08f5d3b..a16d9b4 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -52,10 +52,7 @@ the same commits: Remember to run `git gc --aggressive` after cloning a repository, especially if it's a big one. Otherwise lots of space will be wasted. -The newest supported version of Mercurial is 6.1 but only through Python 2. The -oldest one is 2.4. - -Support for Python 3 is ready, but will be released in the next version soon. +The newest supported version of Mercurial is 6.2, the oldest one is 2.4. === Pushing branches === diff --git a/git-remote-hg b/git-remote-hg index 72d8b8a..199cd47 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # # Copyright (c) 2012 Felipe Contreras # @@ -26,12 +26,23 @@ import atexit import hashlib import time as ptime -from urlparse import urlparse, urljoin -from urllib import quote as urlquote, unquote as urlunquote +if sys.version_info[0] >= 3: + from urllib.parse import urlparse, urljoin + from urllib.parse import quote as urlquote, unquote as urlunquote -# Hack to set default encoding -reload(sys) -sys.setdefaultencoding('utf-8') + ferr = sys.stderr.buffer + fin = sys.stdin.buffer + +else: + from urlparse import urlparse, urljoin + from urllib import quote as urlquote, unquote as urlunquote + + # Hack to set default encoding + reload(sys) + sys.setdefaultencoding('utf-8') + + ferr = sys.stderr + fin = sys.stdin # # If you want to see Mercurial revisions as Git commit notes: @@ -223,7 +234,7 @@ class Parser: self.line = self.get_line() def get_line(self): - return sys.stdin.readline().decode().strip() + return fin.readline().decode().strip() def __getitem__(self, i): return self.line.split()[i] @@ -253,7 +264,7 @@ class Parser: return None i = self.line.index(' ') + 1 size = int(self.line[i:]) - return sys.stdin.read(size) + return fin.read(size) def get_author(self): ex = None @@ -416,7 +427,7 @@ def get_repo(url, alias): myui = ui.ui() myui.setconfig(b'ui', b'interactive', b'off') - myui.fout = sys.stderr + myui.fout = ferr if get_config_bool('remote-hg.insecure'): myui.setconfig(b'web', b'cacerts', b'') diff --git a/test/bidi.t b/test/bidi.t index 9bc9821..cbcb0bd 100755 --- a/test/bidi.t +++ b/test/bidi.t @@ -17,7 +17,7 @@ then test_done fi -if ! python2 -c 'import mercurial' > /dev/null 2>&1 +if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' test_done diff --git a/test/hg-git.t b/test/hg-git.t index b552544..ba3995e 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -17,16 +17,16 @@ then test_done fi -if ! python2 -c 'import mercurial' > /dev/null 2>&1 +if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' test_done fi -if python2 -c 'import hggit' > /dev/null 2>&1 +if python -c 'import hggit' > /dev/null 2>&1 then hggit=hggit -elif python2 -c 'import hgext.git' > /dev/null 2>&1 +elif python -c 'import hgext.git' > /dev/null 2>&1 then hggit=hgext.git else diff --git a/test/main.t b/test/main.t index 7c12c4d..a3c48bd 100755 --- a/test/main.t +++ b/test/main.t @@ -17,7 +17,7 @@ then test_done fi -if ! python2 -c 'import mercurial' > /dev/null 2>&1 +if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' test_done diff --git a/tools/check-versions b/tools/check-versions index e553643..38e0d8b 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -102,7 +102,7 @@ class Component def build Dir.chdir(dir) do targets = %w[build_py build_ext].map { |e| [e, '--build-lib', "#{$builddir}/python"] } - run_cmd %w[python2 setup.py --quiet] + targets.flatten + run_cmd %w[python setup.py --quiet] + targets.flatten end end diff --git a/tools/versions.txt b/tools/versions.txt index 839bbab..e8bb3ea 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -40,3 +40,5 @@ hg:5.5 hggit:0.9.0 dulwich:0.19.15 # 2020_08 hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01 + +hg:5.8 hggit:0.10.1 dulwich:0.20.0 # 2021_05 # python3 From 6b8ee2f1b67fee637ed50cabdbeeb06acd112a9b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 7 Aug 2022 22:12:29 -0500 Subject: [PATCH 040/109] check-versions: update version list All these work with python3, and finally we are up-to-date. Signed-off-by: Felipe Contreras --- tools/versions.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/versions.txt b/tools/versions.txt index e8bb3ea..e7780ab 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -41,4 +41,8 @@ hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01 -hg:5.8 hggit:0.10.1 dulwich:0.20.0 # 2021_05 # python3 +hg:5.8 hggit:0.10.2 dulwich:0.20.0 # 2021_05 # python3 +hg:5.9 hggit:0.10.2 dulwich:0.20.0 # 2021_08 +hg:6.0 hggit:0.10.2 dulwich:0.20.0 # 2021_11 +hg:6.1 hggit:0.10.2 dulwich:0.20.0 # 2022_02 +hg:6.2 hggit:0.10.2 dulwich:0.20.0 # 2022_07 From ce38d52ce5f37d89cf6683a82170e2f0ec9f3fff Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 7 Aug 2022 22:16:38 -0500 Subject: [PATCH 041/109] check-versions: add latest version Signed-off-by: Felipe Contreras --- tools/versions.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/versions.txt b/tools/versions.txt index e7780ab..8ac50b3 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -46,3 +46,5 @@ hg:5.9 hggit:0.10.2 dulwich:0.20.0 # 2021_08 hg:6.0 hggit:0.10.2 dulwich:0.20.0 # 2021_11 hg:6.1 hggit:0.10.2 dulwich:0.20.0 # 2022_02 hg:6.2 hggit:0.10.2 dulwich:0.20.0 # 2022_07 + +hg:6.2 hggit:1.0.0 dulwich:0.20.45 # latest From 6e13c1c8186df8ae7b87be8122ccb2f1c1f67a4e Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 8 Aug 2022 00:16:08 -0500 Subject: [PATCH 042/109] github: run tests with python3 Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84dd14f..dbb32bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,16 +7,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7' ] + hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2' ] env: HG_VERSION: ${{ matrix.hg }} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 with: - python-version: '2.7' - - name: Install python-dev - run: sudo apt-get install -y python2.7-dev + python-version: '3.8' + check-latest: true - name: Cache check-versions script id: cache-check-versions uses: actions/cache@v3 From 485806e1e37229c79301888c16d3523458c71b85 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 10 Aug 2022 21:12:05 -0500 Subject: [PATCH 043/109] Dump data contents as-is We don't care if it's valid utf-8 or not, just dump it. Signed-off-by: Felipe Contreras --- git-remote-hg | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 199cd47..705029a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -77,6 +77,11 @@ RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') VERSION = 2 +def print_data(d): + print('data %d' % len(d)) + sys.stdout.flush() + os.write(1, d) + def debug(*args): sys.stderr.write('DEBUG: %s\n' % repr(args)) @@ -311,8 +316,7 @@ def export_files(files): print("blob") print("mark :%u" % mark) - print("data %d" % len(d)) - print(d.decode()) + print_data(d) path = fix_file_path(f.path()) final.append((gitmode(f.flags()), mark, path)) @@ -611,8 +615,7 @@ def export_ref(repo, name, kind, head): print("mark :%d" % (marks.get_mark(c.hex()))) print("author %s" % (author)) print("committer %s" % (committer)) - print("data %d" % (len(desc))) - print(desc.decode()) + print_data(desc) if len(parents) > 0: print("from :%s" % (rev_to_mark(parents[0]))) @@ -653,8 +656,7 @@ def export_ref(repo, name, kind, head): c = repo[rev] print("N inline :%u" % rev_to_mark(c)) msg = c.hex() - print(("data %d" % (len(msg)))) - print(msg.decode()) + print_data(msg) print("") marks.last_note = note_mark From 30f31c13cec7e9d5c219dc1e422c4a3caaf0ed28 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 10 Aug 2022 23:52:59 -0500 Subject: [PATCH 044/109] Skip close check for non-local branches Apparently nowadays some remotes contain a bunch of topic branches which are not pulled by default. Signed-off-by: Felipe Contreras --- git-remote-hg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 705029a..071be43 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -741,8 +741,11 @@ def do_list(parser): for branch, heads in items: # only open heads - heads = [h for h in heads if b'close' not in repo.changelog.read(h)[5]] - if heads: + try: + heads = [h for h in heads if b'close' not in repo.changelog.read(h)[5]] + if heads: + branches[branch] = heads + except error.LookupError: branches[branch] = heads list_head(repo, cur) From 104e8895d60a188cc40b684ee62a35511a5e66b2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 19 Aug 2022 18:37:24 -0500 Subject: [PATCH 045/109] doc: update and cleanup Signed-off-by: Felipe Contreras --- doc/git-remote-hg.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/git-remote-hg.txt b/doc/git-remote-hg.txt index 0cceb76..8ebe1d1 100644 --- a/doc/git-remote-hg.txt +++ b/doc/git-remote-hg.txt @@ -38,7 +38,8 @@ If you want to see Mercurial revisions as Git commit notes: % git config core.notesRef refs/notes/hg -------------------------------------- -If you are not interested in Mercurial permanent and global branches (aka. commit labels): +If you are not interested in Mercurial permanent and global branches (aka. +commit labels): -------------------------------------- % git config --global remote-hg.track-branches false @@ -52,7 +53,8 @@ If you want the equivalent of `hg clone --insecure`: % git config --global remote-hg.insecure true -------------------------------------- -If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly the same commits: +If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly +the same commits: -------------------------------------- % git config --global remote-hg.hg-git-compat true @@ -61,16 +63,15 @@ If you want 'git-remote-hg' to be compatible with 'hg-git', and generate exactly NOTES ----- -Remember to run `git gc --aggressive` after cloning a repository, specially if +Remember to run `git gc --aggressive` after cloning a repository, especially if it's a big one. Otherwise lots of space will be wasted. -The oldest version of Mercurial supported is 1.9. For the most part 1.8 works, -but you might experience some issues. +The newest supported version of Mercurial is 6.2, the oldest one is 2.4. Pushing branches ~~~~~~~~~~~~~~~~ -To push a Mercurial named branch, you need to use the "branches/" prefix: +To push a branch, you need to use the "branches/" prefix: -------------------------------------- % git checkout branches/next @@ -91,7 +92,7 @@ The simplest way is to specify the user and password in the URL: git clone hg::https://user:password@bitbucket.org/user/repo -------------------------------------- -You can also use the http://mercurial.selenic.com/wiki/SchemesExtension[schemes extension]: +You can also use the https://mercurial-scm.org/wiki/SchemesExtension[schemes extension]: -------------------------------------- [auth] @@ -101,7 +102,7 @@ bb.password = password -------------------------------------- Finally, you can also use the -https://pypi.python.org/pypi/mercurial_keyring[keyring extension]. +https://pypi.org/project/mercurial_keyring[keyring extension]. CAVEATS ------- @@ -113,9 +114,9 @@ Mercurial branches and bookmarks have some limitations of Git branches: you can't have both 'dev/feature' and 'dev' (as Git uses files and directories to store them). -Multiple anonymous heads (which are useless anyway) are not supported; you +Multiple anonymous heads (which are useless anyway) are not supported: you would only see the latest head. -Closed branches are not supported; they are not shown and you can't close or +Closed branches are not supported: they are not shown and you can't close or reopen. Additionally in certain rare situations a synchronization issue can occur (https://github.com/felipec/git/issues/65[Bug #65]). From a5bc03d4d6f8111d5b4333fa0f192c374d1d50f2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 19 Aug 2022 18:41:53 -0500 Subject: [PATCH 046/109] doc: use asdiidoctor Signed-off-by: Felipe Contreras --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c654faf..38df75f 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ test: $(MAKE) -C test doc/git-remote-hg.1: doc/git-remote-hg.txt - a2x -d manpage -f manpage $< + asciidoctor -b manpage $< clean: $(RM) doc/git-remote-hg.1 From bf7ad934d7e933208380df6586a74ceb1d1d18f9 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 1 Mar 2023 11:03:45 -0600 Subject: [PATCH 047/109] check-versions: update Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- tools/versions.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dbb32bf..6691374 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2' ] + hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3' ] env: HG_VERSION: ${{ matrix.hg }} steps: diff --git a/tools/versions.txt b/tools/versions.txt index 8ac50b3..30357df 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -47,4 +47,6 @@ hg:6.0 hggit:0.10.2 dulwich:0.20.0 # 2021_11 hg:6.1 hggit:0.10.2 dulwich:0.20.0 # 2022_02 hg:6.2 hggit:0.10.2 dulwich:0.20.0 # 2022_07 -hg:6.2 hggit:1.0.0 dulwich:0.20.45 # latest +hg:6.3 hggit:1.0.1 dulwich:0.20.50 + +# hg:6.3 hggit:1.0.1 dulwich:0.21.3 # latest From 5cd03ad0fd0f8dbdb95aa13818f133507355d392 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 1 Mar 2023 11:08:56 -0600 Subject: [PATCH 048/109] github: update python version Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6691374..724ed37 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.10' check-latest: true - name: Cache check-versions script id: cache-check-versions From 22229dd738ae3d0752b293cca1cf948c1d154cfa Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 18 Jun 2019 15:25:28 -0500 Subject: [PATCH 049/109] Only report success after successful push Otherwise git core will update the namespaced refs, and show success to the user, even in the case of a crash. Signed-off-by: Felipe Contreras --- git-remote-hg | 31 ++++++++++++++++++++++--------- test/main.t | 27 ++++++++++++--------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 071be43..9162953 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1198,6 +1198,7 @@ def bookmark_is_fake(bmark, real_bmarks): def do_export(parser): p_bmarks = [] p_revs = {} + ok_refs = [] parser.next() @@ -1236,7 +1237,7 @@ def do_export(parser): continue p_revs[bnode] = ref - print("ok %s" % ref) + ok_refs.append(ref) elif ref.startswith('refs/heads/'): g_bmark = ref[len('refs/heads/'):] bmark = g_bmark.encode() @@ -1246,8 +1247,9 @@ def do_export(parser): if old == new: continue - print("ok %s" % ref) - if not bookmark_is_fake(bmark, parser.repo._bookmarks): + if bookmark_is_fake(bmark, parser.repo._bookmarks): + ok_refs.append(ref) + else: p_bmarks.append((ref, bmark, old, new)) if peer: @@ -1261,7 +1263,7 @@ def do_export(parser): p_revs[bnode] = ref elif ref.startswith('refs/tags/'): if dry_run: - print("ok %s" % ref) + ok_refs.append(ref) continue tag = ref[len('refs/tags/'):] tag = hgref(tag) @@ -1280,7 +1282,7 @@ def do_export(parser): fp.write(b'%s %s\n' % (node, tag)) fp.close() p_revs[bnode] = ref - print("ok %s" % ref) + ok_refs.append(ref) else: # transport-helper/fast-export bugs continue @@ -1290,8 +1292,11 @@ def do_export(parser): return if dry_run: - if peer: - checkheads(parser.repo, peer, p_revs) + if not peer or checkheads(parser.repo, peer, p_revs): + for ref, bmark, old, new in p_bmarks: + print("ok %s" % ref) + for ref in ok_refs: + print("ok %s" % ref) print("") return @@ -1306,14 +1311,22 @@ def do_export(parser): for ref, bmark, old, new in p_bmarks: if force_push: old = remote_bmarks.get(bmark, b'') - if not peer.pushkey(b'bookmarks', bmark, old, new): + if peer.pushkey(b'bookmarks', bmark, old, new): + print("ok %s" % ref) + else: print("error %s" % ref) else: # update local bookmarks for ref, bmark, old, new in p_bmarks: - if not bookmarks.pushbookmark(parser.repo, bmark, old, new): + if bookmarks.pushbookmark(parser.repo, bmark, old, new): + print("ok %s" % ref) + else: print("error %s" % ref) + # update rest of the refs + for ref in ok_refs: + print("ok %s" % ref) + print("") def do_option(parser): diff --git a/test/main.t b/test/main.t index a3c48bd..249ae39 100755 --- a/test/main.t +++ b/test/main.t @@ -607,17 +607,14 @@ test_expect_success 'remote big push' ' cd gitrepo && check_push 1 --all <<-\EOF - master - good_bmark - branches/good_branch - new_bmark:new - branches/new_branch:new bad_bmark1:non-fast-forward bad_bmark2:non-fast-forward branches/bad_branch:non-fast-forward EOF ) && + check gitrepo origin/master one && + check gitrepo hg/origin/bookmarks/master one && check_branch hgrepo default one && check_branch hgrepo good_branch "good branch" && check_branch hgrepo bad_branch "bad branch" && @@ -645,8 +642,6 @@ test_expect_success 'remote big push fetch first' ' cd gitrepo && check_push 1 --all <<-\EOF && - master - good_bmark bad_bmark1:fetch-first branches/bad_branch:fetch-first EOF @@ -654,12 +649,13 @@ test_expect_success 'remote big push fetch first' ' git fetch && check_push 1 --all <<-\EOF - master - good_bmark bad_bmark1:non-fast-forward branches/bad_branch:non-fast-forward EOF - ) + ) && + + check gitrepo origin/master one && + check gitrepo hg/origin/bookmarks/master one ' test_expect_success 'remote big push force' ' @@ -682,6 +678,8 @@ test_expect_success 'remote big push force' ' EOF ) && + check gitrepo origin/master two && + check gitrepo hg/origin/bookmarks/master two && check_branch hgrepo default four && check_branch hgrepo good_branch eight && check_branch hgrepo bad_branch nine && @@ -701,11 +699,6 @@ test_expect_success 'remote big push dry-run' ' cd gitrepo && check_push 1 --dry-run --all <<-\EOF && - master - good_bmark - branches/good_branch - new_bmark:new - branches/new_branch:new bad_bmark1:non-fast-forward bad_bmark2:non-fast-forward branches/bad_branch:non-fast-forward @@ -720,6 +713,8 @@ test_expect_success 'remote big push dry-run' ' EOF ) && + check gitrepo origin/master one && + check gitrepo hg/origin/bookmarks/master one && check_branch hgrepo default one && check_branch hgrepo good_branch "good branch" && check_branch hgrepo bad_branch "bad branch" && @@ -750,6 +745,8 @@ test_expect_success 'remote big push force dry-run' ' EOF ) && + check gitrepo origin/master one && + check gitrepo hg/origin/bookmarks/master one && check_branch hgrepo default one && check_branch hgrepo good_branch "good branch" && check_branch hgrepo bad_branch "bad branch" && From 7394fc890e76ec3919fa30048338a9cbb59ce899 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 2 Mar 2023 16:54:33 -0600 Subject: [PATCH 050/109] Simplify gitrange The internal function for `a %% b` is marginally faster, and much simpler. Nowadays most versions of hg should have it. Signed-off-by: Felipe Contreras --- git-remote-hg | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 9162953..1568a51 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -497,41 +497,6 @@ def rev_to_mark(rev): def mark_to_rev(mark): return marks.to_rev(mark).encode() -# Get a range of revisions in the form of a..b (git committish) -def gitrange(repo, a, b): - if a == b: - return [] - - pfunc = repo.changelog.parentrevs - it = iter(range(b.rev(), -1, -1)) - - positive = [] - pending = set([b.rev()]) - negative = set([a.rev()]) - - def get_parents(rev): - for p in pfunc(rev): - if p == -1: continue - yield p - - while pending: - cur = next(it) - - if cur in negative: - negative.remove(cur) - for p in get_parents(cur): - negative.add(p) - pending.discard(p) - elif cur in pending: - positive.append(cur) - pending.remove(cur) - for p in get_parents(cur): - if p not in negative: - pending.add(p) - - positive.reverse() - return positive - def export_ref(repo, name, kind, head): ename = '%s/%s' % (kind, name) try: @@ -540,7 +505,8 @@ def export_ref(repo, name, kind, head): except (KeyError,error.RepoLookupError): tip = repo[-1] - revs = gitrange(repo, tip, head) + # tip..head + revs = repo.changelog.findmissingrevs(common={tip.rev()}, heads={head.rev()}) total = len(revs) tip = tip.rev() From 857d68708babcac0122908b75dfe14684c202c18 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 22:32:27 -0600 Subject: [PATCH 051/109] test: trivial cleanups TEST_DIRECTORY doesn't even exist in sharness. Signed-off-by: Felipe Contreras --- test/Makefile | 4 ++-- test/bidi.t | 3 +-- test/hg-git.t | 3 +-- test/main.t | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/test/Makefile b/test/Makefile index 13915fe..00d63a1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,9 @@ RM ?= rm -f T = main.t bidi.t -TEST_DIRECTORY := $(CURDIR) +SHARNESS_TEST_DIRECTORY := $(CURDIR) -export TEST_DIRECTORY +export SHARNESS_TEST_DIRECTORY all: test diff --git a/test/bidi.t b/test/bidi.t index cbcb0bd..b6d2bbb 100755 --- a/test/bidi.t +++ b/test/bidi.t @@ -8,8 +8,7 @@ test_description='Test bidirectionality of remote-hg' -test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ -. "$TEST_DIRECTORY"/test-lib.sh +. ./test-lib.sh if ! test_have_prereq PYTHON then diff --git a/test/hg-git.t b/test/hg-git.t index ba3995e..58a78a8 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -8,8 +8,7 @@ test_description='Test remote-hg output compared to hg-git' -test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ -. "$TEST_DIRECTORY"/test-lib.sh +. ./test-lib.sh if ! test_have_prereq PYTHON then diff --git a/test/main.t b/test/main.t index 249ae39..8fd35fe 100755 --- a/test/main.t +++ b/test/main.t @@ -8,8 +8,7 @@ test_description='Test remote-hg' -test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ -. "$TEST_DIRECTORY"/test-lib.sh +. ./test-lib.sh if ! test_have_prereq PYTHON then From de9bf3538837d0a8ff65e81ee0c9053f8332312d Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 22:40:09 -0600 Subject: [PATCH 052/109] test: include sharness properly So that it can be overridden. Signed-off-by: Felipe Contreras --- test/test-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index b14e32c..727083e 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1,6 +1,7 @@ #!/bin/sh -. ./sharness.sh +: "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "${BASH_SOURCE-$0}")" && pwd)}" +. "$SHARNESS_TEST_SRCDIR"/sharness.sh test_set_prereq PYTHON From b4c3277f72f995cc0babcdc5bc6f6d0e2254acc3 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:42:51 -0600 Subject: [PATCH 053/109] github: trigger actions on all branches Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 724ed37..0014115 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,5 @@ on: push: - branches: [ master ] jobs: test: From 6ae5e3961edf242d2d224ebd64c99b9821ed7da3 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 15:18:39 -0600 Subject: [PATCH 054/109] test: hg-git: cleanup Signed-off-by: Felipe Contreras --- test/hg-git.t | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 58a78a8..d154f84 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -6,6 +6,8 @@ # https://bitbucket.org/durin42/hg-git/src # +# shellcheck disable=SC2016,SC2034,SC2086,SC2164,SC1091 + test_description='Test remote-hg output compared to hg-git' . ./test-lib.sh @@ -36,7 +38,11 @@ fi # clone to a git repo with git git_clone_git () { git clone -q "hg::$1" $2 && - (cd $2 && git checkout master && git branch -D default) + ( + cd $2 && + git checkout master && + { git branch -D default || true ;} + ) } # clone to an hg repo with git @@ -57,7 +63,7 @@ git_clone_hg () { git init -q $2 && cd $1 && hg bookmark -i -f -r tip master && - hg -q push -r master ../$2 || true + { hg -q push -r master ../$2 || true ;} ) } @@ -73,8 +79,8 @@ hg_push_git () { git checkout -q -b tmp && git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' && git branch -D default && - git checkout -q @{-1} && - git branch -q -D tmp 2> /dev/null || true + git checkout -q '@{-1}' && + { git branch -q -D tmp 2> /dev/null || true ;} ) } @@ -82,44 +88,43 @@ hg_push_git () { hg_push_hg () { ( cd $1 && - hg -q push ../$2 || true + { hg -q push ../$2 || true ;} ) } hg_log () { - hg -R $1 log --graph --debug > log && - grep -v 'tag: *default/' log + hg -R $1 log --graph --debug | + grep -v 'tag: *default/' } git_log () { - git --git-dir=$1/.git fast-export --branches + git -C $1 fast-export --branches } setup () { - cat > "$HOME"/.hgrc <<-EOF && + cat > "$HOME"/.hgrc <<-EOF [ui] username = A U Thor [defaults] - backout = -d "0 0" commit = -d "0 0" - debugrawcommit = -d "0 0" tag = -d "0 0" [extensions] $hggit = - graphlog = [git] debugextrainmessage = 1 EOF - git config --global receive.denycurrentbranch warn - git config --global remote-hg.hg-git-compat true - git config --global remote-hg.track-branches false - HGEDITOR=true - HGMERGE=true + cat > "$HOME"/.gitconfig <<-EOF + [remote-hg] + hg-git-compat = true + track-branches = false + EOF - GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" - GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" - export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE + export HGEDITOR=true + export HGMERGE=true + + export GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" + export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" } setup From ec7119d0efec344958b5e460ea1a420d4e4a5aed Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 12:28:28 -0600 Subject: [PATCH 055/109] test: relax hg-git checks We don't care about the revision number of the commits, only the topology. Signed-off-by: Felipe Contreras --- test/hg-git.t | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index d154f84..3ef11d5 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -93,8 +93,9 @@ hg_push_hg () { } hg_log () { - hg -R $1 log --graph --debug | - grep -v 'tag: *default/' + hg -R $1 log --debug -r 'sort(tip:0, date)' | + grep -v 'tag: *default/' | + sed -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/' } git_log () { @@ -232,16 +233,16 @@ test_expect_success 'merge conflict 1' ' hg ci -m "origin" && echo B > afile && - hg ci -m "A->B" && + hg ci -m "A->B" -d "1 0" && hg up -r0 && echo C > afile && - hg ci -m "A->C" && + hg ci -m "A->C" -d "2 0" && hg merge -r1 && echo C > afile && hg resolve -m afile && - hg ci -m "merge to C" + hg ci -m "merge to C" -d "3 0" ) && for x in hg git @@ -267,16 +268,16 @@ test_expect_success 'merge conflict 2' ' hg ci -m "origin" && echo B > afile && - hg ci -m "A->B" && + hg ci -m "A->B" -d "1 0" && hg up -r0 && echo C > afile && - hg ci -m "A->C" && + hg ci -m "A->C" -d "2 0" && hg merge -r1 || true && echo B > afile && hg resolve -m afile && - hg ci -m "merge to B" + hg ci -m "merge to B" -d "3 0" ) && for x in hg git @@ -302,17 +303,17 @@ test_expect_success 'converged merge' ' hg ci -m "origin" && echo B > afile && - hg ci -m "A->B" && + hg ci -m "A->B" -d "1 0" && echo C > afile && - hg ci -m "B->C" && + hg ci -m "B->C" -d "2 0" && hg up -r0 && echo C > afile && - hg ci -m "A->C" && + hg ci -m "A->C" -d "3 0" && hg merge -r2 || true && - hg ci -m "merge" + hg ci -m "merge" -d "4 0" ) && for x in hg git From 08e453f8db5c9146a8811d84d9cb4b23b7f3e57e Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:25:44 -0600 Subject: [PATCH 056/109] test: hg-git: simplify hg log filter Signed-off-by: Felipe Contreras --- test/hg-git.t | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 3ef11d5..146341b 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -94,8 +94,7 @@ hg_push_hg () { hg_log () { hg -R $1 log --debug -r 'sort(tip:0, date)' | - grep -v 'tag: *default/' | - sed -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/' + sed -e '/tag: *default/d' -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/' } git_log () { From 7078666c776f577cf462512a904dd23f7d43e9cd Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 20:26:19 -0600 Subject: [PATCH 057/109] test: hg-git: add main helper Simplifies current code and will be useful later. Signed-off-by: Felipe Contreras --- test/hg-git.t | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 146341b..1a80938 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -129,9 +129,15 @@ setup () { setup -test_expect_success 'rename' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && +# save old function +eval "old_$(declare -f test_expect_success)" +test_expect_success () { + old_test_expect_success "$1" " + test_when_finished \"rm -rf gitrepo* hgrepo*\" && $2" +} + +test_expect_success 'rename' ' ( hg init hgrepo1 && cd hgrepo1 && @@ -155,8 +161,6 @@ test_expect_success 'rename' ' ' test_expect_success 'executable bit' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( git init -q gitrepo && cd gitrepo && @@ -191,8 +195,6 @@ test_expect_success 'executable bit' ' ' test_expect_success 'symlink' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( git init -q gitrepo && cd gitrepo && @@ -222,8 +224,6 @@ test_expect_success 'symlink' ' ' test_expect_success 'merge conflict 1' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( hg init hgrepo1 && cd hgrepo1 && @@ -257,8 +257,6 @@ test_expect_success 'merge conflict 1' ' ' test_expect_success 'merge conflict 2' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( hg init hgrepo1 && cd hgrepo1 && @@ -292,8 +290,6 @@ test_expect_success 'merge conflict 2' ' ' test_expect_success 'converged merge' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( hg init hgrepo1 && cd hgrepo1 && @@ -328,8 +324,6 @@ test_expect_success 'converged merge' ' ' test_expect_success 'encoding' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( git init -q gitrepo && cd gitrepo && @@ -368,8 +362,6 @@ test_expect_success 'encoding' ' ' test_expect_success 'file removal' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( git init -q gitrepo && cd gitrepo && @@ -408,8 +400,6 @@ test_expect_success 'file removal' ' ' test_expect_success 'git tags' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - ( git init -q gitrepo && cd gitrepo && @@ -435,8 +425,6 @@ test_expect_success 'git tags' ' ' test_expect_success 'hg author' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - for x in hg git do ( @@ -502,8 +490,6 @@ test_expect_success 'hg author' ' ' test_expect_success 'hg branch' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - for x in hg git do ( @@ -539,8 +525,6 @@ test_expect_success 'hg branch' ' ' test_expect_success 'hg tags' ' - test_when_finished "rm -rf gitrepo* hgrepo*" && - for x in hg git do ( From d45d5cde50e82bb0b595a2e208e349a030233042 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 10:01:27 -0600 Subject: [PATCH 058/109] test: switch to bash We are using some bash-specific tricks. Signed-off-by: Felipe Contreras --- test/Makefile | 2 +- test/bidi.t | 2 +- test/hg-git.t | 2 +- test/main.t | 2 +- test/test-lib.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index 00d63a1..02c8c01 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ test: $(T) $(MAKE) clean $(T): - $(SHELL) $@ $(TEST_OPTS) + ./$@ $(TEST_OPTS) clean: $(RM) -r 'trash directory'.* test-results diff --git a/test/bidi.t b/test/bidi.t index b6d2bbb..cdbe07f 100755 --- a/test/bidi.t +++ b/test/bidi.t @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2012 Felipe Contreras # diff --git a/test/hg-git.t b/test/hg-git.t index 1a80938..7d0fc4a 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2012 Felipe Contreras # diff --git a/test/main.t b/test/main.t index 8fd35fe..dccec35 100755 --- a/test/main.t +++ b/test/main.t @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2012 Felipe Contreras # diff --git a/test/test-lib.sh b/test/test-lib.sh index 727083e..b0d6580 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash : "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "${BASH_SOURCE-$0}")" && pwd)}" . "$SHARNESS_TEST_SRCDIR"/sharness.sh From 79797918ff85b847fed0b9987e573486cffcfa92 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 17:14:01 -0600 Subject: [PATCH 059/109] test: hg-git: add helper functions It's tedious to do almost exactly the same thing over and over. Signed-off-by: Felipe Contreras --- test/hg-git.t | 149 +++++++++++++++++--------------------------------- 1 file changed, 50 insertions(+), 99 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 7d0fc4a..8b24cb3 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -101,6 +101,45 @@ git_log () { git -C $1 fast-export --branches } +cmp_hg_to_git_log () { + for x in hg git + do + hg_log hgrepo2-$x > "hg-log-$x" && + git_log gitrepo-$x > "git-log-$x" + done && + + test_cmp hg-log-hg hg-log-git && + test_cmp git-log-hg git-log-git +} + +cmp_hg_to_git_log_hgrepo1 () { + for x in hg git + do + git_clone_$x hgrepo1 gitrepo-$x && + hg_clone_$x gitrepo-$x hgrepo2-$x + done && + + cmp_hg_to_git_log +} + +cmp_hg_to_git_manifest () { + for x in hg git + do + ( + hg_clone_$x gitrepo hgrepo-$x && + cd hgrepo-$x && + hg_log . && + eval "$1" + ) > "output-$x" && + + git_clone_$x hgrepo-$x gitrepo2-$x && + git_log gitrepo2-$x > "log-$x" + done && + + test_cmp output-hg output-git && + test_cmp log-hg log-git +} + setup () { cat > "$HOME"/.hgrc <<-EOF [ui] @@ -148,16 +187,7 @@ test_expect_success 'rename' ' hg commit -m "rename alpha to beta" ) && - for x in hg git - do - git_clone_$x hgrepo1 gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" - done && - - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log_hgrepo1 ' test_expect_success 'executable bit' ' @@ -176,22 +206,7 @@ test_expect_success 'executable bit' ' git commit -m "clear executable bit" ) && - for x in hg git - do - ( - hg_clone_$x gitrepo hgrepo-$x && - cd hgrepo-$x && - hg_log . && - hg manifest -r 1 -v && - hg manifest -v - ) > "output-$x" && - - git_clone_$x hgrepo-$x gitrepo2-$x && - git_log gitrepo2-$x > "log-$x" - done && - - test_cmp output-hg output-git && - test_cmp log-hg log-git + cmp_hg_to_git_manifest "hg manifest -v -r -1; hg manifest -v" ' test_expect_success 'symlink' ' @@ -206,21 +221,7 @@ test_expect_success 'symlink' ' git commit -m "add beta" ) && - for x in hg git - do - ( - hg_clone_$x gitrepo hgrepo-$x && - cd hgrepo-$x && - hg_log . && - hg manifest -v - ) > "output-$x" && - - git_clone_$x hgrepo-$x gitrepo2-$x && - git_log gitrepo2-$x > "log-$x" - done && - - test_cmp output-hg output-git && - test_cmp log-hg log-git + cmp_hg_to_git_manifest "hg manifest -v" ' test_expect_success 'merge conflict 1' ' @@ -244,16 +245,7 @@ test_expect_success 'merge conflict 1' ' hg ci -m "merge to C" -d "3 0" ) && - for x in hg git - do - git_clone_$x hgrepo1 gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" - done && - - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log_hgrepo1 ' test_expect_success 'merge conflict 2' ' @@ -277,16 +269,7 @@ test_expect_success 'merge conflict 2' ' hg ci -m "merge to B" -d "3 0" ) && - for x in hg git - do - git_clone_$x hgrepo1 gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" - done && - - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log_hgrepo1 ' test_expect_success 'converged merge' ' @@ -311,16 +294,7 @@ test_expect_success 'converged merge' ' hg ci -m "merge" -d "4 0" ) && - for x in hg git - do - git_clone_$x hgrepo1 gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" - done && - - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log_hgrepo1 ' test_expect_success 'encoding' ' @@ -381,22 +355,7 @@ test_expect_success 'file removal' ' git commit -m "remove foo/bar" ) && - for x in hg git - do - ( - hg_clone_$x gitrepo hgrepo-$x && - cd hgrepo-$x && - hg_log . && - hg manifest -r 3 && - hg manifest - ) > "output-$x" && - - git_clone_$x hgrepo-$x gitrepo2-$x && - git_log gitrepo2-$x > "log-$x" - done && - - test_cmp output-hg output-git && - test_cmp log-hg log-git + cmp_hg_to_git_manifest "hg manifest -r 3; hg manifest" ' test_expect_success 'git tags' ' @@ -479,14 +438,10 @@ test_expect_success 'hg author' ' ) && hg_push_$x hgrepo-$x gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" + hg_clone_$x gitrepo-$x hgrepo2-$x done && - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log ' test_expect_success 'hg branch' ' @@ -514,14 +469,10 @@ test_expect_success 'hg branch' ' ) && hg_push_$x hgrepo-$x gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && - - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" + hg_clone_$x gitrepo-$x hgrepo2-$x done && - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + cmp_hg_to_git_log ' test_expect_success 'hg tags' ' From 2fdb786fc4accd50194222ea30e3b7b49ca653cc Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 20:29:16 -0600 Subject: [PATCH 060/109] test: hg-git: add test_cmp_expected helper No functional changes. Signed-off-by: Felipe Contreras --- test/hg-git.t | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 8b24cb3..c6dd7e1 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -101,6 +101,10 @@ git_log () { git -C $1 fast-export --branches } +test_cmp_expected () { + test_cmp "${1}-hg" "${1}-git" +} + cmp_hg_to_git_log () { for x in hg git do @@ -108,8 +112,8 @@ cmp_hg_to_git_log () { git_log gitrepo-$x > "git-log-$x" done && - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + test_cmp_expected hg-log && + test_cmp_expected git-log } cmp_hg_to_git_log_hgrepo1 () { @@ -136,8 +140,8 @@ cmp_hg_to_git_manifest () { git_log gitrepo2-$x > "log-$x" done && - test_cmp output-hg output-git && - test_cmp log-hg log-git + test_cmp_expected output && + test_cmp_expected log } setup () { @@ -331,8 +335,8 @@ test_expect_success 'encoding' ' git_log gitrepo2-$x > "git-log-$x" done && - test_cmp hg-log-hg hg-log-git && - test_cmp git-log-hg git-log-git + test_cmp_expected hg-log && + test_cmp_expected git-log ' test_expect_success 'file removal' ' @@ -380,7 +384,7 @@ test_expect_success 'git tags' ' hg_log hgrepo-$x > "log-$x" done && - test_cmp log-hg log-git + test_cmp_expected log ' test_expect_success 'hg author' ' @@ -506,7 +510,7 @@ test_expect_success 'hg tags' ' ) > "output-$x" done && - test_cmp output-hg output-git + test_cmp_expected output ' test_done From 30a2d61bdf695aa8940f8e3b39fa81e4864694fc Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 21:39:56 -0600 Subject: [PATCH 061/109] test: add expected output Generated with: hg:6.3 hggit:1.0.1 dulwich:0.20.50 Signed-off-by: Felipe Contreras --- test/expected/converged merge/git-log | 60 +++++++++++ test/expected/converged merge/hg-log | 67 ++++++++++++ test/expected/encoding/git-log | 56 ++++++++++ test/expected/encoding/hg-log | 58 ++++++++++ test/expected/executable bit/log | 32 ++++++ test/expected/executable bit/output | 46 ++++++++ test/expected/file removal/log | 60 +++++++++++ test/expected/file removal/output | 75 +++++++++++++ test/expected/git tags/log | 32 ++++++ test/expected/hg author/git-log | 141 +++++++++++++++++++++++++ test/expected/hg author/hg-log | 134 +++++++++++++++++++++++ test/expected/hg branch/git-log | 38 +++++++ test/expected/hg branch/hg-log | 44 ++++++++ test/expected/hg tags/output | 33 ++++++ test/expected/merge conflict 1/git-log | 51 +++++++++ test/expected/merge conflict 1/hg-log | 54 ++++++++++ test/expected/merge conflict 2/git-log | 52 +++++++++ test/expected/merge conflict 2/hg-log | 54 ++++++++++ test/expected/rename/git-log | 27 +++++ test/expected/rename/hg-log | 29 +++++ test/expected/symlink/log | 27 +++++ test/expected/symlink/output | 32 ++++++ 22 files changed, 1202 insertions(+) create mode 100644 test/expected/converged merge/git-log create mode 100644 test/expected/converged merge/hg-log create mode 100644 test/expected/encoding/git-log create mode 100644 test/expected/encoding/hg-log create mode 100644 test/expected/executable bit/log create mode 100644 test/expected/executable bit/output create mode 100644 test/expected/file removal/log create mode 100644 test/expected/file removal/output create mode 100644 test/expected/git tags/log create mode 100644 test/expected/hg author/git-log create mode 100644 test/expected/hg author/hg-log create mode 100644 test/expected/hg branch/git-log create mode 100644 test/expected/hg branch/hg-log create mode 100644 test/expected/hg tags/output create mode 100644 test/expected/merge conflict 1/git-log create mode 100644 test/expected/merge conflict 1/hg-log create mode 100644 test/expected/merge conflict 2/git-log create mode 100644 test/expected/merge conflict 2/hg-log create mode 100644 test/expected/rename/git-log create mode 100644 test/expected/rename/hg-log create mode 100644 test/expected/symlink/log create mode 100644 test/expected/symlink/output diff --git a/test/expected/converged merge/git-log b/test/expected/converged merge/git-log new file mode 100644 index 0000000..39f2f99 --- /dev/null +++ b/test/expected/converged merge/git-log @@ -0,0 +1,60 @@ +blob +mark :1 +data 2 +A + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 7 +origin +M 100644 :1 afile + +blob +mark :3 +data 2 +C + +commit refs/heads/master +mark :4 +author A U Thor 3 +0000 +committer A U Thor 3 +0000 +data 5 +A->C +from :2 +M 100644 :3 afile + +blob +mark :5 +data 2 +B + +commit refs/heads/master +mark :6 +author A U Thor 1 +0000 +committer A U Thor 1 +0000 +data 5 +A->B +from :2 +M 100644 :5 afile + +commit refs/heads/master +mark :7 +author A U Thor 2 +0000 +committer A U Thor 2 +0000 +data 5 +B->C +from :6 +M 100644 :3 afile + +commit refs/heads/master +mark :8 +author A U Thor 4 +0000 +committer A U Thor 4 +0000 +data 6 +merge +from :4 +merge :7 + diff --git a/test/expected/converged merge/hg-log b/test/expected/converged merge/hg-log new file mode 100644 index 0000000..e694892 --- /dev/null +++ b/test/expected/converged merge/hg-log @@ -0,0 +1,67 @@ +changeset: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 331ac2e605f2e6092ccb3802244a65b71f3be726 +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: afile +extra: branch=default +description: +origin + + +changeset: ead35d346ecb18ce9d9d54604ff62b41caa196ce +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 894f8ad9a84f743d52747963d0b9f4e9cf37d489 +user: A U Thor +date: Thu Jan 01 00:00:01 1970 +0000 +files: afile +extra: branch=default +description: +A->B + + +changeset: 541c7bc8b2d01c8bf71b2298d17edcda120e49bf +phase: draft +parent: ead35d346ecb18ce9d9d54604ff62b41caa196ce +parent: -0000000000000000000000000000000000000000 +manifest: 04dae4001cb1fb2384111589720617c4b742044c +user: A U Thor +date: Thu Jan 01 00:00:02 1970 +0000 +files: afile +extra: branch=default +description: +B->C + + +changeset: 5694aadcd7171ecb9768b13e29d027e22a360d44 +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 6efc6bb8e097947aa212887bdb01fb89dfa3de13 +user: A U Thor +date: Thu Jan 01 00:00:03 1970 +0000 +files: afile +extra: branch=default +description: +A->C + + +changeset: 9ee75b4362cc15f9110d6538b2f1c9f0cf14825a +bookmark: master +tag: tip +phase: draft +parent: 5694aadcd7171ecb9768b13e29d027e22a360d44 +parent: 541c7bc8b2d01c8bf71b2298d17edcda120e49bf +manifest: eb9f4687448653e876d787cd6f2e59140680ff09 +user: A U Thor +date: Thu Jan 01 00:00:04 1970 +0000 +files: afile +extra: branch=default +description: +merge + + diff --git a/test/expected/encoding/git-log b/test/expected/encoding/git-log new file mode 100644 index 0000000..9d6bffa --- /dev/null +++ b/test/expected/encoding/git-log @@ -0,0 +1,56 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 12 +add älphà +M 100644 :1 alpha + +blob +mark :3 +data 5 +beta + +commit refs/heads/master +mark :4 +author tést èncödîng 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 9 +add beta +from :2 +M 100644 :3 beta + +blob +mark :5 +data 6 +gamma + +commit refs/heads/master +mark :6 +author tést èncödîng 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 12 +add gämmâ +from :4 +M 100644 :5 gamma + +blob +mark :7 +data 6 +delta + +commit refs/heads/master +mark :8 +author tést èncödîng 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 12 +add déltà +from :6 +M 100644 :7 delta + diff --git a/test/expected/encoding/hg-log b/test/expected/encoding/hg-log new file mode 100644 index 0000000..4608233 --- /dev/null +++ b/test/expected/encoding/hg-log @@ -0,0 +1,58 @@ +changeset: 6674f1c866b5c428db4acde16404c14077889646 +bookmark: master +tag: tip +phase: draft +parent: 7e9fd3fd2f75d7de4bf3d77c47f192a51927ac28 +parent: -0000000000000000000000000000000000000000 +manifest: ea49f93388380ead5601c8fcbfa187516e7c2ed8 +user: tést èncödîng +date: Mon Jan 01 00:00:00 2007 +0230 +files+: delta +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add déltà + + +changeset: 7e9fd3fd2f75d7de4bf3d77c47f192a51927ac28 +phase: draft +parent: 99c5adad03b9a9935e181f4be91ff7693a790110 +parent: -0000000000000000000000000000000000000000 +manifest: f580e7da3673c137370da2b931a1dee83590d7b4 +user: tést èncödîng +date: Mon Jan 01 00:00:00 2007 +0230 +files+: gamma +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add gämmâ + + +changeset: 99c5adad03b9a9935e181f4be91ff7693a790110 +phase: draft +parent: 1e3e49d2cc8feaad4942d100108f20f207742d3a +parent: -0000000000000000000000000000000000000000 +manifest: f0bd6fbafbaebe4bb59c35108428f6fce152431d +user: tést èncödîng +date: Mon Jan 01 00:00:00 2007 +0230 +files+: beta +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add beta + + +changeset: 1e3e49d2cc8feaad4942d100108f20f207742d3a +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add älphà + + diff --git a/test/expected/executable bit/log b/test/expected/executable bit/log new file mode 100644 index 0000000..aac4409 --- /dev/null +++ b/test/expected/executable bit/log @@ -0,0 +1,32 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 10 +add alpha +M 100644 :1 alpha + +commit refs/heads/master +mark :3 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 19 +set executable bit +from :2 +M 100755 :1 alpha + +commit refs/heads/master +mark :4 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 21 +clear executable bit +from :3 +M 100644 :1 alpha + diff --git a/test/expected/executable bit/output b/test/expected/executable bit/output new file mode 100644 index 0000000..f8a41c8 --- /dev/null +++ b/test/expected/executable bit/output @@ -0,0 +1,46 @@ +changeset: 1efb93106a36bf71352ab04e769a3422522cf946 +bookmark: master +tag: tip +phase: draft +parent: d7cae8b1fdab97568ba5eca44ca2bf5a44d7c394 +parent: -0000000000000000000000000000000000000000 +manifest: 51e6255d794f794a8c4e0f03edf264444e3c5ce7 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +clear executable bit + + +changeset: d7cae8b1fdab97568ba5eca44ca2bf5a44d7c394 +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: e4bf4ef5e9aea7a6a57573e533a5519bd062f144 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +set executable bit + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + +644 alpha +644 alpha diff --git a/test/expected/file removal/log b/test/expected/file removal/log new file mode 100644 index 0000000..77785f9 --- /dev/null +++ b/test/expected/file removal/log @@ -0,0 +1,60 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 10 +add alpha +M 100644 :1 alpha + +blob +mark :3 +data 5 +beta + +commit refs/heads/master +mark :4 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 9 +add beta +from :2 +M 100644 :3 beta + +blob +mark :5 +data 5 +blah + +commit refs/heads/master +mark :6 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 8 +add foo +from :4 +M 100644 :5 foo/bar + +commit refs/heads/master +mark :7 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 13 +remove alpha +from :6 +D alpha + +commit refs/heads/master +mark :8 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 15 +remove foo/bar +from :7 +D foo/bar + diff --git a/test/expected/file removal/output b/test/expected/file removal/output new file mode 100644 index 0000000..56a80b6 --- /dev/null +++ b/test/expected/file removal/output @@ -0,0 +1,75 @@ +changeset: 54f595cbdf1f516dc3b2b25faa6f051aae712f5d +bookmark: master +tag: tip +phase: draft +parent: 7fe32a9185c6d37db430ee5248cdb2ae66582478 +parent: -0000000000000000000000000000000000000000 +manifest: 3f83f42fa00fb0cac14a83aa48baac2f287a9329 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files-: foo/bar +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +remove foo/bar + + +changeset: 7fe32a9185c6d37db430ee5248cdb2ae66582478 +phase: draft +parent: a21fd0b26a555427c2ea72f8ed37190f6216f705 +parent: -0000000000000000000000000000000000000000 +manifest: cd10925837609b99d345c44c85bd1f73d742cbbc +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files-: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +remove alpha + + +changeset: a21fd0b26a555427c2ea72f8ed37190f6216f705 +phase: draft +parent: 7cd99375c843931bd8959b766a94e050f428512b +parent: -0000000000000000000000000000000000000000 +manifest: a6ee442a94bfc6fb0b7d717183bb8b4534ca4ccd +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: foo/bar +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add foo + + +changeset: 7cd99375c843931bd8959b766a94e050f428512b +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: f0bd6fbafbaebe4bb59c35108428f6fce152431d +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: beta +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add beta + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + +beta +foo/bar +beta diff --git a/test/expected/git tags/log b/test/expected/git tags/log new file mode 100644 index 0000000..02a4fda --- /dev/null +++ b/test/expected/git tags/log @@ -0,0 +1,32 @@ +changeset: 7cd99375c843931bd8959b766a94e050f428512b +bookmark: master +tag: beta +tag: tip +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: f0bd6fbafbaebe4bb59c35108428f6fce152431d +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: beta +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add beta + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +tag: alpha +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + diff --git a/test/expected/hg author/git-log b/test/expected/hg author/git-log new file mode 100644 index 0000000..7299257 --- /dev/null +++ b/test/expected/hg author/git-log @@ -0,0 +1,141 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/not-master +commit refs/heads/not-master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 10 +add alpha +M 100644 :1 alpha + +blob +mark :3 +data 5 +beta + +commit refs/heads/master +mark :4 +author test 0 +0000 +committer test 0 +0000 +data 9 +add beta +from :2 +M 100644 :3 beta + +blob +mark :5 +data 11 +beta +gamma + +commit refs/heads/master +mark :6 +author test ext:(%20%28comment%29) 0 +0000 +committer test ext:(%20%28comment%29) 0 +0000 +data 12 +modify beta +from :4 +M 100644 :5 beta + +blob +mark :7 +data 6 +gamma + +commit refs/heads/master +mark :8 +author 0 +0000 +committer 0 +0000 +data 10 +add gamma +from :6 +M 100644 :7 gamma + +blob +mark :9 +data 6 +delta + +commit refs/heads/master +mark :10 +author name 0 +0000 +committer name 0 +0000 +data 10 +add delta +from :8 +M 100644 :9 delta + +blob +mark :11 +data 8 +epsilon + +commit refs/heads/master +mark :12 +author name 0 +0000 +committer name 0 +0000 +data 12 +add epsilon +from :10 +M 100644 :11 epsilon + +blob +mark :13 +data 5 +zeta + +commit refs/heads/master +mark :14 +author test 0 +0000 +committer test 0 +0000 +data 9 +add zeta +from :12 +M 100644 :13 zeta + +blob +mark :15 +data 4 +eta + +commit refs/heads/master +mark :16 +author test 0 +0000 +committer test 0 +0000 +data 8 +add eta +from :14 +M 100644 :15 eta + +blob +mark :17 +data 6 +theta + +commit refs/heads/master +mark :18 +author test ?test@example.com 0 +0000 +committer test ?test@example.com 0 +0000 +data 10 +add theta +from :16 +M 100644 :17 theta + +blob +mark :19 +data 5 +iota + +commit refs/heads/master +mark :20 +author test ext:(%20example%20%3Cdot%3E%20com%3E) 0 +0000 +committer test ext:(%20example%20%3Cdot%3E%20com%3E) 0 +0000 +data 9 +add iota +from :18 +M 100644 :19 iota + diff --git a/test/expected/hg author/hg-log b/test/expected/hg author/hg-log new file mode 100644 index 0000000..e88da6b --- /dev/null +++ b/test/expected/hg author/hg-log @@ -0,0 +1,134 @@ +changeset: 307c03466a07cccafaafc991f36d695d6ad595f3 +bookmark: master +tag: tip +phase: draft +parent: 5832614d351449a2f8d6f7ccbef4877c2b18cbe0 +parent: -0000000000000000000000000000000000000000 +manifest: e8f1b3ae088bdd25e3570a4953ccb6b948524473 +user: test example com> +date: Thu Jan 01 00:00:00 1970 +0000 +files+: iota +extra: branch=default +description: +add iota + + +changeset: 5832614d351449a2f8d6f7ccbef4877c2b18cbe0 +phase: draft +parent: e52ded4aca5d210ed58c63158d64fb911876f345 +parent: -0000000000000000000000000000000000000000 +manifest: 7e4875db7e2970c529f462520121d333e514bf4d +user: test ?test@example.com +date: Thu Jan 01 00:00:00 1970 +0000 +files+: theta +extra: branch=default +description: +add theta + + +changeset: e52ded4aca5d210ed58c63158d64fb911876f345 +phase: draft +parent: 9a34ba7d552e8b73ad306baf1d1eb83de0f74c12 +parent: -0000000000000000000000000000000000000000 +manifest: ef03e54a9916ac3158c9686503dd4f609c26b3ec +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +files+: eta +extra: branch=default +description: +add eta + + +changeset: 9a34ba7d552e8b73ad306baf1d1eb83de0f74c12 +phase: draft +parent: 6281edc25b9fe9538407726f044a9a61ac7ba5bc +parent: -0000000000000000000000000000000000000000 +manifest: 616201b85baf7ed02d41f6a7deb04c52009d8483 +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +files+: zeta +extra: branch=default +description: +add zeta + + +changeset: 6281edc25b9fe9538407726f044a9a61ac7ba5bc +phase: draft +parent: 4c7841053c633cb51f8375555d08b6bea54fc4cb +parent: -0000000000000000000000000000000000000000 +manifest: c703b3d7be8a0638047142f57ff83d4e94b5d1fa +user: name +date: Thu Jan 01 00:00:00 1970 +0000 +files+: epsilon +extra: branch=default +description: +add epsilon + + +changeset: 4c7841053c633cb51f8375555d08b6bea54fc4cb +phase: draft +parent: fa8f26586397dd4797842e9300c8db221fe5514d +parent: -0000000000000000000000000000000000000000 +manifest: 300b54001cbfa5d027b4bccdb594ccb463adb55d +user: name +date: Thu Jan 01 00:00:00 1970 +0000 +files+: delta +extra: branch=default +description: +add delta + + +changeset: fa8f26586397dd4797842e9300c8db221fe5514d +phase: draft +parent: 2708ff417fb7e2c0a4f9596286c0a398553fa793 +parent: -0000000000000000000000000000000000000000 +manifest: 45b0c483a79307d14f7e234feb78776478f828ec +user: +date: Thu Jan 01 00:00:00 1970 +0000 +files+: gamma +extra: branch=default +description: +add gamma + + +changeset: 2708ff417fb7e2c0a4f9596286c0a398553fa793 +phase: draft +parent: 8c51e5fe974fe1cc63a56bbfad343f9ede6bed30 +parent: -0000000000000000000000000000000000000000 +manifest: c305998040b12e956b998318982c9eb92d2d7b28 +user: test (comment) +date: Thu Jan 01 00:00:00 1970 +0000 +files: beta +extra: branch=default +description: +modify beta + + +changeset: 8c51e5fe974fe1cc63a56bbfad343f9ede6bed30 +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: f0bd6fbafbaebe4bb59c35108428f6fce152431d +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +files+: beta +extra: branch=default +description: +add beta + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +bookmark: not-master +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + diff --git a/test/expected/hg branch/git-log b/test/expected/hg branch/git-log new file mode 100644 index 0000000..dec10d5 --- /dev/null +++ b/test/expected/hg branch/git-log @@ -0,0 +1,38 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/not-master +commit refs/heads/not-master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 10 +add alpha +M 100644 :1 alpha + +commit refs/heads/master +mark :3 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 52 +rename alpha to beta + +--HG-- +rename : alpha => beta +from :2 +D alpha +M 100644 :1 beta + +commit refs/heads/master +mark :4 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 44 +started branch gamma + +--HG-- +branch : gamma +from :3 + diff --git a/test/expected/hg branch/hg-log b/test/expected/hg branch/hg-log new file mode 100644 index 0000000..e5d9951 --- /dev/null +++ b/test/expected/hg branch/hg-log @@ -0,0 +1,44 @@ +changeset: 3320583a8de0b31511f499a4ab3426bee1a7f478 +branch: gamma +bookmark: master +tag: tip +phase: draft +parent: 5889597089fea2d144989baa9427d1a080293fdb +parent: -0000000000000000000000000000000000000000 +manifest: e353b4d5282d044ad738398fd32d0b684d04a14b +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +extra: branch=gamma +description: +started branch gamma + + +changeset: 5889597089fea2d144989baa9427d1a080293fdb +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: e353b4d5282d044ad738398fd32d0b684d04a14b +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: beta +files-: alpha +extra: branch=default +description: +rename alpha to beta + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +bookmark: not-master +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + diff --git a/test/expected/hg tags/output b/test/expected/hg tags/output new file mode 100644 index 0000000..56c5cf4 --- /dev/null +++ b/test/expected/hg tags/output @@ -0,0 +1,33 @@ +alpha +changeset: 16869bbe54be9f8082a8aec346de09f6c05cf1de +bookmark: master +tag: tip +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: 26f8145fb5b20cc6f70dd131b646f95ab79738c0 +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: .hgtags +extra: branch=default +description: +Added tag alpha for changeset 362b656574c3 + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +bookmark: not-master +tag: alpha +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + +362b656574c3c9e89fa7f2d7a943091dc93bce4d alpha diff --git a/test/expected/merge conflict 1/git-log b/test/expected/merge conflict 1/git-log new file mode 100644 index 0000000..c9a3fff --- /dev/null +++ b/test/expected/merge conflict 1/git-log @@ -0,0 +1,51 @@ +blob +mark :1 +data 2 +A + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 7 +origin +M 100644 :1 afile + +blob +mark :3 +data 2 +C + +commit refs/heads/master +mark :4 +author A U Thor 2 +0000 +committer A U Thor 2 +0000 +data 5 +A->C +from :2 +M 100644 :3 afile + +blob +mark :5 +data 2 +B + +commit refs/heads/master +mark :6 +author A U Thor 1 +0000 +committer A U Thor 1 +0000 +data 5 +A->B +from :2 +M 100644 :5 afile + +commit refs/heads/master +mark :7 +author A U Thor 3 +0000 +committer A U Thor 3 +0000 +data 11 +merge to C +from :4 +merge :6 + diff --git a/test/expected/merge conflict 1/hg-log b/test/expected/merge conflict 1/hg-log new file mode 100644 index 0000000..5e6408b --- /dev/null +++ b/test/expected/merge conflict 1/hg-log @@ -0,0 +1,54 @@ +changeset: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 331ac2e605f2e6092ccb3802244a65b71f3be726 +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: afile +extra: branch=default +description: +origin + + +changeset: ead35d346ecb18ce9d9d54604ff62b41caa196ce +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 894f8ad9a84f743d52747963d0b9f4e9cf37d489 +user: A U Thor +date: Thu Jan 01 00:00:01 1970 +0000 +files: afile +extra: branch=default +description: +A->B + + +changeset: d585ac55494928500f510b965b878d47f9ee60f6 +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 6efc6bb8e097947aa212887bdb01fb89dfa3de13 +user: A U Thor +date: Thu Jan 01 00:00:02 1970 +0000 +files: afile +extra: branch=default +description: +A->C + + +changeset: c6ab734e24c39948e5a25713b48f4972c960ff8b +bookmark: master +tag: tip +phase: draft +parent: d585ac55494928500f510b965b878d47f9ee60f6 +parent: ead35d346ecb18ce9d9d54604ff62b41caa196ce +manifest: 96bedb13781f1b9d729a2210a530f0c5c68f42e6 +user: A U Thor +date: Thu Jan 01 00:00:03 1970 +0000 +files: afile +extra: branch=default +description: +merge to C + + diff --git a/test/expected/merge conflict 2/git-log b/test/expected/merge conflict 2/git-log new file mode 100644 index 0000000..9825c68 --- /dev/null +++ b/test/expected/merge conflict 2/git-log @@ -0,0 +1,52 @@ +blob +mark :1 +data 2 +A + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 7 +origin +M 100644 :1 afile + +blob +mark :3 +data 2 +C + +commit refs/heads/master +mark :4 +author A U Thor 2 +0000 +committer A U Thor 2 +0000 +data 5 +A->C +from :2 +M 100644 :3 afile + +blob +mark :5 +data 2 +B + +commit refs/heads/master +mark :6 +author A U Thor 1 +0000 +committer A U Thor 1 +0000 +data 5 +A->B +from :2 +M 100644 :5 afile + +commit refs/heads/master +mark :7 +author A U Thor 3 +0000 +committer A U Thor 3 +0000 +data 11 +merge to B +from :4 +merge :6 +M 100644 :5 afile + diff --git a/test/expected/merge conflict 2/hg-log b/test/expected/merge conflict 2/hg-log new file mode 100644 index 0000000..fc479c9 --- /dev/null +++ b/test/expected/merge conflict 2/hg-log @@ -0,0 +1,54 @@ +changeset: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 331ac2e605f2e6092ccb3802244a65b71f3be726 +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: afile +extra: branch=default +description: +origin + + +changeset: ead35d346ecb18ce9d9d54604ff62b41caa196ce +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 894f8ad9a84f743d52747963d0b9f4e9cf37d489 +user: A U Thor +date: Thu Jan 01 00:00:01 1970 +0000 +files: afile +extra: branch=default +description: +A->B + + +changeset: d585ac55494928500f510b965b878d47f9ee60f6 +phase: draft +parent: 9a6668f453c3003b71e11bb8d7572af57a7ce891 +parent: -0000000000000000000000000000000000000000 +manifest: 6efc6bb8e097947aa212887bdb01fb89dfa3de13 +user: A U Thor +date: Thu Jan 01 00:00:02 1970 +0000 +files: afile +extra: branch=default +description: +A->C + + +changeset: 542b187b70e70dc759631d1065794f3c2c5a3e7b +bookmark: master +tag: tip +phase: draft +parent: d585ac55494928500f510b965b878d47f9ee60f6 +parent: ead35d346ecb18ce9d9d54604ff62b41caa196ce +manifest: 0907d7dbc98790102fa6cb91b68b271ef0bc5b64 +user: A U Thor +date: Thu Jan 01 00:00:03 1970 +0000 +files: afile +extra: branch=default +description: +merge to B + + diff --git a/test/expected/rename/git-log b/test/expected/rename/git-log new file mode 100644 index 0000000..3204636 --- /dev/null +++ b/test/expected/rename/git-log @@ -0,0 +1,27 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 10 +add alpha +M 100644 :1 alpha + +commit refs/heads/master +mark :3 +author A U Thor 0 +0000 +committer A U Thor 0 +0000 +data 52 +rename alpha to beta + +--HG-- +rename : alpha => beta +from :2 +D alpha +M 100644 :1 beta + diff --git a/test/expected/rename/hg-log b/test/expected/rename/hg-log new file mode 100644 index 0000000..08139a3 --- /dev/null +++ b/test/expected/rename/hg-log @@ -0,0 +1,29 @@ +changeset: a985b184598fd779e53576c65c5dd1d274736c73 +bookmark: master +tag: tip +phase: draft +parent: 0558a161e3ca0d59f5f165e3182402d9f1e574a8 +parent: -0000000000000000000000000000000000000000 +manifest: e353b4d5282d044ad738398fd32d0b684d04a14b +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: beta +files-: alpha +extra: branch=default +description: +rename alpha to beta + + +changeset: 0558a161e3ca0d59f5f165e3182402d9f1e574a8 +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Thu Jan 01 00:00:00 1970 +0000 +files+: alpha +extra: branch=default +description: +add alpha + + diff --git a/test/expected/symlink/log b/test/expected/symlink/log new file mode 100644 index 0000000..5ae198d --- /dev/null +++ b/test/expected/symlink/log @@ -0,0 +1,27 @@ +blob +mark :1 +data 6 +alpha + +reset refs/heads/master +commit refs/heads/master +mark :2 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 10 +add alpha +M 100644 :1 alpha + +blob +mark :3 +data 5 +alpha +commit refs/heads/master +mark :4 +author A U Thor 1167600600 +0230 +committer C O Mitter 1167600600 +0230 +data 9 +add beta +from :2 +M 120000 :3 beta + diff --git a/test/expected/symlink/output b/test/expected/symlink/output new file mode 100644 index 0000000..d270f0e --- /dev/null +++ b/test/expected/symlink/output @@ -0,0 +1,32 @@ +changeset: 87cbc97576079d3dfef04c678bfc8ab69999ebdf +bookmark: master +tag: tip +phase: draft +parent: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +parent: -0000000000000000000000000000000000000000 +manifest: 4950f48a7f5b0ce6f31c2f4307e296dbac652026 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: beta +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add beta + + +changeset: 362b656574c3c9e89fa7f2d7a943091dc93bce4d +phase: draft +parent: -0000000000000000000000000000000000000000 +parent: -0000000000000000000000000000000000000000 +manifest: 8b8a0e87dfd7a0706c0524afa8ba67e20544cbf0 +user: A U Thor +date: Mon Jan 01 00:00:00 2007 +0230 +files+: alpha +extra: branch=default +extra: committer=C O Mitter 1167600600 -9000 +description: +add alpha + + +644 alpha +644 @ beta From 83620648ab02cd03443837bba25eb4208abd0441 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 5 Mar 2023 20:31:37 -0600 Subject: [PATCH 062/109] test: hg-git: fetch output from expected dir So we don't actually have to run hg-git every time (it's broken most of the time anyway). Signed-off-by: Felipe Contreras --- test/hg-git.t | 59 +++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 47 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index c6dd7e1..99353ea 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -12,6 +12,8 @@ test_description='Test remote-hg output compared to hg-git' . ./test-lib.sh +export EXPECTED_DIR="$SHARNESS_TEST_DIRECTORY/expected" + if ! test_have_prereq PYTHON then skip_all='skipping remote-hg tests; python not available' @@ -24,17 +26,6 @@ then test_done fi -if python -c 'import hggit' > /dev/null 2>&1 -then - hggit=hggit -elif python -c 'import hgext.git' > /dev/null 2>&1 -then - hggit=hgext.git -else - skip_all='skipping remote-hg tests; hg-git not available' - test_done -fi - # clone to a git repo with git git_clone_git () { git clone -q "hg::$1" $2 && @@ -57,21 +48,6 @@ hg_clone_git () { (cd $2 && hg -q update) } -# clone to a git repo with hg -git_clone_hg () { - ( - git init -q $2 && - cd $1 && - hg bookmark -i -f -r tip master && - { hg -q push -r master ../$2 || true ;} - ) -} - -# clone to an hg repo with hg -hg_clone_hg () { - hg -q clone $1 $2 -} - # push an hg repo with git hg_push_git () { ( @@ -84,14 +60,6 @@ hg_push_git () { ) } -# push an hg git repo with hg -hg_push_hg () { - ( - cd $1 && - { hg -q push ../$2 || true ;} - ) -} - hg_log () { hg -R $1 log --debug -r 'sort(tip:0, date)' | sed -e '/tag: *default/d' -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/' @@ -102,11 +70,11 @@ git_log () { } test_cmp_expected () { - test_cmp "${1}-hg" "${1}-git" + test_cmp "$EXPECTED_DIR/$test_id/$1" "${1}-git" } cmp_hg_to_git_log () { - for x in hg git + for x in git do hg_log hgrepo2-$x > "hg-log-$x" && git_log gitrepo-$x > "git-log-$x" @@ -117,7 +85,7 @@ cmp_hg_to_git_log () { } cmp_hg_to_git_log_hgrepo1 () { - for x in hg git + for x in git do git_clone_$x hgrepo1 gitrepo-$x && hg_clone_$x gitrepo-$x hgrepo2-$x @@ -127,7 +95,7 @@ cmp_hg_to_git_log_hgrepo1 () { } cmp_hg_to_git_manifest () { - for x in hg git + for x in git do ( hg_clone_$x gitrepo hgrepo-$x && @@ -151,10 +119,6 @@ setup () { [defaults] commit = -d "0 0" tag = -d "0 0" - [extensions] - $hggit = - [git] - debugextrainmessage = 1 EOF cat > "$HOME"/.gitconfig <<-EOF @@ -176,6 +140,7 @@ setup eval "old_$(declare -f test_expect_success)" test_expect_success () { + test_id="$1" && old_test_expect_success "$1" " test_when_finished \"rm -rf gitrepo* hgrepo*\" && $2" } @@ -326,7 +291,7 @@ test_expect_success 'encoding' ' git commit -m "add déltà" ) && - for x in hg git + for x in git do hg_clone_$x gitrepo hgrepo-$x && git_clone_$x hgrepo-$x gitrepo2-$x && @@ -378,7 +343,7 @@ test_expect_success 'git tags' ' git tag -a -m "added tag beta" beta ) && - for x in hg git + for x in git do hg_clone_$x gitrepo hgrepo-$x && hg_log hgrepo-$x > "log-$x" @@ -388,7 +353,7 @@ test_expect_success 'git tags' ' ' test_expect_success 'hg author' ' - for x in hg git + for x in git do ( git init -q gitrepo-$x && @@ -449,7 +414,7 @@ test_expect_success 'hg author' ' ' test_expect_success 'hg branch' ' - for x in hg git + for x in git do ( git init -q gitrepo-$x && @@ -480,7 +445,7 @@ test_expect_success 'hg branch' ' ' test_expect_success 'hg tags' ' - for x in hg git + for x in git do ( git init -q gitrepo-$x && From 9949745533e58140a35ce91d78c97607cc7847d7 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:33:48 -0600 Subject: [PATCH 063/109] test: hg-git: general cleanup Now that we don't have to run hg-git the code is much simpler. No functional changes. Signed-off-by: Felipe Contreras --- test/hg-git.t | 233 ++++++++++++++++++++++---------------------------- 1 file changed, 103 insertions(+), 130 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index 99353ea..01fc4ac 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -26,8 +26,7 @@ then test_done fi -# clone to a git repo with git -git_clone_git () { +git_clone () { git clone -q "hg::$1" $2 && ( cd $2 && @@ -36,8 +35,7 @@ git_clone_git () { ) } -# clone to an hg repo with git -hg_clone_git () { +hg_clone () { ( hg init $2 && hg -R $2 bookmark -i master && @@ -48,8 +46,7 @@ hg_clone_git () { (cd $2 && hg -q update) } -# push an hg repo with git -hg_push_git () { +hg_push () { ( cd $2 git checkout -q -b tmp && @@ -70,43 +67,34 @@ git_log () { } test_cmp_expected () { - test_cmp "$EXPECTED_DIR/$test_id/$1" "${1}-git" + test_cmp "$EXPECTED_DIR/$test_id/$1" "$1" } cmp_hg_to_git_log () { - for x in git - do - hg_log hgrepo2-$x > "hg-log-$x" && - git_log gitrepo-$x > "git-log-$x" - done && + hg_log hgrepo2 > hg-log && + git_log gitrepo > git-log && test_cmp_expected hg-log && test_cmp_expected git-log } cmp_hg_to_git_log_hgrepo1 () { - for x in git - do - git_clone_$x hgrepo1 gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x - done && + git_clone hgrepo1 gitrepo && + hg_clone gitrepo hgrepo2 && cmp_hg_to_git_log } cmp_hg_to_git_manifest () { - for x in git - do - ( - hg_clone_$x gitrepo hgrepo-$x && - cd hgrepo-$x && - hg_log . && - eval "$1" - ) > "output-$x" && + ( + hg_clone gitrepo hgrepo && + cd hgrepo && + hg_log . && + eval "$1" + ) > output && - git_clone_$x hgrepo-$x gitrepo2-$x && - git_log gitrepo2-$x > "log-$x" - done && + git_clone hgrepo gitrepo2 && + git_log gitrepo2 > log && test_cmp_expected output && test_cmp_expected log @@ -291,14 +279,11 @@ test_expect_success 'encoding' ' git commit -m "add déltà" ) && - for x in git - do - hg_clone_$x gitrepo hgrepo-$x && - git_clone_$x hgrepo-$x gitrepo2-$x && + hg_clone gitrepo hgrepo && + git_clone hgrepo gitrepo2 && - HGENCODING=utf-8 hg_log hgrepo-$x > "hg-log-$x" && - git_log gitrepo2-$x > "git-log-$x" - done && + HGENCODING=utf-8 hg_log hgrepo > hg-log && + git_log gitrepo2 > git-log && test_cmp_expected hg-log && test_cmp_expected git-log @@ -343,137 +328,125 @@ test_expect_success 'git tags' ' git tag -a -m "added tag beta" beta ) && - for x in git - do - hg_clone_$x gitrepo hgrepo-$x && - hg_log hgrepo-$x > "log-$x" - done && + hg_clone gitrepo hgrepo && + hg_log hgrepo > log && test_cmp_expected log ' test_expect_success 'hg author' ' - for x in git - do - ( - git init -q gitrepo-$x && - cd gitrepo-$x && + ( + git init -q gitrepo && + cd gitrepo && - echo alpha > alpha && - git add alpha && - git commit -m "add alpha" && - git checkout -q -b not-master - ) && + echo alpha > alpha && + git add alpha && + git commit -m "add alpha" && + git checkout -q -b not-master + ) && - ( - hg_clone_$x gitrepo-$x hgrepo-$x && - cd hgrepo-$x && + ( + hg_clone gitrepo hgrepo && + cd hgrepo && - hg co master && - echo beta > beta && - hg add beta && - hg commit -u "test" -m "add beta" && + hg co master && + echo beta > beta && + hg add beta && + hg commit -u "test" -m "add beta" && - echo gamma >> beta && - hg commit -u "test (comment)" -m "modify beta" && + echo gamma >> beta && + hg commit -u "test (comment)" -m "modify beta" && - echo gamma > gamma && - hg add gamma && - hg commit -u "" -m "add gamma" && + echo gamma > gamma && + hg add gamma && + hg commit -u "" -m "add gamma" && - echo delta > delta && - hg add delta && - hg commit -u "name" -m "add delta" && + echo delta > delta && + hg add delta && + hg commit -u "name" -m "add delta" && - echo epsilon > epsilon && - hg add epsilon && - hg commit -u "name epsilon && + hg add epsilon && + hg commit -u "name zeta && - hg add zeta && - hg commit -u " test " -m "add zeta" && + echo zeta > zeta && + hg add zeta && + hg commit -u " test " -m "add zeta" && - echo eta > eta && - hg add eta && - hg commit -u "test < test@example.com >" -m "add eta" && + echo eta > eta && + hg add eta && + hg commit -u "test < test@example.com >" -m "add eta" && - echo theta > theta && - hg add theta && - hg commit -u "test >test@example.com>" -m "add theta" && + echo theta > theta && + hg add theta && + hg commit -u "test >test@example.com>" -m "add theta" && - echo iota > iota && - hg add iota && - hg commit -u "test example com>" -m "add iota" - ) && + echo iota > iota && + hg add iota && + hg commit -u "test example com>" -m "add iota" + ) && - hg_push_$x hgrepo-$x gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x - done && + hg_push hgrepo gitrepo && + hg_clone gitrepo hgrepo2 && cmp_hg_to_git_log ' test_expect_success 'hg branch' ' - for x in git - do - ( - git init -q gitrepo-$x && - cd gitrepo-$x && + ( + git init -q gitrepo && + cd gitrepo && - echo alpha > alpha && - git add alpha && - git commit -q -m "add alpha" && - git checkout -q -b not-master - ) && + echo alpha > alpha && + git add alpha && + git commit -q -m "add alpha" && + git checkout -q -b not-master + ) && - ( - hg_clone_$x gitrepo-$x hgrepo-$x && + ( + hg_clone gitrepo hgrepo && - cd hgrepo-$x && - hg -q co master && - hg mv alpha beta && - hg -q commit -m "rename alpha to beta" && - hg branch gamma | grep -v "permanent and global" && - hg -q commit -m "started branch gamma" - ) && + cd hgrepo && + hg -q co master && + hg mv alpha beta && + hg -q commit -m "rename alpha to beta" && + hg branch gamma | grep -v "permanent and global" && + hg -q commit -m "started branch gamma" + ) && - hg_push_$x hgrepo-$x gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x - done && + hg_push hgrepo gitrepo && + hg_clone gitrepo hgrepo2 && cmp_hg_to_git_log ' test_expect_success 'hg tags' ' - for x in git - do - ( - git init -q gitrepo-$x && - cd gitrepo-$x && + ( + git init -q gitrepo && + cd gitrepo && - echo alpha > alpha && - git add alpha && - git commit -m "add alpha" && - git checkout -q -b not-master - ) && + echo alpha > alpha && + git add alpha && + git commit -m "add alpha" && + git checkout -q -b not-master + ) && - ( - hg_clone_$x gitrepo-$x hgrepo-$x && + ( + hg_clone gitrepo hgrepo && - cd hgrepo-$x && - hg co master && - hg tag alpha - ) && + cd hgrepo && + hg co master && + hg tag alpha + ) && - hg_push_$x hgrepo-$x gitrepo-$x && - hg_clone_$x gitrepo-$x hgrepo2-$x && + hg_push hgrepo gitrepo && + hg_clone gitrepo hgrepo2 && - ( - git --git-dir=gitrepo-$x/.git tag -l && - hg_log hgrepo2-$x && - cat hgrepo2-$x/.hgtags - ) > "output-$x" - done && + ( + git --git-dir=gitrepo/.git tag -l && + hg_log hgrepo2 && + cat hgrepo2/.hgtags + ) > output && test_cmp_expected output ' From ffcb41cc52f6f8f7673bcb99012563cc502509a7 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:37:02 -0600 Subject: [PATCH 064/109] test: hg-git: trivial cleanup Signed-off-by: Felipe Contreras --- test/hg-git.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hg-git.t b/test/hg-git.t index 01fc4ac..f0aedd5 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -443,7 +443,7 @@ test_expect_success 'hg tags' ' hg_clone gitrepo hgrepo2 && ( - git --git-dir=gitrepo/.git tag -l && + git -C gitrepo tag -l && hg_log hgrepo2 && cat hgrepo2/.hgtags ) > output && From a8bb2a28a32803b3fac87336fad15857f7b367ee Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 14:48:42 -0600 Subject: [PATCH 065/109] test: enable hg-git tests They have been working for a long time but the standard packages needed to be patched with check-versions to run them successfully. Now that the expected output is stored we don't need to patch anything and they can just be run. This reverts commit b022367aefa0186e4b7512762fbab805caad178d. Signed-off-by: Felipe Contreras --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 02c8c01..01ae05a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,6 +1,6 @@ RM ?= rm -f -T = main.t bidi.t +T = $(wildcard *.t) SHARNESS_TEST_DIRECTORY := $(CURDIR) export SHARNESS_TEST_DIRECTORY From a1e2c4acc9eeb1a91b0eba10b2deba597f06e616 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:14:35 -0600 Subject: [PATCH 066/109] test: remove pointless prereq checks The prereq check was necessary in upstream git, not here where it's a noop. Signed-off-by: Felipe Contreras --- test/bidi.t | 6 ------ test/hg-git.t | 6 ------ test/main.t | 6 ------ test/test-lib.sh | 2 -- 4 files changed, 20 deletions(-) diff --git a/test/bidi.t b/test/bidi.t index cdbe07f..4140b01 100755 --- a/test/bidi.t +++ b/test/bidi.t @@ -10,12 +10,6 @@ test_description='Test bidirectionality of remote-hg' . ./test-lib.sh -if ! test_have_prereq PYTHON -then - skip_all='skipping remote-hg tests; python not available' - test_done -fi - if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' diff --git a/test/hg-git.t b/test/hg-git.t index f0aedd5..42545ab 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -14,12 +14,6 @@ test_description='Test remote-hg output compared to hg-git' export EXPECTED_DIR="$SHARNESS_TEST_DIRECTORY/expected" -if ! test_have_prereq PYTHON -then - skip_all='skipping remote-hg tests; python not available' - test_done -fi - if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' diff --git a/test/main.t b/test/main.t index dccec35..9315aa1 100755 --- a/test/main.t +++ b/test/main.t @@ -10,12 +10,6 @@ test_description='Test remote-hg' . ./test-lib.sh -if ! test_have_prereq PYTHON -then - skip_all='skipping remote-hg tests; python not available' - test_done -fi - if ! python -c 'import mercurial' > /dev/null 2>&1 then skip_all='skipping remote-hg tests; mercurial not available' diff --git a/test/test-lib.sh b/test/test-lib.sh index b0d6580..3daee04 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -3,8 +3,6 @@ : "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "${BASH_SOURCE-$0}")" && pwd)}" . "$SHARNESS_TEST_SRCDIR"/sharness.sh -test_set_prereq PYTHON - GIT_AUTHOR_EMAIL=author@example.com GIT_AUTHOR_NAME='A U Thor' GIT_COMMITTER_EMAIL=committer@example.com From 5e6ef0a1d53f86ced25b0652b58f0e59e087859a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 09:22:03 -0600 Subject: [PATCH 067/109] test: properly check for mercurial We want to fail if it's not present, not skip the tests. Signed-off-by: Felipe Contreras --- test/bidi.t | 6 ------ test/hg-git.t | 6 ------ test/main.t | 6 ------ test/test-lib.sh | 5 +++++ 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/test/bidi.t b/test/bidi.t index 4140b01..ebc0d88 100755 --- a/test/bidi.t +++ b/test/bidi.t @@ -10,12 +10,6 @@ test_description='Test bidirectionality of remote-hg' . ./test-lib.sh -if ! python -c 'import mercurial' > /dev/null 2>&1 -then - skip_all='skipping remote-hg tests; mercurial not available' - test_done -fi - # clone to a git repo git_clone () { git clone -q "hg::$1" $2 diff --git a/test/hg-git.t b/test/hg-git.t index 42545ab..f33835c 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -14,12 +14,6 @@ test_description='Test remote-hg output compared to hg-git' export EXPECTED_DIR="$SHARNESS_TEST_DIRECTORY/expected" -if ! python -c 'import mercurial' > /dev/null 2>&1 -then - skip_all='skipping remote-hg tests; mercurial not available' - test_done -fi - git_clone () { git clone -q "hg::$1" $2 && ( diff --git a/test/main.t b/test/main.t index 9315aa1..bb8fdc5 100755 --- a/test/main.t +++ b/test/main.t @@ -10,12 +10,6 @@ test_description='Test remote-hg' . ./test-lib.sh -if ! python -c 'import mercurial' > /dev/null 2>&1 -then - skip_all='skipping remote-hg tests; mercurial not available' - test_done -fi - check () { echo $3 > expected && git --git-dir=$1/.git log --format='%s' -1 $2 > actual && diff --git a/test/test-lib.sh b/test/test-lib.sh index 3daee04..0dada11 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -3,6 +3,11 @@ : "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "${BASH_SOURCE-$0}")" && pwd)}" . "$SHARNESS_TEST_SRCDIR"/sharness.sh +if ! python -c 'import mercurial' > /dev/null 2>&1 +then + error 'mercurial not available' +fi + GIT_AUTHOR_EMAIL=author@example.com GIT_AUTHOR_NAME='A U Thor' GIT_COMMITTER_EMAIL=committer@example.com From 890080673baee9102d6b7157baaa529cd75b0577 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 10:06:28 -0600 Subject: [PATCH 068/109] check-versions: remove hg-git stuff It's not worth it to keep trying to run this. Signed-off-by: Felipe Contreras --- tools/check-versions | 14 -------------- tools/hggit_rename_fix_0.8.0.patch | 22 ---------------------- tools/hggit_rename_fix_0.9.0.patch | 22 ---------------------- 3 files changed, 58 deletions(-) delete mode 100644 tools/hggit_rename_fix_0.8.0.patch delete mode 100644 tools/hggit_rename_fix_0.9.0.patch diff --git a/tools/check-versions b/tools/check-versions index 38e0d8b..b57fa54 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -220,20 +220,6 @@ end add_component(:hg, 'https://www.mercurial-scm.org/repo/hg', checkout_fix: hg_checkout_fix) -hggit_checkout_fix = lambda do |version| - return unless check_version(version, '0.8.0') - - if check_version(version, '0.9.0') - run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.9.0.patch], fatal: false - else - run_cmd %W[hg import -q --no-commit #{__dir__}/hggit_rename_fix_0.8.0.patch], fatal: false - end -end - -add_component(:hggit, 'https://foss.heptapod.net/mercurial/hg-git', checkout_fix: hggit_checkout_fix) - -add_component(:dulwich, 'https://github.com/dulwich/dulwich.git', version_format: 'dulwich-%s', kind: :git) - def load_checks(file) file.each do |e| e.chomp! diff --git a/tools/hggit_rename_fix_0.8.0.patch b/tools/hggit_rename_fix_0.8.0.patch deleted file mode 100644 index 71ca694..0000000 --- a/tools/hggit_rename_fix_0.8.0.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/hggit/git_handler.py b/hggit/git_handler.py ---- a/hggit/git_handler.py -+++ b/hggit/git_handler.py -@@ -693,6 +693,8 @@ - def import_git_commit(self, commit): - self.ui.debug(_("importing: %s\n") % commit.id) - -+ extra_in_message = self.ui.configbool('git', 'debugextrainmessage', False) -+ - detect_renames = False - (strip_message, hg_renames, - hg_branch, extra) = git2hg.extract_hg_metadata( -@@ -703,7 +705,8 @@ - # renames detected from Git. This is because we export an extra - # 'HG:rename-source' Git parameter when this isn't set, which will - # break bidirectionality. -- extra['hg-git-rename-source'] = 'git' -+ if not extra_in_message: -+ extra['hg-git-rename-source'] = 'git' - else: - renames = hg_renames - diff --git a/tools/hggit_rename_fix_0.9.0.patch b/tools/hggit_rename_fix_0.9.0.patch deleted file mode 100644 index fd4a206..0000000 --- a/tools/hggit_rename_fix_0.9.0.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/hggit/git_handler.py b/hggit/git_handler.py ---- a/hggit/git_handler.py -+++ b/hggit/git_handler.py -@@ -829,6 +829,8 @@ - def import_git_commit(self, commit): - self.ui.debug(_(b"importing: %s\n") % commit.id) - -+ extra_in_message = self.ui.configbool(b'git', b'debugextrainmessage', False) -+ - detect_renames = False - (strip_message, hg_renames, - hg_branch, extra) = git2hg.extract_hg_metadata( -@@ -839,7 +841,8 @@ - # renames detected from Git. This is because we export an extra - # 'HG:rename-source' Git parameter when this isn't set, which will - # break bidirectionality. -- extra[b'hg-git-rename-source'] = b'git' -+ if not extra_in_message: -+ extra[b'hg-git-rename-source'] = b'git' - else: - renames = hg_renames - From 4496af4a5c37cd4a1bc78dabe81a2c69158e7642 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 10:30:33 -0600 Subject: [PATCH 069/109] check-versions: remove hg hack It was only needed for hg-git tests. Signed-off-by: Felipe Contreras --- tools/check-versions | 4 ---- tools/hg_revert_5.7.patch | 24 ------------------------ 2 files changed, 28 deletions(-) delete mode 100644 tools/hg_revert_5.7.patch diff --git a/tools/check-versions b/tools/check-versions index b57fa54..06d4e4c 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -203,10 +203,6 @@ def add_component(id, url, **args) end hg_checkout_fix = lambda do |version| - if check_version(version, '5.7') - run_cmd %W[hg import -q --no-commit #{__dir__}/hg_revert_5.7.patch] - end - FileUtils.cp('hg', "#{$builddir}/bin/") return if check_version(version, '4.3') diff --git a/tools/hg_revert_5.7.patch b/tools/hg_revert_5.7.patch deleted file mode 100644 index 71dd115..0000000 --- a/tools/hg_revert_5.7.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/hg b/hg -index 4ec2b6140b..a3e61ad39c 100755 ---- a/hg -+++ b/hg -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # - # mercurial - scalable distributed SCM - # -diff --git a/mercurial/hg.py b/mercurial/hg.py -index 1a7a281e30..bf75f15ac1 100644 ---- a/mercurial/hg.py -+++ b/mercurial/hg.py -@@ -1013,7 +1013,7 @@ def clone( - pass - if uprev is None: - try: -- if destrepo._activebookmark: -+ if False: - uprev = destrepo.lookup(destrepo._activebookmark) - update = destrepo._activebookmark - else: - From b590aec106bef018ed54078c98fe7d6a2b81929b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 10:22:57 -0600 Subject: [PATCH 070/109] check-versions: remove code for other tools Only support hg. Signed-off-by: Felipe Contreras --- tools/check-versions | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tools/check-versions b/tools/check-versions index 06d4e4c..c74600e 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -62,13 +62,10 @@ class Component attr_reader :id - def initialize(id, url, kind: nil, **args) + def initialize(id, url, **args) @id = id @url = url - @kind = kind || (url.start_with?('git') ? :git : :hg) - @tool = @kind.to_s @checkout_fix = args[:checkout_fix] - @version_format = args[:version_format] end def dir @@ -76,25 +73,16 @@ class Component end def get_version(version) - return @kind == :hg ? 'tip' : '@' if version == '@' - @version_format ? @version_format % version : version + version == '@' ? 'tip' : version end def clone - run_cmd [@tool, 'clone', '-q', @url, dir] + run_cmd ['hg', 'clone', '-q', @url, dir] end def checkout(version) Dir.chdir(dir) do - case @kind - when :hg - cmd = %w[update --clean] - when :git - cmd = %w[reset --hard] - else - cmd = %w[checkout] - end - run_cmd [@tool] + cmd + ['-q', get_version(version)] + run_cmd %w[hg update --clean -q] << get_version(version) @checkout_fix.call(version) if @checkout_fix end end From bb663c032fc632008b7af9f99c1a48aaad196739 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 14:08:41 -0600 Subject: [PATCH 071/109] github: use standard hg packages Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd0040e..ac6496f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,18 +7,17 @@ jobs: strategy: matrix: hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3' ] - env: - HG_VERSION: ${{ matrix.hg }} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 with: python-version: '3.10' - check-latest: true - - name: Cache check-versions script - id: cache-check-versions - uses: actions/cache@v3 + - uses: actions/cache@v3 + id: cache-pip with: - path: ~/.cache/git-remote-hg - key: check-versions - - run: ./tools/check-versions $HG_VERSION + path: ~/.cache/pip + key: pip + - name: Install hg + run: + pip install mercurial==${{ matrix.hg }} + - run: make test From 09c4726083a0c40a29b2b4199e717232ecac922c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 12:45:17 -0600 Subject: [PATCH 072/109] check-versions: simplify for a single component No need for all the extra complexity just for hg. Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- tools/check-versions | 166 +++++++++++-------------------------- tools/versions.txt | 92 +++++++++----------- 3 files changed, 89 insertions(+), 171 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0014115..bd0040e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,4 +21,4 @@ jobs: with: path: ~/.cache/git-remote-hg key: check-versions - - run: ./tools/check-versions hg:$HG_VERSION + - run: ./tools/check-versions $HG_VERSION diff --git a/tools/check-versions b/tools/check-versions index c74600e..76c5eed 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -1,22 +1,16 @@ #!/usr/bin/env ruby # -# Copyright (c) 2019 Felipe Contreras +# Copyright (c) 2019-2023 Felipe Contreras # -# This script runs the tests for all versions of the components: -# hg, hggit and dulwich +# This script runs the tests for all versions of hg. # -# You can run it without arguments, in which case it reads the file -# 'versions.txt' and executes all those checks. +# You can run it without arguments, in which case it runs the tests for all +# versions in `versions.txt`. # -# Or you can pass the versions to check manually, like: +# Or you can specify a single version manually: # -# ./check-versions hg:4.7 hggit:0.8.12 dulwich:0.19.7 -# -# Or you can pass just the hg version, the other versions are fetched from -# 'versions.txt': -# -# ./check-versions hg:5.0 +# ./check-versions 6.3 # require 'fileutils' @@ -56,34 +50,26 @@ def check_version(a, b) (a <=> b) >= 0 end -# Component {{{1 +# Hg {{{1 -class Component +class Hg - attr_reader :id - - def initialize(id, url, **args) - @id = id - @url = url - @checkout_fix = args[:checkout_fix] + def initialize + @url = 'https://www.mercurial-scm.org/repo/hg' end def dir - "#{$workdir}/#{@id}" - end - - def get_version(version) - version == '@' ? 'tip' : version + "#{$workdir}/hg" end def clone - run_cmd ['hg', 'clone', '-q', @url, dir] + run_cmd %w[hg clone -q] + [@url, dir] end def checkout(version) Dir.chdir(dir) do - run_cmd %w[hg update --clean -q] << get_version(version) - @checkout_fix.call(version) if @checkout_fix + run_cmd %w[hg update --clean -q] << version + checkout_fix(version) end end @@ -94,6 +80,18 @@ class Component end end + def checkout_fix(version) + FileUtils.cp('hg', "#{$builddir}/bin/") + + return if check_version(version, '4.3') + + if run_cmd %W[hg import -q --no-commit #{__dir__}/hg_setup_hack_2.4.patch], fatal: false + File.write('.hg_force_version', "%s\n" % version) + else + File.write('mercurial/__version__.py', "version = \"%s\"\n" % version) + end + end + end # Functions {{{1 @@ -103,16 +101,14 @@ def setup FileUtils.mkdir_p(dirs.map { |e| "#{$builddir}/#{e}" }) FileUtils.mkdir_p($workdir) - $components.each do |id, component| - next if File.exists?(component.dir) + return if File.exists?($hg.dir) - if $verbosity < HIGH - puts "Cloning #{component.id}" - else - title "Cloning #{component.id}" - end - component.clone + if $verbosity < HIGH + puts "Cloning hg" + else + title "Cloning hg" end + $hg.clone end def test_env(paths: nil) @@ -145,31 +141,14 @@ def run_tests(tests) end end -def versions_to_s(versions) - versions.map { |k,v| "#{k}:#{v}" }.join(' ') -end +def check(version) + section version -def versions_from_args(args) - args.map { |e| k, v = e.split(':'); [k.to_sym, v] }.to_h -end + title "Checking out hg #{version}" + $hg.checkout(version) -def versions_from_s(str) - versions_from_args(str.split(' ')) -end - -def check(versions) - section versions_to_s(versions) - - versions.each do |id, version| - component = $components[id] - next unless component - - title "Checking out #{component.id} #{version}" - component.checkout(version) - - title "Building #{component.id}" - component.build - end + title "Building hg" + $hg.build paths = { PATH: "#{$builddir}/bin", @@ -182,43 +161,12 @@ def check(versions) end end -# Add components {{{1 - -$components = {} - -def add_component(id, url, **args) - $components[id] = Component.new(id, url, **args) -end - -hg_checkout_fix = lambda do |version| - FileUtils.cp('hg', "#{$builddir}/bin/") - - return if check_version(version, '4.3') - - if run_cmd %W[hg import -q --no-commit #{__dir__}/hg_setup_hack_2.4.patch], fatal: false - File.write('.hg_force_version', "%s\n" % version) - else - File.write('mercurial/__version__.py', "version = \"%s\"\n" % version) - end -end - -add_component(:hg, 'https://www.mercurial-scm.org/repo/hg', checkout_fix: hg_checkout_fix) - -def load_checks(file) - file.each do |e| - e.chomp! - next if e.empty? or e.start_with?('#') - content, comment = e.split(' # ') - versions = versions_from_s(content) - $checks << versions - end -end +$hg = Hg.new() def store_results(file) - $results.each do |versions, result| - content = versions_to_s(versions) + $results.each do |version, result| comment = result ? 'OK' : 'FAIL' - file.puts '%s # %s' % [content, comment] + file.puts '%s # %s' % [version, comment] end end @@ -229,32 +177,14 @@ setup $checks = [] $results = [] -$versions = versions_from_args(ARGV) +$version = ARGV.first +$checks = File.readlines(__dir__ + '/versions.txt', chomp: true) -File.open("#{__dir__}/versions.txt") do |f| - load_checks(f) -end - -if $versions.size == 1 and $versions.key?(:hg) - # mode 1 - $verbosity = LOW - - if ['@', nil].include?($versions[:hg]) - versions = $checks.last - versions[:hg] = $versions[:hg] if $versions[:hg] - else - versions = $checks.find { |e| e[:hg] == $versions[:hg] } - exit 1 unless versions - end - - exit check(versions) ? 0 : 1 -elsif not $versions.empty? - # mode 2 +if $version $verbosity = HIGH - exit check($versions) ? 0 : 1 + exit check($version) ? 0 : 1 else - # mode 3 $verbosity = QUIET at_exit do @@ -265,10 +195,10 @@ else failures = 0 - $checks.each do |versions| - result = check(versions) + $checks.each do |version| + result = check(version) failures += 1 unless result - $results << [versions, result] + $results << [version, result] end exit 1 unless failures == 0 diff --git a/tools/versions.txt b/tools/versions.txt index 30357df..3981c12 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -1,52 +1,40 @@ -# vi: ft=ruby - -hg:2.4 hggit:0.4.0 dulwich:0.9.0 # 2013_02 -hg:2.5 hggit:0.4.0 dulwich:0.9.0 # 2013_02 -hg:2.6 hggit:0.4.0 dulwich:0.9.0 # 2013_02 -hg:2.7 hggit:0.4.0 dulwich:0.9.0 # 2013_02 -hg:2.8 hggit:0.4.0 dulwich:0.9.0 # 2013_02 -hg:2.9 hggit:0.4.0 dulwich:0.9.0 # 2013_02 - -hg:3.0 hggit:0.7.0 dulwich:0.10.0 # 2014_11 -hg:3.1 hggit:0.7.0 dulwich:0.10.0 # 2014_11 -hg:3.2 hggit:0.7.0 dulwich:0.10.0 # 2014_11 - -hg:3.3 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.4 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.5 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.6 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.7 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.8 hggit:0.8.4 dulwich:0.13.0 # 2016_01 -hg:3.9 hggit:0.8.4 dulwich:0.13.0 # 2016_01 - -hg:4.0 hggit:0.8.10 dulwich:0.18.0 # 2017_11 -hg:4.1 hggit:0.8.10 dulwich:0.18.0 # 2017_11 -hg:4.2 hggit:0.8.10 dulwich:0.18.0 # 2017_11 -hg:4.3 hggit:0.8.10 dulwich:0.18.0 # 2017_11 -hg:4.4 hggit:0.8.10 dulwich:0.18.0 # 2017_11 - -hg:4.5 hggit:0.8.11 dulwich:0.18.0 # 2018_02 -hg:4.6 hggit:0.8.13 dulwich:0.19.7 # 2018_10 -hg:4.7 hggit:0.8.13 dulwich:0.19.7 # 2018_10 -hg:4.8 hggit:0.8.13 dulwich:0.19.7 # 2018_10 -hg:4.9 hggit:0.8.13 dulwich:0.19.7 # 2019_01 -hg:5.0 hggit:0.8.13 dulwich:0.19.7 # 2019_04 -hg:5.1 hggit:0.8.13 dulwich:0.19.7 # 2019_07 -hg:5.2 hggit:0.8.13 dulwich:0.19.7 # 2019_11 - -hg:5.3 hggit:0.9.0 dulwich:0.19.15 # 2020_01 -hg:5.4 hggit:0.9.0 dulwich:0.19.15 # 2020_04 -hg:5.5 hggit:0.9.0 dulwich:0.19.15 # 2020_08 -hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 - -hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01 - -hg:5.8 hggit:0.10.2 dulwich:0.20.0 # 2021_05 # python3 -hg:5.9 hggit:0.10.2 dulwich:0.20.0 # 2021_08 -hg:6.0 hggit:0.10.2 dulwich:0.20.0 # 2021_11 -hg:6.1 hggit:0.10.2 dulwich:0.20.0 # 2022_02 -hg:6.2 hggit:0.10.2 dulwich:0.20.0 # 2022_07 - -hg:6.3 hggit:1.0.1 dulwich:0.20.50 - -# hg:6.3 hggit:1.0.1 dulwich:0.21.3 # latest +2.4 +2.5 +2.6 +2.7 +2.8 +2.9 +3.0 +3.1 +3.2 +3.3 +3.4 +3.5 +3.6 +3.7 +3.8 +3.9 +4.0 +4.1 +4.2 +4.3 +4.4 +4.5 +4.6 +4.7 +4.8 +4.9 +5.0 +5.1 +5.2 +5.3 +5.4 +5.5 +5.6 +5.7 +5.8 +5.9 +6.0 +6.1 +6.2 +6.3 From 9916fead4657b165dff69222f576761388070934 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 14:39:44 -0600 Subject: [PATCH 073/109] github: trivial update Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ac6496f..f8753db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: matrix: hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.10' From d51f508916d543f987868dd6f7072c72e8f692b2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 13:19:38 -0600 Subject: [PATCH 074/109] check-versions: trivial results cleanup --- tools/check-versions | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tools/check-versions b/tools/check-versions index 76c5eed..3fcc9af 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -163,22 +163,15 @@ end $hg = Hg.new() -def store_results(file) - $results.each do |version, result| - comment = result ? 'OK' : 'FAIL' - file.puts '%s # %s' % [version, comment] - end -end - # Main {{{1 setup $checks = [] -$results = [] $version = ARGV.first $checks = File.readlines(__dir__ + '/versions.txt', chomp: true) +$results = File.open(__dir__ + '/results.txt', 'w') if $version $verbosity = HIGH @@ -187,18 +180,12 @@ if $version else $verbosity = QUIET - at_exit do - File.open("#{__dir__}/results.txt", 'w') do |f| - store_results(f) - end - end - failures = 0 $checks.each do |version| result = check(version) failures += 1 unless result - $results << [version, result] + $results.puts '%s # %s' % [version, result ? 'OK' : 'FAIL'] end exit 1 unless failures == 0 From 9b54c626bcf25d390861b430145e96af3ec8459c Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 6 Mar 2023 13:48:06 -0600 Subject: [PATCH 075/109] Remove support for hg < 4.0 2016 is ancient anyway. Signed-off-by: Felipe Contreras --- README.asciidoc | 2 +- git-remote-hg | 47 ++++++++++------------------------------------ tools/versions.txt | 16 ---------------- 3 files changed, 11 insertions(+), 54 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index a16d9b4..0d9e5d1 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -52,7 +52,7 @@ the same commits: Remember to run `git gc --aggressive` after cloning a repository, especially if it's a big one. Otherwise lots of space will be wasted. -The newest supported version of Mercurial is 6.2, the oldest one is 2.4. +The newest supported version of Mercurial is 6.2, the oldest one is 4.0. === Pushing branches === diff --git a/git-remote-hg b/git-remote-hg index 1568a51..0950298 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -15,6 +15,7 @@ from mercurial import hg, ui, bookmarks, context, encoding from mercurial import node, error, extensions, discovery, util from mercurial import changegroup +from mercurial import exchange import re import sys @@ -411,12 +412,6 @@ def updatebookmarks(repo, peer): localmarks.applychanges(repo, tr, changes.items()) else: localmarks.update(changes) - if check_version(3, 2): - localmarks.recordchange(tr) - elif check_version(2, 5): - localmarks.write() - else: - bookmarks.write(repo) tr.close() finally: tr.release() @@ -481,11 +476,7 @@ def get_repo(url, alias): except: die('Repository error') - if check_version(3, 0): - from mercurial import exchange - exchange.pull(repo, peer, heads=None, force=True) - else: - repo.pull(peer, heads=None, force=True) + exchange.pull(repo, peer, heads=None, force=True) updatebookmarks(repo, peer) @@ -792,10 +783,8 @@ def c_style_unescape(string): def make_memfilectx(repo, changectx, path, data, islink=False, isexec=False, copied=None): if check_version(4, 5): return context.memfilectx(repo, changectx, path, data, islink, isexec, copied) - elif check_version(3, 1): - return context.memfilectx(repo, path, data, islink, isexec, copied) else: - return context.memfilectx(path, data, islink, isexec, copied) + return context.memfilectx(repo, path, data, islink, isexec, copied) def parse_commit(parser): from_mark = merge_mark = None @@ -847,12 +836,9 @@ def parse_commit(parser): def getfilectx(repo, memctx, f): of = files[f] if 'deleted' in of: - if check_version(3, 2): - return None - else: - raise IOError + return None if 'ctx' in of: - if mode == 'hg' and check_version(3, 2): + if mode == 'hg': # force the creation of a new filelog ctx = of['ctx'] is_exec = ctx.isexec() @@ -1059,10 +1045,7 @@ def checkheads(repo, remote, p_revs): for branch, heads in new.items(): old = [repo.changelog.rev(x) for x in remotemap[branch]] for rev in heads: - if check_version(2, 3): - ancestors = repo.changelog.ancestors([rev], stoprev=min(old)) - else: - ancestors = repo.changelog.ancestors(rev) + ancestors = repo.changelog.ancestors([rev], stoprev=min(old)) found = False for x in old: @@ -1100,17 +1083,10 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): # Nothing to push return True - if check_version(4, 0): - if check_version(4, 4): - cg = changegroup.makechangegroup(repo, outgoing, b'01', b'push') - else: - cg = changegroup.getchangegroup(repo, b'push', outgoing) - elif check_version(3, 2): - cg = changegroup.getchangegroup(repo, b'push', heads=list(p_revs), common=common) - elif check_version(3, 0): - cg = changegroup.getbundle(repo, b'push', heads=list(p_revs), common=common) + if check_version(4, 4): + cg = changegroup.makechangegroup(repo, outgoing, b'01', b'push') else: - cg = repo.getbundle(b'push', heads=list(p_revs), common=common) + cg = changegroup.getchangegroup(repo, b'push', outgoing) unbundle = remote.capable(b'unbundle') if unbundle: @@ -1240,10 +1216,7 @@ def do_export(parser): tagnode, branch = write_tag(parser.repo, tag, node, msg, author) p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch) else: - if check_version(2, 4): - vfs = parser.repo.vfs - else: - vfs = parser.repo.opener + vfs = parser.repo.vfs fp = vfs(b'localtags', b'a') fp.write(b'%s %s\n' % (node, tag)) fp.close() diff --git a/tools/versions.txt b/tools/versions.txt index 3981c12..176c30e 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -1,19 +1,3 @@ -2.4 -2.5 -2.6 -2.7 -2.8 -2.9 -3.0 -3.1 -3.2 -3.3 -3.4 -3.5 -3.6 -3.7 -3.8 -3.9 4.0 4.1 4.2 From 10aec96d8817435acc22ef8a7f189868e701258e Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 11:33:30 -0600 Subject: [PATCH 076/109] Simplify absolute path fix This actually works on Windows. Signed-off-by: Felipe Contreras --- git-remote-hg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 0950298..f860d57 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1284,8 +1284,7 @@ def fix_path(alias, repo, orig_url): url = urlparse(orig_url, 'file') if url.scheme != 'file' or os.path.isabs(os.path.expanduser(url.path)): return - abs_url = urljoin("%s/" % os.getcwd(), orig_url) - cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url] + cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % os.path.abspath(orig_url)] subprocess.call(cmd) def main(args): From 60a1d7ae7a60988f122d8d9ba9ad3c693c5141ae Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 7 Mar 2023 11:43:54 -0600 Subject: [PATCH 077/109] Fix for paths in Windows Rewritten-by: Felipe Contreras Signed-off-by: Felipe Contreras --- git-remote-hg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index f860d57..1778144 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -299,9 +299,12 @@ class Parser: def fix_file_path(path): path = os.path.normpath(path.decode()) - if not os.path.isabs(path): + if os.path.isabs(path): + path = os.path.relpath(path, '/') + if os.sep == '/': return path - return os.path.relpath(path, '/') + # Git for Windows expects forward + return path.replace(os.sep, '/') def export_files(files): final = [] From f032d3617bb47585f20006abee83d7309498c17d Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 11:37:10 -0600 Subject: [PATCH 078/109] Improve output writing Let's avoid all python weirdness and just write directly. Signed-off-by: Felipe Contreras --- git-remote-hg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 1778144..b36163e 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -12,6 +12,8 @@ # For remote repositories a local clone is stored in # "$GIT_DIR/hg/origin/clone/.hg/". +from __future__ import print_function + from mercurial import hg, ui, bookmarks, context, encoding from mercurial import node, error, extensions, discovery, util from mercurial import changegroup @@ -78,10 +80,12 @@ RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') VERSION = 2 -def print_data(d): - print('data %d' % len(d)) - sys.stdout.flush() - os.write(1, d) +def print(arg): + os.write(1, arg.encode() + b'\n') + +def print_data(data): + os.write(1, b'data %d\n' % len(data)) + os.write(1, data) def debug(*args): sys.stderr.write('DEBUG: %s\n' % repr(args)) @@ -1360,10 +1364,6 @@ def main(args): marks_path = os.path.join(dirname, 'marks-hg') marks = Marks(marks_path, repo) - if sys.platform == 'win32': - import msvcrt - msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) - parser = Parser(repo) for line in parser: if parser.check('capabilities'): From 63cf2780ba07050a1985a83540ad17d5382334ee Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 11:52:57 -0600 Subject: [PATCH 079/109] test: fixes for Windows It's not clear if these tests can't work, or don't work at the moment, but at least some seem to be the fault of hg, not us. Signed-off-by: Felipe Contreras --- test/hg-git.t | 10 ++++++---- test/main.t | 2 +- test/test-lib.sh | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/hg-git.t b/test/hg-git.t index f33835c..6d7e782 100755 --- a/test/hg-git.t +++ b/test/hg-git.t @@ -116,8 +116,10 @@ setup eval "old_$(declare -f test_expect_success)" test_expect_success () { - test_id="$1" && - old_test_expect_success "$1" " + local req + test "$#" = 3 && { req=$1; shift; } || req= + test_id="$1" + old_test_expect_success "$req" "$1" " test_when_finished \"rm -rf gitrepo* hgrepo*\" && $2" } @@ -135,7 +137,7 @@ test_expect_success 'rename' ' cmp_hg_to_git_log_hgrepo1 ' -test_expect_success 'executable bit' ' +test_expect_success !WIN 'executable bit' ' ( git init -q gitrepo && cd gitrepo && @@ -154,7 +156,7 @@ test_expect_success 'executable bit' ' cmp_hg_to_git_manifest "hg manifest -v -r -1; hg manifest -v" ' -test_expect_success 'symlink' ' +test_expect_success !WIN 'symlink' ' ( git init -q gitrepo && cd gitrepo && diff --git a/test/main.t b/test/main.t index bb8fdc5..6da6a00 100755 --- a/test/main.t +++ b/test/main.t @@ -454,7 +454,7 @@ test_expect_success 'remote new bookmark multiple branch head' ' # cleanup previous stuff rm -rf hgrepo -test_expect_success 'fetch special filenames' ' +test_expect_success !WIN 'fetch special filenames' ' test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" && LC_ALL=en_US.UTF-8 diff --git a/test/test-lib.sh b/test/test-lib.sh index 0dada11..61ffa8b 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -14,3 +14,8 @@ GIT_COMMITTER_EMAIL=committer@example.com GIT_COMMITTER_NAME='C O Mitter' export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME + +if [[ $(uname -s) = MSYS* ]]; then + test_set_prereq WIN + export TEST_CMP='diff --strip-trailing-cr -u' +fi From 7f6a843f0d397ddde16ad4c8dca6fa48c3cf5d82 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 11:58:08 -0600 Subject: [PATCH 080/109] github: add windows job Signed-off-by: Felipe Contreras --- .github/workflows/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8753db..819e0d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,3 +21,21 @@ jobs: run: pip install mercurial==${{ matrix.hg }} - run: make test + test-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - uses: actions/cache@v3 + id: cache-pip + with: + path: ~/appdata/local/pip/cache + key: pip-windows + - name: Install hg + run: + pip install mercurial + - name: Run all tests + run: | + make SHELL='C:/Program Files/Git/usr/bin/bash' -C test From 35d32d5a75555c69f0dd412f4c7add8d44d40167 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 21:42:37 -0600 Subject: [PATCH 081/109] Remove ancient marks upgrade path It's safe to safe everyone already moved on since 2013. This reverts d379f37 (remote-hg: upgrade version 1 marks, 2013-05-24). Signed-off-by: Felipe Contreras --- git-remote-hg | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index b36163e..7006d21 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -150,21 +150,11 @@ def get_config_bool(config, default=False): class Marks: - def __init__(self, path, repo): + def __init__(self, path): self.path = path - self.repo = repo self.clear() self.load() - if self.version < VERSION: - if self.version == 1: - self.upgrade_one() - - # upgraded? - if self.version < VERSION: - self.clear() - self.version = VERSION - def clear(self): self.tips = {} self.marks = {} @@ -182,20 +172,12 @@ class Marks: self.tips = tmp['tips'] self.marks = tmp['marks'] self.last_mark = tmp['last-mark'] - self.version = tmp.get('version', 1) + self.version = tmp['version'] self.last_note = tmp.get('last-note', 0) for rev, mark in self.marks.items(): self.rev_marks[mark] = rev - def upgrade_one(self): - def get_id(rev): - return hghex(self.repo.changelog.node(int(rev))).decode() - self.tips = dict((name, get_id(rev)) for name, rev in self.tips.items()) - self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.items()) - self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.items()) - self.version = 2 - def dict(self): return { 'tips': self.tips, 'marks': self.marks, 'last-mark': self.last_mark, 'version': self.version, @@ -1362,7 +1344,7 @@ def main(args): fix_path(alias, peer or repo, url) marks_path = os.path.join(dirname, 'marks-hg') - marks = Marks(marks_path, repo) + marks = Marks(marks_path) parser = Parser(repo) for line in parser: From 4c50223dbaaeb11105e1c5f66ffa403d69c83c0e Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 21:49:37 -0600 Subject: [PATCH 082/109] remote-hg: remove shared repo upgrade We are not in 2013 anymore. This reverts commit 8f9a87c (remote-hg: add shared repo upgrade, 2013-08-09). Signed-off-by: Felipe Contreras --- git-remote-hg | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 7006d21..9105e7b 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -431,18 +431,6 @@ def get_repo(url, alias): else: shared_path = os.path.join(gitdir, 'hg') - # check and upgrade old organization - hg_path = os.path.join(shared_path, '.hg') - if os.path.exists(shared_path) and not os.path.exists(hg_path): - repos = os.listdir(shared_path) - for x in repos: - local_hg = os.path.join(shared_path, x, 'clone', '.hg') - if not os.path.exists(local_hg): - continue - if not os.path.exists(hg_path): - shutil.move(local_hg, hg_path) - shutil.rmtree(os.path.join(shared_path, x, 'clone')) - # setup shared repo (if not there) try: hg.peer(myui, {}, shared_path.encode(), create=True) @@ -457,6 +445,7 @@ def get_repo(url, alias): hg.share(myui, shared_path.encode(), local_path.encode(), update=False) else: # make sure the shared path is always up-to-date + hg_path = os.path.join(shared_path, '.hg') util.writefile(os.path.join(local_path, '.hg', 'sharedpath').encode(), hg_path.encode()) repo = hg.repository(myui, local_path.encode()) From b8b9a2f571c322bb3fe8a19c102a0f75fe9f3a9a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 22:12:52 -0600 Subject: [PATCH 083/109] Use relative option to hg.share When available. Signed-off-by: Felipe Contreras --- git-remote-hg | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 9105e7b..ce83b14 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -441,12 +441,16 @@ def get_repo(url, alias): os.makedirs(dirname) local_path = os.path.join(dirname, 'clone') - if not os.path.exists(local_path): - hg.share(myui, shared_path.encode(), local_path.encode(), update=False) + if check_version(4, 2): + if not os.path.exists(local_path): + hg.share(myui, shared_path.encode(), local_path.encode(), update=False, relative=True) else: - # make sure the shared path is always up-to-date - hg_path = os.path.join(shared_path, '.hg') - util.writefile(os.path.join(local_path, '.hg', 'sharedpath').encode(), hg_path.encode()) + if not os.path.exists(local_path): + hg.share(myui, shared_path.encode(), local_path.encode(), update=False) + else: + # make sure the shared path is always up-to-date + hg_path = os.path.join(shared_path, '.hg') + util.writefile(os.path.join(local_path, '.hg', 'sharedpath').encode(), hg_path.encode()) repo = hg.repository(myui, local_path.encode()) try: From e6c479c1363e1d26f722d09a7908e9f718df34dd Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 14 Mar 2023 04:10:54 -0600 Subject: [PATCH 084/109] Cleanup timezone stuff No functional changes. Signed-off-by: Felipe Contreras --- git-remote-hg | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index ce83b14..eb1881b 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -101,16 +101,12 @@ def gitmode(flags): return b'l' in flags and '120000' or b'x' in flags and '100755' or '100644' def gittz(tz): - sign = 1 if tz >= 0 else -1 - hours, minutes = divmod(abs(tz), 60 * 60) - return '%+03d%02d' % (-sign * hours, minutes / 60) + tz /= 60.0 + return '%+03d%02d' % (tz / -60, tz % 60) def hgtz(tz): - tz = int(tz) - sign = 1 if tz >= 0 else -1 - hours, minutes = divmod(abs(tz), 100) - tz = hours * 60 * 60 + minutes * 60 - return -sign * tz + sign = -1 if tz[0] == '-' else 1 + return sign * (int(tz[-4:-2]) * 60 + int(tz[-2:])) * -60 def hgmode(mode): m = { '100755': 'x', '120000': 'l' } From 995179444c11d5d680b4aa1e82ad94ef628ca2c0 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:37:49 -0600 Subject: [PATCH 085/109] Trivial simplification When there's no parents the files are the same as the manifest. Signed-off-by: Felipe Contreras --- git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index eb1881b..51c3ae9 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -507,7 +507,7 @@ def export_ref(repo, name, kind, head): parents = [repo[p] for p in repo.changelog.parentrevs(rev) if p >= 0] if len(parents) == 0: - modified = c.manifest().keys() + modified = files removed = [] else: modified, removed = get_filechanges(repo, c, parents[0]) From 740c681c1ddf71e592e1fdfce47e3bfff6600749 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:39:33 -0600 Subject: [PATCH 086/109] Trivial style change More idiomatic. Signed-off-by: Felipe Contreras --- git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index 51c3ae9..91604c3 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -506,7 +506,7 @@ def export_ref(repo, name, kind, head): parents = [repo[p] for p in repo.changelog.parentrevs(rev) if p >= 0] - if len(parents) == 0: + if not parents: modified = files removed = [] else: From 4ad9c8d70ca8d7273499031e01267f98baf18934 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:44:13 -0600 Subject: [PATCH 087/109] Reorganize get_filechanges So it's more extensible. Signed-off-by: Felipe Contreras --- git-remote-hg | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 91604c3..9559b0a 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -309,25 +309,30 @@ def export_files(files): return final -def get_filechanges(repo, ctx, parent): - modified = set() - added = set() - removed = set() +def get_filechanges(repo, ctx, parents, files): + if not parents: + modified = files + removed = [] + return modified, removed + else: + modified = set() + added = set() + removed = set() - # load earliest manifest first for caching reasons - prev = parent.manifest().copy() - cur = ctx.manifest() + # load earliest manifest first for caching reasons + prev = parents[0].manifest().copy() + cur = ctx.manifest() - for fn in cur: - if fn in prev: - if (cur.flags(fn) != prev.flags(fn) or cur[fn] != prev[fn]): - modified.add(fn) - del prev[fn] - else: - added.add(fn) - removed |= set(prev.keys()) + for fn in cur: + if fn in prev: + if (cur.flags(fn) != prev.flags(fn) or cur[fn] != prev[fn]): + modified.add(fn) + del prev[fn] + else: + added.add(fn) + removed |= set(prev.keys()) - return added | modified, removed + return added | modified, removed def fixup_user_git(user): name = mail = None @@ -506,11 +511,7 @@ def export_ref(repo, name, kind, head): parents = [repo[p] for p in repo.changelog.parentrevs(rev) if p >= 0] - if not parents: - modified = files - removed = [] - else: - modified, removed = get_filechanges(repo, c, parents[0]) + modified, removed = get_filechanges(repo, c, parents, files) desc += b'\n' From 33dccdfab06b4b7cbb12d4ca4a710bdedf272335 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:47:48 -0600 Subject: [PATCH 088/109] Simplify get_filechanges No functional changes. Signed-off-by: Felipe Contreras --- git-remote-hg | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 9559b0a..7bb7e25 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -311,13 +311,9 @@ def export_files(files): def get_filechanges(repo, ctx, parents, files): if not parents: - modified = files - removed = [] - return modified, removed + return files, [] else: modified = set() - added = set() - removed = set() # load earliest manifest first for caching reasons prev = parents[0].manifest().copy() @@ -329,10 +325,9 @@ def get_filechanges(repo, ctx, parents, files): modified.add(fn) del prev[fn] else: - added.add(fn) - removed |= set(prev.keys()) + modified.add(fn) - return added | modified, removed + return modified, prev.keys() def fixup_user_git(user): name = mail = None From 8025945a62d16ef078299ad5903081f250d762ed Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:52:19 -0600 Subject: [PATCH 089/109] Simpler get_filechanges algorithm The status method achieves the same thing as the current code. Signed-off-by: Felipe Contreras --- git-remote-hg | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 7bb7e25..d32b822 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -313,21 +313,8 @@ def get_filechanges(repo, ctx, parents, files): if not parents: return files, [] else: - modified = set() - - # load earliest manifest first for caching reasons - prev = parents[0].manifest().copy() - cur = ctx.manifest() - - for fn in cur: - if fn in prev: - if (cur.flags(fn) != prev.flags(fn) or cur[fn] != prev[fn]): - modified.add(fn) - del prev[fn] - else: - modified.add(fn) - - return modified, prev.keys() + stat = parents[0].status(ctx) + return stat.modified + stat.added, stat.removed def fixup_user_git(user): name = mail = None From 537e5a4735921277901a1ed7659c0c694e71722b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 01:58:42 -0600 Subject: [PATCH 090/109] Reorganize export_files No functional changes. Signed-off-by: Felipe Contreras --- git-remote-hg | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index d32b822..e0ceff9 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -288,25 +288,27 @@ def fix_file_path(path): # Git for Windows expects forward return path.replace(os.sep, '/') +def export_file(f): + fid = node.hex(f.filenode()) + + if fid in filenodes: + mark = filenodes[fid] + else: + mark = marks.next_mark() + filenodes[fid] = mark + d = f.data() + + print("blob") + print("mark :%u" % mark) + print_data(d) + + path = fix_file_path(f.path()) + return gitmode(f.flags()), mark, path + def export_files(files): final = [] for f in files: - fid = node.hex(f.filenode()) - - if fid in filenodes: - mark = filenodes[fid] - else: - mark = marks.next_mark() - filenodes[fid] = mark - d = f.data() - - print("blob") - print("mark :%u" % mark) - print_data(d) - - path = fix_file_path(f.path()) - final.append((gitmode(f.flags()), mark, path)) - + final.append(export_file(f)) return final def get_filechanges(repo, ctx, parents, files): From 9c5b8835f46fa1b851593952872b0e16a6154048 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 02:02:11 -0600 Subject: [PATCH 091/109] Get rid of export_files It's not necessary. Signed-off-by: Felipe Contreras --- git-remote-hg | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index e0ceff9..b0cc5b2 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -305,12 +305,6 @@ def export_file(f): path = fix_file_path(f.path()) return gitmode(f.flags()), mark, path -def export_files(files): - final = [] - for f in files: - final.append(export_file(f)) - return final - def get_filechanges(repo, ctx, parents, files): if not parents: return files, [] @@ -529,7 +523,7 @@ def export_ref(repo, name, kind, head): if len(parents) == 0 and rev: print('reset %s/%s' % (prefix, ename)) - modified_final = export_files(c.filectx(f) for f in modified) + modified_final = [export_file(c.filectx(fname)) for fname in modified] print("commit %s/%s" % (prefix, ename)) print("mark :%d" % (marks.get_mark(c.hex()))) From 7cff2c6adb02fbb2d0f6c6a01ed49fc9b805669f Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 02:07:45 -0600 Subject: [PATCH 092/109] Simplify export_file args Signed-off-by: Felipe Contreras --- git-remote-hg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index b0cc5b2..e500211 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -288,7 +288,8 @@ def fix_file_path(path): # Git for Windows expects forward return path.replace(os.sep, '/') -def export_file(f): +def export_file(ctx, fname): + f = ctx.filectx(fname) fid = node.hex(f.filenode()) if fid in filenodes: @@ -302,7 +303,7 @@ def export_file(f): print("mark :%u" % mark) print_data(d) - path = fix_file_path(f.path()) + path = fix_file_path(fname) return gitmode(f.flags()), mark, path def get_filechanges(repo, ctx, parents, files): @@ -523,7 +524,7 @@ def export_ref(repo, name, kind, head): if len(parents) == 0 and rev: print('reset %s/%s' % (prefix, ename)) - modified_final = [export_file(c.filectx(fname)) for fname in modified] + modified_final = [export_file(c, fname) for fname in modified] print("commit %s/%s" % (prefix, ename)) print("mark :%d" % (marks.get_mark(c.hex()))) From 7908c70efbd0420e21c2b0b7841b61e3b933be51 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 20 Mar 2023 02:08:37 -0600 Subject: [PATCH 093/109] Trivial simplifications Signed-off-by: Felipe Contreras --- git-remote-hg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index e500211..797ebbc 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -297,14 +297,12 @@ def export_file(ctx, fname): else: mark = marks.next_mark() filenodes[fid] = mark - d = f.data() print("blob") print("mark :%u" % mark) - print_data(d) + print_data(f.data()) - path = fix_file_path(fname) - return gitmode(f.flags()), mark, path + return gitmode(f.flags()), mark, fix_file_path(fname) def get_filechanges(repo, ctx, parents, files): if not parents: From 3bfec5fc6feea7d29fdf0a42f55247c2680fce80 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 22 Mar 2023 18:16:52 -0600 Subject: [PATCH 094/109] github: give a name to the action Signed-off-by: Felipe Contreras --- .github/workflows/{main.yml => ci.yml} | 2 ++ 1 file changed, 2 insertions(+) rename .github/workflows/{main.yml => ci.yml} (99%) diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 99% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index 819e0d4..6fb0b15 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,5 @@ +name: CI + on: push: From 7c373be665ebcf794a297b3c98afd9d94365d9f9 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 May 2023 07:20:51 -0600 Subject: [PATCH 095/109] test: test against hg 6.4 Signed-off-by: Felipe Contreras --- .github/workflows/ci.yml | 2 +- tools/versions.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fb0b15..027b999 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3' ] + hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3', '6.4' ] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/tools/versions.txt b/tools/versions.txt index 176c30e..379a81b 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -22,3 +22,4 @@ 6.1 6.2 6.3 +6.4 From 086ca235076d7450d3e46e8f80f483b895856777 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 May 2023 07:45:58 -0600 Subject: [PATCH 096/109] Trivial cleanups Signed-off-by: Felipe Contreras --- git-remote-hg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 797ebbc..59d1db7 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -470,7 +470,7 @@ def export_ref(repo, name, kind, head): if marks.is_marked(c.hex()): continue - (manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node) + manifest, user, (time, tz), files, desc, extra = repo.changelog.read(node) rev_branch = extra[b'branch'].decode() user = user.decode() @@ -486,7 +486,7 @@ def export_ref(repo, name, kind, head): else: committer = author - parents = [repo[p] for p in repo.changelog.parentrevs(rev) if p >= 0] + parents = [p for p in c.parents() if p.rev() != -1] modified, removed = get_filechanges(repo, c, parents, files) @@ -519,11 +519,11 @@ def export_ref(repo, name, kind, head): if extra_msg: desc += b'\n--HG--\n' + extra_msg.encode() + modified_final = [export_file(c, fname) for fname in modified] + if len(parents) == 0 and rev: print('reset %s/%s' % (prefix, ename)) - modified_final = [export_file(c, fname) for fname in modified] - print("commit %s/%s" % (prefix, ename)) print("mark :%d" % (marks.get_mark(c.hex()))) print("author %s" % (author)) From e774ad2d96ae27e23c8ede88384bb1c085d631e8 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 May 2023 08:25:01 -0600 Subject: [PATCH 097/109] Fix initial marks version [no ci] Signed-off-by: Felipe Contreras --- git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index 59d1db7..0972cc7 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -156,7 +156,7 @@ class Marks: self.marks = {} self.rev_marks = {} self.last_mark = 0 - self.version = 0 + self.version = VERSION self.last_note = 0 def load(self): From 463f397ba49b9f5f416c1cf85c1104c3939be224 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 4 May 2023 15:07:19 -0600 Subject: [PATCH 098/109] Remove last-note We can take advantage of `ref^0` and let `git fast-import` figure out the most recent commit. Signed-off-by: Felipe Contreras --- git-remote-hg | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 0972cc7..6dbae86 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -157,7 +157,6 @@ class Marks: self.rev_marks = {} self.last_mark = 0 self.version = VERSION - self.last_note = 0 def load(self): if not os.path.exists(self.path): @@ -169,15 +168,13 @@ class Marks: self.marks = tmp['marks'] self.last_mark = tmp['last-mark'] self.version = tmp['version'] - self.last_note = tmp.get('last-note', 0) for rev, mark in self.marks.items(): self.rev_marks[mark] = rev def dict(self): return { 'tips': self.tips, 'marks': self.marks, - 'last-mark': self.last_mark, 'version': self.version, - 'last-note': self.last_note } + 'last-mark': self.last_mark, 'version': self.version } def store(self): json.dump(self.dict(), open(self.path, 'w')) @@ -552,17 +549,16 @@ def export_ref(repo, name, kind, head): pending_revs = set(revs) - notes if pending_revs: - note_mark = marks.next_mark() ref = "refs/notes/hg" print("commit %s" % ref) - print("mark :%d" % (note_mark)) + print("mark :%d" % marks.next_mark()) print("committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone))) desc = "Notes for %s\n" % (name) print("data %d" % (len(desc))) print(desc) - if marks.last_note: - print("from :%u" % marks.last_note) + if tip != -1: + print("from %s^0" % ref) for rev in pending_revs: notes.add(rev) @@ -572,8 +568,6 @@ def export_ref(repo, name, kind, head): print_data(msg) print("") - marks.last_note = note_mark - marks.set_tip(ename, head.hex()) def export_tag(repo, tag): From 9c61c09ebf85a4387c95ba5758904d3381ad2876 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 May 2023 09:51:33 -0600 Subject: [PATCH 099/109] Remove support for lock-based unbundling This was deprecated in 0.9.1 and support for those servers dropped in 4.4. Signed-off-by: Felipe Contreras --- git-remote-hg | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 6dbae86..c24f4f9 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1038,13 +1038,9 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): else: cg = changegroup.getchangegroup(repo, b'push', outgoing) - unbundle = remote.capable(b'unbundle') - if unbundle: - if force: - remoteheads = [b'force'] - ret = remote.unbundle(cg, remoteheads, b'push') - else: - ret = remote.addchangegroup(cg, b'push', repo.url()) + if force: + remoteheads = [b'force'] + ret = remote.unbundle(cg, remoteheads, b'push') phases = remote.listkeys(b'phases') if phases: @@ -1062,17 +1058,7 @@ def push(repo, remote, parsed_refs, p_revs): # nothing to push return - lock = None - unbundle = remote.capable(b'unbundle') - if not unbundle: - lock = remote.lock() - try: - ret = push_unsafe(repo, remote, parsed_refs, p_revs) - finally: - if lock is not None: - lock.release() - - return ret + return push_unsafe(repo, remote, parsed_refs, p_revs) def check_tip(ref, kind, name, heads): try: From 451e31022a7039967e84e80c8dc66c84f07dd14b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 May 2023 10:13:16 -0600 Subject: [PATCH 100/109] Restrict common discovery This was added in hg 4.5. Signed-off-by: Felipe Contreras --- git-remote-hg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index 54a6949..ff00ec9 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1027,7 +1027,10 @@ def push(repo, remote, parsed_refs, p_revs): force = force_push fci = discovery.findcommonincoming - commoninc = fci(repo, remote, force=force) + if check_version(4, 5): + commoninc = fci(repo, remote, force=force, ancestorsof=list(p_revs)) + else: + commoninc = fci(repo, remote, force=force) common, _, remoteheads = commoninc fco = discovery.findcommonoutgoing outgoing = fco(repo, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force) From b274b8057e26da19e25c82d5fd93f49b35aaa6e3 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 May 2023 10:22:40 -0600 Subject: [PATCH 101/109] Don't force public pushes This is something that needs to explicitly happen. Signed-off-by: Felipe Contreras --- git-remote-hg | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index ff00ec9..9262e91 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1049,15 +1049,7 @@ def push(repo, remote, parsed_refs, p_revs): if force: remoteheads = [b'force'] - ret = remote.unbundle(cg, remoteheads, b'push') - - phases = remote.listkeys(b'phases') - if phases: - for head in p_revs: - # update to public - remote.pushkey(b'phases', hghex(head), b'1', b'0') - - return ret + return remote.unbundle(cg, remoteheads, b'push') def check_tip(ref, kind, name, heads): try: From 7713b7ecefea9f0df2970079086fe318e3d26311 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 5 May 2023 10:43:04 -0600 Subject: [PATCH 102/109] Remove push_unsafe() It's not needed anymore. Signed-off-by: Felipe Contreras --- git-remote-hg | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index c24f4f9..54a6949 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1016,7 +1016,13 @@ def checkheads(repo, remote, p_revs): return ret -def push_unsafe(repo, remote, parsed_refs, p_revs): +def push(repo, remote, parsed_refs, p_revs): + if hasattr(remote, 'canpush') and not remote.canpush(): + print("error cannot push") + + if not p_revs: + # nothing to push + return force = force_push @@ -1050,16 +1056,6 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): return ret -def push(repo, remote, parsed_refs, p_revs): - if hasattr(remote, 'canpush') and not remote.canpush(): - print("error cannot push") - - if not p_revs: - # nothing to push - return - - return push_unsafe(repo, remote, parsed_refs, p_revs) - def check_tip(ref, kind, name, heads): try: ename = '%s/%s' % (kind, name) From 79e75991ab3c7a757d4a77518643e81089e12682 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Sat, 18 Nov 2023 00:49:16 -0600 Subject: [PATCH 103/109] Use raw strings for regexes Fixes #94. Signed-off-by: Felipe Contreras --- git-remote-hg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 9262e91..465f1af 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -72,11 +72,11 @@ else: # Commits are modified to preserve hg information and allow bidirectionality. # -NAME_RE = re.compile('^([^<>]+)') -AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)') +NAME_RE = re.compile(r'^([^<>]+)') +AUTHOR_RE = re.compile(r'^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)') EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)') -AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.*))?$') -RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') +AUTHOR_HG_RE = re.compile(r'^(.*?) ?<(.*?)(?:>(.*))?$') +RAW_AUTHOR_RE = re.compile(r'^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') VERSION = 2 @@ -258,7 +258,7 @@ class Parser: return None _, name, email, date, tz = m.groups() if name and 'ext:' in name: - m = re.match('^(.+?) ext:\((.+)\)$', name) + m = re.match(r'^(.+?) ext:\((.+)\)$', name) if m: name = m.group(1) ex = urlunquote(m.group(2)) @@ -328,7 +328,7 @@ def fixup_user_git(user): def fixup_user_hg(user): def sanitize(name): # stole this from hg-git - return re.sub('[<>\n]', '?', name.lstrip('< ').rstrip('> ')) + return re.sub(r'[<>\n]', '?', name.lstrip('< ').rstrip('> ')) m = AUTHOR_HG_RE.match(user) if m: From 615cc7fe045d0417ac97f7790ebe941b39652ad2 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 7 Mar 2024 01:07:07 -0600 Subject: [PATCH 104/109] github: disable windows tests It's not working. Probably related to actions/runner-images#7253. Signed-off-by: Felipe Contreras --- .github/workflows/ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 027b999..6586f84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,21 +23,3 @@ jobs: run: pip install mercurial==${{ matrix.hg }} - run: make test - test-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - uses: actions/cache@v3 - id: cache-pip - with: - path: ~/appdata/local/pip/cache - key: pip-windows - - name: Install hg - run: - pip install mercurial - - name: Run all tests - run: | - make SHELL='C:/Program Files/Git/usr/bin/bash' -C test From 474cacd81d0f34717aebc6df473406285d5868ad Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 7 Mar 2025 23:53:09 -0600 Subject: [PATCH 105/109] check-versions: fix for newer ruby versions --- tools/check-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check-versions b/tools/check-versions index 3fcc9af..0cd7dd2 100755 --- a/tools/check-versions +++ b/tools/check-versions @@ -101,7 +101,7 @@ def setup FileUtils.mkdir_p(dirs.map { |e| "#{$builddir}/#{e}" }) FileUtils.mkdir_p($workdir) - return if File.exists?($hg.dir) + return if File.exist?($hg.dir) if $verbosity < HIGH puts "Cloning hg" From f00911668a023181f18a429956d865807f962da1 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 8 Mar 2025 02:01:54 -0600 Subject: [PATCH 106/109] Avoid decoding some binary stuff --- git-remote-hg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 465f1af..8f05536 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -507,11 +507,11 @@ def export_ref(repo, name, kind, head): extra_msg += (b"rename : %s => %s\n" % e).decode() for key, value in extra.items(): - key, value = key.decode(), value.decode() - if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'): + key = key.decode() + if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git', 'transplant_source'): continue else: - extra_msg += "extra : %s : %s\n" % (key, urlquote(value)) + extra_msg += "extra : %s : %s\n" % (key, urlquote(value.decode())) if extra_msg: desc += b'\n--HG--\n' + extra_msg.encode() From d2a3a646afdad0203e0f7e6164e4851eddcb5e08 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 8 Mar 2025 08:30:24 -0600 Subject: [PATCH 107/109] test: unset user some config --- test/test-lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test-lib.sh b/test/test-lib.sh index 61ffa8b..7a4a4f7 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -15,6 +15,8 @@ GIT_COMMITTER_NAME='C O Mitter' export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME +unset XDG_CONFIG_HOME + if [[ $(uname -s) = MSYS* ]]; then test_set_prereq WIN export TEST_CMP='diff --strip-trailing-cr -u' From c861db6add8485148f4e4ecca5fb917994c9c425 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 8 Mar 2025 08:32:03 -0600 Subject: [PATCH 108/109] check-versions: add newer versions --- tools/versions.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/versions.txt b/tools/versions.txt index 379a81b..d8d86b7 100644 --- a/tools/versions.txt +++ b/tools/versions.txt @@ -23,3 +23,8 @@ 6.2 6.3 6.4 +6.5 +6.6 +6.7 +6.8 +6.9 From 408333afca931970d19c57bb697cdf83f6abcbef Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sat, 8 Mar 2025 08:48:47 -0600 Subject: [PATCH 109/109] github: use newer hg versions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6586f84..04b08ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - hg: [ '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3', '6.4' ] + hg: [ '6.0', '6.1', '6.2', '6.3', '6.4', '6.5', '6.6', '6.7', '6.8', '6.9' ] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4