/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 bzrlib/selftest/test_revision_info.py

  • Committer: Robert Collins
  • Date: 2005-10-29 23:48:45 UTC
  • Revision ID: robertc@robertcollins.net-20051029234845-7ae4e7d118bdd3ed
Implement a 'bzr push' command, with saved locations; update diff to return 1.

    * 'bzr diff' now returns 1 when there are changes in the working 
      tree.

    * 'bzr push' now exists and can push changes to a remote location. 
      This uses the transport infrastructure, and can store the remote
      location in the ~/.bazaar/branches.conf configuration file.

    * WorkingTree.pull has been split across Branch and WorkingTree,
      to allow Branch only pulls.

    * commands.display_command now returns the result of the decorated 
      function.

    * LocationConfig now has a set_user_option(key, value) call to save
      a setting in its matching location section (a new one is created
      if needed).

    * Branch has two new methods, get_push_location and set_push_location
      to respectively, get and set the push location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2004, 2005 by Canonical Ltd
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
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
 
16
 
 
17
import os
 
18
from bzrlib.selftest import TestCaseInTempDir
 
19
from bzrlib.errors import BzrCommandError, NoSuchRevision
 
20
from bzrlib.branch import Branch
 
21
from bzrlib.revisionspec import RevisionSpec
 
22
 
 
23
class TestRevisionInfo(TestCaseInTempDir):
 
24
    
 
25
    def check_error(self, output, *args):
 
26
        """Verify that the expected error matches what bzr says.
 
27
        
 
28
        The output is supplied first, so that you can supply a variable
 
29
        number of arguments to bzr.
 
30
        """
 
31
        self.assertEquals(self.run_bzr_captured(args, retcode=1)[1], output)
 
32
 
 
33
    def check_output(self, output, *args):
 
34
        """Verify that the expected output matches what bzr says.
 
35
        
 
36
        The output is supplied first, so that you can supply a variable
 
37
        number of arguments to bzr.
 
38
        """
 
39
        self.assertEquals(self.run_bzr_captured(args)[0], output)
 
40
 
 
41
    def test_revision_info(self):
 
42
        """Test that 'bzr revision-info' reports the correct thing.
 
43
        """
 
44
 
 
45
        b = Branch.initialize('.')
 
46
 
 
47
        b.commit('Commit one', rev_id='a@r-0-1')
 
48
        b.commit('Commit two', rev_id='a@r-0-2')
 
49
        b.commit('Commit three', rev_id='a@r-0-3')
 
50
 
 
51
        # Make sure revision-info without any arguments throws an exception
 
52
        self.check_error('bzr: ERROR: You must supply a revision identifier\n',
 
53
                         'revision-info')
 
54
 
 
55
        values = {
 
56
            1:'   1 a@r-0-1\n',
 
57
            2:'   2 a@r-0-2\n',
 
58
            3:'   3 a@r-0-3\n'
 
59
        }
 
60
 
 
61
        # Check the results of just specifying a numeric revision
 
62
        self.check_output(values[1], 'revision-info', '1')
 
63
        self.check_output(values[2], 'revision-info', '2')
 
64
        self.check_output(values[3], 'revision-info', '3')
 
65
        self.check_output(values[1]+values[2], 'revision-info', '1', '2')
 
66
        self.check_output(values[1]+values[2]+values[3], 'revision-info', '1', '2', '3')
 
67
        self.check_output(values[2]+values[1], 'revision-info', '2', '1')
 
68
 
 
69
        # Check as above, only using the '--revision' syntax
 
70
        
 
71
        self.check_output('   1 a@r-0-1\n', 'revision-info', '-r', '1')
 
72
        self.check_output('   2 a@r-0-2\n', 'revision-info', '--revision', '2')
 
73
        self.check_output('   3 a@r-0-3\n', 'revision-info', '-r', '3')
 
74
        self.check_output('   1 a@r-0-1\n   2 a@r-0-2\n', 'revision-info', '-r', '1..2')
 
75
        self.check_output('   1 a@r-0-1\n   2 a@r-0-2\n   3 a@r-0-3\n'
 
76
                , 'revision-info', '-r', '1..2..3')
 
77
        self.check_output('   2 a@r-0-2\n   1 a@r-0-1\n', 'revision-info', '-r', '2..1')
 
78
 
 
79
        # Now try some more advanced revision specifications
 
80
        
 
81
        self.check_output('   1 a@r-0-1\n', 'revision-info', '-r', 'revid:a@r-0-1')
 
82
        self.check_output('   2 a@r-0-2\n', 'revision-info', '--revision', 'revid:a@r-0-2')
 
83
 
 
84
    def test_cat_revision(self):
 
85
        """Test bzr cat-revision.
 
86
        """
 
87
        b = Branch.initialize('.')
 
88
 
 
89
        b.commit('Commit one', rev_id='a@r-0-1')
 
90
        b.commit('Commit two', rev_id='a@r-0-2')
 
91
        b.commit('Commit three', rev_id='a@r-0-3')
 
92
 
 
93
        revs = {
 
94
            1:b.get_revision_xml_file('a@r-0-1').read(),
 
95
            2:b.get_revision_xml_file('a@r-0-2').read(),
 
96
            3:b.get_revision_xml_file('a@r-0-3').read()
 
97
        }
 
98
 
 
99
        self.check_output(revs[1], 'cat-revision', 'a@r-0-1')
 
100
        self.check_output(revs[2], 'cat-revision', 'a@r-0-2')
 
101
        self.check_output(revs[3], 'cat-revision', 'a@r-0-3')
 
102
 
 
103
        self.check_output(revs[1], 'cat-revision', '-r', '1')
 
104
        self.check_output(revs[2], 'cat-revision', '-r', '2')
 
105
        self.check_output(revs[3], 'cat-revision', '-r', '3')
 
106
 
 
107
        self.check_output(revs[1], 'cat-revision', '-r', 'revid:a@r-0-1')
 
108
        self.check_output(revs[2], 'cat-revision', '-r', 'revid:a@r-0-2')
 
109
        self.check_output(revs[3], 'cat-revision', '-r', 'revid:a@r-0-3')
 
110