Edgewall Software

Ticket #4027 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: jl <linne@…> Owned by: cboos
Priority: normal Milestone: 0.11
Component: general Version: 0.10
Severity: minor Keywords: mimeview
Cc:

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

patch_end_of_line.patch (0.8 KB) - added by jl 2 years ago.
This patch file could not be shown!

Change History

Changed 2 years ago by jl

This patch file could not be shown!

Changed 2 years ago by cboos

  • keywords mimeview added
  • owner changed from jonas to cboos

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

Changed 2 years ago by cboos

  • priority changed from high to normal
  • status changed from new to closed
  • resolution set to fixed
  • severity changed from normal to minor
  • milestone changed from 0.10.1 to 0.11

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.

Add/Change #4027 (Error showing patch file - "no newline at end of file" sign accepted)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.