/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_branch/test_get_rev_id.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007, 2009-2012, 2016 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
"""Tests for Branch.get_rev_id."""
 
18
 
 
19
from breezy.errors import RevnoOutOfBounds
 
20
from breezy.revision import NULL_REVISION
 
21
from breezy.tests import TestCaseWithTransport
 
22
 
 
23
 
 
24
class TestGetRevid(TestCaseWithTransport):
 
25
 
 
26
    def test_empty_branch(self):
 
27
        # on an empty branch we want (0, NULL_REVISION)
 
28
        branch = self.make_branch('branch')
 
29
        self.assertEqual(NULL_REVISION, branch.get_rev_id(0))
 
30
        self.assertRaises(RevnoOutOfBounds, branch.get_rev_id, 1)
 
31
        self.assertRaises(RevnoOutOfBounds, branch.get_rev_id, -1)
 
32
 
 
33
    def test_non_empty_branch(self):
 
34
        # after the second commit we want (2, 'second-revid')
 
35
        tree = self.make_branch_and_tree('branch')
 
36
        revid1 = tree.commit('1st post')
 
37
        revid2 = tree.commit('2st post', allow_pointless=True)
 
38
        self.assertEqual(revid2, tree.branch.get_rev_id(2))
 
39
        self.assertEqual(revid1, tree.branch.get_rev_id(1))
 
40
        self.assertRaises(RevnoOutOfBounds, tree.branch.get_rev_id, 3)