~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

Late bind to PatienceSequenceMatcher to allow plugin to override.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# (C) 2005 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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
import os
19
 
import warnings
20
19
 
21
20
from bzrlib.branch import Branch
22
21
from bzrlib.errors import NoSuchRevision
 
22
from bzrlib.commit import commit
23
23
from bzrlib.graph import Graph
24
24
from bzrlib.revision import (find_present_ancestors, combined_graph,
25
25
                             common_ancestor,
26
 
                             is_ancestor, MultipleRevisionSources,
27
 
                             NULL_REVISION)
 
26
                             is_ancestor, MultipleRevisionSources)
28
27
from bzrlib.tests import TestCaseWithTransport
29
28
from bzrlib.trace import mutter
30
29
from bzrlib.workingtree import WorkingTree
31
30
 
32
 
# We're allowed to test deprecated interfaces
33
 
warnings.filterwarnings('ignore',
34
 
        '.*get_intervening_revisions was deprecated',
35
 
        DeprecationWarning,
36
 
        r'bzrlib\.tests\.test_revision')
37
 
 
38
31
# XXX: Make this a method of a merge base case
39
32
def make_branches(self):
40
33
    """Create two branches
147
140
class TestIntermediateRevisions(TestCaseWithTransport):
148
141
 
149
142
    def setUp(self):
 
143
        from bzrlib.commit import commit
150
144
        TestCaseWithTransport.setUp(self)
151
145
        self.br1, self.br2 = make_branches(self)
152
146
        wt1 = self.br1.bzrdir.open_workingtree()
222
216
        self.assertTrue(common_ancestor(revisions_2[6], revisions[5], sources),
223
217
                        (revisions[4], revisions_2[5]))
224
218
        self.assertEqual(None, common_ancestor(None, revisions[5], sources))
225
 
        self.assertEqual(NULL_REVISION,
226
 
            common_ancestor(NULL_REVISION, NULL_REVISION, sources))
227
 
        self.assertEqual(NULL_REVISION,
228
 
            common_ancestor(revisions[0], NULL_REVISION, sources))
229
 
        self.assertEqual(NULL_REVISION,
230
 
            common_ancestor(NULL_REVISION, revisions[0], sources))
231
219
 
232
220
    def test_combined(self):
233
221
        """combined_graph
297
285
        self.assertEqual({'B':['A'],
298
286
                          'A':[]},
299
287
                         source.get_revision_graph('B'))
300
 
 
301
 
class TestRevisionAttributes(TestCaseWithTransport):
302
 
    """Test that revision attributes are correct."""
303
 
 
304
 
    def test_revision_accessors(self):
305
 
        """Make sure the values that come out of a revision are the same as the ones that go in.
306
 
        """
307
 
        tree1 = self.make_branch_and_tree("br1")
308
 
 
309
 
        # create a revision
310
 
        tree1.commit(message="quux", allow_pointless=True, committer="jaq",
311
 
                     revprops={'empty':'',
312
 
                               'value':'one',
313
 
                               'unicode':'\xb5',
314
 
                               'multiline':'foo\nbar\n\n'
315
 
                              })
316
 
        assert len(tree1.branch.revision_history()) > 0
317
 
        rev_a = tree1.branch.repository.get_revision(tree1.branch.last_revision())
318
 
 
319
 
        tree2 = self.make_branch_and_tree("br2")
320
 
        tree2.commit(message=rev_a.message,
321
 
                     timestamp=rev_a.timestamp,
322
 
                     timezone=rev_a.timezone,
323
 
                     committer=rev_a.committer,
324
 
                     rev_id=rev_a.revision_id,
325
 
                     revprops=rev_a.properties,
326
 
                     allow_pointless=True, # there's nothing in this commit
327
 
                     strict=True,
328
 
                     verbose=True)
329
 
        rev_b = tree2.branch.repository.get_revision(tree2.branch.last_revision())
330
 
        
331
 
        self.assertEqual(rev_a.message, rev_b.message)
332
 
        self.assertEqual(rev_a.timestamp, rev_b.timestamp)
333
 
        self.assertEqual(rev_a.timezone, rev_b.timezone)
334
 
        self.assertEqual(rev_a.committer, rev_b.committer)
335
 
        self.assertEqual(rev_a.revision_id, rev_b.revision_id)
336
 
        self.assertEqual(rev_a.properties, rev_b.properties)