~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_revision_id_to_revno.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2011, 2016 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Tests for Branch.revision_id_to_revno()"""
18
18
 
19
19
from bzrlib import errors
20
 
from bzrlib.tests import TestNotApplicable
21
20
 
22
21
from bzrlib.tests.per_branch import TestCaseWithBranch
23
22
 
40
39
        self.assertRaises(errors.NoSuchRevision,
41
40
                          the_branch.revision_id_to_revno, 'rev-1.1.1')
42
41
 
43
 
    def test_mainline_ghost(self):
44
 
        tree = self.make_branch_and_tree('tree1')
45
 
        if not tree.branch.repository._format.supports_ghosts:
46
 
            raise TestNotApplicable("repository format does not support ghosts")
47
 
        tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
48
 
        tree.add('')
49
 
        tree.commit('msg1', rev_id='rev1')
50
 
        tree.commit('msg2', rev_id='rev2')
51
 
        # Some older branch formats store the full known revision history
52
 
        # and thus can't distinguish between not being able to find a revno because of
53
 
        # a ghost and the revision not being on the mainline. As such,
54
 
        # allow both NoSuchRevision and GhostRevisionsHaveNoRevno here.
55
 
        self.assertRaises((errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno),
56
 
            tree.branch.revision_id_to_revno, "unknown")
57
 
        self.assertEqual(1, tree.branch.revision_id_to_revno("rev1"))
58
 
        self.assertEqual(2, tree.branch.revision_id_to_revno("rev2"))
59
 
 
60
 
    def test_empty(self):
61
 
        branch = self.make_branch('.')
62
 
        self.assertRaises(errors.NoSuchRevision,
63
 
            branch.revision_id_to_revno, "unknown")
64
 
        self.assertEqual(0, branch.revision_id_to_revno('null:'))