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

'module' object has no attribute 'write' #62

Closed hsharrison closed 5 years ago

hsharrison commented 8 years ago

I don't really know enough to troubleshoot this. I have this repo as a submodule in my personal dotfiles repo. Here's the bug reproduced in a standard clone. All the other hg submodules worked fine.

$ git clone hg::https://bitbucket.org/marmoute/mutable-history
Cloning into 'mutable-history'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 1720 changesets with 3018 changes to 168 files (+2 heads)
adding remote bookmark @
ERROR: 'module' object has no attribute 'write'
mnauw commented 8 years ago

Have you tried this with the latest version, since that one does not reproduce the above error on a casual attempt (might also depend on the Mercurial version > 3.7)? It looks a lot like 822c6e4b03d9e66df8261f323caded716e8d8b8d addresses this.

rightpad commented 8 years ago

My apologies for commenting on an old issue, however I am experiencing the same issue when attempting to clone as well. I'm using the homebrew version on macOS, which I believe points to this repo's HEAD if I'm not mistaken.

...
remote:
requesting all changes
adding changesets
adding manifests
adding file changes
added 39 changesets with 110 changes to 30 files
adding remote bookmark master
adding remote bookmark remote/master
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1343, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1307, in main
    repo = get_repo(url, alias)
  File "/usr/local/bin/git-remote-hg", line 440, in get_repo
    updatebookmarks(repo, peer)
  File "/usr/local/bin/git-remote-hg", line 379, in updatebookmarks
    bookmarks.write(repo)
AttributeError: 'module' object has no attribute 'write'
sooheon commented 8 years ago

I'm getting the same as @peterdimou, with the exact same traceback.

mnauw commented 8 years ago

The traceback shown above refers to bookmarks.write(repo) on line 379. However, git-remote-hg in HEAD (which is 822c6e4 at this time) does not have such on line 379. That line, however, does have exactly that content in HEAD^ (tagged v0.3). So, it looks like homebrew is pointing to that revision, not HEAD, where the HEAD commit is highly likely one that addresses this very issue.

craiga commented 6 years ago

I'm getting the same issue, and can verify that Homebrew is installing version 0.3.

Any chance of getting a new release of this so it can be updated in Homebrew? I don't think it's unreasonable to expect that the following should work:

$ brew install git-remote-hg
$ git clone hg::https://bitbucket.org/morphus_imaia/django-otp
Cloning into 'django-otp'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 100 changesets with 892 changes to 321 files
adding remote bookmark stable/0.1.x
adding remote bookmark stable/0.2.x
adding remote bookmark stable/0.3.x
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1343, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1307, in main
    repo = get_repo(url, alias)
  File "/usr/local/bin/git-remote-hg", line 440, in get_repo
    updatebookmarks(repo, peer)
  File "/usr/local/bin/git-remote-hg", line 379, in updatebookmarks
    bookmarks.write(repo)
AttributeError: 'module' object has no attribute 'write'
mnauw commented 6 years ago

Note that this issue is fixed (as well as other issues with recent Mercurial) in the latest version of this fork, though it is another matter for downstream to pick that up (see also issue #69).

apjanke commented 6 years ago

I'm getting a similar issue with bookmarks even when using the latest version from HEAD instead of v0.3.

$ git clone hg::https://www.octave.org/hg/octave
Cloning into 'octave'...
real URL is https://hg.savannah.gnu.org/hgweb/octave
requesting all changes
adding changesets
adding manifests
adding file changes
added 25590 changesets with 170203 changes to 13870 files (+1 heads)
adding remote bookmark @
new changesets 22412e3a4641:c21edcb90cbf
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1356, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1320, in main
    repo = get_repo(url, alias)
  File "/usr/local/bin/git-remote-hg", line 453, in get_repo
    updatebookmarks(repo, peer)
  File "/usr/local/bin/git-remote-hg", line 374, in updatebookmarks
    localmarks[k] = hgbin(v)
  File "/usr/local/lib/python2.7/site-packages/mercurial/bookmarks.py", line 106, in __setitem__
    raise error.ProgrammingError("use 'bookmarks.applychanges' instead")
mercurial.error.ProgrammingError: use 'bookmarks.applychanges' instead
[~/local/repos]
$ hg --version                                                                                 ✘ 128
Mercurial Distributed SCM (version 4.6.2)

Any chance of getting this fixed, and a new release tagged?

felipec commented 5 years ago

Any chance of getting this fixed, and a new release tagged?

Yes, I finally got around to doing it. This should be fixed in v0.4.

The relevant commit is aaef56a2a3238d45c5556d22a00d9d676d27711a.