Giter Club home page Giter Club logo

git-remote-hg's People

Contributors

ambakshi avatar apelisse avatar artagnon avatar benabik avatar berenm avatar delcypher avatar doctorjei avatar felipec avatar fingolfin avatar gitster avatar jcb91 avatar jcristau avatar mnauw avatar native-api avatar noschinl avatar novalis avatar ostueker avatar pabs3 avatar razcampagne avatar rhansen avatar rudis avatar tboegi avatar wking avatar zetten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-remote-hg's Issues

Add option to match hash from hg-git

The semi-offical hg-git extension for mecurial provides an analigous solution to bridge git to hg. As such when converting mercurial repositories to git one may use hg-git or git-remote-hg to do the transformation.

Unfortunately despite the history appearing to be identical, some subtle difference appears to be creating a difference in hash.

As a result, difficult merge problems occur in the transition where native git users cannot merge or rebase with the legacy hg servers using git-remote-hg without causing a rift in the space-time continuum because git believes the histories are different.

I propose finding the difference and offering a compatibility mode.
The same change could/should be made on the hg-git side, and I'll propose it there as well.

When/if I figure out the issue causing the divergence I'll update this ticket.

Exception when cloning a repository

I used this git-remote-hg version for a while and it worked fine... until this morning :)

$ hg --version                                                                                                                                                                                                                                                                                                                                                                   
Mercurial Distributed SCM (version 4.6)

$ git clone hg::https://foo/bar/yzodb yzodb
Clonage dans 'yzodb'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 508 changesets with 1381 changes to 164 files (+1 heads)
new changesets 2c831d24c6cf:8739b3153c04
Traceback (most recent call last):
  File "/home/eloi/bin/git-remote-hg", line 1781, in <module>
    sys.exit(main(sys.argv))
  File "/home/eloi/bin/git-remote-hg", line 1762, in main
    do_import(parser)
  File "/home/eloi/bin/git-remote-hg", line 779, in do_import
    export_bookmark(repo, bmark)
  File "/home/eloi/bin/git-remote-hg", line 629, in export_bookmark
    export_ref(repo, bmark, 'bookmarks', head)
  File "/home/eloi/bin/git-remote-hg", line 529, in export_ref
    revs = revwalk(repo, ename, head)
  File "/home/eloi/bin/git-remote-hg", line 506, in revwalk
    pending.add(int(b))
TypeError: int() argument must be a string or a number, not 'changectx'
fatal: stream ends early
fast-import: dumping crash report to /home/eloi/dev/yzodb/.git/fast_import_crash_17297
fatal: Error while running fast-import```

Idea: repair corrupt marks

As we've seen in the past (e.g. felipec#4), sometimes the marks get out-of-sync between git and hg. One way that this can happen (I think) is if commits are stripped on the hg side. We've experienced this repeatedly internally; unfortunately, all of our repos are proprietary, and at any rate, we don't get copies of those repos until after the issue has already caused fast-import to crash. I propose that (configurably) before git-remote-hg starts work, it should open up the git and hg marks files and delete any marks which are missing from either side. I'm happy to write this code (indeed, I already have an internal version of it that's about to go into testing, based on felipec's Ruby script). But before I clean up my work for upstreaming, I want to know if such a patch is likely to be accepted.

Does this seem like a good idea to you?

Thanks.

cc @abliss

A pip package

Hi, congratulations for you project. So far it is the only version of git-remote-hg I have seen working with mercurial 4.5. Did you consider to release a pip package ? That would make the installation easier!

`main.t` test `23 - remote big push force` fails with git 2.35.1

Forwarding Debian git-remote-hg#1006038.

In Debian, upgrading from git 1:2.34.1-1 in Debian bookworm to git 1:2.35.1-1 in Debian unstable causes main.t test 23 - remote big push force to fail. Switching back to git 1:2.34.1-1 makes it work again.

This is the log from that failure in verbose mode:

expecting success: 
	test_when_finished "rm -rf hgrepo gitrepo*" &&

	setup_big_push

	(
	cd gitrepo &&

	if test "$CAPABILITY_PUSH" = "t"
	then
		check_push 0 --force --all <<-\EOF
		master:forced-update
		good_bmark:forced-update
		branches/good_branch:forced-update
		new_bmark:new
		branches/new_branch:new
		bad_bmark1:forced-update
		bad_bmark2:forced-update
		branches/bad_branch:forced-update
		EOF
	else
		check_push 0 --force --all <<-\EOF
		master
		good_bmark
		branches/good_branch
		new_bmark:new
		branches/new_branch:new
		bad_bmark1:forced-update
		bad_bmark2:forced-update
		branches/bad_branch:forced-update
		EOF
	fi
	) &&

	check_branch hgrepo default six &&
	check_branch hgrepo good_branch eight &&
	check_branch hgrepo bad_branch nine &&
	check_branch hgrepo new_branch ten &&
	check_bookmark hgrepo good_bmark three &&
	check_bookmark hgrepo bad_bmark1 four &&
	check_bookmark hgrepo bad_bmark2 five &&
	check_bookmark hgrepo new_bmark six

Cloning into 'gitrepo'...
WARNING: capability_push is disabled, only do so when really sure
WARNING: various enhanced features might fail in subtle ways
adding changesets
adding manifests
adding file changes
adding remote bookmark bad_bmark1
adding remote bookmark bad_bmark2
adding remote bookmark good_bmark
added 4 changesets with 4 changes to 1 files
new changesets 6d7a5bc6993c:5b7d9dcafec0
progress revision walk 'bookmarks/master' (1/1)
progress revision 0 'master' (0/2)
progress revision 2 'bad_branch' (0/2)
HEAD is now at 284b5c6 zero
HEAD is now at 284b5c6 zero
HEAD is now at 6bb95b0 good branch
WARNING: capability_push is disabled, only do so when really sure
WARNING: various enhanced features might fail in subtle ways
no changes found
searching for changes
adding changesets
adding manifests
adding file changes
added 9 changesets with 9 changes to 1 files (+7 heads)
To hg::test/trash directory.main/tmp/hgrepo
 + 2377e89...85b16bc branches/bad_branch -> branches/bad_branch (forced update)
   6bb95b0..f00fc03  branches/good_branch -> branches/good_branch
 + a322050...cf5f1c9 bad_bmark1 -> bad_bmark1 (forced update)
 + a322050...1eb0be9 bad_bmark2 -> bad_bmark2 (forced update)
   a322050..aeafffd  good_bmark -> good_bmark
   a322050..5ecae6c  master -> master
 * [new branch]      branches/new_branch -> branches/new_branch
 * [new branch]      new_bmark -> new_bmark
   a322050..5ecae6c  master -> master
   a322050..aeafffd  good_bmark -> good_bmark
   6bb95b0..f00fc03  branches/good_branch -> branches/good_branch
 * [new branch]      new_bmark -> new_bmark
 * [new branch]      branches/new_branch -> branches/new_branch
 + a322050...cf5f1c9 bad_bmark1 -> bad_bmark1 (forced update)
 + a322050...1eb0be9 bad_bmark2 -> bad_bmark2 (forced update)
 + 2377e89...85b16bc branches/bad_branch -> branches/bad_branch (forced update)
--- expected	2022-02-20 07:09:15.389175133 +0000
+++ actual	2022-02-20 07:09:15.641175789 +0000
@@ -1 +1 @@
-six
+four
not ok 23 - remote big push force
#	
#		test_when_finished "rm -rf hgrepo gitrepo*" &&
#	
#		setup_big_push
#	
#		(
#		cd gitrepo &&
#	
#		if test "$CAPABILITY_PUSH" = "t"
#		then
#			check_push 0 --force --all <<-\EOF
#			master:forced-update
#			good_bmark:forced-update
#			branches/good_branch:forced-update
#			new_bmark:new
#			branches/new_branch:new
#			bad_bmark1:forced-update
#			bad_bmark2:forced-update
#			branches/bad_branch:forced-update
#			EOF
#		else
#			check_push 0 --force --all <<-\EOF
#			master
#			good_bmark
#			branches/good_branch
#			new_bmark:new
#			branches/new_branch:new
#			bad_bmark1:forced-update
#			bad_bmark2:forced-update
#			branches/bad_branch:forced-update
#			EOF
#		fi
#		) &&
#	
#		check_branch hgrepo default six &&
#		check_branch hgrepo good_branch eight &&
#		check_branch hgrepo bad_branch nine &&
#		check_branch hgrepo new_branch ten &&
#		check_bookmark hgrepo good_bmark three &&
#		check_bookmark hgrepo bad_bmark1 four &&
#		check_bookmark hgrepo bad_bmark2 five &&
#		check_bookmark hgrepo new_bmark six
#	

Checkout fails and file paths have backslashes if using Windows Mercurial

Using windows Git 2.17.1.2 with windows CPython 2.7.15:

(The command are run from Git Bash prompt. Had to make an NTFS symlink for python.exe so that python2 is found on PATH. My Python has local modifications but they only affect Tkinter.)

$ git --version
git version 2.17.1.windows.2

$ ls -l `which python2`
lrwxrwxrwx 1 Sasha 197121 10 Jan  1 20:25 /c/Python27/python2 -> python.exe*

$ python2 -c 'import sys; print sys.version'
2.7.15+ (heads/tcltk_race_2.7-dirty:d3981ea259, May 30 2018, 06:09:23) [MSC v.15                                                                                                                00 64 bit (AMD64)]

$ which hg
/c/Python27/Scripts/hg

$ hg --version
Mercurial Distributed SCM (version 4.8.1)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2018 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When checking out, I get lots of errors like this:

Sasha@Sasha-PC MINGW64 ~/Documents/pypy (master)
$ git checkout --force
error: unable to create file _pytest\README-BEFORE-UPDATING: No such file or directory
error: unable to create file _pytest\__init__.py: No such file or directory
error: unable to create file _pytest\_argcomplete.py: No such file or directory
<etc>

And in git ls-files, all files in subdirectories feature backslashes instead of slashes. It looks like hg reports the paths in such a way, and git-remote-hg just copies them blindly.

The fix should be to replace os.path.sep with / when cloning, but I've no idea where to put it.

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int' when doing "git clone hg::..." with mercurial 5.0

OS: Ubuntu 18.04
git version: 2.17.1
Mercurial version: 5.0
git-remote-hg: 1.0.1

While cloning an open-source repo:

$ git clone hg::ssh://[email protected]/takluyver/greentreesnakes
Cloning into 'greentreesnakes'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 63 changesets with 73 changes to 16 files
new changesets 40df06a42a64:16e8d3ce9a18
progress revision walk 'bookmarks/master' (62/62)
progress revision 0 'master' (0/63)
Traceback (most recent call last):
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 1802, in <module>
    sys.exit(main(sys.argv))
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 1783, in main
    do_import(parser)
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 789, in do_import
    export_branch(repo, branch)
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 647, in export_branch
    export_ref(repo, branch, 'branches', head)
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 542, in export_ref
    revs = revwalk(repo, ename, head)
  File "/home/mateusz/Software/git-remote-hg/git-remote-hg", line 520, in revwalk
    interval = b.rev() / 10
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
fatal: stream ends early
fast-import: dumping crash report to /home/mateusz/Projects/greentreesnakes/.git/fast_import_crash_5633
fatal: Error while running fast-import

Maybe the fix could be as simple as:

interval = b.rev() / 10 if b.rev() is not None else ...

but as I'm not familiar with Mercurial I have no idea what a good default value would be in this case. Also, haven't tried other repos yet.

Any release comming soon?

Hi.
I am a packager for Mageia, and found this tool today, and plan to package it for Mageia.
Your current releases are the same as the original repo from felipec.

Since you have done quite a few commits, do you plan to do a new release? (i.e. a v0.4 tag)
I would encurage you to do that, as that makes packaging easier.

git fetch fails with "error: fast-import died of signal 9"

git clone hg::http://hg.code.sf.net/p/mrbs/hg-code succeeds.
Then git fetch inside the cloned repository fails with

no changes found
error: fast-import died of signal 9
fatal: error while running fast-import

Mercurial 5.5.2, Python 3.8.6, Git 2.29.2 on macOS 10.13.6

Can't clone

$ git clone "hg::https://bitbucket.org/capitalmatch/webdriver-utils" 3rdparty/webdriver-utils
Cloning into '3rdparty/webdriver-utils'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 124 changesets with 207 changes to 37 files (+1 heads)
new changesets a137b649f934:a8b15525a1cc
progress revision 99 'master' (100/122)
WARNING: Branch 'default' has more than one head, consider merging
Traceback (most recent call last):
  File "/usr/host/bin/git-remote-hg", line 1348, in <module>
    sys.exit(main(sys.argv))
  File "/usr/host/bin/git-remote-hg", line 1332, in main
    do_import(parser)
  File "/usr/host/bin/git-remote-hg", line 737, in do_import
    export_tag(repo, tag)
  File "/usr/host/bin/git-remote-hg", line 614, in export_tag
    export_ref(repo, tag, 'tags', repo[hgref(tag)])
  File "/usr/x86_64-pc-linux-gnu/lib/python2.7/site-packages/mercurial/localrepo.py", line 856, in __getitem__
    return context.changectx(self, changeid)
  File "/usr/x86_64-pc-linux-gnu/lib/python2.7/site-packages/mercurial/context.py", line 439, in __init__
    (changeid, type(changeid)))
mercurial.error.ProgrammingError: unsupported changeid 'v0.1.0' of type <type 'str'>
fatal: stream ends early
fast-import: dumping crash report to /home/hasufell/git/CM_app/app/3rdparty/webdriver-utils/.git/fast_import_crash_22867
fatal: error while running fast-import

"not ok 18 - push commits with copy and rename"

test-push.t fails for me on Debian sid. I don't really understand what it's doing, so I can't really work out why.

cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=844939

Cloning into 'gitrepo'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
new changesets 6f6ffe13c16f
progress revision walk 'bookmarks/master' (0/0)
progress revision 0 'master' (0/1)
[master b3130fb] copy
 Author: A U Thor <[email protected]>
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 content-copy
[master fd1a6bf] moved
 Author: A U Thor <[email protected]>
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename content-copy => content-moved (100%)
searching for changes
no changes found
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 3 changes to 3 files
To hg::/root/src/git-remote-hg/test/trash directory.main-push/hgrepo
   fffffff..fd1a6bf  master -> master
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
not ok 18 - push commits with copy and rename

At the end, it looks like it's checking for three changesets, but there are only two?

# hg log -f content-moved
changeset:   2:beb6c5cbcf9d
tag:         tip
user:        ...
date:        Tue Nov 28 12:01:07 2017 +0000
summary:     moved

changeset:   1:5f44b7021c3b
user:        ...
date:        Tue Nov 28 12:01:07 2017 +0000
summary:     copy

hg-remote-helper HEAD (76be528), hg 4.4.1, git 2.15.0, python 2.7.14, locales-all 2.25-2, amd64 docker on 4.13 / btrfs; running as root.

Any guesses, or anything else I can provide to help?

Transfer the githashes to the mercurial repository (locally)

Hi
I am a mercurial user, who clones git repository to my machine and then use, at the moment Felip's converter to generate
the corresponding mercurial repositories (with named branches), work and would then to push to the remote git
server via hg-git.
That however currently is not possible since the converter does not transfer the git hashes to the (local) mercurial repository.
Since your fork has very similar features and since it is not clear whether Felipe still is developping his code,
is there any change that you might consider implementing such a feature?
I don't know enough git and python to try this even. I will rise this question also on the hg-git mailing list
regards
Uwe Brauer

git-remote-hg does not run in windows because of extensionless script file

I've installed this script in Windows 7 with Python 2.7.15. D:\Python27\Scripts is on the PATH and all Python files are associated with 3.7's Python Launcher.

The script install successfully, but when trying to clone a repo, I get:

C:\Users\Amalia\Desktop>git clone hg::https://... xxx
Cloning into 'xxx'...
fatal: 'remote-hg' appears to be a git command, but we were not
able to execute it. Maybe git-remote-hg is broken?

The script can be run if I use py -2 git-remote-hg or any other way, just not through CMD.

port to Python 3

Now that mercurial has been ported to Python 3 it would be useful to have git-remote-hg work with Python 3, especially since distributions like Debian are removing Python 2. Currently the version of git-remote-hg in Debian just crashes since mercurial in Debian no longer provides Python 2 support.

https://bugs.debian.org/943032

Cannot use .hgrc file

When trying to clone a mercurial repo using this tool (by following the instructions and running: git clone hg::https://REPO_NAME) I am getting an error about the repository using the largefiles extension. I have prepared ~/.hgrc with the appropriate settings for cloning the repo using mercurial itself, but this files doesn't seem to get used by the git-remote-hg script.

Can this be fixed? Or is there a way to pass configuration to the hg process when invoked by git?

git-remote-hg can't push backwards

#!/bin/bash

set -xeuo pipefail

rm -rf /tmp/g1 /tmp/h1

git init /tmp/g1
hg init /tmp/h1

cd /tmp/g1

touch a
git add a
git commit -am a
FIRST=$(git rev-parse HEAD)

touch b
git add b
git commit -am b
SECOND=$(git rev-parse HEAD)

git push hg::/tmp/h1 $SECOND:refs/heads/master
git push hg::/tmp/h1 $FIRST:refs/heads/master
+ git push hg::/tmp/h1 4a530a3c7284686ff8d62d3f9b63cc9c7bea57f2:refs/heads/master
no changes found
2 local changesets published
To hg::/tmp/h1
 ! [remote rejected] 4a530a3c7284686ff8d62d3f9b63cc9c7bea57f2 -> master (unknown)
error: failed to push some refs to 'hg::/tmp/h1'

Add option to translate invalid characters in hg tag names to valid characters in git tag names

Forwarding Debian git-remote-hg#826002. When cloning repos that contain tags that contain invalid characters, git-remote-hg prints a warning and then ignores the tag, not creating any corresponding git tags. It would be nice if (optionally) instead the characters that are invalid in git tag names could be translated to valid ones. For example the tilde/~ characters could be translated to underscores. This is most often an issue when cloning repos containing Debian backports, which use the tilde/~ character in their version numbers.

$ mkdir hg
$ cd hg
hg $ hg init
hg $ touch foo 
hg $ hg add foo
hg $ hg commit -m foo
hg $ hg tag foo~bar
hg $ hg log
changeset:   1:3f7b12984249
tag:         tip
user:        Paul Wise
date:        Tue Aug 17 15:28:34 2021 +0800
summary:     Added tag foo~bar for changeset 2fe0783478a5

changeset:   0:2fe0783478a5
tag:         foo~bar
user:        Paul Wise
date:        Tue Aug 17 15:28:08 2021 +0800
summary:     foo

hg $ cd ..
$ git clone hg::hg git
Cloning into 'git'...
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
new changesets 2fe0783478a5:3f7b12984249
error: * Ignoring funny ref 'refs/tags/foo~bar' locally
progress revision walk 'bookmarks/master' (1/1)
progress revision 0 'master' (0/2)
$ cd git 
git (master=) $ git tag
git (master=) $ 

Cloning fails from repository requiring HTTP authentication

Summary

Cloning a repo that requires HTTP authentication using Mercurial will prompt the user for a username and a password.

user@hostname:~/Projects$ hg clone $REPO_URL
http authorization required for $REPO_URL
realm: Mercurial Repositories
user: 
password: 

Using git-remote-hg, the program will exit with ERROR: Repository error. I don't know if this is helpful or not, but adding a traceback before the die statement gives the following:

Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 613, in get_repo
    peer = hg.peer(repo.ui, {}, url)
  File "/usr/lib/python3/dist-packages/mercurial/hg.py", line 240, in peer
    return _peerorrepo(
  File "/usr/lib/python3/dist-packages/mercurial/hg.py", line 188, in _peerorrepo
    obj = _peerlookup(path).instance(
  File "/usr/lib/python3/dist-packages/mercurial/httppeer.py", line 1106, in instance
    inst = makepeer(ui, path)
  File "/usr/lib/python3/dist-packages/mercurial/httppeer.py", line 1067, in makepeer
    respurl, info = performhandshake(ui, url, opener, requestbuilder)
  File "/usr/lib/python3/dist-packages/mercurial/httppeer.py", line 984, in performhandshake
    resp = sendrequest(ui, opener, req)
  File "/usr/lib/python3/dist-packages/mercurial/httppeer.py", line 300, in sendrequest
    res = opener.open(req)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 1054, in http_error_401
    response = self.http_error_auth_reqed('www-authenticate',
  File "/usr/lib/python3/dist-packages/mercurial/url.py", line 520, in http_error_auth_reqed
    return urlreq.httpbasicauthhandler.http_error_auth_reqed(
  File "/usr/lib/python3.9/urllib/request.py", line 1003, in http_error_auth_reqed
    return self.retry_http_basic_auth(host, req, realm)
  File "/usr/lib/python3/dist-packages/mercurial/url.py", line 525, in retry_http_basic_auth
    user, pw = self.passwd.find_user_password(
  File "/usr/lib/python3/dist-packages/mercurial/url.py", line 81, in find_user_password
    raise error.Abort(
mercurial.error.Abort: http authorization required for $REPO_URL
ERROR: Repository error

Workarounds

Cloning a repository using hg, and then cloning that cloned repository will bypass authentication until the need to push or pull arises.

v0.4 tag conflicts between felipec & mnauw repositories

I noticed that the v0.4 tag conflicts between the felipec and mnauw repositories. I'm not sure which of the two repos has the correct tag, but I think felipec's one is correct because the v0.4 tag from it is close to the v0.3 tag, but the v0.4 tag from your repository is closer to the v1.0.1 tag.

If you agree with my assessment, here is how to fix the issue:

git push --delete origin v0.4
git tag --delete v0.4
git remote add felipec https://github.com/felipec/git-remote-hg.git
git fetch --tags felipec v0.4
git push --tags
git remote remove felipec

Here is the verification for the issue:

$ git clone -o felipec -q https://github.com/felipec/git-remote-hg.git

$ cd git-remote-hg/

git-remote-hg (master=) $ git remote add mnauw https://github.com/mnauw/git-remote-hg.git

git-remote-hg (master=) $ git fetch --tags mnauw 
remote: Enumerating objects: 457, done.
remote: Counting objects: 100% (234/234), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 457 (delta 190), reused 229 (delta 188), pack-reused 223
Receiving objects: 100% (457/457), 214.71 KiB | 648.00 KiB/s, done.
Resolving deltas: 100% (312/312), completed with 22 local objects.
From https://github.com/mnauw/git-remote-hg
 * [new branch]      master      -> mnauw/master
 * [new branch]      test        -> mnauw/test
 * [new branch]      topic_notes -> mnauw/topic_notes
 ! [rejected]        v0.4        -> v0.4  (would clobber existing tag)
 * [new tag]         v1.0.0      -> v1.0.0
 * [new tag]         v1.0.1      -> v1.0.1
 * [new tag]         v1.0.2      -> v1.0.2
 * [new tag]         v1.0.2.1    -> v1.0.2.1

git-remote-hg (master=) $ git fetch --tags mnauw 
From https://github.com/mnauw/git-remote-hg
 ! [rejected]        v0.4       -> v0.4  (would clobber existing tag)

git-remote-hg (master=) $ grep -F v0.4 .git/packed-refs
cc4e5659d941845d7b80798f7261aebcbf64b4c0 refs/tags/v0.4

git-remote-hg (master=) $ git log --oneline cc4e5659d941845d7b80798f7261aebcbf64b4c0 | head -n1
cc4e565 Merge branch 'check-versions'

git-remote-hg (master=) $ git tag -d v0.4 
Deleted tag 'v0.4' (was cc4e565)

git-remote-hg (master=) $ git fetch --tags mnauw 
From https://github.com/mnauw/git-remote-hg
 * [new tag]         v0.4       -> v0.4

git-remote-hg (master=) $ cat .git/refs/tags/v0.4 
5e96683f67af35475175bb057271102edb4a3c9a

$ git log --oneline 5e96683f67af35475175bb057271102edb4a3c9a | head -n1
5e96683 Adjust to Mercurial 4.6 wrt revision numbers

"git fetch" doesn't work on hg::https://gmplib.org/repo/gmp/

I got

[hjl@gnu-cfl-1 gmp]$ git fetch origin
searching for changes
no changes found
fatal: Branch name doesn't conform to GIT standards: hg/origin/refs/tags/gmp-3_0___**FUNKY**
fast-import: dumping crash report to .git/fast_import_crash_2922933
fatal: error while running fast-import
[hjl@gnu-cfl-1 gmp]$ 

This is similar to felipec#7.

"git push" fails with "ValueError: string too long"

searching for changes
no changes found
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1785, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1770, in main
    do_push(parser)
  File "/usr/local/bin/git-remote-hg", line 1548, in do_push
    do_push_refspec(parser, line.lstrip('push '), localrevs)
  File "/usr/local/bin/git-remote-hg", line 1475, in do_push_refspec
    ok = do_push_hg(nparser)
  File "/usr/local/bin/git-remote-hg", line 1278, in do_push_hg
    parse_commit(parser)
  File "/usr/local/bin/git-remote-hg", line 1023, in parse_commit
    node = hghex(repo.commitctx(ctx))
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 142, in wrapper
    return orig(repo.unfiltered(), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 1950, in commitctx
    trp, changed)
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 1702, in _filecommit
    flog = self.file(fname)
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 1022, in file
    return filelog.filelog(self.svfs, f)
  File "/usr/local/lib/python2.7/site-packages/mercurial/filelog.py", line 45, in __init__
    "/".join(("data", path + ".i")))
  File "/usr/local/lib/python2.7/site-packages/mercurial/revlog.py", line 624, in __init__
    f = self.opener(self.indexfile)
  File "/usr/local/lib/python2.7/site-packages/mercurial/store.py", line 492, in __call__
    return self.vfs(self.encode(path), mode, *args, **kw)
ValueError: string too long

Mercurial 4.5, Git 2.14.3, on macOS 10.13.3.

setup.py doesn't work with release versions

Downloading version 1.0.0 and trying to install it as a python pip package fails:

fatal: not a git repository (or any parent up to mount point /var/tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    assert (len(version) > 0)
AssertionError

git-remote-hg fails to detect case changes on MacOS

For example, if the repository contains a file foo.txt which used to be named Foo.txt, Git will still create Foo.txt. I assume this is caused by the Mac filesystem being case insensitive by default.

It would be desirable for the git history to be identical regardless of the tool having run on Linux or MacOS.

Here's a demo shell script:

#!/bin/sh

set -e -x

if [ ! -x bin/git-remote-hg ]; then
    mkdir -p bin
    wget https://raw.github.com/mnauw/git-remote-hg/master/git-remote-hg -O bin/git-remote-hg
    chmod +x bin/git-remote-hg
fi
PATH="$PWD/bin:$PATH"

rm -rf hg_repo git_repo

mkdir hg_repo
cd hg_repo
hg init

echo 1 >Foo.txt
hg add Foo.txt
hg commit -m "Create Foo.txt"

hg mv Foo.txt dummy
hg mv dummy foo.txt
hg commit -m "Move Foo.txt to foo.txt"

echo 2 >foo.txt
hg commit -m "Modify foo.txt"

cd ..
git clone hg::file://$PWD/hg_repo git_repo

# git_repo should contain Foo.txt, not foo.txt
ls git_repo | fgrep foo.txt

Crash when cloning or pulling some repositories

Since a few weeks, some repositories I work with fail to pull. Each time the error looks like this:

git clone hg::https://***********/hg/foobar                                                                                                                  
Clonage dans 'foobar'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 691 changesets with 4745 changes to 1271 files
new changesets 1ce35169e0be:f4a8ebebef69
progress revision walk 'bookmarks/master' (690/690)
progress revision 0 'master' (0/690)
progress revision 101 'master' (100/690)
progress revision 201 'master' (200/690)
progress revision 301 'master' (300/690)
progress revision 401 'master' (400/690)
progress revision 501 'master' (500/690)
progress revision 601 'master' (600/690)
Traceback (most recent call last):
  File "/home/azmeuk/bin/git-remote-hg", line 1788, in <module>
    sys.exit(main(sys.argv))
  File "/home/azmeuk/bin/git-remote-hg", line 1769, in main
    do_import(parser)
  File "/home/azmeuk/bin/git-remote-hg", line 789, in do_import
    export_tag(repo, tag)
  File "/home/azmeuk/bin/git-remote-hg", line 632, in export_tag
    export_ref(repo, tag, 'tags', repo[hgref(tag)])
  File "/usr/lib/python2.7/site-packages/mercurial/localrepo.py", line 856, in __getitem__                                                                                      
    return context.changectx(self, changeid)
  File "/usr/lib/python2.7/site-packages/mercurial/context.py", line 439, in __init__
    (changeid, type(changeid)))
mercurial.error.ProgrammingError: unsupported changeid 'production_2018_02_27_16_32_44' of type <type 'str'>                                                                    
fatal: stream ends early
fast-import: dumping crash report to /home/azmeuk/dev/foobar/.git/fast_import_crash_3951
fatal: Error while running fast-import

production_2018_02_27_16_32_44 is a mercurial tag in the distant repository.

Python3 compatability

git-remote-hg 1.0.1 installed via pip3 appears to use prints without parenthesis causing

$  git-remote-hg
  File "/home/catskul/.local/bin/git-remote-hg", line 311
    print "blob"
               ^
SyntaxError: Missing parentheses in call to 'print'

Looking at the head of the file in question shows indeed it's requesting python3 as the interpreter

$  head /home/catskul/.local/bin/git-remote-hg
#!/usr/bin/python3
#
# Copyright (c) 2012 Felipe Contreras
# Copyright (c) 2016 Mark Nauwelaerts
#

However the repo shows python2 in at tag 1.0.1:

https://github.com/mnauw/git-remote-hg/blob/v1.0.1/git-remote-hg

#!/usr/bin/env python2
#
# Copyright (c) 2012 Felipe Contreras
# Copyright (c) 2016 Mark Nauwelaerts
#

Not sure if pip3 did the change?? or if the setup scripts do. If it's not python3 compatible and it's possible, pip3 installation should be prevented.

Beyond the issues with pep3, python3 compatibility would itself be desirable.

Mercurial 4.4: AttributeError: 'module' object has no attribute 'getlocalchangegroup'

Starting with Mercurial 4.4, I get the following error when trying to push to a repository:

$ git push
searching for changes
no changes found
searching for changes
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1763, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1748, in main
    do_push(parser)
  File "/usr/local/bin/git-remote-hg", line 1526, in do_push
    do_push_refspec(parser, line.lstrip('push '), localrevs)
  File "/usr/local/bin/git-remote-hg", line 1453, in do_push_refspec
    ok = do_push_hg(nparser)
  File "/usr/local/bin/git-remote-hg", line 1329, in do_push_hg
    ret = push(parser.repo, peer, p_revs, force_push)
  File "/usr/local/bin/git-remote-hg", line 1215, in push
    ret = push_unsafe(repo, remote, p_revs, force)
  File "/usr/local/bin/git-remote-hg", line 1178, in push_unsafe
    cg = changegroup.getlocalchangegroup(repo, 'push', outgoing)
AttributeError: 'module' object has no attribute 'getlocalchangegroup'
To hg::ssh://user@fqdn//path/to/repository
   fffffffff..5f36207a3  master -> master
error: failed to push some refs to 'hg::ssh://user@fqdn//path/to/repository'
$ git --version                                                                                                                  ❌ 1 ↵
git version 2.15.0
$ hg --version
Mercurial Distributed SCM (version 4.4)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2017 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ sw_vers
ProductName:   Mac OS X
ProductVersion: 10.12.6
BuildVersion:   16G29
$  

It worked with Mercurial 4.3.3 (and downgrading helped, for now):

$ git push
searching for changes
no changes found
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 2 changes to 2 files
To hg::ssh://user@fqdn//path/to/repository
   fffffffff..5f36207a3  master -> master$ hg --version
Mercurial Distributed SCM (version 4.3.3)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2017 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$

Please let me know if I can help with something!

tests fail with new version of git: transport 'file' not allowed

Forwarding Debian git-remote-hg bug #1023804.

The tests fail with a new version of git due to a security update that blocks the file transport by default.

This bug will cause removal of git-remote-hg from Debian bookworm, so once the issue is fixed, a new release would be appreciated.

Please note a similar issue was reported in Debian hg-git bug #1023806.

...
Initialized empty Git repository in 
src/test/trash 
directory.main-push/tmp/sub/.git/
[master (root-commit) be983cd] init
 Author: A U Thor <[email protected]>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 empty
Initialized empty Git repository in 
src/test/trash 
directory.main-push/tmp/gitrepo/.git/
Cloning into 
'/tmp/autopkgtest-lxc.4ir0bv3l/downtmp/build.jzc/src/test/trash 
directory.main-push/tmp/gitrepo/sub'...
fatal: transport 'file' not allowed
fatal: clone of 
'src/test/trash 
directory.main-push/tmp/sub' into submodule path 
'src/test/trash 
directory.main-push/tmp/gitrepo/sub' failed
not ok 52 - push with submodule

Fails to clone repo with branches "tests" and "tests/test1"

I was successfully using git-remote-hg until someone added those two branches to the repository. Now I cannot pull or clone it.

I included a sample mercurial repository sample-mercurial-repo.zip unzip it with unzip -d /tmp /tmp/sample-mercurial-repo.zip and then try doing a local clone with git clone "hg::file:///tmp/nested-branches-repro" /tmp/git-nested-branches-repro

I get the following error:

Cloning into '/tmp/git-nested-branches-repro'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 1 files
progress revision walk 'bookmarks/master' (0/0)
progress revision 0 'master' (0/1)
progress revision 1 'tests' (0/1)
progress revision 2 'tests/test1' (0/1)
error: cannot lock ref 'hg/origin/refs/branches/tests/test1': 'hg/origin/refs/branches/tests' exists; cannot create 'hg/origin/refs/branches/tests/test1'
fatal: Error while running fast-import
Traceback (most recent call last):
File "/usr/local/bin/git-remote-hg", line 1763, in
sys.exit(main(sys.argv))
File "/usr/local/bin/git-remote-hg", line 1755, in main
marks.store()
File "/usr/local/bin/git-remote-hg", line 180, in store
json.dump(self.dict(), open(self.path, 'w'))
IOError: [Errno 2] No such file or directory: '/private/tmp/git-nested-branches-repro/.git/hg/marks-hg'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.