~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Lalo Martins
  • Date: 2005-09-09 10:58:51 UTC
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050909105851-25aa36ea27f4ce7b
creating the new branch constructors

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
# repeatedly to calculate deltas.  We could perhaps have a weakref
44
44
# cache in memory to make this faster.
45
45
 
46
 
# TODO: please move the revision-string syntax stuff out of the branch
47
 
# object; it's clutter
48
 
 
49
 
 
50
 
def find_branch(f, **args):
51
 
    if f and (f.startswith('http://') or f.startswith('https://')):
52
 
        from bzrlib.remotebranch import RemoteBranch
53
 
        return RemoteBranch(f, **args)
54
 
    else:
55
 
        return LocalBranch(f, **args)
 
46
 
 
47
def find_branch(base, init=False, find_root=True):
 
48
    if init:
 
49
        return Branch.initialize(base)
 
50
    if find_root:
 
51
        return Branch.open_containing(base)
 
52
    return Branch.open(base)
56
53
 
57
54
 
58
55
def find_cached_branch(f, cache_root, **args):
154
151
        b = object.__new__(cls)
155
152
        return b
156
153
 
 
154
    @staticmethod
 
155
    def open(base):
 
156
        """Open an existing branch, rooted at 'base' (url)"""
 
157
        if base and (base.startswith('http://') or base.startswith('https://')):
 
158
            from bzrlib.remotebranch import RemoteBranch
 
159
            return RemoteBranch(base, find_root=False)
 
160
        else:
 
161
            return LocalBranch(base, find_root=False)
 
162
 
 
163
    @staticmethod
 
164
    def open_containing(url):
 
165
        """Open an existing branch, containing url (search upwards for the root)
 
166
        """
 
167
        if url and (url.startswith('http://') or url.startswith('https://')):
 
168
            from bzrlib.remotebranch import RemoteBranch
 
169
            return RemoteBranch(url)
 
170
        else:
 
171
            return LocalBranch(url)
 
172
 
 
173
    @staticmethod
 
174
    def initialize(base):
 
175
        """Create a new branch, rooted at 'base' (url)"""
 
176
        if base and (base.startswith('http://') or base.startswith('https://')):
 
177
            from bzrlib.remotebranch import RemoteBranch
 
178
            return RemoteBranch(base, init=True)
 
179
        else:
 
180
            return LocalBranch(base, init=True)
 
181
 
157
182
 
158
183
class LocalBranch(Branch):
159
184
    """A branch stored in the actual filesystem.