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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21
from bzrlib import (
24
from bzrlib.errors import (
26
InvalidLineInBugsProperty,
28
from bzrlib.revision import NULL_REVISION
25
from bzrlib.branch import Branch
26
from bzrlib.errors import NoSuchRevision
27
from bzrlib.deprecated_graph import Graph
28
from bzrlib.revision import (find_present_ancestors,
30
from bzrlib.symbol_versioning import one_three
29
31
from bzrlib.tests import TestCase, TestCaseWithTransport
30
from bzrlib.tests.matchers import MatchesAncestry
32
from bzrlib.trace import mutter
33
from bzrlib.workingtree import WorkingTree
32
35
# We're allowed to test deprecated interfaces
33
36
warnings.filterwarnings('ignore',
58
61
tree1 = self.make_branch_and_tree("branch1", format=format)
61
64
tree1.commit("Commit one", rev_id="a@u-0-0")
62
65
tree1.commit("Commit two", rev_id="a@u-0-1")
63
66
tree1.commit("Commit three", rev_id="a@u-0-2")
65
tree2 = tree1.bzrdir.sprout("branch2").open_workingtree()
68
tree2 = tree1.bzrdir.clone("branch2").open_workingtree()
67
70
tree2.commit("Commit four", rev_id="b@u-0-3")
68
71
tree2.commit("Commit five", rev_id="b@u-0-4")
69
72
revisions_2 = br2.revision_history()
70
73
self.assertEquals(revisions_2[-1], 'b@u-0-4')
72
75
tree1.merge_from_branch(br2)
73
76
tree1.commit("Commit six", rev_id="a@u-0-3")
74
77
tree1.commit("Commit seven", rev_id="a@u-0-4")
75
78
tree2.commit("Commit eight", rev_id="b@u-0-5")
76
79
self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
78
81
tree1.merge_from_branch(br2)
79
82
tree1.commit("Commit nine", rev_id="a@u-0-5")
80
83
# DO NOT MERGE HERE - we WANT a GHOST.
81
84
tree2.add_parent_tree_id(br1.revision_history()[4])
82
85
tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
104
107
('a@u-0-5', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
105
108
'b@u-0-3', 'b@u-0-4',
106
109
'b@u-0-5', 'a@u-0-5']),
107
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-4',
110
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2',
108
111
'b@u-0-3', 'b@u-0-4',
109
112
'b@u-0-5', 'b@u-0-6']),
117
120
if rev_id in br2_only and not branch is br2:
120
MatchesAncestry(branch.repository, rev_id))
122
mutter('ancestry of {%s}: %r',
123
rev_id, branch.repository.get_ancestry(rev_id))
124
result = sorted(branch.repository.get_ancestry(rev_id))
125
self.assertEquals(result, [None] + sorted(anc))
123
128
class TestIntermediateRevisions(TestCaseWithTransport):
199
204
self.assertEqual('a', r.get_summary())
200
205
r.message = '\na\nb'
201
206
self.assertEqual('a', r.get_summary())
203
self.assertEqual('', r.get_summary())
205
def test_get_apparent_authors(self):
208
def test_get_apparent_author(self):
206
209
r = revision.Revision('1')
207
210
r.committer = 'A'
208
self.assertEqual(['A'], r.get_apparent_authors())
211
self.assertEqual('A', r.get_apparent_author())
209
212
r.properties['author'] = 'B'
210
self.assertEqual(['B'], r.get_apparent_authors())
211
r.properties['authors'] = 'C\nD'
212
self.assertEqual(['C', 'D'], r.get_apparent_authors())
214
def test_get_apparent_authors_no_committer(self):
215
r = revision.Revision('1')
216
self.assertEqual([], r.get_apparent_authors())
219
class TestRevisionBugs(TestCase):
220
"""Tests for getting the bugs that a revision is linked to."""
222
def test_no_bugs(self):
223
r = revision.Revision('1')
224
self.assertEqual([], list(r.iter_bugs()))
226
def test_some_bugs(self):
227
r = revision.Revision(
229
'bugs': bugtracker.encode_fixes_bug_urls(
230
['http://example.com/bugs/1',
231
'http://launchpad.net/bugs/1234'])})
233
[('http://example.com/bugs/1', bugtracker.FIXED),
234
('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
237
def test_no_status(self):
238
r = revision.Revision(
239
'1', properties={'bugs': 'http://example.com/bugs/1'})
240
self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
242
def test_too_much_information(self):
243
r = revision.Revision(
244
'1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
245
self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
247
def test_invalid_status(self):
248
r = revision.Revision(
249
'1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
250
self.assertRaises(InvalidBugStatus, list, r.iter_bugs())
213
self.assertEqual('B', r.get_apparent_author())