13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for branch.last_revision_info."""
26
26
# on an empty branch we want (0, NULL_REVISION)
27
27
branch = self.make_branch('branch')
28
28
self.assertEqual((0, NULL_REVISION), branch.last_revision_info())
30
30
def test_non_empty_branch(self):
31
31
# after the second commit we want (2, 'second-revid')
32
32
tree = self.make_branch_and_tree('branch')
33
33
tree.commit('1st post')
34
34
revid = tree.commit('2st post', allow_pointless=True)
35
35
self.assertEqual((2, revid), tree.branch.last_revision_info())
37
def test_import(self):
38
# importing and setting last revision
39
tree1 = self.make_branch_and_tree('branch1')
40
tree1.commit('1st post')
41
revid = tree1.commit('2st post', allow_pointless=True)
42
branch2 = self.make_branch('branch2')
43
branch2.import_last_revision_info(tree1.branch.repository, 2, revid)
44
self.assertEqual((2, revid), branch2.last_revision_info())
45
self.assertTrue(branch2.repository.has_revision(revid))
47
def test_same_repo(self):
48
# importing and setting last revision within the same repo
49
tree = self.make_branch_and_tree('branch1')
50
tree.commit('1st post')
51
revid = tree.commit('2st post', allow_pointless=True)
52
tree.branch.set_last_revision_info(0, NULL_REVISION)
53
tree.branch.import_last_revision_info(tree.branch.repository, 2, revid)
54
self.assertEqual((2, revid), tree.branch.last_revision_info())