I just did an update to my Redmine hours. It hadn’t been done in way too long and thus took me way to long to do it. I needed some way to automatically browse all of the code commits that I have done in a particular time, in all of the different repos that our development is spread across. Turns out that all of the pieces to do this are already in place… one just need to read a few man pages to put them all together.

First of all, let’s find all of my hg repositories:

james@basalt ~ $ find ./ -name .hg
./code/hg/pydap-3.1/.hg
./code/hg/pydap.git/.hg
./code/hg/analytics/.hg
./code/hg/pydap.responses.netcdf/.hg
./code/hg/gpstools/.hg
./code/hg/rat2/.hg
./code/hg/pydap.handlers.hdf5/.hg
./code/hg/PyCDS/.hg
./code/hg/ziperator/.hg
./code/hg/pupynere_bitbucket/.hg
./code/hg/crmprtd/.hg
./code/hg/data_portal_dev/.hg
./code/hg/pgraster/.hg
./code/hg/pydap.responses.html/.hg
./code/hg/py_modelmeta/.hg
./code/hg/pydap.handlers.pcic/.hg
./code/hg/pydap.handlers.sql/.hg
./code/hg/pydap_leftovers-3.2/.hg
./code/hg/pydap.responses.xls/.hg
./code/hg/pydap-3.2/.hg
./code/hg/crmp/.hg
./code/hg/pdp_util/.hg
./code/hg/pupynere/.hg
./code/hg/naggerbot/.hg
./code/hg/pydap.handlers.csv/.hg
./code/hg/data_portal_pycharm/.hg
./code/hg/openid2rp/.hg
./code/hg/pdp/.hg
./code/hg/pydap-3.2-rob/.hg
./code/hg/data_portal-2.0/bootstrap/src/modelmeta/.hg
./code/hg/data_portal-2.0/pydap-3.2/.hg
./code/hg/data_portal-2.0/pydap/.hg
./code/hg/data_portal-2.0/.hg
./code/hg/pydap.responses.aaigrid/.hg

That was easy. So I want to run “hg log” in each of those directories. I could try to use cut or something to pull the “.hg” off of each directory, but hey, it turns out that find has a -execdir option which allows you to run a command in the directory where each file is found. Perfect.

Now to craft the hg log command. I want all of my commits within a certain date range and those options already exist. So, putting it all together:

james@basalt ~/code/hg $ find ./ -name ".hg" -execdir hg log -v -d "2014-01-20 to 2014-01-27" -u "James Hiebert <hiebert@uvic.ca>" \; | head -50
changeset:   28:82cf794b9f1e
tag:         tip
user:        James Hiebert <hiebert@uvic.ca>
date:        Wed Jan 22 14:22:38 2014 -0800
files:       .hgtags
description:
Added tag 0.4 for changeset 3cfa57fa5315

changeset:   27:3cfa57fa5315
tag:         0.4
user:        James Hiebert <hiebert@uvic.ca>
date:        Wed Jan 22 14:22:35 2014 -0800
files:       setup.py
description:
Version bump

changeset:   43:17fcf1c1f43c
tag:         tip
user:        James Hiebert <hiebert@uvic.ca>
date:        Wed Jan 22 13:44:07 2014 -0800
files:       setup.py
description:
Added SQLAlchemy requirement <0.9.0

changeset:   42:3e5a8db15bda
user:        James Hiebert <hiebert@uvic.ca>
date:        Wed Jan 22 13:05:38 2014 -0800
files:       .hgtags
description:
Added tag 0.0.15 for changeset cc0590810109

changeset:   41:cc0590810109
tag:         0.0.15
user:        James Hiebert <hiebert@uvic.ca>
date:        Wed Jan 22 13:05:31 2014 -0800
files:       pycds/__init__.py setup.py tests/test_unique_constraints.py
description:
Fixed some problems with geometry handling for sqlite



blog comments powered by Disqus

Published

30 January 2014

Category

work

Tags