/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to backend/info.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-08 17:36:59 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060708173659-8ab442681dadd8ea
2006-07-08  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * backend/errors.py: added some exceptions related to diff() and log()
    * backend/info.py: implemented log()
    * backend/info.py: diff() works well with revnos
    * added e-mail address to copyright header

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
2
# Some parts of the code are:
3
3
# Copyright (C) 2005, 2006 by Canonical Ltd
4
 
#
 
4
 
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
#
 
9
 
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
14
 
#
 
14
 
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
20
import bzrlib.errors as errors
21
21
 
22
22
from bzrlib.branch import Branch
23
 
from bzrlib.workingtree import WorkingTree
24
23
 
25
 
from errors import (DifferentBranchesError, NotBranchError, PermissionDenied,
26
 
                    PrefixFormatError, RevisionValueError)
 
24
from errors import (DifferentBranchesError, NotBranchError, PrefixFormatError,
 
25
                    RevisionValueError)
27
26
 
28
27
def diff(revision=None, file_list=None, diff_options=None, prefix=None):
29
28
    """ Save the diff into a temporary file.
118
117
    else:
119
118
        return tmpfile[1]
120
119
 
121
 
def get_push_location(location):
122
 
    """ Get the stored push location of a branch.
123
 
    
124
 
    :param location: the path to the branch
125
 
    
126
 
    :return: the stored location
127
 
    """
128
 
    from bzrlib.branch import Branch
129
 
    
130
 
    try:
131
 
        branch = Branch.open_containing(location)[0]
132
 
    except errors.NotBranchError:
133
 
        raise NotBranchError(location)
134
 
    except:
135
 
        raise
136
 
    
137
 
    return branch.get_push_location()
138
 
 
139
120
def info(location):
140
121
    """ Get info about branch, working tree, and repository
141
122
    
160
141
    ret['locking']['workingtree']: Working tree lock status
161
142
    ret['locking']['branch']: Branch lock status
162
143
    ret['locking']['repository']: Repository lock status
163
 
    ret['missing']['branch']: Missing revisions in branch
164
 
    ret['missing']['workingtree']: Missing revisions in working tree
 
144
    ret['mrevbranch']['missing']: Missing revisions in branch
 
145
    ret['mrevworking']['missing']: Missing revisions in working tree
165
146
    ret['wtstats']['unchanged']: Unchanged files
166
147
    ret['wtstats']['modified']: Modified files
167
148
    ret['wtstats']['added']: Added files
183
164
    import info_helper
184
165
    
185
166
    ret = {}
186
 
    try:
187
 
        a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
188
 
    except errors.NotBranchError:
189
 
        raise NotBranchError(location)
190
 
 
 
167
    a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
191
168
    try:
192
169
        working = a_bzrdir.open_workingtree()
193
170
        working.lock_read()
195
172
            branch = working.branch
196
173
            repository = branch.repository
197
174
            control = working.bzrdir
198
 
            
 
175
 
199
176
            ret['location'] = info_helper.get_location_info(repository, branch, working)
200
177
            ret['related'] = info_helper.get_related_info(branch)
201
178
            ret['format'] = info_helper.get_format_info(control, repository, branch, working)
202
179
            ret['locking'] = info_helper.get_locking_info(repository, branch, working)
203
 
            ret['missing'] = {}
204
 
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
205
 
            ret['missing']['workingtree'] = info_helper.get_missing_revisions_working(working)
 
180
            ret['mrevbranch'] = info_helper.get_missing_revisions_branch(branch)
 
181
            ret['mrevworking'] = info_helper.get_missing_revisions_working(working)
206
182
            ret['wtstats'] = info_helper.get_working_stats(working)
207
183
            ret['brstats'] = info_helper.get_branch_stats(branch)
208
184
            ret['repstats'] = info_helper.get_repository_stats(repository)
221
197
            ret['related'] = info_helper.get_related_info(branch)
222
198
            ret['format'] = info_helper.get_format_info(control, repository, branch)
223
199
            ret['locking'] = info_helper.get_locking_info(repository, branch)
224
 
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
200
            ret['mrevbranch'] = info_helper.get_missing_revisions_branch(branch)
225
201
            ret['brstats'] = info_helper.get_branch_stats(branch)
226
202
            ret['repstats'] = info_helper.get_repository_stats(repository)
227
203
        finally:
246
222
    except errors.NoRepositoryPresent:
247
223
        pass
248
224
 
249
 
def is_branch(location):
250
 
    """ Check if the location is a branch.
251
 
    
252
 
    :param location: the location you want to check
253
 
    
254
 
    :return: True or False respectively
255
 
    """
256
 
    try:
257
 
        branch = Branch.open_containing(location)[0]
258
 
    except errors.NotBranchError:
259
 
        return False
260
 
    except errors.PermissionDenied:
261
 
        raise PermissionDenied(location)
262
 
    else:
263
 
        return True
264
 
        
265
 
 
266
 
def is_checkout(location):
267
 
    """ Check if the location is a checkout.
268
 
    
269
 
    :param location: the location you want to check
270
 
    
271
 
    :return: True or False respectively
272
 
    """
273
 
    try:
274
 
        branch = Branch.open_containing(location)[0]
275
 
    except errors.NotBranchError:
276
 
        raise NotBranchError
277
 
    
278
 
    try:
279
 
        working = WorkingTree.open_containing(location)[0]
280
 
    except:
281
 
        raise
282
 
    
283
 
    working_path = working.bzrdir.root_transport.base
284
 
    branch_path = branch.bzrdir.root_transport.base
285
 
    
286
 
    if working_path != branch_path:
287
 
        # lightweight checkout
288
 
        return True
289
 
    elif branch.get_bound_location():
290
 
        # checkout
291
 
        return True
292
 
    else:
293
 
        return False
294
 
 
295
225
def log(location, timezone='original', verbose=False, show_ids=False,
296
226
        forward=False, revision=None, log_format=None, message=None,
297
227
        long=False, short=False, line=False):