The git plugin provides the following environment variables:
GIT_PREVIOUS_COMMIT: The hash of the commit last built on this branch, if any.
GIT_PREVIOUS_SUCCESSFUL_COMMIT: The hash of the commit last successfully built on this branch, if any.
It would be useful if the mercurial plugin provided the same information, e.g.
MERCURIAL_PREVIOUS_REVISION: Full ID of revision last built on this job.
MERCURIAL_PREVIOUS_SUCCESSFUL_REVISION: Full ID of revision last successfully built on this job.