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

'module' object has no attribute 'bookmark' #178

Closed lebedov closed 10 years ago

lebedov commented 13 years ago

Using mercurial 1.8.1, git 1.7.3.4, hg-git 0.2.6, dulwich 0.7.0, and python 2.6.5, I came across the following way to cause mercurial to throw an AttributeError:

  1. Initialize a new mercurial repository in the directory ~/test-hg:
    mkdir test-hg
    hg init test-hg
    
  2. Initialize a new bare git repository in the directory ~/test-git.
    mkdir test-git
    git init --bare test-git
    
  3. Commit some files to the mercurial repository.
    cd test-hg
    (create some files)
    hg add *
    hg ci
    
  4. Attempt to push the contents of the mercurial repository to the git repository.
    hg push ../test-git
    
  5. The following exception occurs:
    pushing to ../test-git
    importing Hg objects into Git
    creating and sending data
    *\* unknown exception encountered, please report by visiting
    *\*  http://mercurial.selenic.com/wiki/BugTracker
    *\* Python 2.6.5 (r265:79063, Oct 29 2010, 14:48:18) [GCC 4.4.3]
    *\* Mercurial Distributed SCM (version 1.8.1)
    *\* Extensions loaded: hggit, purge, fetch, hgk
    Traceback (most recent call last):
    File "/usr/bin/hg", line 38, in 
     mercurial.dispatch.run()
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 16, in run
     sys.exit(dispatch(sys.argv[1:]))
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 36, in dispatch
     return _runcatch(u, args)
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 58, in _runcatch
     return _dispatch(ui, args)
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 601, in _dispatch
     cmdpats, cmdoptions)
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 406, in runcommand
     ret = _runcommand(ui, options, cmd, d)
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 655, in _runcommand
     return checkargs()
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 609, in checkargs
     return cmdfunc()
    File "/usr/lib64/python2.6/site-packages/mercurial/dispatch.py", line 598, in 
     d = lambda: util.checksignature(func)(ui, _args, *_cmdoptions)
    File "/usr/lib64/python2.6/site-packages/mercurial/util.py", line 433, in check
     return func(_args, *_kwargs)
    File "/usr/lib64/python2.6/site-packages/mercurial/commands.py", line 3019, in push
     newbranch=opts.get('new_branch'))
    File "/usr/lib/python2.6/site-packages/hggit/hgrepo.py", line 22, in push
     git.push(remote.path, revs, force)
    File "/usr/lib/python2.6/site-packages/hggit/git_handler.py", line 152, in push
     changed_refs = self.upload_pack(remote, revs, force)
    File "/usr/lib/python2.6/site-packages/hggit/git_handler.py", line 554, in upload_pack
     changed_refs = client.send_pack(path, changed, genpack)
    File "/usr/lib64/python2.6/site-packages/dulwich/client.py", line 153, in send_pack
     new_refs = determine_wants(old_refs)
    File "/usr/lib/python2.6/site-packages/hggit/git_handler.py", line 549, in changed
     return self.get_changed_refs(refs, to_push, force)
    File "/usr/lib/python2.6/site-packages/hggit/git_handler.py", line 567, in get_changed_refs
     bookmarks.bookmark(self.ui, self.repo, 'master', tip, force=True)
    AttributeError: 'module' object has no attribute 'bookmark'
    fatal: The remote end hung up unexpectedly
    
nightkr commented 13 years ago

It is caused by the move of the hgext.bookmarks extension to Mercurial core. In the move they removed bookmarks.bookmark. While hg-git is aware of the move and uses mercurial.bookmarks if possible, it is not aware of that bookmarks.bookmark got removed and still tries to use it.

develop7 commented 13 years ago

@dontcare4free, I've just pushed commits to github successfully after running hg bookmark master on tip. My suggestion is to automatically add missing (but required) bookmarks like master before pushing it to git. @schacon and/or @durin42, what do you think?

tinjaw commented 13 years ago

Is there a workaround to allow clones? I want to check out some code from github and I get the error. I do not need to commit anything to this repo.

schlamar commented 12 years ago

The workaround is to run hg bookmark master like pointed out above...

tinjaw commented 12 years ago

ms4spy,

I'm not sure I understand.

"I've just pushed commits to github successfully after running hg bookmark master on tip."

I am NOT pushing or committing. I want to pull from an opensource project that is not mine. How do I bookmark master when I can't even clone it?

develop7 commented 12 years ago

@tinjaw, that was me who ran into same issue but other way. Commenting before reading whole issue description was bad idea.

tinjaw commented 12 years ago

"Commenting before reading whole issue description was bad idea." << I do not understand.

schlamar commented 12 years ago

Yours is another issue, not related to this one, please file a new one...