/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_revisionspec.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        self.assertEqual((self.tree.branch, None), spec.last_call)
124
124
 
125
125
 
126
 
 
127
126
class TestOddRevisionSpec(TestRevisionSpec):
128
127
    """Test things that aren't normally thought of as revision specs"""
129
128
 
190
189
 
191
190
    def test_append_dwim_revspec(self):
192
191
        original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
 
192
 
193
193
        def reset_dwim_revspecs():
194
194
            RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
195
195
        self.addCleanup(reset_dwim_revspecs)
198
198
 
199
199
    def test_append_lazy_dwim_revspec(self):
200
200
        original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs)
 
201
 
201
202
        def reset_dwim_revspecs():
202
203
            RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs
203
204
        self.addCleanup(reset_dwim_revspecs)
330
331
        wtb.commit('Commit two', rev_id=b'b@r-0-2')
331
332
        wtb.commit('Commit three', rev_id=b'b@r-0-3')
332
333
 
333
 
 
334
334
        self.assertEqual((1, b'a@r-0-1'),
335
335
                         spec_in_history('revno:1:a/', ba))
336
336
        # The argument of in_history should be ignored since it is
397
397
        revision_id = u'\N{SNOWMAN}'.encode('utf-8')
398
398
        self.tree.commit('unicode', rev_id=revision_id)
399
399
        self.assertInHistoryIs(3, revision_id, u'revid:\N{SNOWMAN}')
400
 
        self.assertInHistoryIs(3, revision_id, 'revid:' + revision_id.decode('utf-8'))
 
400
        self.assertInHistoryIs(3, revision_id, 'revid:' +
 
401
                               revision_id.decode('utf-8'))
401
402
 
402
403
    def test_as_revision_id(self):
403
404
        self.assertAsRevisionId(b'r1', 'revid:r1')
499
500
        # tags that don't exist give a specific message: arguably we should
500
501
        # just give InvalidRevisionSpec but I think this is more helpful
501
502
        self.assertRaises(errors.NoSuchTag,
502
 
            self.get_in_history,
503
 
            'tag:some-random-tag')
 
503
                          self.get_in_history,
 
504
                          'tag:some-random-tag')
504
505
 
505
506
    def test_as_revision_id(self):
506
507
        self.tree.branch.tags.set_tag('my-tag', b'r2')
517
518
 
518
519
        new_tree = self.make_branch_and_tree('new_tree')
519
520
        new_tree.commit('Commit one', rev_id=b'new_r1',
520
 
                        timestamp=time.time() - 60*60*24)
 
521
                        timestamp=time.time() - 60 * 60 * 24)
521
522
        new_tree.commit('Commit two', rev_id=b'new_r2')
522
523
        new_tree.commit('Commit three', rev_id=b'new_r3')
523
524
 
543
544
    def test_day(self):
544
545
        now = datetime.datetime.now()
545
546
        self.assertInHistoryIs(2, b'new_r2',
546
 
            'date:%04d-%02d-%02d' % (now.year, now.month, now.day))
 
547
                               'date:%04d-%02d-%02d' % (now.year, now.month, now.day))
547
548
 
548
549
    def test_as_revision_id(self):
549
550
        self.assertAsRevisionId(b'new_r2', 'date:today')
635
636
        self.assertTrue(self.tree.branch.repository.has_revision(b'new_r3'))
636
637
 
637
638
    def test_no_commits(self):
638
 
        new_tree = self.make_branch_and_tree('new_tree')
 
639
        self.make_branch_and_tree('new_tree')
639
640
        self.assertRaises(errors.NoCommits,
640
641
                          self.get_in_history, 'branch:new_tree')
641
642
        self.assertRaises(errors.NoCommits,
660
661
        self.assertInHistoryIs(None, b'alt_r2', 'submit:')
661
662
        self.tree.branch.set_parent('bogus')
662
663
        self.assertRaises(errors.NotBranchError, self.get_in_history,
663
 
            'submit:')
 
664
                          'submit:')
664
665
        # submit branch overrides parent branch
665
666
        self.tree.branch.set_submit_branch('tree2')
666
667
        self.assertInHistoryIs(None, b'alt_r2', 'submit:')
680
681
        e = self.assertRaises(errors.InvalidRevisionSpec,
681
682
                              spec.as_revision_id, self.tree.branch)
682
683
        self.assertContainsRe(str(e),
683
 
            "Requested revision: 'mainline:revid:alt_r22' does not exist in"
684
 
            " branch: ")
 
684
                              "Requested revision: 'mainline:revid:alt_r22' does not exist in"
 
685
                              " branch: ")
685
686
 
686
687
    def test_in_history(self):
687
688
        self.assertInHistoryIs(2, b'r2', 'mainline:revid:alt_r2')
710
711
        e = self.assertRaises(errors.InvalidRevisionSpec,
711
712
                              spec.as_revision_id, self.tree.branch)
712
713
        self.assertContainsRe(str(e),
713
 
            r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
714
 
            " exist in branch: .*\nLine 3 has not been committed.")
 
714
                              r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
 
715
                              " exist in branch: .*\nLine 3 has not been committed.")
715
716
 
716
717
    def test_non_existent_line(self):
717
718
        spec = RevisionSpec.from_string('annotate:annotate-tree/file1:4')
718
719
        e = self.assertRaises(errors.InvalidRevisionSpec,
719
720
                              spec.as_revision_id, self.tree.branch)
720
721
        self.assertContainsRe(str(e),
721
 
            r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
722
 
            " exist in branch: .*\nNo such line: 4")
 
722
                              r"Requested revision: \'annotate:annotate-tree/file1:4\' does not"
 
723
                              " exist in branch: .*\nNo such line: 4")
723
724
 
724
725
    def test_invalid_line(self):
725
726
        spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q')
726
727
        e = self.assertRaises(errors.InvalidRevisionSpec,
727
728
                              spec.as_revision_id, self.tree.branch)
728
729
        self.assertContainsRe(str(e),
729
 
            r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
730
 
            " exist in branch: .*\nNo such line: q")
 
730
                              r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
 
731
                              " exist in branch: .*\nNo such line: q")
731
732
 
732
733
    def test_no_such_file(self):
733
734
        spec = RevisionSpec.from_string('annotate:annotate-tree/file2:1')
734
735
        e = self.assertRaises(errors.InvalidRevisionSpec,
735
736
                              spec.as_revision_id, self.tree.branch)
736
737
        self.assertContainsRe(str(e),
737
 
            r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
738
 
            " exist in branch: .*\nFile 'file2' is not versioned")
 
738
                              r"Requested revision: \'annotate:annotate-tree/file2:1\' does not"
 
739
                              " exist in branch: .*\nFile 'file2' is not versioned")
739
740
 
740
741
    def test_no_such_file_with_colon(self):
741
742
        spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1')
742
743
        e = self.assertRaises(errors.InvalidRevisionSpec,
743
744
                              spec.as_revision_id, self.tree.branch)
744
745
        self.assertContainsRe(str(e),
745
 
            r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
746
 
            " exist in branch: .*\nFile 'fi:le2' is not versioned")
 
746
                              r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
 
747
                              " exist in branch: .*\nFile 'fi:le2' is not versioned")