Issue #2407 resolved

Application crash when repository's file contains \\\

nicola_molinazzi
created an issue

One file contains the following code:

DEFINES += VERSION=\\\"$$VERSION\\\"

DEFINES += VERSION_DATE=\\\"$$VERSION_DATE\\\"

the \\\ makes tortoiseHg crash when i try to commit the project.

TortoiseHr version 2.7

Comments (15)

  1. André Sintzoff
    • edited description

    Edited description to display the 3 backslashes.

    Which OS are you using?

    I'm not able to reproduce your issue on Windows XP 32-bit and on Mac OS X 10.6

  2. nicola_molinazzi reporter

    Hi, I have Windows XP 32 bit SP3, running on a virtual machine.

    the problem occurred when i added the \\ to the .pro file and then try to commit the version: I opened the workbench and it got stuck after i selected the working directory to commit the version. It was like, It could not visualize the difference in the file and the progress bar in bottom left of the windows didn't move and beside it there was written something like "updating file status". At this point the windows stops responding and I had to kill the process by task manager.

    I did different tests to understand what it was, finally i understood that the problem was in the \. It's not a problem in the repository because i tried in others projects and i have the same problem. The only solution I found was to delete the \.

    I've talked to a colleague of mine and he also experienced the same problem.

    From the following link u can download a repository where i have the problem i have just described: first commit file without \\, working directory with file containing \. I can not commit this version because it get stuck before.

    https://dl.dropbox.com/u/27539469/HgProblem.rar

    Sorry if i hasn't been enough clear in my previous explanation. Thanks for your help!

  3. Yuya Nishihara

    You've hit the bug of Pygments. Pygments' PrologLexer seems to have infinite (or quite heavy) regexp pattern.

    Our code uses guess_lexer_for_filename(), which tries all possible lexers. Probably we should use lightweight get_lexer_for_filename() instead.

    # not well tested
    diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
    --- a/tortoisehg/hgqt/commit.py
    +++ b/tortoisehg/hgqt/commit.py
    @@ -506,12 +506,12 @@ class CommitWidget(QWidget, qtlib.TaskWi
             tokens.add(wfile)
             tokens.add(os.path.basename(wfile))
             try:
    -            from pygments.lexers import guess_lexer_for_filename
    +            from pygments.lexers import get_lexer_for_filename
                 from pygments.token import Token
                 from pygments.util import ClassNotFound
                 try:
                     contents = unicode(contents)
    -                lexer = guess_lexer_for_filename(wfile, contents)
    +                lexer = get_lexer_for_filename(wfile, contents)
                     for tokentype, value in lexer.get_tokens(contents):
                         if tokentype in Token.Name and len(value) > 4:
                             tokens.add(value)
    
  4. Yuya Nishihara

    Our code uses guess_lexer_for_filename(), which tries all possible lexers. Probably we should use lightweight get_lexer_for_filename() instead.

    Oops, it isn't true. There isn't so much difference between these functions.

  5. André Sintzoff

    Unfortunately the bug is not yet fixed. As Yuya said, get_lexer_for_filename() has the same behaviour as guess_lexer_for_filename().

    BTW, yesterday I didn't reproduce the issue because I didn't the ".pro" extension file...

  6. Log in to comment