883: GitDiffParser parses file additions badly (fix patch enclosed in description)

anfe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
chipx86
chipx86
March 12, 2009
What's the URL of the page containing the problem?

http://localhost:8000/r/11/diff/#index_header

What steps will reproduce the problem?
1. Submit patch with new added files using post-review.py
2. Go to diff page
3. Notice that first two letters of the file name are cut off

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

Expected:

-- quote --
Files Changed:

   1. test.post: 1 change [ new content ]
-- endquote --

Saw:

-- quote --
Files Changed:
   1. st.post: 1 change [ new content ]
-- endquote --

What operating system are you using? What browser?

Ubuntu 8.10
Firefox 3.0.5
Python 2.5.2 on server

Please provide any additional information below.

This patch fixes things:

Index: scmtools/git.py                                                
===================================================================   
--- scmtools/git.py     (revision 1768)                               
+++ scmtools/git.py     (working copy)                                
@@ -105,8 +105,9 @@                                                   
             diffLine = self.lines[i].split()                         
             try:                                                     
                 # Need to remove the "a/" and "b/" prefix
-                file.origFile = diffLine[-2][2:]
-                file.newFile = diffLine[-1][2:]
+                remPrefix = re.compile("^[a|b]/");
+                file.origFile = remPrefix.sub("", diffLine[-2])
+                file.newFile = remPrefix.sub("", diffLine[-1])
             except ValueError:
                 raise DiffParserError(
                     "The diff file is missing revision information",
david
#1 david
Can you post this on http://reviews.review-board.org/ ? Thanks.
  • -Type-Defect
    +Type-Patch
    +Component-SCMTools
#2 anfe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Done: http://reviews.review-board.org/r/745/
chipx86
#3 chipx86
Fixed in r1814.
  • +Fixed
  • +Milestone-Release1.0
  • +chipx86