comparing dates in a mercurial hook

Haszlakiewicz, Eric EHASZLA at transunion.com
Fri Oct 14 13:05:18 CDT 2011


I'm trying to write a hook that doesn't apply to changesets older than 6 months, but I'm having trouble actually performing the date comparison.  I can't figure out what the date() function is returning, or how to work with it.  Can someone point me at an example that does stuff with the dates?

Here's a snippet of the code I have:

def myhook(ui, repo, rev):
    ctx = repo[rev]
    """ don't validate really old changesets """
    sixmonthsback = datetime.today() - timedelta(days=180)
    if (ctx.date() < sixmonthsback):
        return 0

    ...rest of hook...

In a more general sense, is there a good way to tell what any particular method returns?  I find that I spend tons of time reading through code just to figure out what kind of object I'm working with.

Thanks,
eric


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 474 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20111014/c7e5759c/attachment.pgp>


More information about the Mercurial-devel mailing list