Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the dates of pull and update in Mercurial

Is it possible to know when a certain commit was pulled from a distant repository and the files updated with Mercurial ?

More precisely, I made a hg pull -u a few days ago, and now I'd like to know if this pull downloaded only the last commit, or if there were some commits that had not been pulled yet, making my last pull getting them as well.

hg log seems to give the dates of the commits, but nothing about the updates. Is this information anywhere ?

like image 568
nIcO Avatar asked Apr 17 '12 10:04

nIcO


2 Answers

This information is not recorded by Mercurial. A Mercurial repository is just a container for changesets and Mercurial does not store how (or when) the changesets entered the repository.

You can setup hooks for this, though you would have to build the scripts yourself. A very rudimentary system would be

[hooks]
pre-pull = (date; hg root; hg tip) >> ~/.pull-log
post-pull = hg tip >> ~/.pull-log

This would record the current date, the current repository, and the current tip in ~/.pull-log just before every hg pull. After the pull the new tip is recorded. You could build scripts that parse the log file to extract information about what each pull did.

hg log seems to give the dates of the commits, but nothing about the updates

Yes, hg log is only concerned with the stored history (changesets) and working copy operations like updating is not part of recorded history.

Finally, let me mention that this is the first time I've seen someone ask for a "pull log". However, the opposite is quite common: there are scripts for maintaining a "push log" on a server to see who pushed what and when. This is done by Mozilla among others. See this README for some starting instructions.

like image 137
Martin Geisler Avatar answered Nov 18 '22 05:11

Martin Geisler


If you want to log when and with which revision hg update was used to update the code, then use these hooks:

[hooks]
pre-update = (echo "---------------------------------"; date --rfc-3339=s; hg root; echo "pre-update:"; hg identify --id --branch) >> .hgupdates
post-update = (echo "post-update:"; hg identify --id --branch) >> .hgupdates

the above hooks produce a log entry like this for each time hg update is run:

2015-12-23 00:44:31+02:00
/var/www/my/project
pre-update:
802120d1d3a0 somebranch
post-update:
302720d1d3d2 otherbranch

This also works when hg update is run without a specific revision flag (-r) set

like image 37
allanlaal Avatar answered Nov 18 '22 05:11

allanlaal