/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: Jelmer Vernooij
  • Date: 2008-06-29 19:07:23 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629190723-l8mzg9x4oec0lhsl
Return cleartext from seahorse module

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib
22
22
 
23
 
import bzrlib.osutils as osutils
 
23
from bzrlib import (
 
24
    bzrdir,
 
25
    diff,
 
26
    errors,
 
27
    osutils,
 
28
    urlutils,
 
29
    )
24
30
 
25
 
from bzrlib.info import _repo_relpath
26
31
from bzrlib.missing import find_unmerged
27
32
 
 
33
def _repo_rel_url(repo_url, inner_url):
 
34
    """Return path with common prefix of repository path removed.
 
35
 
 
36
    If path is not part of the repository, the original path is returned.
 
37
    If path is equal to the repository, the current directory marker '.' is
 
38
    returned.
 
39
    Otherwise, a relative path is returned, with trailing '/' stripped.
 
40
    """
 
41
    inner_url = urlutils.normalize_url(inner_url)
 
42
    repo_url = urlutils.normalize_url(repo_url)
 
43
    if inner_url == repo_url:
 
44
        return '.'
 
45
    result = urlutils.relative_url(repo_url, inner_url)
 
46
    if result != inner_url:
 
47
        result = result.rstrip('/')
 
48
    return result
 
49
 
28
50
def get_location_info(repository, branch=None, working=None):
29
51
    """ Get known locations for working, branch and repository.
30
52
    
41
63
            if repository.is_shared():
42
64
                # lightweight checkout of branch in shared repository
43
65
                ret['sharedrepo'] = repository_path
44
 
                ret['repobranch'] = _repo_relpath(repository_path, branch_path)
 
66
                ret['repobranch'] = _repo_rel_url(repository_path, branch_path)
45
67
            else:
46
68
                # lightweight checkout of standalone branch
47
69
                ret['cobranch'] = branch_path
48
70
        elif repository.is_shared():
49
71
            # branch with tree inside shared repository
50
72
            ret['sharedrepo'] = repository_path
51
 
            ret['repoco'] = _repo_relpath(repository_path, branch_path)
 
73
            ret['repoco'] = _repo_rel_url(repository_path, branch_path)
52
74
        elif branch.get_bound_location():
53
75
            # normal checkout
54
76
            ret['coroot'] = working_path
61
83
        if repository.is_shared():
62
84
            # branch is part of shared repository
63
85
            ret['sharedrepo'] = repository_path
64
 
            ret['repobranch'] = _repo_relpath(repository_path, branch_path)
 
86
            ret['repobranch'] = _repo_rel_url(repository_path, branch_path)
65
87
        else:
66
88
            # standalone branch
67
89
            ret['branchroot'] = branch_path
163
185
    ret = {}
164
186
    branch = working.branch
165
187
    basis = working.basis_tree()
166
 
    work_inv = working.inventory
167
 
    
 
188
 
168
189
    if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
169
190
        delta = compare_trees(basis, working, want_unchanged=True)
170
191
    else:
192
213
    
193
214
    ret = {}
194
215
    basis = working.basis_tree()
195
 
    work_inv = working.inventory
196
 
    
 
216
 
197
217
    if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
198
218
        delta = compare_trees(basis, working, want_unchanged=True)
199
219
    else:
215
235
    ret['ignored'] = ignore_cnt
216
236
 
217
237
    dir_cnt = 0
218
 
    for file_id in work_inv:
219
 
        if work_inv.get_file_kind(file_id) == 'directory':
 
238
    for path, ie in working.iter_entries_by_dir():
 
239
        if ie.kind == 'directory':
220
240
            dir_cnt += 1
221
241
    ret['subdirs'] = dir_cnt
222
242