Error 'module' object has no attribute 'mergestate'
Mercurial extension for managing file timestamps.
Brought to you by:
nedmech
Hi,
I'm not sure about the project's activity since it has been moved from Bitbucket to SourceForge.
I will report the following bug anyways:
After upgrading to TortoiseHg/Mercurial 5.5 the following error occurs when I perform a local merge with a branch:
TimestampMod|Post-Merge Hook accessed!
Fehler: Hook post-merge. TimestampMod löste eine Ausnahme aus:
'module' object has no attribute 'mergestate'
(run with --traceback for stack trace)
Best regards,
Michael
Found the reason here:
https://www.mercurial-scm.org/wiki/Release5.5
The mercurial API has changed:
Here is my quick & dirty resolution:
Edit in the import modules section line 54 from
to
But I think this makes the Extension incompatible to the API < v5.5. I'm no python developer. Thus I don't know how to handle this issue gracefully.
Best regards
Michael
Hi Michael,
Thanks for the issue report and for doing some of the research for me! This project is not really active right now since I haven't been updating my Mercurial/TortoiseHg version recently due to my current job being stuck on 5.0.2 for a while now. Python's not my primary language either, but I think I can see how to make a "try...else..." type include for that module. Can you edit your file and test something for me?
Delete line 54 entirely, then insert the following at line 57 (after the closing parenthesis):
That should attempt to import the original library, then fall into the new 5.5 name if it doesn't succeed. It seems to be working fine for my 5.0.2 version.
Hi Nathan,
thank you for your quick reply!
Unfortunately your proposed edit doesn't work, because the module 'mercurial.merge' still exists in API V5.5. Just the class 'mergestate' was extracted to 'mercurial.mergestate'. Therefore the import does always succeed but 'mergestate' may still not be available...
But that's no big problem: Swapping the statements in the try/except branches resolves the issue:
Tested whit TortoiseHg 5.5.1.
Unfortunately, neither of our attempts was fully cross-compatible across the API change. I've ended up importing the class instead of the module to remove the ambigutiy of the import path. Try grabbing the file from the tip of my development branch and see if it works for you in 5.5.
https://sourceforge.net/p/timestampmod/code/ci/development/tree/TimestampMod.py?format=raw
Yes! It's working with TortoiseHg 5.5.1.
Thank you very much!
Excellent! I'll go ahead and merge the fix back into the default branch and tag the release. Thanks for your help testing.
Closing ticket - issue resolved.