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

Error cloning a Git repository on Heroku #34

Closed look closed 14 years ago

look commented 14 years ago

Cool plugin. I got it working for a GitHub repository, but when I tried cloning one from Heroku I got the following error. Heroku says I'm fetching an invalid path.

When I use git to clone the repository with the same Git URL it works. Anyone get this working? I know this usage is probably kind of non-standard. ;)

hg gclone git@heroku.com:repository-name.git
fetching from : origin
importing Hg objects into Git
Invalid path.
Syntax is: git@heroku.com:<app>.git where <app> is your app's name
** 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: churn, fetch, bookmarks, hg-git, hgk
Traceback (most recent call last):
  File "/opt/local/bin/hg", line 27, in <module>
    mercurial.dispatch.run()
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 16, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 25, in dispatch
    return _runcatch(u, args)
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 41, in _runcatch
    return _dispatch(ui, args)
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 372, in _dispatch
    return runcommand(lui, repo, cmd, fullargs, ui, options, d)
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 247, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 417, in _runcommand
    return checkargs()
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 377, in checkargs
    return cmdfunc()
  File "/opt/local/lib/python2.5/site-packages/mercurial/dispatch.py", line 371, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/opt/local/lib/python2.5/site-packages/mercurial/util.py", line 718, in check
    return func(*args, **kwargs)
  File "/Users/look/hg-git/__init__.py", line 42, in gclone
    git.fetch('origin')
  File "/Users/look/hg-git/git_handler.py", line 105, in fetch
    refs = self.fetch_pack(remote_name)
  File "/Users/look/hg-git/git_handler.py", line 557, in fetch_pack
    refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
  File "/Users/look/hg-git/dulwich/client.py", line 344, in fetch_pack
    progress)
  File "/Users/look/hg-git/dulwich/client.py", line 166, in fetch_pack
    (refs, server_capabilities) = self.read_refs()
  File "/Users/look/hg-git/dulwich/client.py", line 112, in read_refs
    for pkt in self.proto.read_pkt_seq():
  File "/Users/look/hg-git/dulwich/protocol.py", line 77, in read_pkt_seq
    pkt = self.read_pkt_line()
  File "/Users/look/hg-git/dulwich/protocol.py", line 64, in read_pkt_line
    raise HangupException()
hgext_hgext_hg-git.dulwich.errors.HangupException
abderrahim commented 14 years ago

try git+ssh://git@heroku.com/repository-name.git

undees commented 14 years ago

This alone won't work, because hg-git adds a leading slash to the repo name, and Heroku doesn't like that. One of these days, I'll make the path-parsing function generic enough to understand both Github-style and Heroku-style paths. In the meantime, since I only have to push to Heroku once every few weeks, I just qpush and qpop this patch in my hg-git repo for that one special case:

diff --git a/git_handler.py b/git_handler.py
--- a/git_handler.py
+++ b/git_handler.py
@@ -838,6 +838,6 @@
                     host = 'git@' + host
                 else:
                     host, path = uri[len(handler):].split("/", 1)
-                return transport(host), '/' + path
+                return transport(host), path
         # if its not git or git+ssh, try a local url..
         return SubprocessGitClient(), uri
ebrahim commented 14 years ago

See http://bitbucket.org/mml/hg-git/

look commented 14 years ago

Using the current version I am able to push to Heroku using a URL like this:

hg push git+ssh://git@heroku.com:your-app-name.git

Cloning works too.

deemoowoor commented 12 years ago

The workaround proposed by 'look' stops working with Mercurial 2.0 (at least). hg-git adds a trailing slash to the repository path, which is not expected by Heroku.