comparing dates in a mercurial hook

Haszlakiewicz, Eric EHASZLA at
Fri Oct 14 13:41:06 CDT 2011

> -----Original Message-----
> From: Matt Mackall [mailto:mpm at]
> Why does everyone want to write hooks in Python?
> On the command line, you can do this with something like:
>  hg id -r "$SOMENODE and not date('-180')"
> and get a non-zero return code if the set is empty.

I have pre-existing hookthat needs to work on both unix and windows.  
They do more than just the date check (env variable check, regexp check of the description, works for both commit and push, etc...), and I thought the best practice for a portable hook was to use python.  
Is that not the case?

> A datetime is presumably a number in seconds since (the local) UNIX
> epoch. Mercurial dates are all of the form:
>  (seconds since epoch in GMT, seconds offset from GMT)
> so this comparison won't work. You should instead use
> util.matchdate("-180").

Ok, thanks, I'll give that a shot.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 474 bytes
Desc: not available
URL: <>

More information about the Mercurial-devel mailing list