def test_local_merge(self, vcsbackend_hg): target_repo = vcsbackend_hg.create_repo(number_of_commits=1) source_repo = vcsbackend_hg.clone_repo(target_repo) vcsbackend_hg.add_file(target_repo, 'README_MERGE1', 'Version 1') target_repo = MercurialRepository(target_repo.path) target_rev = target_repo.branches['default'] target_ref = Reference(type='branch', name='default', commit_id=target_rev) vcsbackend_hg.add_file(source_repo, 'README_MERGE2', 'Version 2') source_repo = MercurialRepository(source_repo.path) source_rev = source_repo.branches['default'] source_ref = Reference(type='branch', name='default', commit_id=source_rev) target_repo._local_pull(source_repo.path, source_ref) merge_message = 'Merge message\n\nDescription:...' user_name = 'Albert Einstein' user_email = '*****@*****.**' merge_commit_id, needs_push = target_repo._local_merge( target_ref, merge_message, user_name, user_email, source_ref) assert needs_push target_repo = MercurialRepository(target_repo.path) assert target_repo.commit_ids[-3] == target_rev assert target_repo.commit_ids[-2] == source_rev last_commit = target_repo.get_commit(merge_commit_id) assert last_commit.message.strip() == merge_message assert last_commit.author == '%s <%s>' % (user_name, user_email) assert not os.path.exists( os.path.join(target_repo.path, '.hg', 'merge', 'state'))
def test_repo_clone(self): if os.path.exists(TEST_HG_REPO_CLONE): self.fail( 'Cannot test mercurial clone repo as location %s already ' 'exists. You should manually remove it first.' % TEST_HG_REPO_CLONE) repo = MercurialRepository(TEST_HG_REPO) repo_clone = MercurialRepository(TEST_HG_REPO_CLONE, src_url=TEST_HG_REPO) assert len(repo.commit_ids) == len(repo_clone.commit_ids) # Checking hashes of commits should be enough for commit in repo.get_commits(): raw_id = commit.raw_id assert raw_id == repo_clone.get_commit(raw_id).raw_id