Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

#4027 closed defect (fixed)

Error showing patch file - "no newline at end of file" sign accepted

Reported by: jl <linne@…> Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: general Version: 0.10
Severity: minor Keywords: mimeview
Cc: Branch:
Release Notes:
API 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)

patch_end_of_line.patch (860 bytes ) - added by jl 13 years ago.
This patch file could not be shown!

Download all attachments as: .zip

Change History (3)

by jl , 13 years ago

Attachment: patch_end_of_line.patch added

This patch file could not be shown!

comment:1 by Christian Boos, 13 years ago

Keywords: mimeview added
Owner: changed from Jonas Borgström to Christian Boos

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 Christian Boos, 13 years ago

Milestone: 0.10.10.11
Priority: highnormal
Resolution: fixed
Severity: normalminor
Status: newclosed

Fixed in r4067.

As the fix is not easy to backport to 0.10.1 and the defect is minor, I've changed the milestone.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.