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
21
21
from bzrlib import (
25
26
from bzrlib.branch import Branch
26
from bzrlib.errors import NoSuchRevision
27
from bzrlib.errors import (
29
InvalidLineInBugsProperty,
27
32
from bzrlib.deprecated_graph import Graph
28
33
from bzrlib.revision import (find_present_ancestors,
30
from bzrlib.symbol_versioning import one_three
31
35
from bzrlib.tests import TestCase, TestCaseWithTransport
32
36
from bzrlib.trace import mutter
33
37
from bzrlib.workingtree import WorkingTree
61
65
tree1 = self.make_branch_and_tree("branch1", format=format)
64
68
tree1.commit("Commit one", rev_id="a@u-0-0")
65
69
tree1.commit("Commit two", rev_id="a@u-0-1")
66
70
tree1.commit("Commit three", rev_id="a@u-0-2")
68
tree2 = tree1.bzrdir.clone("branch2").open_workingtree()
72
tree2 = tree1.bzrdir.sprout("branch2").open_workingtree()
70
74
tree2.commit("Commit four", rev_id="b@u-0-3")
71
75
tree2.commit("Commit five", rev_id="b@u-0-4")
72
76
revisions_2 = br2.revision_history()
73
77
self.assertEquals(revisions_2[-1], 'b@u-0-4')
75
79
tree1.merge_from_branch(br2)
76
80
tree1.commit("Commit six", rev_id="a@u-0-3")
77
81
tree1.commit("Commit seven", rev_id="a@u-0-4")
78
82
tree2.commit("Commit eight", rev_id="b@u-0-5")
79
83
self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
81
85
tree1.merge_from_branch(br2)
82
86
tree1.commit("Commit nine", rev_id="a@u-0-5")
83
87
# DO NOT MERGE HERE - we WANT a GHOST.
84
88
tree2.add_parent_tree_id(br1.revision_history()[4])
85
89
tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
214
212
def test_get_apparent_author(self):
215
213
r = revision.Revision('1')
216
214
r.committer = 'A'
217
self.assertEqual('A', r.get_apparent_author())
218
r.properties['author'] = 'B'
219
self.assertEqual('B', r.get_apparent_author())
215
author = self.applyDeprecated(
216
symbol_versioning.deprecated_in((1, 13, 0)),
217
r.get_apparent_author)
218
self.assertEqual('A', author)
219
r.properties['author'] = 'B'
220
author = self.applyDeprecated(
221
symbol_versioning.deprecated_in((1, 13, 0)),
222
r.get_apparent_author)
223
self.assertEqual('B', author)
224
r.properties['authors'] = 'C\nD'
225
author = self.applyDeprecated(
226
symbol_versioning.deprecated_in((1, 13, 0)),
227
r.get_apparent_author)
228
self.assertEqual('C', author)
230
def test_get_apparent_author_none(self):
231
r = revision.Revision('1')
232
author = self.applyDeprecated(
233
symbol_versioning.deprecated_in((1, 13, 0)),
234
r.get_apparent_author)
235
self.assertEqual(None, author)
237
def test_get_apparent_authors(self):
238
r = revision.Revision('1')
240
self.assertEqual(['A'], r.get_apparent_authors())
241
r.properties['author'] = 'B'
242
self.assertEqual(['B'], r.get_apparent_authors())
243
r.properties['authors'] = 'C\nD'
244
self.assertEqual(['C', 'D'], r.get_apparent_authors())
246
def test_get_apparent_authors_no_committer(self):
247
r = revision.Revision('1')
248
self.assertEqual([], r.get_apparent_authors())
251
class TestRevisionBugs(TestCase):
252
"""Tests for getting the bugs that a revision is linked to."""
254
def test_no_bugs(self):
255
r = revision.Revision('1')
256
self.assertEqual([], list(r.iter_bugs()))
258
def test_some_bugs(self):
259
r = revision.Revision(
261
'bugs': bugtracker.encode_fixes_bug_urls(
262
['http://example.com/bugs/1',
263
'http://launchpad.net/bugs/1234'])})
265
[('http://example.com/bugs/1', bugtracker.FIXED),
266
('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
269
def test_no_status(self):
270
r = revision.Revision(
271
'1', properties={'bugs': 'http://example.com/bugs/1'})
272
self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
274
def test_too_much_information(self):
275
r = revision.Revision(
276
'1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
277
self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
279
def test_invalid_status(self):
280
r = revision.Revision(
281
'1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
282
self.assertRaises(InvalidBugStatus, list, r.iter_bugs())