Opened 19 years ago
Closed 19 years ago
#4027 closed defect (fixed)
Error showing patch file - "no newline at end of file" sign accepted
| Reported by: | Owned by: | Christian Boos | |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.11 | 
| Component: | general | Version: | 0.10 | 
| Severity: | minor | Keywords: | mimeview | 
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
When attaching a patch-file with an incomplete line sign the trac system hangs.
The following error is found in the log:
2006-10-25 10:29:09,480 Trac[__init__] DEBUG: Trying to open attachment at D:\SCM\trac\data\testproject\attachments\ticket\22\Neu%20Textdokument.patch
2006-10-25 10:29:09,480 Trac[__init__] DEBUG: Rendering preview of file Neu Textdokument.patch with mime-type text/x-diff; charset=iso-8859-15
2006-10-25 10:29:09,480 Trac[__init__] DEBUG: Trying to render HTML preview using PatchRenderer
2006-10-25 10:29:09,496 Trac[__init__] WARNING: HTML preview using <trac.mimeview.patch.PatchRenderer object at 0x04EAE3B0> failed (Invalid unified diff content)
Traceback (most recent call last):
  File "D:\PROGRA~1\Python23\Lib\site-packages\trac\mimeview\api.py", line 448, in render
    filename, url)
  File "D:\PROGRA~1\Python23\Lib\site-packages\trac\mimeview\patch.py", line 72, in render
    raise TracError, 'Invalid unified diff content'
TracError: Invalid unified diff content
2006-10-25 10:29:09,496 Trac[__init__] DEBUG: Trying to render HTML preview using EnscriptRenderer
2006-10-25 10:29:09,496 Trac[__init__] DEBUG: Enscript command line: enscript --color -h -q --language=html -p - -Ediffu
It seems that it not understand the diff character '\'
Here is the patch file, that is not shown up:
Index: applications/BestFitDataLog/BestFitDataLog.bpr =================================================================== --- applications/BestFitDataLog/BestFitDataLog.bpr (revision 621) +++ applications/BestFitDataLog/BestFitDataLog.bpr (working copy) @@ -129,4 +129,4 @@ LinkDebugVcl=0 LinkCGLIB=0 </IDEOPTIONS> -</PROJECT> \ No newline at end of file +</PROJECT>
I attached the test file, that is unable to preview.
Also a small patch that solves the problem is here:
Index: patch.py
===================================================================
--- patch.py	(revision 4044)
+++ patch.py	(working copy)
@@ -176,7 +176,8 @@
                         elif command == '-':
                             blocks[-1]['base.lines'].append(line)
                             fromline += 1
-                        else:
+                        # Ignore incomplete line command, other commands exit
+                        elif command != '\\':
                             return None
                 line = lines.next()
         except StopIteration:
      Attachments (1)
Change History (3)
by , 19 years ago
| Attachment: | patch_end_of_line.patch added | 
|---|
comment:1 by , 19 years ago
| Keywords: | mimeview added | 
|---|---|
| Owner: | changed from to | 
Thanks for the report, but I'll fix it differently, as I think it's better to explicitely show what happens. In particular, I want to make it clear which file has a missing end-of-line (the base or the target for the diff?).
e.g.
$ diff -u nonewline newline --- nonewline 2006-10-27 08:36:48.453125000 +0200 +++ newline 2006-10-27 08:36:57.187500000 +0200 @@ -1 +1 @@ -ONELINE \ No newline at end of file +ONELINE cboos@cblaptop:/C/TEMP $ diff -u newline nonewline --- newline 2006-10-27 08:36:57.187500000 +0200 +++ nonewline 2006-10-27 08:36:48.453125000 +0200 @@ -1 +1 @@ -ONELINE +ONELINE \ No newline at end of file
comment:2 by , 19 years ago
| Milestone: | 0.10.1 → 0.11 | 
|---|---|
| Priority: | high → normal | 
| Resolution: | → fixed | 
| Severity: | normal → minor | 
| Status: | new → closed | 



  
This patch file could not be shown!