schacon / hg-git

mercurial to git bridge, pushed to directly from the hg-git plugin in Hg
GNU General Public License v2.0
620 stars 71 forks source link

gclone seems to fail on git+ssh type URLs #15

Closed NorwegianRockCat closed 15 years ago

NorwegianRockCat commented 15 years ago

It seems that the hg-git plugin has issues when given a URL that uses SSH public keys.

An example can be seen with the Qt repository (http://qt.gitorious.org/qt). Assuming you have a login, you will see the following clone URLs available:

Public clone url: git://gitorious.org/qt/qt.git
Your clone url: git@gitorious.org:qt/qt.git

If you run gclone with the "Public clone url," it works as expected.

If you run gclone with the "Your clone url," it crashes with the following backtrace:


hg gclone git@gitorious.org:qt/qt.git
fetching from : origin
exporting git objects
Access denied or bad command
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.2.1)
** Extensions loaded: convert, fetch, graphlog, bookmarks, hg-git, parentrevspec, purge, rebase, hgk, mq, record, transplant
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 27, in 
    mercurial.dispatch.run()
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 16, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 25, in dispatch
    return _runcatch(u, args)
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch
    return _dispatch(ui, args)
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch
    return runcommand(lui, repo, cmd, fullargs, ui, options, d)
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand
    return checkargs()
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs
    return cmdfunc()
  File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 371, in 
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/Library/Python/2.5/site-packages/mercurial/util.py", line 718, in check
    return func(*args, **kwargs)
  File "/Users/twschulz/projects/hg-git/__init__.py", line 38, in gclone
    git.fetch('origin')
  File "/Users/twschulz/projects/hg-git/git_handler.py", line 114, in fetch
    refs = self.fetch_pack(remote_name)
  File "/Users/twschulz/projects/hg-git/git_handler.py", line 421, in fetch_pack
    refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
  File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 344, in fetch_pack
    progress)
  File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 166, in fetch_pack
    (refs, server_capabilities) = self.read_refs()
  File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 112, in read_refs
    for pkt in self.proto.read_pkt_seq():
  File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 77, in read_pkt_seq
    pkt = self.read_pkt_line()
  File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 64, in read_pkt_line
    raise HangupException()
hgext_hgext_hg-git.dulwich.errors.HangupException

It also fails if you set this as a remote and do a gfetch.

This was on Mac OS X 10.5.6 using the binary Mercurial package available from:

http://www.selenic.com/mercurial/wiki/BinaryPackages#head-ea0494fa54ddf09d8995040bbe29a65ecc04d9d9

Sorry if I'm using the wrong terminology.

NorwegianRockCat commented 15 years ago

Eep. The backtrace got totally mangled. Here it is marked down (or at least I hope it is): hg gclone git@gitorious.org:qt/qt.git fetching from : origin exporting git objects Access denied or bad command * unknown exception encountered, details follow * report bug details to http://www.selenic.com/mercurial/bts * or mercurial@selenic.com * Mercurial Distributed SCM (version 1.2.1) * Extensions loaded: convert, fetch, graphlog, bookmarks, hg-git, parentrevspec, purge, rebase, hgk, mq, record, transplant Traceback (most recent call last): File "/usr/local/bin/hg", line 27, in mercurial.dispatch.run() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 16, in run sys.exit(dispatch(sys.argv[1:])) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 25, in dispatch return _runcatch(u, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch return _dispatch(ui, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch return runcommand(lui, repo, cmd, fullargs, ui, options, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand ret = _runcommand(ui, options, cmd, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand return checkargs() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs return cmdfunc() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 371, in d = lambda: util.checksignature(func)(ui, _args, _cmdoptions) File "/Library/Python/2.5/site-packages/mercurial/util.py", line 718, in check return func(_args, *_kwargs) File "/Users/twschulz/projects/hg-git/init.py", line 38, in gclone git.fetch('origin') File "/Users/twschulz/projects/hg-git/git_handler.py", line 114, in fetch refs = self.fetch_pack(remote_name) File "/Users/twschulz/projects/hg-git/git_handler.py", line 421, in fetch_pack refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 344, in fetch_pack progress) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 166, in fetch_pack (refs, server_capabilities) = self.read_refs() File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 112, in read_refs for pkt in self.proto.read_pkt_seq(): File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 77, in read_pkt_seq pkt = self.read_pkt_line() File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 64, in read_pkt_line raise HangupException() hgext_hgext_hg-git.dulwich.errors.HangupException

undees commented 15 years ago

Hi, NorwegianRockCat.

I'm having the same issue with a public-key setup on Heroku. In this case, it was because hg-git was adding a leading slash to the remote path. Heroku was responding, "No, you can't push to /reponame, it has to be just reponame instead."

The quick fix was to change the get_transport_and_path function in git_handler.py to return transport(host), path instead of transport(host), '/' + path.

Does this work in your case? If so, I'll ask Scott about the circumstances under which we can or can't add a slash, and cook up something more formal in the way of a real patch.

schacon commented 15 years ago

ah yes, for now you actually have to use 'git+ssh://git@gitorious.org:qt/qt.git' - it doesn't assume the ssh part yet. soon.

undees commented 15 years ago

Hi, Scott. I think the git+ssh URL style you mention is likely to address issue #15, but the Heroku path issue persists. I'll continue discussion of it here (since it's kind of related), but am happy to move to a new ticket if you prefer.

May I propose a patch where we don't add the leading slash unless the repo URL has a colon-slash (for git@ URLs) or a double-slash (for git+svn:// URLs)? If that sounds reasonable, I'll check in a change and send a pull request.

NorwegianRockCat commented 15 years ago

Hi Schacon,

If I change to using a git+ssh URL I get further, but still get into problems. I then get the error "access denied or bad command."

Here's another backtrace:

hg gremote remote.origin.url git+ssh://git@gitorious.org/qt/qt.git hg gfetch pulling from git url fetching from : origin exporting git objects at: 0/1391 at: 100/1391 at: 200/1391 at: 300/1391 at: 400/1391 at: 500/1391 at: 600/1391 at: 700/1391 at: 800/1391 at: 900/1391 at: 1000/1391 at: 1100/1391 at: 1200/1391 at: 1300/1391 Access denied or bad command * unknown exception encountered, details follow * report bug details to http://www.selenic.com/mercurial/bts * or mercurial@selenic.com * Mercurial Distributed SCM (version 1.2.1) * Extensions loaded: convert, fetch, graphlog, bookmarks, hg-git, parentrevspec, purge, rebase, hgk, mq, record, transplant Traceback (most recent call last): File "/usr/local/bin/hg", line 27, in mercurial.dispatch.run() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 16, in run sys.exit(dispatch(sys.argv[1:])) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 25, in dispatch return _runcatch(u, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch return _dispatch(ui, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch return runcommand(lui, repo, cmd, fullargs, ui, options, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand ret = _runcommand(ui, options, cmd, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand return checkargs() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs return cmdfunc() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 371, in d = lambda: util.checksignature(func)(ui, _args, _cmdoptions) File "/Library/Python/2.5/site-packages/mercurial/util.py", line 718, in check return func(_args, *_kwargs) File "/Users/twschulz/projects/hg-git/init.py", line 87, in gfetch git.fetch(remote_name) File "/Users/twschulz/projects/hg-git/git_handler.py", line 124, in fetch refs = self.fetch_pack(remote_name) File "/Users/twschulz/projects/hg-git/git_handler.py", line 472, in fetch_pack refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 344, in fetch_pack progress) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 166, in fetch_pack (refs, server_capabilities) = self.read_refs() File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 112, in read_refs for pkt in self.proto.read_pkt_seq(): File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 77, in read_pkt_seq pkt = self.read_pkt_line() File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 64, in read_pkt_line raise HangupException() hgext_hgext_hg-git.dulwich.errors.HangupException

NorwegianRockCat commented 15 years ago

Hmm... I would say something also is wrong with the paths too. If I just change to using git+ssh it seems to get confused with the colon as well. The last one I showed just had a slash instead and it got further: hg gremote remote.origin.url git+ssh://git@gitorious.org:qt/qt.git hg gfetch ... (same "at" stuff from before) then: ssh: Could not resolve hostname gitorious.org:qt: nodename nor servname provided, or not known * unknown exception encountered, details follow * report bug details to http://www.selenic.com/mercurial/bts * or mercurial@selenic.com * Mercurial Distributed SCM (version 1.2.1) * Extensions loaded: convert, fetch, graphlog, bookmarks, hg-git, parentrevspec, purge, rebase, hgk, mq, record, transplant Traceback (most recent call last): File "/usr/local/bin/hg", line 27, in mercurial.dispatch.run() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 16, in run sys.exit(dispatch(sys.argv[1:])) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 25, in dispatch return _runcatch(u, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch return _dispatch(ui, args) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch return runcommand(lui, repo, cmd, fullargs, ui, options, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand ret = _runcommand(ui, options, cmd, d) File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand return checkargs() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs return cmdfunc() File "/Library/Python/2.5/site-packages/mercurial/dispatch.py", line 371, in d = lambda: util.checksignature(func)(ui, _args, _cmdoptions) File "/Library/Python/2.5/site-packages/mercurial/util.py", line 718, in check return func(_args, *_kwargs) File "/Users/twschulz/projects/hg-git/init.py", line 87, in gfetch git.fetch(remote_name) File "/Users/twschulz/projects/hg-git/git_handler.py", line 124, in fetch refs = self.fetch_pack(remote_name) File "/Users/twschulz/projects/hg-git/git_handler.py", line 472, in fetch_pack refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 344, in fetch_pack progress) File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 166, in fetch_pack (refs, server_capabilities) = self.read_refs() File "/Users/twschulz/projects/hg-git/dulwich/client.py", line 112, in read_refs for pkt in self.proto.read_pkt_seq(): File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 77, in read_pkt_seq pkt = self.read_pkt_line() File "/Users/twschulz/projects/hg-git/dulwich/protocol.py", line 64, in read_pkt_line raise HangupException() hgext_hgext_hg-git.dulwich.errors.HangupException

Hope this helps.