felipec / git-remote-hg

Transparent bidirectional bridge between Git and Mercurial for Git
GNU General Public License v2.0
369 stars 87 forks source link

TypeError: int() argument must be a string or a number, not 'changectx' #72

Closed eigengrau closed 5 years ago

eigengrau commented 6 years ago

With git-remote-hg (HEAD) and mercurial 4.6, git fetch yields:

  File "/usr/bin/git-remote-hg", line 1359, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-hg", line 1343, in main
    do_import(parser)
  File "/usr/bin/git-remote-hg", line 742, in do_import
    export_branch(repo, branch)
  File "/usr/bin/git-remote-hg", line 634, in export_branch
    export_ref(repo, branch, 'branches', head)
  File "/usr/bin/git-remote-hg", line 502, in export_ref
    revs = gitrange(repo, tip, head)
  File "/usr/bin/git-remote-hg", line 469, in gitrange
    pending = set([int(b)])
TypeError: int() argument must be a string or a number, not 'changectx'

I haven’t dug deeper, but I suspect mercurial is now encapsulating revisions in changectx objects, where it passed hashes before.

In my case, it looks like unwrapping the a, b arguments to gitrange resolves this.

def gitrange(repo, a, b):
   a = a.rev()
   b = b.rev()
   …

I’d open a PR, but I suspect you’ll want to guard this for backwards compatibility somehow.

matthewfl commented 6 years ago

I just tested this and it works as a fix for me.

I just added:

if hasattr(a, 'rev'):
    a = a.rev()
    b = b.rev()

To the getrange function to check if there is a rev attribute/function that it can call. I am not 100% sure what was getting passed before or if that is sufficient to guard calling the rev method.

dliessi commented 6 years ago

This solves the problem also for me. I would check the presence of rev in both a and b.

karianna commented 6 years ago

@matthewfl patch worked for me also

hasufell commented 6 years ago

Still doesn't work for me:

$ 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

Even tried forks of this repo, all are broken.

mnauw commented 6 years ago

These issues are due to changes in recent Mercurial's internal API. They have also been reported as issues in this fork and are already fixed there (along with many other ones), see also generally #69.

devinrhode2 commented 6 years ago

fork worked for me @mnauw, thank you guys very much!!!!

felipec commented 5 years ago
def gitrange(repo, a, b):
   a = a.rev()
   b = b.rev()
   …

This is the correct fix: 00e95fd8df745db297eab035b31af8a518627bb1.

Should be fixed in v0.4.

felipec commented 5 years ago

Still doesn't work for me:

Even tried forks of this repo, all are broken.

Your's a separate issue fixed in c95fba3c184128599f73c45ca6a3c32e0bd7f87e.

Both of those issues should work in v0.4.