Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eigengrau opened this issue May 16, 2018 · 8 comments
Closed
Labels

Comments

@eigengrau
Copy link

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
Copy link

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
Copy link

dliessi commented Jul 8, 2018

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

@karianna
Copy link

@matthewfl patch worked for me also

Creamen added a commit to Creamen/git-remote-hg that referenced this issue Sep 3, 2018
	- As suggested there :
	[Issue felipec#72](felipec#72)
	and I need this script to work, I forked the repo and apply that for me.
@hasufell
Copy link

hasufell commented Sep 16, 2018

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
Copy link
Contributor

mnauw commented Sep 16, 2018

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
Copy link

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

alyssais added a commit to alyssais/nixpkgs that referenced this issue Mar 15, 2019
…b2 -> 1.0.0

The current version no longer works with our packaged Mecurial.[1]

The original repository appears to no longer be maintained, but there is
a maintained fork, which is now used for the Debian package.

[1]: felipec/git-remote-hg#72
@felipec
Copy link
Owner

felipec commented Jun 4, 2019

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

This is the correct fix: 00e95fd.

Should be fixed in v0.4.

@felipec felipec added the bug label Jun 4, 2019
@felipec
Copy link
Owner

felipec commented Jun 4, 2019

Still doesn't work for me:

Even tried forks of this repo, all are broken.

Your's a separate issue fixed in c95fba3.

Both of those issues should work in v0.4.

@felipec felipec closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants