def testToFirstParent(self): r = self.mkRepo() SK = r['refs/heads/branch_SK'] S, K = r['refs/heads/branch_S'], r['refs/heads/branch_K'] spec_S, spec_K = GitEntry.spec_for(r, S.ref), GitEntry.spec_for(r, K.ref) newTreeHsh = GitTree.from_spec( GitEntry.merge_specs(spec_S, spec_K)).intern(r) cd = data.CommitData( newTreeHsh, [S.commit.hsh, K.commit.hsh], S.commit.data.author, S.commit.data.committer, (), ["merge commit"], (), False) merge = r.get_commit(r.intern(cd, 'commit')) SK.update_to(merge) A = r['refs/heads/root_A'] self.assertEqual( list(c.hsh for c in A.to(SK)), [self.repo[c] for c in 'BCGDHILJMKNOPQRS'] + [merge.hsh] ) self.assertEqual( list(c.hsh for c in A.to(SK, first_parent=True)), [self.repo[c] for c in 'BCDLMNOPQRS'] + [merge.hsh] )
def merge_commit(origin, run, checkpoint, mirrors, **_): master = origin['refs/heads/master'] mc = master.make_commit mc('main 1', {'mirrored_path': {'some_file': 'data'}}) master_head = mc('main 2', {'mirrored_path': {'some_file': 'data2'}}) mc = origin['refs/heads/other'].make_commit other_head = mc('other 1', {'mirrored_path': {'other_file': 'something'}}) # do a crappy merge commit. this logic should probably be on TestRepo at some # point, but merge commits are pretty rare so keep it here until the next # person needs to do this. tree_hsh = GitEntry.from_spec(GitEntry.merge_specs( origin.spec_for(master_head), origin.spec_for(other_head), )).intern(origin) user = master_head.data.author commit = origin.get_commit(origin.intern(data.CommitData( tree_hsh, [master_head.hsh, other_head.hsh], user, user, (), ["squish"], (), False ), 'commit')) master.fast_forward(commit) checkpoint('setup') run() checkpoint('should not see `other 1` in subtree mirror') assert GitEntry.spec_for(mirrors['mirrored_path'], 'refs/heads/master') == { 'some_file': ('data2', 0644), 'other_file': ('something', 0644), }
def merge_commit(origin, run, checkpoint, mirrors, **_): master = origin['refs/heads/master'] mc = master.make_commit mc('main 1', {'mirrored_path': {'some_file': 'data'}}) master_head = mc('main 2', {'mirrored_path': {'some_file': 'data2'}}) mc = origin['refs/heads/other'].make_commit other_head = mc('other 1', {'mirrored_path': {'other_file': 'something'}}) # do a crappy merge commit. this logic should probably be on TestRepo at some # point, but merge commits are pretty rare so keep it here until the next # person needs to do this. tree_hsh = GitEntry.from_spec( GitEntry.merge_specs( origin.spec_for(master_head), origin.spec_for(other_head), )).intern(origin) user = master_head.data.author commit = origin.get_commit( origin.intern( data.CommitData(tree_hsh, [master_head.hsh, other_head.hsh], user, user, (), ["squish"], (), False), 'commit')) master.fast_forward(commit) checkpoint('setup') run() checkpoint('should not see `other 1` in subtree mirror') assert GitEntry.spec_for(mirrors['mirrored_path'], 'refs/heads/master') == { 'some_file': ('data2', 0644), 'other_file': ('something', 0644), }
def testToFirstParent(self): r = self.mkRepo() SK = r['refs/heads/branch_SK'] S, K = r['refs/heads/branch_S'], r['refs/heads/branch_K'] spec_S, spec_K = GitEntry.spec_for(r, S.ref), GitEntry.spec_for(r, K.ref) newTreeHsh = GitTree.from_spec(GitEntry.merge_specs(spec_S, spec_K)).intern(r) cd = data.CommitData(newTreeHsh, [S.commit.hsh, K.commit.hsh], S.commit.data.author, S.commit.data.committer, (), ["merge commit"], (), False) merge = r.get_commit(r.intern(cd, 'commit')) SK.update_to(merge) A = r['refs/heads/root_A'] self.assertEqual(list(c.hsh for c in A.to(SK)), [self.repo[c] for c in 'BCGDHILJMKNOPQRS'] + [merge.hsh]) self.assertEqual(list(c.hsh for c in A.to(SK, first_parent=True)), [self.repo[c] for c in 'BCDLMNOPQRS'] + [merge.hsh])