<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def last_commit():
 """Returns the SHA1 of the last commit."""

    try:
        root = subprocess.check_output(
            ['hg', 'parent', '--template={node}'],
            stderr=subprocess.STDOUT).strip()
        # Convert to unicode first
        return root.decode('utf-8')
    except subprocess.CalledProcessError:
        return None