diff without removing empty lines

Post Reply
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

diff without removing empty lines

Post by Josef Templ »

I noticed that the diffs available in our redmine mirror remove empty lines.
This makes the diffs hard to read because it is not visible where one
procedure ends and where the next starts. It is only one big list of text lines
and you have to scan through it in order to find the boundaries.

I assume that this behavior comes from odcread, the tool behind the diffs.
If this is the case, my proposal would be to modify odcread such that it does not remove empty lines,
which would actually simplify it.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: diff without removing empty lines

Post by Ivan Denisov »

No, this is done by my python post-processing script, so I can easily modify this. This will work for all new diffs, old are stored in cache already. Should I reset the cache?
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: diff without removing empty lines

Post by Ivan Denisov »

Now the script is:

Code: Select all

#!/usr/bin/python
import os, sys
oneline = False
try:
        p = os.popen("/usr/bin/odcread " + sys.argv[1] + " 2>&1", "r")
        while 1:
                line = p.readline()
                if not line: break
                newline = line.replace("\t", "  ")
                if newline != "\n" and newline != "":
                        print newline,
                        oneline = True
        p.close()
except IndexError:
        print "Error: no file passed to converter. Please report event to server admin"

if not oneline:
        print "empty result of odc-to-ascii conversion"
I am also replacing tabs because they take very mush space in the text (8 spaces). Should we keep this?
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: diff without removing empty lines

Post by Josef Templ »

Ivan Denisov wrote:No, this is done by my python post-processing script, so I can easily modify this. This will work for all new diffs, old are stored in cache already. Should I reset the cache?
thanks and yes, please reset the cache.

In addition, why is there any cache at all?
Standard diff tools generate the diffs on-the-fly.
Isn't this fast enough?

Can the cache be disabled?
If yes, I would try to disable it and see if generating a diff is still fast enough.

Replacing TAB by 2 spaces is OK.

- Josef
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: diff without removing empty lines

Post by Ivan Denisov »

It is not very fast. If it is few files, it can work without caching, but for big changes like initial commit it takes long time and much RAM to make the diff. This is the default behaviour of Redmine, so do not want to change it. I am resetting cache by removing the repository and making the new one in the project settings.

I made changes in script. Now you can see, that there are empty lines:
http://redmine.blackboxframework.org/pr ... eeab10a439

Code: Select all

#!/usr/bin/python
import os, sys
oneline = False
try:
        p = os.popen("/usr/bin/odcread " + sys.argv[1] + " 2>&1", "r")
        while 1:
                line = p.readline()
                if not line: break
                print line.replace("\t", "  "),
                oneline = True
        p.close()
except IndexError:
        print "Error: no file passed to converter. Please report event to server admin"

if not oneline:
        print "empty result of odc-to-ascii conversion"
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: diff without removing empty lines

Post by Josef Templ »

thanks, Ivan.
The redmine diffs look much better now.

As long as there is enough disc space the cache is of course not an issue.
If it is a problem, we can go without a cache. The initial import is
an exceptional operation and tzhe diff to the empty repository is of no big value.
Normal diffs cover one or very few files only.

- Josef
Post Reply