~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Martin Pool
  • Date: 2006-12-21 03:59:43 UTC
  • mfrom: (2206 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2207.
  • Revision ID: mbp@sourcefrog.net-20061221035943-2qazd36lrxms0bug
merge bzr.dev, reconcile with option changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import time
20
20
 
21
21
 
22
 
import bzrlib.diff as diff
 
22
from bzrlib import (
 
23
    diff,
 
24
    osutils,
 
25
    urlutils,
 
26
    )
23
27
from bzrlib.errors import (NoWorkingTree, NotBranchError,
24
28
                           NoRepositoryPresent, NotLocalUrl)
25
29
from bzrlib.missing import find_unmerged
26
 
import bzrlib.osutils as osutils
27
30
from bzrlib.symbol_versioning import (deprecated_function, 
28
31
        zero_eight)
29
32
 
37
40
        return 's'
38
41
 
39
42
 
40
 
def _repo_relpath(repo_path, path):
 
43
def _repo_rel_url(repo_url, inner_url):
41
44
    """Return path with common prefix of repository path removed.
42
45
 
43
46
    If path is not part of the repository, the original path is returned.
44
47
    If path is equal to the repository, the current directory marker '.' is
45
48
    returned.
 
49
    Otherwise, a relative path is returned, with trailing '/' stripped.
46
50
    """
47
 
    path = osutils.normalizepath(path)
48
 
    repo_path = osutils.normalizepath(repo_path)
49
 
    if path == repo_path:
 
51
    inner_url = urlutils.normalize_url(inner_url)
 
52
    repo_url = urlutils.normalize_url(repo_url)
 
53
    if inner_url == repo_url:
50
54
        return '.'
51
 
    if osutils.is_inside(repo_path, path):
52
 
        return osutils.relpath(repo_path, path)
53
 
    return path
 
55
    result = urlutils.relative_url(repo_url, inner_url)
 
56
    if result != inner_url:
 
57
        result = result.rstrip('/')
 
58
    return result
54
59
 
55
60
 
56
61
def _show_location_info(repository, branch=None, working=None):
67
72
                # lightweight checkout of branch in shared repository
68
73
                print '   shared repository: %s' % repository_path
69
74
                print '   repository branch: %s' % (
70
 
                    _repo_relpath(repository_path, branch_path))
 
75
                    _repo_rel_url(repository_path, branch_path))
71
76
            else:
72
77
                # lightweight checkout of standalone branch
73
78
                print '  checkout of branch: %s' % branch_path
75
80
            # branch with tree inside shared repository
76
81
            print '    shared repository: %s' % repository_path
77
82
            print '  repository checkout: %s' % (
78
 
                _repo_relpath(repository_path, branch_path))
 
83
                _repo_rel_url(repository_path, branch_path))
79
84
        elif branch.get_bound_location():
80
85
            # normal checkout
81
86
            print '       checkout root: %s' % working_path
89
94
            # branch is part of shared repository
90
95
            print '  shared repository: %s' % repository_path
91
96
            print '  repository branch: %s' % (
92
 
                _repo_relpath(repository_path, branch_path))
 
97
                _repo_rel_url(repository_path, branch_path))
93
98
        else:
94
99
            # standalone branch
95
100
            print '  branch root: %s' % branch_path