/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 olive/info_helper.py

  • Committer: Jasper Groenewegen
  • Date: 2008-07-27 12:01:40 UTC
  • mfrom: (576.3.2 improve-merge)
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: colbrac@xs4all.nl-20080727120140-1agdlzkc9fumjk5f
Merge merge dialog improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
import time
 
20
import sys
20
21
 
21
22
import bzrlib
22
23
 
23
 
import bzrlib.osutils as osutils
 
24
from bzrlib import (
 
25
    bzrdir,
 
26
    diff,
 
27
    errors,
 
28
    osutils,
 
29
    urlutils,
 
30
    )
24
31
 
25
 
from bzrlib.info import _repo_rel_url
 
32
from bzrlib.diff import show_diff_trees
26
33
from bzrlib.missing import find_unmerged
 
34
    
 
35
def _repo_rel_url(repo_url, inner_url):
 
36
    """Return path with common prefix of repository path removed.
 
37
 
 
38
    If path is not part of the repository, the original path is returned.
 
39
    If path is equal to the repository, the current directory marker '.' is
 
40
    returned.
 
41
    Otherwise, a relative path is returned, with trailing '/' stripped.
 
42
    """
 
43
    inner_url = urlutils.normalize_url(inner_url)
 
44
    repo_url = urlutils.normalize_url(repo_url)
 
45
    if inner_url == repo_url:
 
46
        return '.'
 
47
    result = urlutils.relative_url(repo_url, inner_url)
 
48
    if result != inner_url:
 
49
        result = result.rstrip('/')
 
50
    return result
27
51
 
28
52
def get_location_info(repository, branch=None, working=None):
29
53
    """ Get known locations for working, branch and repository.
163
187
    ret = {}
164
188
    branch = working.branch
165
189
    basis = working.basis_tree()
166
 
    work_inv = working.inventory
167
 
    
 
190
 
168
191
    if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
169
192
        delta = compare_trees(basis, working, want_unchanged=True)
170
193
    else:
192
215
    
193
216
    ret = {}
194
217
    basis = working.basis_tree()
195
 
    work_inv = working.inventory
196
 
    
 
218
 
197
219
    if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
198
220
        delta = compare_trees(basis, working, want_unchanged=True)
199
221
    else:
215
237
    ret['ignored'] = ignore_cnt
216
238
 
217
239
    dir_cnt = 0
218
 
    for file_id in work_inv:
219
 
        if work_inv.get_file_kind(file_id) == 'directory':
 
240
    for path, ie in working.iter_entries_by_dir():
 
241
        if ie.kind == 'directory':
220
242
            dir_cnt += 1
221
243
    ret['subdirs'] = dir_cnt
222
244
 
240
262
    if revno > 0:
241
263
        firstrev = repository.get_revision(history[0])
242
264
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
243
 
        ret['age'] = age
 
265
        ret['age'] = '%d days'%age
244
266
        ret['firstrev'] = osutils.format_date(firstrev.timestamp,
245
267
                                              firstrev.timezone)
246
268
 
259
281
    if repository.bzrdir.root_transport.listable():
260
282
        c, t = repository._revision_store.total_size(repository.get_transaction())
261
283
        ret['revisions'] = c
262
 
        ret['size'] = t
 
284
        ret['size'] = '%d KiB'%t
263
285
 
264
286
    return ret
265
287
 
278
300
 
279
301
    :param new_revision_spec:  if None, use working tree as new revision, otherwise use the tree for the specified revision.
280
302
    """
281
 
    import sys
282
 
    
283
 
    from bzrlib.diff import show_diff_trees
284
303
    
285
304
    if output == None:
286
305
        output = sys.stdout
287
306
    
288
 
    def spec_tree(spec):
289
 
        revision_id = spec.in_store(tree.branch).rev_id
290
 
        return tree.branch.repository.revision_tree(revision_id)
291
 
    
292
307
    if old_revision_spec is None:
293
308
        old_tree = tree.basis_tree()
294
309
    else:
302
317
    return show_diff_trees(old_tree, new_tree, output, specific_files,
303
318
                           external_diff_options,
304
319
                           old_label=old_label, new_label=new_label)
 
320
 
 
321
def spec_tree(spec):
 
322
        revision_id = spec.in_store(tree.branch).rev_id
 
323
        return tree.branch.repository.revision_tree(revision_id)