def METHOD_NAME(self, name):
    if name is None:
        name = self.get_branch_name()
    try:
        return self._decode(self._repo.log(self._encode(name))[0].node)
    except hglib.error.CommandError as err:
        if b'unknown revision' in err.err:
            raise NoSuchNameError(name)
        raise