From 63cf2780ba07050a1985a83540ad17d5382334ee Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 11:52:57 -0600 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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: