Properly display SVN diffs with changes in $Keyword$ formatting

Review Request #3105 — Created May 11, 2012 and submitted — Latest diff uploaded

stilor
Review Board
reviewboard
We encountered this issue when a developer accidentally committed several files with inappropriate keyword format, namely $Header:$ instead of $Header$. I am not sure how it happened at that time and I cannot reproduce adding such file with a recent Subversion by just adding a file. The same end result can be reproduced, though, using the Subversion's svnmucc utility:

$ cd /tmp
$ svnadmin create foo
$ echo '$Header:$' > file
$ svnmucc put file file:///tmp/foo/file 
r1 committed by aneyman at 2012-05-12T04:22:21.507824Z
$ svnmucc mv file:///tmp/foo/file file:///tmp/foo/badfile propset svn:keywords Header file:///tmp/foo/badfile
r2 committed by aneyman at 2012-05-12T04:22:48.440614Z
$ svn co file:///tmp/foo foo.wc
A    foo.wc/badfile
Checked out revision 2.
$ cd foo.wc/
$ cat badfile 
$Header: file:///tmp/foo/badfile 2 2012-05-12 04:22:48Z aneyman $
$ echo hi >> badfile 
$ svn di badfile 
Index: badfile
===================================================================
--- badfile     (revision 2)
+++ badfile     (working copy)
@@ -1 +1,2 @@
-$Header:$
+$Header$
+hi

As seen above, whenever one of these files is modified, 'svn diff' generates (and then post-review uploads) a diff which contains the following lines:

- ... $Header:$
+ ... $Header$

However, when RB tries to apply this diff, it first contracts the keywords in the file it gets from the repository. Thus, a file with contracted keyword has $Header$ and the patch above fails to apply cleanly.

The solution proposed is to apply the same keyword contraction technique to the patch as it is applied to the sources from the repository. This makes the change in $Header:$ not be displayed, but the rest of the changes are displayed fine. The regexp matching header contraction is modified to account for the $Keyword:$ form (i.e. with no characters following the colon).
./reviewboard/manage.py test
Loading...