Exemplo n.º 1
0
 def build_a_rev(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id1 = builder.build_snapshot('A-id', None,
         [('add', ('', 'a-root-id', 'directory', None)),
          ('add', ('a', 'a-id', 'file', 'contents'))])
     self.assertEqual('A-id', rev_id1)
     return builder
Exemplo n.º 2
0
 def test_get_branch(self):
     """get_branch returns the created branch."""
     builder = BranchBuilder(self.get_transport().clone("foo"))
     branch = builder.get_branch()
     self.assertIsInstance(branch, _mod_branch.Branch)
     self.assertEqual(self.get_transport().clone("foo").base, branch.base)
     self.assertEqual((0, _mod_revision.NULL_REVISION), branch.last_revision_info())
 def build_a_rev(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id1 = builder.build_snapshot(
         'A-id', None, [('add', ('', 'a-root-id', 'directory', None)),
                        ('add', ('a', 'a-id', 'file', 'contents'))])
     self.assertEqual('A-id', rev_id1)
     return builder
Exemplo n.º 4
0
 def test_build_one_commit(self):
     """doing build_commit causes a commit to happen."""
     builder = BranchBuilder(self.get_transport().clone("foo"))
     rev_id = builder.build_commit()
     branch = builder.get_branch()
     self.assertEqual((1, rev_id), branch.last_revision_info())
     self.assertEqual("commit 1", branch.repository.get_revision(branch.last_revision()).message)
Exemplo n.º 5
0
 def build_a_rev(self):
     builder = BranchBuilder(self.get_transport().clone("foo"))
     rev_id1 = builder.build_snapshot(
         "A-id", None, [("add", ("", "a-root-id", "directory", None)), ("add", ("a", "a-id", "file", "contents"))]
     )
     self.assertEqual("A-id", rev_id1)
     return builder
Exemplo n.º 6
0
 def test_commit_message_default(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id = builder.build_snapshot(None, None,
         [('add', (u'', None, 'directory', None))])
     branch = builder.get_branch()
     rev = branch.repository.get_revision(rev_id)
     self.assertEqual(u'commit 1', rev.message)
Exemplo n.º 7
0
 def test_commit_message_callback(self):
     builder = BranchBuilder(self.get_transport().clone("foo"))
     rev_id = builder.build_snapshot(
         None, None, [("add", (u"", None, "directory", None))], message_callback=lambda x: u"Foo"
     )
     branch = builder.get_branch()
     rev = branch.repository.get_revision(rev_id)
     self.assertEqual(u"Foo", rev.message)
Exemplo n.º 8
0
 def test_unversion_root_add_new_root(self):
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     builder.build_snapshot("rev-1", None, [("add", ("", "TREE_ROOT", "directory", ""))])
     builder.build_snapshot("rev-2", None, [("unversion", "TREE_ROOT"), ("add", ("", "my-root", "directory", ""))])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree("rev-2")
     self.assertTreeShape([(u"", "my-root", "directory")], rev_tree)
 def test_get_branch(self):
     """get_branch returns the created branch."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
     branch = builder.get_branch()
     self.assertIsInstance(branch, _mod_branch.Branch)
     self.assertEqual(self.get_transport().clone('foo').base, branch.base)
     self.assertEqual((0, _mod_revision.NULL_REVISION),
                      branch.last_revision_info())
 def test_commit_message_default(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id = builder.build_snapshot(None, None,
                                     [('add',
                                       (u'', None, 'directory', None))])
     branch = builder.get_branch()
     rev = branch.repository.get_revision(rev_id)
     self.assertEqual(u'commit 1', rev.message)
Exemplo n.º 11
0
 def test_build_commit_parent_ids(self):
     """build_commit() takes a parent_ids argument."""
     builder = BranchBuilder(self.get_transport().clone("foo"))
     rev_id1 = builder.build_commit(parent_ids=["ghost"], allow_leftmost_as_ghost=True)
     rev_id2 = builder.build_commit(parent_ids=[])
     branch = builder.get_branch()
     self.assertEqual((1, rev_id2), branch.last_revision_info())
     self.assertEqual(["ghost"], branch.repository.get_revision(rev_id1).parent_ids)
Exemplo n.º 12
0
 def test_straightline_ancestry(self):
     """Test ancestry file when just committing."""
     builder = BranchBuilder(self.get_transport())
     rev_id_one = builder.build_commit()
     rev_id_two = builder.build_commit()
     branch = builder.get_branch()
     self.assertAncestryEqual([None, rev_id_one, rev_id_two],
         rev_id_two, branch)
     self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
Exemplo n.º 13
0
 def test_straightline_ancestry(self):
     """Test ancestry file when just committing."""
     builder = BranchBuilder(self.get_transport())
     rev_id_one = builder.build_commit()
     rev_id_two = builder.build_commit()
     branch = builder.get_branch()
     self.assertAncestryEqual([None, rev_id_one, rev_id_two], rev_id_two,
                              branch)
     self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
Exemplo n.º 14
0
 def test_build_two_commits(self):
     """The second commit has the right parents and message."""
     builder = BranchBuilder(self.get_transport().clone("foo"))
     rev_id1 = builder.build_commit()
     rev_id2 = builder.build_commit()
     branch = builder.get_branch()
     self.assertEqual((2, rev_id2), branch.last_revision_info())
     self.assertEqual("commit 2", branch.repository.get_revision(branch.last_revision()).message)
     self.assertEqual([rev_id1], branch.repository.get_revision(branch.last_revision()).parent_ids)
 def test_build_one_commit(self):
     """doing build_commit causes a commit to happen."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id = builder.build_commit()
     branch = builder.get_branch()
     self.assertEqual((1, rev_id), branch.last_revision_info())
     self.assertEqual(
         'commit 1',
         branch.repository.get_revision(branch.last_revision()).message)
Exemplo n.º 16
0
 def test_empty_flush(self):
     """A flush with no actions before it is a no-op."""
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     builder.build_snapshot("rev-1", None, [("add", ("", "TREE_ROOT", "directory", ""))])
     builder.build_snapshot("rev-2", None, [("flush", None)])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree("rev-2")
     self.assertTreeShape([(u"", "TREE_ROOT", "directory")], rev_tree)
Exemplo n.º 17
0
 def test_straightline_ancestry(self):
     """Test ancestry file when just committing."""
     builder = BranchBuilder(self.get_transport())
     rev_id_one = builder.build_commit()
     rev_id_two = builder.build_commit()
     branch = builder.get_branch()
     self.assertThat([rev_id_one, rev_id_two],
         MatchesAncestry(branch.repository, rev_id_two))
     self.assertThat([rev_id_one],
         MatchesAncestry(branch.repository, rev_id_one))
 def test_build_commit_parent_ids(self):
     """build_commit() takes a parent_ids argument."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id1 = builder.build_commit(parent_ids=["ghost"],
                                    allow_leftmost_as_ghost=True)
     rev_id2 = builder.build_commit(parent_ids=[])
     branch = builder.get_branch()
     self.assertEqual((1, rev_id2), branch.last_revision_info())
     self.assertEqual(["ghost"],
                      branch.repository.get_revision(rev_id1).parent_ids)
Exemplo n.º 19
0
 def test_start_finish_series(self):
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     try:
         self.assertIsNot(None, builder._tree)
         self.assertEqual("w", builder._tree._lock_mode)
         self.assertTrue(builder._branch.is_locked())
     finally:
         builder.finish_series()
     self.assertIs(None, builder._tree)
     self.assertFalse(builder._branch.is_locked())
Exemplo n.º 20
0
 def makeRepo(self, tree_contents):
     branch = Branch.open(self.repository_path)
     branch.get_config().set_user_option("create_signatures", "never")
     builder = BranchBuilder(branch=branch)
     actions = [('add', ('', 'tree-root', 'directory', None))]
     actions += [
         ('add', (path, path + '-id', 'file', content))
         for (path, content) in tree_contents]
     builder.build_snapshot(
         None, None, actions, committer='Joe Foo <*****@*****.**>',
             message=u'<The commit message>')
Exemplo n.º 21
0
 def makeRepo(self, tree_contents):
     branch = Branch.open(self.repository_path)
     branch.get_config().set_user_option("create_signatures", "never")
     builder = BranchBuilder(branch=branch)
     actions = [('add', ('', 'tree-root', 'directory', None))]
     actions += [
         ('add', (path, path + '-id', 'file', content))
         for (path, content) in tree_contents]
     builder.build_snapshot(
         None, None, actions, committer='Joe Foo <*****@*****.**>',
             message=u'<The commit message>')
 def test_build_two_commits(self):
     """The second commit has the right parents and message."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
     rev_id1 = builder.build_commit()
     rev_id2 = builder.build_commit()
     branch = builder.get_branch()
     self.assertEqual((2, rev_id2), branch.last_revision_info())
     self.assertEqual(
         'commit 2',
         branch.repository.get_revision(branch.last_revision()).message)
     self.assertEqual([rev_id1],
                      branch.repository.get_revision(
                          branch.last_revision()).parent_ids)
Exemplo n.º 23
0
 def test_kind_change(self):
     """It's possible to change the kind of an entry in a single snapshot
     with a bit of help from the 'flush' action.
     """
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     builder.build_snapshot(
         "A-id", None, [("add", (u"", "a-root-id", "directory", None)), ("add", (u"a", "a-id", "file", "content\n"))]
     )
     builder.build_snapshot(
         "B-id", None, [("unversion", "a-id"), ("flush", None), ("add", (u"a", "a-id", "directory", None))]
     )
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree("B-id")
     self.assertTreeShape([(u"", "a-root-id", "directory"), (u"a", "a-id", "directory")], rev_tree)
 def test_ghost_mainline_history(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     try:
         builder.build_snapshot('tip', ['ghost'],
                                [('add', ('', 'ROOT_ID', 'directory', ''))],
                                allow_leftmost_as_ghost=True)
     finally:
         builder.finish_series()
     b = builder.get_branch()
     b.lock_read()
     self.addCleanup(b.unlock)
     self.assertEqual(
         ('ghost', ),
         b.repository.get_graph().get_parent_map(['tip'])['tip'])
Exemplo n.º 25
0
 def test_ghost_mainline_history(self):
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     try:
         builder.build_snapshot(
             "tip", ["ghost"], [("add", ("", "ROOT_ID", "directory", ""))], allow_leftmost_as_ghost=True
         )
     finally:
         builder.finish_series()
     b = builder.get_branch()
     b.lock_read()
     self.addCleanup(b.unlock)
     self.assertEqual(("ghost",), b.repository.get_graph().get_parent_map(["tip"])["tip"])
Exemplo n.º 26
0
 def test_pivot_root(self):
     """It's possible (albeit awkward) to move an existing dir to the root
     in a single snapshot by using unversion then flush then add.
     """
     builder = BranchBuilder(self.get_transport().clone("foo"))
     builder.start_series()
     builder.build_snapshot(
         "A-id",
         None,
         [("add", (u"", "orig-root", "directory", None)), ("add", (u"dir", "dir-id", "directory", None))],
     )
     builder.build_snapshot(
         "B-id",
         None,
         [
             ("unversion", "orig-root"),  # implicitly unversions all children
             ("flush", None),
             ("add", (u"", "dir-id", "directory", None)),
         ],
     )
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree("B-id")
     self.assertTreeShape([(u"", "dir-id", "directory")], rev_tree)
 def test_start_finish_series(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     try:
         self.assertIsNot(None, builder._tree)
         self.assertEqual('w', builder._tree._lock_mode)
         self.assertTrue(builder._branch.is_locked())
     finally:
         builder.finish_series()
     self.assertIs(None, builder._tree)
     self.assertFalse(builder._branch.is_locked())
 def test_kind_change(self):
     """It's possible to change the kind of an entry in a single snapshot
     with a bit of help from the 'flush' action.
     """
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     builder.build_snapshot('A-id', None,
                            [('add', (u'', 'a-root-id', 'directory', None)),
                             ('add', (u'a', 'a-id', 'file', 'content\n'))])
     builder.build_snapshot('B-id', None,
                            [('unversion', 'a-id'), ('flush', None),
                             ('add', (u'a', 'a-id', 'directory', None))])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree('B-id')
     self.assertTreeShape([(u'', 'a-root-id', 'directory'),
                           (u'a', 'a-id', 'directory')], rev_tree)
 def test_empty_flush(self):
     """A flush with no actions before it is a no-op."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     builder.build_snapshot('rev-1', None,
                            [('add', ('', 'TREE_ROOT', 'directory', ''))])
     builder.build_snapshot('rev-2', None, [('flush', None)])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree('rev-2')
     self.assertTreeShape([(u'', 'TREE_ROOT', 'directory')], rev_tree)
 def test_unversion_root_add_new_root(self):
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     builder.build_snapshot('rev-1', None,
                            [('add', ('', 'TREE_ROOT', 'directory', ''))])
     builder.build_snapshot('rev-2', None,
                            [('unversion', 'TREE_ROOT'),
                             ('add', ('', 'my-root', 'directory', ''))])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree('rev-2')
     self.assertTreeShape([(u'', 'my-root', 'directory')], rev_tree)
 def test_format(self):
     """Making a BranchBuilder with a format option sets the branch type."""
     builder = BranchBuilder(self.get_transport(), format='dirstate-tags')
     branch = builder.get_branch()
     self.assertIsInstance(branch, _mod_branch.BzrBranch6)
 def test_create(self):
     """Test the constructor api."""
     builder = BranchBuilder(self.get_transport().clone('foo'))
Exemplo n.º 33
0
 def test_format(self):
     """Making a BranchBuilder with a format option sets the branch type."""
     builder = BranchBuilder(self.get_transport(), format="dirstate-tags")
     branch = builder.get_branch()
     self.assertIsInstance(branch, _mod_branch.BzrBranch6)
 def test_pivot_root(self):
     """It's possible (albeit awkward) to move an existing dir to the root
     in a single snapshot by using unversion then flush then add.
     """
     builder = BranchBuilder(self.get_transport().clone('foo'))
     builder.start_series()
     builder.build_snapshot('A-id', None,
                            [('add', (u'', 'orig-root', 'directory', None)),
                             ('add',
                              (u'dir', 'dir-id', 'directory', None))])
     builder.build_snapshot(
         'B-id',
         None,
         [
             ('unversion',
              'orig-root'),  # implicitly unversions all children
             ('flush', None),
             ('add', (u'', 'dir-id', 'directory', None))
         ])
     builder.finish_series()
     rev_tree = builder.get_branch().repository.revision_tree('B-id')
     self.assertTreeShape([(u'', 'dir-id', 'directory')], rev_tree)