felipec / git

Fork of Junio Hamano's git for users
Other
204 stars 34 forks source link

git-remote-hg with "git remote add -f ..." #33

Closed ijstokes closed 11 years ago

ijstokes commented 11 years ago

Also posted to WordPress blog:

I tried to do a remote add with a fetch and got the following error:

git remote add -f extern/ipython-physics hg::https://bitbucket.org/birkenfeld/ipython-physics
Updating extern/ipython-physics
Traceback (most recent call last):
  File "/usr/bin/git-remote-hg", line 1024, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-hg", line 992, in main
    repo = get_repo(url, alias)
  File "/usr/bin/git-remote-hg", line 383, in get_repo
    os.mkdir(dirname)
OSError: [Errno 2] No such file or directory: '.git/hg/extern/ipython-physics'
error: Could not fetch extern/ipython-physics

A few variations such as just adding the remote then doing a separate fetch didn’t work either. I am able to clone the mercurial repo, however. Ultimately I’m trying to add a remote to an existing repo to then insert it as a subtree dependency. Suggestions as to how I could achieve this would be appreciated!

TIA

FWIW, the next things I'm going to try and execute are:

git merge -s ours --no-commit extern/ipython-physics/master
git read-tree --prefix=subtree/ipython-physics -u extern/ipython-physics/master
git commit -m "Subtree merged in ipython-physics"
git pull -s subtree extern/ipython-physics master
felipec commented 11 years ago

This should do the trick:

--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -381,7 +381,7 @@ def get_repo(url, alias):
                 die('Repository error')

         if not os.path.exists(dirname):
-            os.mkdir(dirname)
+            os.makedirs(dirname)

         local_path = os.path.join(dirname, 'clone')
         if not os.path.exists(local_path):
felipec commented 11 years ago

Yeap. This is fixed.