Search code examples
mercurialpycharm

PyCharm or Mercurial error: Number of lines annotated by Mercurial is not equal to number of lines in the file


When I click on Annotate, I often get this message in PyCharm 2018.2.5 (running on Ubuntu 18.04):

Number of lines annotated by Mercurial is not equal to number of lines in the file. Check file econding and line separators

It looks like a Mercurial error, but in command line, the following command on the same file is succesful:

# hg annotate -ud <file>

Line enconding is LF, File encoding is UTF-8

EDIT

Mercurial version:

# hg --version
Mercurial Distributed SCM (version 4.5.3)

The file I'm try to annotate is in a subrepository, and checking the logs I discovered PyCharm is trying to annotate using the father's repo. If I execute the command in father's directory, I get an empty result. So the error is misleading, and apparently I don't know how to set up PyCharm in this case.

Is there a way to fix this?


Solution

  • I got it. I think it makes sense answering my own question.

    The structure of my project is the following:

    • Project root (no VCS)
      • RepoDir (hg repository)
        • SubRepoDir (hg subrepository)

    In this configuration something confuses PyCharm, and subrepositories at third level won't be recognized.

    The following works pretty well:

    • RepoDir as Project root (hg repository)
      • SubRepoDir (hg subrepository)

    If other directories are needed, one can add them as content root.