/r in diff files

165 views
Skip to first unread message

Jean-Noel Meneghetti

unread,
May 9, 2012, 11:22:42 AM5/9/12
to revie...@googlegroups.com
Hi,

Python version: 2.5
RBtools version: 0.4.1
reviewboard version: 1.6.6

I have the following error when I upload a diff file generated by reviewboard:

The patch to '//mypath/Annotations.xml' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.fe-Ge_' for debugging purposes. `patch` returned: patching file /tmp/reviewboard.fe-Ge_/tmpAKbuGL Hunk #1 FAILED at 55. 1 out of 1 hunk FAILED -- saving rejects to file /tmp/reviewboard.fe-Ge_/tmpAKbuGL-new.rej missing header for unified diff at line 29 of patch can't find file to patch at input line 29 Perhaps you should have used the -p or --strip option? The text leading up to this was: -------------------------- | </Table> | | <Table TableName="JobModifiedEntity"> | |- <Bidirectional UpQuery="WHERE 1=0" DownQuery="WHERE 1=1" /> | |+ <Bidirectional UpQuery='WHERE ReplicationState == "Satellite"' DownQuery='WHERE ReplicationState != "Satellite"' /> | | </Table> | | <Table TableName="ActivatedKeyGroupPermission"> | | <Down /> | -------------------------- File to patch: Skip this patch? [y] Skipping patch. patch: **** malformed patch at line 36:

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/views.py", line 151, in view_diff
    interdiffset, highlighting, True)
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/diffutils.py", line 1072, in get_diff_files
    large_data=True)
  File "/usr/lib/python2.5/site-packages/Djblets-0.6.16-py2.5.egg/djblets/util/misc.py", line 157, in cache_memoize
    data = lookup_callable()
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/diffutils.py", line 1071, in <lambda>
    enable_syntax_highlighting)),
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/diffutils.py", line 553, in get_chunks
    new = get_patched_file(old, filediff)
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/diffutils.py", line 375, in get_patched_file
    return patch(filediff.diff, buffer, filediff.dest_file)
  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.6.6-py2.5.egg/reviewboard/diffviewer/diffutils.py", line 243, in patch
    (filename, tempdir, patch_output))
Exception: The patch to '//mypath/Annotations.xml' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.fe-Ge_' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.fe-Ge_/tmpAKbuGL
Hunk #1 FAILED at 55.
1 out of 1 hunk FAILED -- saving rejects to file /tmp/reviewboard.fe-Ge_/tmpAKbuGL-new.rej
missing header for unified diff at line 29 of patch
can't find file to patch at input line 29
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
| </Table>
|
| <Table TableName="JobModifiedEntity">
|
|-  <Bidirectional UpQuery="WHERE 1=0" DownQuery="WHERE 1=1" />
|
|+  <Bidirectional UpQuery='WHERE ReplicationState == "Satellite"' DownQuery='WHERE ReplicationState != "Satellite"' />
|
| </Table>
|
| <Table TableName="ActivatedKeyGroupPermission">
|
|   <Down />
|
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
patch: **** malformed patch at line 36: 




the diff files contains /r/r/n at the end of every lines.

however, if I remove the /r manually, the diff files are processed correctly.

I joined a working and a not working file example.
Is there anything I can do against such issue?

Best regards,
Jean-Noël

notworking.diff
working.diff

Christian Hammond

unread,
May 13, 2012, 6:34:16 PM5/13/12
to revie...@googlegroups.com
Hi,

Newline normalization is very hard to get right at the best of times, and impossible at other times. When there's something like \r\n\n, it shows that there's a problem on the client side. Generally, it's due to your editor not handling it right, or your source control tools attempting its own normalization, which is conflicting with things. Sometimes it's that people on different platforms checked files with mixed line endings into the repository and no normalization ever took place.

Basically, we can't solve this for you. You'll need to figure out why it looks that way on your end and take care of it in the repository.

Wish I had a better answer for you.

Christian

--
Christian Hammond - chi...@chipx86.com
Review Board - http://www.reviewboard.org
VMware, Inc. - http://www.vmware.com




--
Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to reviewboard...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en

Jean-Noel Meneghetti

unread,
May 14, 2012, 6:35:23 AM5/14/12
to revie...@googlegroups.com

Hi Christian,

Many thanks for your answer. The diff file were generated by codereview, so I expected it to be compatible with reviewboard. I will ask my colleagues to check what end of line character they are using.

Best regards,
Jean-Noël

Deepanshu Arora

unread,
Apr 9, 2019, 12:00:44 PM4/9/19
to Review Board Community
Hi Christian,

Is this still an issue in RB v3.0.8? Just to clarify, I am facing an issue where reviewboard does not show \r in diff? Is that known behvaiour?

Thanks,
Deepanshu

Christian Hammond

unread,
Apr 10, 2019, 12:49:42 AM4/10/19
to revie...@googlegroups.com
Hi,

Sorry, I'm not sure which issue you're referring to. Can you go into more details on this?

Christian

--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

Deepanshu Arora

unread,
Apr 11, 2019, 10:56:25 AM4/11/19
to revie...@googlegroups.com

Hi Christian,

Review board is treating these two lines as same (present in different files) and shows there is no difference between them.

File 1 -> String name;
File 2 -> String name;\r

Is this behavior expected?

Thanks,
Deepanshu


You received this message because you are subscribed to a topic in the Google Groups "Review Board Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/BUwooo5dy4g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.

Christian Hammond

unread,
Apr 29, 2019, 4:52:54 PM4/29/19
to revie...@googlegroups.com
Hi Deepanshu,

Yes, it's expected. We don't do byte-for-byte diffing. We normalize all newlines. This is a very important step, because diffs are never guaranteed to use the same type of newline as the version in the repository. This is because a repository may keep one version of a file (often normalized itself, just like we're doing) and present a different version to clients based on their OS or settings.

Worse, if editing files on one system (say, Linux) that are checked out on another (Windows) via a network share or some other mechanism, diffs can end up with very confused line endings. We see this with Perforce a lot, where files (or at least parts of files) use \r\r\n for newlines, due to confusion between the editor and Perforce itself.

Is there a particular case that's biting you here? Are you just interested in whether there's a change in the presence of a trailing newline in the file?

Christian
Reply all
Reply to author
Forward
0 new messages