/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-30 13:04:15 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060930130415-aba4100709e11f0a
Loads of fixes. Pyflakes cleanup.

Show diffs side-by-side

added added

removed removed

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