Updating commit timestamp on push.

Sean Farley sean.michael.farley at gmail.com
Thu Dec 5 00:24:26 UTC 2013


kannan at cakoose.com writes:

> We use Mercurial in a mostly centralized manner.  We use local commits and
> local branches during but eventually use some kind of history modification
> to collapse things before pushing to the central repo.  We do not have merge
> commits in our central repo.
>
> The problem: when I do "hg log", the commit timestamps are based on the
> timestamp of the original commit.  It would be more useful to us if the
> timestamps represented when each commit made it to the central repo (at
> least within a minute or two).
>
> I'm trying to figure out how to achieve that.  My initial attempt involves
> creating an alias called "amend" that calls "hg commit --amend --date
> <now>".  This works, but requires that we remember to call "hg amend" right
> before each push.  I'm hoping for something more automatic.
>
> For example, it would be nice if I could run a bit of code right before a
> push and, for each commit that is going to be pushed:
> - if it is marked immutable, fail.
> - otherwise, update the timestamp to the current time.
>
> I looked at "pre-push" hooks and also looked at the way the "mq" extension
> creates a wrapper around the "push" command.  Those options aren't
> straightforward because it looks like I need to parse the arguments to
> "push" (like "-b <branch>") to make sure I figure out the right set of
> commits.  I think I can copy/paste some code from the Mercurial source's
> implementation of "push" to achieve my goal, but that seems brittle.
>
> Any advice on what the right approach is?

Wrapping push like this is asking for *all* kinds trouble. Instead, I
would enable blackbox on the server and then use that information in a
custom mercurial extension that would map each commit to the pushed
timestamp. This map can then be pulled by each client via pushkey in
this custom extension.



More information about the Mercurial mailing list