line endings in svn - page 2 - General Discussion and Assistance - CHDK Forum supplierdeeply

line endings in svn

  • 29 Replies
  • 16497 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: line endings in svn
« Reply #10 on: 20 / August / 2008, 07:16:14 »
Advertisements

whim: i dont think that it'll work, besides you would increase build-time significantly, or i just didnt understand you correctly :D
You could also use svn export to extract the distribution media (readme's etc). You can force whichever EOL style you want, and if you use the working copy form, it should be quite quick.


how can you force the EOL style doing export? Havent found it in the svn book. however this would afford changes to the makefile, which i might be able to do.

I would suggest take latest svn export, apply linux linebreak with dos2unix for all files (besides readme.*, keep it readable for regular windows user) and commit changes back. Let's start with trunk, test it and than change braches too.
This will cause some pain, but developer could apply same linebreak to there local syn export to reduce different to there source before  compare or committing...

Also it maybe a good idea to apply tidy to get a clean structur.... This require to custom tidy to our needs...
This may cause additional pain... but some glitches made by tidy are easier to correct than the hole source...

Project leader should make a decision about what linebreak and code layout should be used and than apply these changes to source once.
I think, this is afford would be very usefull. Devs should not wait, otherwise this will get worse as chdk source expands!


Every Windows dev should have a good texteditor like pspad, ultraedit, notepad+ or else installed anyway, so theres no problem using linux linebreak on windows. Don't be lazy ;).

Maybe i'm wrong... just my 2 cent.

i'd start with branches first, because that's what branches are there for - to test things :)
i think i will somehow just force the EOL style in the properties of the svn server, except in the readmes (well, to make things simpler i also could just use unix2dos on the created readme). apply tidy? what do you mean, "svn clean"? What do you think is "untidy" in the current svn? Do you mean organizational stuff or codewise or layout (see bperrybaps message below)?


Its not just the line endings.
Take a look at the tabs/indents. Its all hosed up as well.
Some of the modules are really tough to read.
There are different tab widths, indention widths, and some folks use spaces with no tabs at all.
(I've struggled/fought with this issue on projects many times over the past 20+ years)
I think much of this caused by most people assuming or wanting to force shift/indention widths to be equal to their tab width.
Over the years I see so many people change their tab settings in order to change the look of their indentations.
This is a horrible practice.
The proper way is to set the indention/shift width separately from the tab width.
Decent editors will allow this.
Some folks think that they avoid the problem by not using tabs. But in fact they ruin the formating
as well because they align what they see on the screen to the tabs indention width set up in their editor.
If their tabwidth was set differently from the one assumed by the file, their new text will not line up
with the existing text that used hard tabs.

To me, hard tabs are 8. Period! Indents can be anything you want.
Even though I abhor the practice of changing the tab width to something
other than 8, at a minimum I'd like to see the tab width locked down to 1 value
or at least use the vi modelines to set the tab widths automatically.


Those that checkin files with screwy misaligned indents, should be spanked 3 times with a wet noodle. :haha

Just my 0.02

--- bill

yeah, the indents/tabs suck. i confess that i also messed up a few things (before i checked the option to NOT convert EOL style in documents in Ultraedit). Having a standard would be great! Is there a tool that can automatically set a "clever" structure and set correct tabs without breaking actual code? i'm sure there is such tool.

btw what kind of EOL do the scripts, grids etc need? do they accept both? and the internal text viewer? will check it tonight.

*

Offline reyalp

  • ******
  • 13456
Re: line endings in svn
« Reply #11 on: 20 / August / 2008, 15:36:50 »
Code: [Select]
svn help export
Quote
--native-eol ARG         : use a different EOL marker than the standard
                            system marker for files with the svn:eol-style
                            property set to 'native'.
                            ARG may be one of 'LF', 'CR', 'CRLF'
As far as indendenting/formatting goes, the only thing that really bugs me is when the formatting doesn't reflect the structure of the code (i.e. not indenting for nested blocks, or indenting / unindenting when the scope hasn't changed. There's a fair bit of this the tree, I assume from people just copy/pasting) It would be nice to have consistent formatting and use of tab/space conventions, but it's not a big deal to me. It tends to stir religious passions, but if you can follow whats going on in a given section of code, it's really not that big a deal.

Keep in mind that if one branch gets reformatted and others don't, porting patches between branches will become more painful.

Finally, for things that are used wholesale from other sources (lua for example) it's probably best to keep whatever convention the original code uses, as it will make the important changes more visible and also make it easier to update when the upstream comes out with a new version.
Don't forget what the H stands for.

*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
Re: line endings in svn
« Reply #12 on: 20 / August / 2008, 16:45:08 »
@PhyrePhoX
Sorry, i missed to include what i meant with tidy... dos2unix and Artistic Style will do a pretty good job to bring us one step closer to a nice source. It's not perfectly but as i wrote in my last post, correct some glitches by hand shouldn't be that hard...

i tested astyle a bit on windows, i would prefer something like this:
Code: [Select]
astyle.exe --brackets=attach --convert-tabs --indent=spaces=4 --exclude="readme.txt readme" --recursive
Begin to change a branche makes more sence, your absolutly right... my fault.
« Last Edit: 20 / August / 2008, 16:51:24 by pixeldoc2000 »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: line endings in svn
« Reply #13 on: 21 / August / 2008, 08:59:06 »
i'm testing universalindentgui right now to see which result makes the most sense :)


Re: line endings in svn
« Reply #14 on: 21 / August / 2008, 14:37:38 »
One thing that I think would really help the indention problem is to pick a TAB indention.
Since most folks equate TABs and Indention levels, it is best to deal with the actual
human behavior rather than to try to change it.

I would suggest that we pick either 4 or 8 as a tab stop and highly publish what the selection is
in stickies, and in FAQs.
Also, I think it would be quite helpful to take advantage of the vi modelines feature so that whatever the
tab stop value is, it will automatically get properly set for all the vi users. - which is what I use  :D
It would be 1 simple line added to each file.

--- bill

*

Offline reyalp

  • ******
  • 13456
Re: line endings in svn
« Reply #15 on: 16 / September / 2008, 02:09:19 »
Based on the above comments I have the following ready to commit on the new trunk. Unless there are objections pretty quickly, I'll check it in.

- All normal source files (.c .h .S) and .txt files in the development tree have eol-style native

- Files intended for distribution (.txt files in CHDK, .grd, lng, .bas files) have eol-style CRLF. (the cameras native format is LF, but this is probably more friendly to average users) see below

- makefiles and sh scripts have eol-style LF, since they might otherwise cause problems for people using cygwin in their build environment on windows.

If you try to check in one of the files in a format that doesn't match your platform, svn will automatically do the right thing, so you don't need to remember which files are set to which. However, if you try to check in a file that has svn:eol-style set, and some lines in each format, svn will refuse to check it in.

It also refuses to apply svn:eol-style to a file like this. I have manually fixed up all the files that were checked in this way.

Unfortunately, some of the automatically generated files end up this way when generated on windows. They should probably be tweaked to produce consistent line endings at some point.

Assembla doesn't yet let us use commit hooks on the svn server to enforce particular properties. That means anyone adding files needs to set them manually. You can automate this on your client with Automatic Property Setting. We might also want to look into using TortoiseSVN Project Properties.

Tabs vs spaces, indenting etc. are all a project for a another day.

I've attached the script I used to set the props, in case anyone is interested.
« Last Edit: 16 / September / 2008, 16:44:13 by reyalp »
Don't forget what the H stands for.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: line endings in svn
« Reply #16 on: 16 / September / 2008, 02:46:53 »
Great,i'm all for it.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: line endings in svn
« Reply #17 on: 16 / September / 2008, 13:20:37 »
My 2 cents about CRLF in .bas: We have a scrict 8 kB file size limit for ubasic scripts. Adding CR's wastes precious bytes and shouldn't be done.

I have a real-world example... I haven't actually been using my MDFB script for months... I use a a570is specific MDFB2 script, which currently weighs in 8026 bytes using LF line endings. It has 285 lines, so converting to CR+LF would bring it past 2^13 bytes and the script would mysteriously fail if it was ever committed. An automatic conversion would thus be dangerous to the extreme.


*

Offline reyalp

  • ******
  • 13456
Re: line endings in svn
« Reply #18 on: 16 / September / 2008, 15:48:36 »
Good point about ubasic scripts. In the long term, this limit should probably be lifted, but regardless it's a waste of space. I don't see any reason why the buffer couldn't be malloc'd instead. (There's a downside that this memory is always allocated when you have a script selected, but that's another thing that could be improved)

Also on further reflection the .lng files are not generally read/modified by the end user, so should probably be LF to save a little bit of malloc memory.

Updated policy:
.TXT files destined for the camera will be in CRLF format. All other text files will be in LF format.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: line endings in svn
« Reply #19 on: 16 / September / 2008, 16:00:32 »
Or the CR's could be filtered out while loading script/lng files? SD card space is not an issue after all.

 

Related Topics