Issue765

Title uncrustify.py Incompatibility Mercurial 4.3.1
Priority feature Status resolved
Superseder Nosy List florian, jendrik, malte, patfer
Assigned To Keywords
Optional summary

Created on 2018-03-16.10:06:32 by patfer, last changed by jendrik.

Files
File name Uploaded Type Edit Remove
uncrustify.py patfer, 2018-03-16.10:06:32 text/x-python
Messages
msg6980 (view) Author: jendrik Date: 2018-04-03.13:19:49
This has already been merged some weeks ago.
msg6979 (view) Author: jendrik Date: 2018-04-03.13:18:51
Marking as resolved.
msg6900 (view) Author: malte Date: 2018-03-16.15:04:25
Looks good to merge then.
msg6896 (view) Author: jendrik Date: 2018-03-16.14:47:18
The code works for my Mercurial version 3.7.3.
msg6892 (view) Author: malte Date: 2018-03-16.14:32:49
Looks good to me.
msg6890 (view) Author: patfer Date: 2018-03-16.13:17:36
Should work now, I added AI Basel access to the wrong repo.
msg6889 (view) Author: malte Date: 2018-03-16.13:08:35
I get an "Access denied" error.
msg6888 (view) Author: patfer Date: 2018-03-16.12:54:53
Here is a clean solution (tested with my Mercurial version):
https://bitbucket.org/PatFer/downward/pull-requests/2/fix-issue765/diff
msg6879 (view) Author: malte Date: 2018-03-16.10:26:35
Thanks for looking into this! Can you prepare a pull request to make this easier
to review?

Jendrik, can you test if the new uncrustify.py works for you?

You can see the clean way to provide a fallback in the try/except block at the
top of the file. I would try to import the "command" decorator, and if it is not
present, implement a do-nothing decorator with something like:

def command(*args, **kwargs):
    def identity_decorator(f):
        return f
    return identity_decorator

(I can provide more details with a pull request.)

Having said that, we don't necessarily have to bother with supporting Mercurial
1.9 or older. hg uncrustify is only an internal tool, and Mercurial 2.0 was
released in 2011. Our oldest software versions are usually the ones on the
sciCORE grid, and on the new login node the default version of Mercurial is 2.6
(from 2013). On aidev, which needs hg for the build master, we have Mercurial
2.8. Not sure about the build slaves, but if they cause problems, we will find
it out.

If you do want to test an older version, they are available on
https://www.mercurial-scm.org/release/?M=D
msg6878 (view) Author: patfer Date: 2018-03-16.10:06:32
When using REPO/misc/style/uncrustify with mercurial version 4.3.1 I get an
error (see end) about failing to import because of missing attributes and that
we should use @command to register the uncrustify action.

In the attached file I fixed the problem by trying the @command  decorator
(mercurial >= 1.9)  and if failing using the old way.

If my approach would be used, do we have someone with mercurial < 1.9 to check
if the fall back works? And what would be the correct Exception to catch?



*** failed to import extension uncrustify from
/home/ferber/repositories/issue762/misc/style/uncrustify.py: missing attributes:
norepo, optionalrepo, inferrepo
*** (use @command decorator to register 'uncrustify')                           
hg uncrustify: option -X not recognized 
alias 'uncrustify' resolves to unknown command 'uncrustify'
History
Date User Action Args
2018-04-03 13:19:49jendriksetmessages: + msg6980
2018-04-03 13:18:51jendriksetstatus: chatting -> resolved
messages: + msg6979
2018-03-16 15:04:25maltesetmessages: + msg6900
2018-03-16 14:47:18jendriksetmessages: + msg6896
2018-03-16 14:32:49maltesetmessages: + msg6892
2018-03-16 13:17:36patfersetmessages: + msg6890
2018-03-16 13:08:35maltesetmessages: + msg6889
2018-03-16 12:54:53patfersetmessages: + msg6888
2018-03-16 11:06:41floriansetnosy: + florian
2018-03-16 10:26:35maltesetstatus: unread -> chatting
messages: + msg6879
2018-03-16 10:06:32patfercreate