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
20
from bzrlib import (
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
24
from bzrlib.errors import (
26
InvalidLineInBugsProperty,
28
from bzrlib.revision import NULL_REVISION
31
29
from bzrlib.tests import TestCase, TestCaseWithTransport
32
from bzrlib.trace import mutter
33
from bzrlib.workingtree import WorkingTree
30
from bzrlib.tests.matchers import MatchesAncestry
35
32
# We're allowed to test deprecated interfaces
36
33
warnings.filterwarnings('ignore',
107
104
('a@u-0-5', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
108
105
'b@u-0-3', 'b@u-0-4',
109
106
'b@u-0-5', 'a@u-0-5']),
110
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2',
107
('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-4',
111
108
'b@u-0-3', 'b@u-0-4',
112
109
'b@u-0-5', 'b@u-0-6']),
120
117
if rev_id in br2_only and not branch is br2:
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))
120
MatchesAncestry(branch.repository, rev_id))
128
123
class TestIntermediateRevisions(TestCaseWithTransport):
204
199
self.assertEqual('a', r.get_summary())
205
200
r.message = '\na\nb'
206
201
self.assertEqual('a', r.get_summary())
203
self.assertEqual('', r.get_summary())
208
def test_get_apparent_author(self):
205
def test_get_apparent_authors(self):
209
206
r = revision.Revision('1')
210
207
r.committer = 'A'
211
self.assertEqual('A', r.get_apparent_author())
208
self.assertEqual(['A'], r.get_apparent_authors())
212
209
r.properties['author'] = 'B'
213
self.assertEqual('B', r.get_apparent_author())
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())