Project

General

Profile

Actions

Defect #18754

open

empty svn logentry crashes revision batch reading

Added by Michał Król almost 10 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
SCM
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

If svn xml log contains logentry without data the revision reading is interruped and no error message is written to redmine logs.

Revisions are read from xml returned from command:

svn log --xml ...

Example:

<?xml version="1.0" encoding="UTF-8"?>
<log>
<logentry
   revision="2178">
<author>mkrol</author>
<date>2015-01-02T06:24:51.507749Z</date>
<msg>test commit</msg>
</logentry>
<logentry
   revision="2177">
</logentry>
...

logentry for revision 2177 is empty - there is no author, msg and date tags.
But the code assumes that revision, date and msg exist in logentry.
This is the code from lib/redmine/scm/adapters/subversion_adapter.rb, lines 175-196:

            begin
              doc = parse_xml(output)
              each_xml_element(doc['log'], 'logentry') do |logentry|

               (...)

                revisions << Revision.new({:identifier => logentry['revision'],
                              :author => (logentry['author'] ? logentry['author']['__content__'] : ""),
                              :time => Time.parse(logentry['date']['__content__'].to_s).localtime,
                              :message => logentry['msg']['__content__'],
                              :paths => paths
                            })
              end
            rescue
            end

If <msg> does not exist the logentry['msg'] returns nil. The call logentry['msg']['__content__'] becomes nil['__content__'] and exception is thrown (then it is ignored and it is ignored outside loop...).

The existing of logentry['author'] is checked before reading logentry['author']['__content__']. It should be done before reading date and msg also. For example:

                revisions << Revision.new({:identifier => logentry['revision'],
                              :author => (logentry['author'] ? logentry['author']['__content__'] : ""),
                              :time => (logentry['date'] ? Time.parse(logentry['date']['__content__'].to_s).localtime : nil),
                              :message => (logentry['msg'] ? logentry['msg']['__content__'] : ""),
                              :paths => paths
                            })

Why there are empty revisions in svn log? This is when revision has only files which are not visible for user performing svn log command. Propably it's a rare case.


Files

subversion_adapter.rb.patch (2.54 KB) subversion_adapter.rb.patch Stephan Wiehr, 2018-01-03 12:09

Related issues

Related to Redmine - Defect #3663: Problem with subversion logentry without date nor author.Needs feedback2009-07-24

Actions
Related to Redmine - Patch #7086: Few fixes for subversionNew2010-12-09

Actions
Actions

Also available in: Atom PDF