Search code examples
svnsvn-mergesvn-mergeinfo

svn mergeinfo - E195016: "must be ancestrally related"


Although there are several similar questions here (e.g., SVN - Reintegration Merge error: "must be ancestrally related") and on the Web, I wasn't able to figure out why svn mergeinfo <file> causes an error in all of my SVN repositories. In contrast to all other Q&As that I have found, I am actually able to execute svn merge successfully. For example, undoing a previous commit to a pom.xmlfile:

svn merge -r 17409:17408 pom.xml
--- Reverse-merging r17409 into 'pom.xml':
U    pom.xml
--- Recording mergeinfo for reverse merge of r17409 into 'pom.xml':
U   pom.xml
--- Eliding mergeinfo from 'pom.xml':
U   pom.xml

However, when I execute svn mergeinfo, I get the following error:

svn: E195016: 'https://../trunk/MyProject/pom.xml@50446' must be ancestrally related to
'https://../trunk/MyProject@50446'

In this example, 50446 is the current head revision number and I get that same error for every file I've tried. Only when I execute the mergeinfo command on the top directory itself, it works:

svn mergeinfo .
    youngest common ancestor
    |         last full merge
    |         |        tip of branch
    |         |        |         repository path
    50446              50446   
    |                  |       
  -------| |------------         ../trunk/MyProject
     \                         
      \                        
       --| |------------         ../trunk/MyProject
                       |       
                       50446   

And even stranger, I don't find any mergeinfo properties set. Commands like svn propget svn:mergeinfo --recursive or svn propget svn:mergeinfo --depth=infinity don't output anything and return successfully with status code 0.

Does anyone have an idea how I can fix our files to be "ancestrally related" again to the projects they are located in?


Solution

  • Short answer: svn mergeinfo <file> is wrong.

    From the SVN documentation (svn help mergeinfo):

    "Summarize the history of merging between SOURCE and TARGET."

    "SOURCE and TARGET are the source and target branch URLs, respectively."

    "The default TARGET is the current working directory ('.')."

    So, if your command was something like svn mergeinfo pom.xml, then the error message is as expected, since there's no "ancestrally relation" between that file and it's directory.
    The correct command would be: svn mergeinfo pom.xml pom.xml, that will compare those two files, and probably is what you want.

    When you run svn mergeinfo ., it's the same as running svn mergeinfo . .. So it works and you get the mergeinfo output.

    You could also run svn mergeinfo pom.xml pom.xml@12345, to compare a specific revision.


    You can also get this error when trying to merge things that are not related.
    If you created the directory tree or files manually (I mean: without using the branch feature), then they are not related and you will get this error.

    Please read this question and note that the author created the branch dev manually, breaking SVN.

    The best solution in this case would be to create the branch normally, migrate all files to this branch manually (copy-paste everything) and then merge it back to trunk.