[Bf-committers] Request for a branch of the 2.5 branch

joe joeedh at gmail.com
Thu Sep 10 02:56:46 CEST 2009


This doesn't work.  I've attached the py script I use to detect
inconsistent newlines.  Just run it from the root blender dir.  It
requires py 2.x.

Joe

On Wed, Sep 9, 2009 at 5:36 AM, Nathan Letwory <jesterking at letwory.net> wrote:
> 2009/9/9 Maxime Curioni <maxime.curioni at gmail.com>:
>> We are facing weird issues with line endings, with the following error;
>>
>> svn: File 'release/scripts/
>> scripttemplate_metaball_create.py' has inconsistent newlines
>> ...
>>
>
> I think you should be able to use  --ignore-eol-style on the
> command-line for this. (And in TortoiseSVN there is an option to
> ignore whitespace changes).
>
> /Nathan
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
-------------- next part --------------
import os, sys

def stat_newlines(buf):
	lasts = 0
	
	totCR = 0
	totLF = 0
	totCRLF = 0
	
	for s in buf:
		if s == "\n" and lasts == "\r":
			totCRLF += 1
		elif s != "\n" and lasts == "\r":
			totCR += 1
		elif s == "\n":
			totLF += 1
			
		lasts = s
		
	if lasts == "\r": totCR += 1

	return [totCR, totLF, totCRLF]

#print stat_newlines("\n\n\r\n\r")

def e(st, st2):
	return st.endswith(st2)

for a in os.walk("."):
	dirs = a[1]
	files = a[2]
	
	for f in files:
		if e(f, ".c") or e(f, ".h") or e(f, ".py") or e(f, ".txt") or e(f, ".cpp") \
		  or e(f, ".hpp") or e(f, ".cxx") or e(f, ".hxx") \
		  or e in ["Sconstruct", "SConscript", "Makefile"]:
			path = a[0] + "\\" + f
			
			file = open(path, "rb")
			res = stat_newlines(file.read())
			file.close()
			sys.stdout.flush()
			
			err = 0
			if res[0] != 0 and res[1] != 0: err = 1
			if res[0] != 0 and res[2] != 0: err = 1
			if res[1] != 0 and res[2] != 0: err = 1
			
			if err:
				print "File", path, "has inconsistent newlines"


More information about the Bf-committers mailing list