dusty-phillips / gitifyhg

Tools for using git as a client to mercurial repositories
GNU General Public License v3.0
62 stars 17 forks source link

Convert paths to str before passing it to hg.py #3

Closed hongrich closed 11 years ago

hongrich commented 11 years ago

Various mercurial functions expects either a repository object or url and it checks by doing if isinstance(source, str): (e.g. http://selenic.com/hg/file/2c1276825e93/mercurial/hg.py#l267)

Caller is apparently expected to convert unicode arguments to str before calling mercurial functions. http://bz.selenic.com/show_bug.cgi?id=1413

I encountered this problem when cloning a local mercurial repository.

dusty-phillips commented 11 years ago

Can you provide a mercurial repository that causes this error?

What version of Mercurial do you have installed?

hongrich commented 11 years ago

I have hg 2.4.2 on mountain lion. I can reproduce this with an empty new repository as well.

% mkdir empty-hg
% cd empty-hg 
% hg init
% cd ..
% git clone gitifyhg::empty-hg empty-git
Cloning into 'empty-git'...
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-gitifyhg", line 8, in <module>
    load_entry_point('gitifyhg==0.6.1', 'console_scripts', 'git-remote-gitifyhg')()
  File "/Library/Python/2.7/site-packages/gitifyhg.py", line 659, in main
    HGRemote(*sys.argv[1:3]).process()
  File "/Library/Python/2.7/site-packages/gitifyhg.py", line 236, in __init__
    self.build_repo(url, alias)
  File "/Library/Python/2.7/site-packages/gitifyhg.py", line 247, in build_repo
    local_path, update=False, pull=True)
  File "/Library/Python/2.7/site-packages/mercurial/hg.py", line 269, in clone
    srcpeer = source.peer() # in case we were called with a localrepo
AttributeError: 'path' object has no attribute 'peer'
dusty-phillips commented 11 years ago

I am able to reproduce this by using the master branch of path.py (from jaraco's version: https://github.com/jaraco/path.py), but it works if I use path.py 2.4.1. I'll try to fix it against master later; I have to catch a flight now.

hongrich commented 11 years ago

Weird, I have path.py 2.4.1 installed as well. Thanks for looking into this.

dusty-phillips commented 11 years ago

I've realized that this error extends to unicode paths in general, so I'm making a bunch of fixes to encode stuff to utf-8 before sending it to Mercurial. I think that should fix your issue as a side effect!

dusty-phillips commented 11 years ago

I've released gitifyhg 0.6.2 which is supposed to have much better handling of unicode paths. Can you tell me if you are still experiencing this issue?

hongrich commented 11 years ago

Works now. Thanks!