Copyright check

A simple script to check whether the year in Copyright header is updated:

hg st -q -n | xargs grep Copyright | grep -v 2014

Nothing fancy! Just to save it.

It would be awesome if such a script updated the year automatically.

Advanced “status” options

Two weeks ago I showed how to filter output of hg status with awk. That simple awk script removes unknown (untracked) files from output and also removes the file status: you get a simple list of modified/added files.

Actually, you can do this without using awk because Mercurial has advanced options for status command:

hg status --quiet --no-status

Or with short aliases:

hg st -q -n

The result is the same: you get the plain list of modified files, and files which are not under source control are ignored.

Print modified/added files

When working with source control systems, sometimes you need to get a list of modified/added files ignoring generated files which are not under source control. You can use this simple awk script:

awk '{ if ($1 != "?") print $2; }'

With Mercurial, the full command looks this way:

hg status | awk '{ if ($1 != "?") print $2; }'

Replace hg with svn if you use Subversion.

Of course, you can redirect the output of the commands to a file.