Torsten Curdt’s weblog

Unexpand Id keywords

While cleaning up my mails I found this tiny script that Sylvain once posted. I know I will need it if I just delete it so why not blog about it.


# Unexpands all "$Id ....$" keywords from files having a certain prefix (i.e. replaces
# them by $Id$) The good thing with Subversion is that it doesn't consider as being
# modified a file where the keyword has changed

find . \( -name '*.java' -or -name '*.xml' \) -print | while read file
 echo $file
 sed -e 's/\$Id:.*\$/$Id$/' $file > ${file}.rmkw-tmp
 mv ${file}.rmkw-tmp $file

  • Eh, thanks for the publicity you give to this little hack!

    Let me just remind the context that led me to write it: that was for the migration of Cocoon from CVS to Subversion, where we discovered a conservative but annoying behavior: if the value of $Id$ doesn't match Subversion's Id pattern, it doesn't replace it.

    We therefore had to crawl all source files to remove the CVS-generated $Id$...
blog comments powered by Disqus