Chovy’s Blog

Example of How to Ignore Files in Subversion

Wed, July 4, 2007 — Category: Development

Brief example of how to ignore files in subversion. Great for those pesky session, cached files, or logs that are constantly changing and are not necessary to “version”.

Have you ever had those pesky little files constantly telling you they’ve been modified? …you couldn’t care less about “commiting” them into the subversion repository every time, right? — log files, session data, temporary caches are all great examples of things that should probably be ignored and forgotten.

Ignoring locally modified files in subversion is quite easy, once you get the hang of it.

I struggled a bit with the example from the SVN book. Mainly because I was unsure where to actually set my property.

I’m writing an application with Smarty and PHP and have several temporary files created in my development environment and wanted to simply “ignore” them all so they do not keep showing up when I run an “svn status” command…


$ touch ./template_c/foo
$ svn st
?      template_c/foo

Everything under “template_c” should be ignored by subversion, I do not want to version temporary cache files of templates created with new requests.

Here’s the quick and easy way to get it done…


$ cd ~/trunk
$ svn propset svn:ignore '*' ./template_c/

First, I change directory into the trunk (or parent of the directory I want to ignore).

Then I simply set an svn property “svn:ignore”, which takes 2 property arguments: the pattern of the file to ignore, and the directory path to apply it to.

In other words, I am telling svn to set the property “svn:ignore” to ignore all files “*” under the sub-directory “./template_c”.

If I wanted to ignore only smarty template php files, I would’ve used something like:


$ svn propset svn:ignore '*.tpl.php' ./template_c/
#ignores files such as "foo.tpl.php"

However, I still have one last step, as shown by the following “status” command:


$ svn st
 M     .
 M     template_c

…commit the new property for the current directory (this property will apply to all svn users once committed).


$ svn ci -m 'ignore smarty template caches' .

If you want to only apply the change to your local repository, then look into the ‘-F’ option to “svn propset” to specify a local file with a list of file patterns to ignore. This way, developers can add/remove entries from their own local copy if they wish.

One last trick — if I really want to see what is in the ignored directory, I just run the command with the “–no-ignore” option:


$ svn st --no-ignore
I      template_c/foo
  • Post Example of How to Ignore Files in Subversion to del.icio.us
  • Post Example of How to Ignore Files in Subversion to digg
  • Post Example of How to Ignore Files in Subversion to Furl
  • Add Example of How to Ignore Files in Subversion to YahooMyWeb
  • Simpify!
  • Post Example of How to Ignore Files in Subversion to shadows
  • Post Example of How to Ignore Files in Subversion to Spurl
  • Post Example of How to Ignore Files in Subversion to BuddyMarks
  • Submit Example of How to Ignore Files in Subversion to Slashdot

Learn to write “Proper Perl”

Tue, March 13, 2007 — Category: Perl, Open Source, Development

Writing “Proper Perl” can take years to master, and even then you may learn a few more tips…all you have to do is validate against “the critic”…

Perl::Critic is an excellent way to not only validate your Perl source code, but to learn some tips from the Perl monks who have contributed to the Perl::Critic documentation.

I uploaded one of my latest CGI scripts written in Perl to see how good my Perl chops are…turns out I picked up a few tips that I was unsure about in my previous Perl scripts.

A few simple techniques can be used to make your code more standardized in the event that your are not the only person reading it.

The Perl Critic web site has a nice usable web interface for uploading source code and checking its validity — although for obvious reasons if you’re working on enterprise code you should probably download an install the Perl::Critic CPAN module on your own server.

  • Post Learn to write “Proper Perl” to del.icio.us
  • Post Learn to write “Proper Perl” to digg
  • Post Learn to write “Proper Perl” to Furl
  • Add Learn to write “Proper Perl” to YahooMyWeb
  • Simpify!
  • Post Learn to write “Proper Perl” to shadows
  • Post Learn to write “Proper Perl” to Spurl
  • Post Learn to write “Proper Perl” to BuddyMarks
  • Submit Learn to write “Proper Perl” to Slashdot

Replacing a Tag Name in VIM

Thu, March 8, 2007 — Category: Development

A simple explanation of using VIM regex syntax to replace acronym tags with abbr tags…preserving title attribute.

I needed to quickly replace acronym tags with abbr tag names since I read somewhere that acronym might eventually be deprecated because of its confusion and redundancy in meaning — although I fully realize the debate is still in progress.

In VIM (vi text editor for the command-line) you can use regular expressions for searching and replacing.
Although a bit confusing at first I have found that my regex chops have quickly improved simply by learning how to use them efficiently within my favorite editor — VIM.

First, if you’re not already familiar with command-mode in VI, we need to invoke the “substitute” mode (type :he substitute for documentation).

The line below will do a search and replace of ‘foo’ with ‘bar’ on the current line (g = greedy/global):

:s/foo/bar/g

To change the acronym tag to abbr we need to do the following:

:s:acronym:abbr:g

Note: I changed the regex delimiter from forward-slash to colon to avoid escaping forward-slashes used in closing HTML tags.

The above example is not good enough, as there’s no gaurantee we are acting only on the tags themselves.

:s:\(<[/]\=\)acronym\([ >]\=\):\1abbr\2:g

A simple explanation for the arcane syntax is that capturing parenthesis need to be escape in VIM: (…) becomes \(…\), and thus can be refered to in the replacement token by \1, \2, etc.

The \= forces a 0 or 1 match on any character(s) defined within the brackets []’s — in this case, we want to first match an option / forward flash to apply to opening as well as closing tags.

The second set of brackets: [ >] contains a literal space character and a closing carat to signify the end of the opening or closing tag. This will preserve other HTML attributes (ie - “title”) defined on the opening tag.

Finally, after testing it on one line first and seeing positive results, you can apply it to the entire document by invoking the substitution function in VIM with a preceding “%”.

The final regex applied to the entire document becomes:

:%s:\(<[/]\=\)acronym\([ >]\=\):\1abbr\2:g

…more VIM tricks from PixelBeat.

  • Post Replacing a Tag Name in VIM to del.icio.us
  • Post Replacing a Tag Name in VIM to digg
  • Post Replacing a Tag Name in VIM to Furl
  • Add Replacing a Tag Name in VIM to YahooMyWeb
  • Simpify!
  • Post Replacing a Tag Name in VIM to shadows
  • Post Replacing a Tag Name in VIM to Spurl
  • Post Replacing a Tag Name in VIM to BuddyMarks
  • Submit Replacing a Tag Name in VIM to Slashdot
« Previous PageNext Page »
 
Keyword Advertisers:
SEO Directory SEO Links Free Link Directory Shopping Submission Directory Gardening Tips Political Forum Search Engine Optimization Search Engine Marketing Audio Video Directory SEO Forum Web Development Blog Organic SEO Wiki Web Development Consulting

Learn more about purchasing keyword text link ads on this site.