Changed hg logic to proper cloning