2294: Unable to parse diff revision header when adding cvs diff with new files

tarant******@abv*** (Google Code) (Is this you? Claim this profile.)
Feb. 1, 2014
What version are you running?
1.5.5

What's the URL of the page containing the problem?
New Review Request Page

What steps will reproduce the problem?
1. Generate a diff file using "cvs diff -uN >output.txt" over a code which has new files
2. Try to submit the generated output.txt through the "New Review Request" page
3. The result is "Unable to parse diff revision header '1 Jan 1970 00:00:00 -0000'"

The problem is because the diff file contains the following lines for new file:
"
--- nul:	1 Jan 1970 00:00:00 -0000
+++ MyFolder/MyFile.cs	17 Sep 2011 16:02:38 -0000
"

and

"
 1 Jan 1970 00:00:00 -0000
"

cannot be parsed.

I modified cvs.py to return PRE_CREATION in this scenario when no revision is provided and it works like a charm.

What is the expected output? What do you see instead?

The diff should be successfully uploaded.

What operating system are you using? What browser?
Windows 7 (64 bit), Windows XP (64 bit), Windows Server 2008 R2 (64 bit); 
Browsers: Firefox, Chrome

Please provide any additional information below.
david
#1 david
Can you create a patch and submit it to http://reviews.reviewboard.org/ ?
david
#2 david
  • +Component-DiffParser
#3 tarant******@abv*** (Google Code) (Is this you? Claim this profile.)
Sorry for the late response. Is the issue still valid? I have a lot of urgent work on other stuff but once I am back to my workstation in the office and I have some free time I can submit the fix we used.
chipx86
#4 chipx86
We'd be happy to take any patches that fix this if you have one :)
david
#5 david
Fixed in master (c89f161). Thanks!
  • +Fixed
#6 tarant******@abv*** (Google Code) (Is this you? Claim this profile.)
Because of various changes, I have not used reviewboard for around 2 years. The patch I was using was on one old HDD, from which I got part of the information recently... I see this is fixed now,
but if it happens to be of interest at some pint, I am pasting a couple of notes from one text file describing the patch we have applied at that time:

"
3. Change in cvs.py that fixes a problem with new files:

    rev_re_new = re.compile(r'^.*?\r?$')
    rev_re = re.compile(r'^.*?(\d+(\.\d+)+)\r?$')
    repopath_re = re.compile(r'^(?P<hostname>.*):(?P<port>\d+)?(?P<path>.*)')
    ext_cvsroot_re = re.compile(r':ext:([^@]+@)?(?P<hostname>[^:/]+)')

    def __init__(self, repository):
        SCMTool.__init__(self, repository)

        self.cvsroot, self.repopath = \
            self.build_cvsroot(self.repository.path,
                               self.repository.username,
                               self.repository.password)
        self.client = CVSClient(self.cvsroot, self.repopath)

    def get_file(self, path, revision=HEAD):
        if not path:
            raise FileNotFoundError(path, revision)

        return self.client.cat_file(path, revision)

    def parse_diff_revision(self, file_str, revision_str):
        if revision_str == "PRE-CREATION":
            return file_str, PRE_CREATION

        m = self.rev_re.match(revision_str)
        if not m:
            m2 = self.rev_re_new.match(revision_str)
            if m2:
            	return file_str, PRE_CREATION
            raise SCMError("Unable to parse diff revision header '%s'" %
                           revision_str)
                           
4.In diffutils.py 

line 220:

change:

    p = subprocess.Popen(['patch', '-o', newfile, oldfile],
                         stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)

with

    p = subprocess.Popen(['patch', '-l', '-o', newfile, oldfile],
                         stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)
"