Wednesday, November 17, 2010

Bookmark and Share
At my day job we are using the SVN property "svn:keywords" to let SVN replace the string "$Id$" with author name, revision number etc. within each Java source file.

One can add this property automatically when creating new files with the help of SVN's auto props feature. But from time to time someone, e.g. a new developer not knowing about auto props, checks in files without having the "svn:keywords" property set.

So I wondered how to identify such files in the repository. SVN doesn't provide a command answering that question, you only can retrieve all files having a certain property set.

But no problem, some shell magic to the rescue:

1
comm -23 <(sort <(sed 's/\.\///g' <(find . -name "*.java"))) <(sort <(sed 's/ - Id//g' <(svn propget svn:keywords * -R)))

So what's happening here? The basic idea is to list those files with the svn:keywords property set (svn propget) and compare this to a list with all files (find).

The outputs of both commands are brought into the same format using sed, sorted and then passed as parameters to the comm command, which compares two input files to each other. The -23 parameter causes only those lines to be put out which are only contained in file1 but not in file2, which are exactly the names of those files lacking the "svn:keywords" property.

I tested the command successfully on Mac OS X, but I think it should work pretty much the same way on other Unix systems, too.

48 comments:

Anonymous said...

Exactly what I needed. Thanks.

Unknown said...

Great that I could be of help. Thanks for your feedback, Gunnar

Anonymous said...

Nice, exactly what i was looking for.

Since i do not use the Id Tag, I use this more generic variant (.* instead of Id):
comm -23 <(sort <(sed 's/\.\///g' <(find . -name "*.java"))) <(sort <(sed 's/ - .*//g' <(svn propget svn:keywords * -R)))

Anonymous said...

> from time to time someone, e.g. a new developer not knowing about auto props, checks in files without having the "svn:keywords" property set.

Or, you know, an experienced developer who realizes that version control information belongs in the version control system and not in the source code...

Found this blog post helpful while looking for information on how to nuke these useless keywords from my code:

svn propdel svn:keywords . --recursive

Anonymous said...

Thank you for this tip.. Exactly what I needed.

The value of the keywords properties is in the eye of the beholder. It is there for a single reason: it is useful for a large group of users.

Some developers love to type commands to find information that can be just read by looking at the top of the file, and it requires no effort to be updated.

Unknown said...

I run this in a single find. For example, the following finds Java files which do not have svn:eol-style=native:

#!/bin/sh

find . -name "*.java" -print |
(while read javaFile
do
eolStyle=`svn propget svn:eol-style $javaFile`
if [ "$eolStyle" != "native" ]; then
echo $javaFile ":" $eolStyle
fi
done
)

Cara Menyembuhkan otitis Media (Radang Telinga Tengah) Secara Alami said...

Never gonna give up
Cara Menyembuhkan otitis Media (Radang Telinga Tengah) Secara Alami

Obat Herbal Gula Darah Tinggi Terbaik said...

Great article on our site. Keep up the good writing.
Obat Herbal Gula Darah Tinggi Terbaik

Unknown said...

Obat Benjolan Di Bibir Vagina

Cara Mengobati Luka Bakar

bela said...

Obat Menghilangkan flek hitam ekas jerawat
Obat Mengatasi Telat Datang Haid
Obat perut keras dan kembung
Obat Menghilangkan Benjolan Lipoma
Obat prurigo secara alami

bela said...

Obat farry liver
Obat impetigo pada anak
Obat penyakit liver

bela said...

Obat Asam Lambung Naik

bela said...

Obat Gatal di Sekitar Kemaluan

bela said...

http://hargajellygamat.net/cara-mengobati-gatal-di-sekitar-kemaluan-dan-selangkangan/

bela said...

cara mengobati telinga berair

bela said...

Obat Cantegan Bodo Isi

bela said...
This comment has been removed by the author.
bela said...

Obat Cacingan

bela said...

Salep Penghilang Bekas Jerawat,Salep penghilang bekas jerawat

bela said...

salep untuk cacar air

bela said...

salep mata ikan

bela said...

http://www.kebunmanggis.web.id/cara-mengobati-penyakit-kuning/
Cara Mengobati Penyakit Kuning

bela said...

Obat Penghilang Bekas Luka Bakar Obat Penghilang Bekas Luka Bakar

bela said...

Obat penghilang benjolan d pergelangan tangan

bela said...

obat jamur kuku djempol kaki

bela said...

Cara Menghilangkan Jamur di Selangkangan

bela said...

obat telinga berdengung sebelah

bela said...

Cara Menghilangkan Bekas Cacar Air Di Wajah Dengan Cepat

bela said...

Hemangioma Pada Bayi

bela said...

Obat gatal di selangkangan

bela said...

obat untuk menghilangkan bekas luka yang menghitam

bela said...

cara menghilangkan balas bogo

bela said...

cara merawat kuku kaki yang rusak

bela said...

Obat Penurun Kolesterol Dalam 5 Hari

bela said...

Nama Obat Batuk Berdahak

bela said...

Vitamin yang Bagus Untuk Daya Tahan Tubuh

bela said...

cara merawat wajah biar awet muda

bela said...

obat Pembersih Jerawat

bela said...

cara mengobati kutu air di jari tangan

bela said...

Cara Menghilangkan Bekas Luka Knalpot

bela said...

Cara mengoabati alergi kulit bentol

Unknown said...


Manfaat Daun Mengkudu Untuk Melangsingkan Tubuhobat jantung bengkak ace maxs

GG. said...

Your publications are always inspiring.
Brunette ladies

write my paper for me said...

Great and useful article. Creating content regularly is very tough. Thanks you.

how to write a scholarship essay said...

Thank you for this post. This is very interesting information for me.

write paper said...

Thanks for this information, I think it will come in handy in the future.

Field Engineer said...

Very nice blog, Thanks for sharing a great article.
You are providing wonderful information, it is very useful to us.
Keep posting like these informative articles.
Thank you.

From: Field Engineer

For more information about: Cloud Architect

Economics assignment help said...

From creating the most technical and bespoke academic assignments on demand to securing the most excellent academic grades, Great Assignment Helper furnishes the best Economics assignment help to students at the cheapest rates.