[Pkg-bazaar-commits] ./bzr/unstable r416: - bzr log and bzr root now accept an http URL
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 07:43:39 UTC 2009
------------------------------------------------------------
revno: 416
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-05-09 18:27:49 +1000
message:
- bzr log and bzr root now accept an http URL
- new RemoteBranch.relpath()
- new find_branch factory method
modified:
NEWS
bzrlib/branch.py
bzrlib/commands.py
bzrlib/remotebranch.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2005-05-09 04:50:11 +0000
+++ b/NEWS 2005-05-09 08:27:49 +0000
@@ -27,6 +27,9 @@
* New syntax ``bzr status [FILE...]`` contributed by Bartosz Oler.
+ * ``bzr log`` and ``bzr root`` can be given an http URL instead of
+ a filename.
+
TESTING:
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-05-09 03:11:21 +0000
+++ b/bzrlib/branch.py 2005-05-09 08:27:49 +0000
@@ -40,9 +40,19 @@
+def find_branch(f, **args):
+ if f.startswith('http://') or f.startswith('https://'):
+ import remotebranch
+ return remotebranch.RemoteBranch(f, **args)
+ else:
+ return Branch(f, **args)
+
+
def find_branch_root(f=None):
"""Find the branch root enclosing f, or pwd.
+ f may be a filename or a URL.
+
It is not necessary that f exists.
Basically we keep looking up until we find the control directory or
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-05-09 04:59:00 +0000
+++ b/bzrlib/commands.py 2005-05-09 08:27:49 +0000
@@ -409,8 +409,9 @@
takes_args = ['filename?']
def run(self, filename=None):
"""Print the branch root."""
- print bzrlib.branch.find_branch_root(filename)
-
+ from branch import find_branch
+ b = find_branch(filename)
+ print getattr(b, 'base', None) or getattr(b, 'baseurl')
class cmd_log(Command):
@@ -423,7 +424,8 @@
takes_args = ['filename?']
takes_options = ['timezone', 'verbose', 'show-ids']
def run(self, filename=None, timezone='original', verbose=False, show_ids=False):
- b = Branch((filename or '.'), lock_mode='r')
+ from branch import find_branch
+ b = find_branch((filename or '.'), lock_mode='r')
if filename:
filename = b.relpath(filename)
bzrlib.show_log(b, filename,
=== modified file 'bzrlib/remotebranch.py'
--- a/bzrlib/remotebranch.py 2005-05-09 06:09:42 +0000
+++ b/bzrlib/remotebranch.py 2005-05-09 08:27:49 +0000
@@ -67,9 +67,34 @@
raise BzrError("remote fetch failed: %r: %s" % (url, e))
+
+def _find_remote_root(url):
+ """Return the prefix URL that corresponds to the branch root."""
+ orig_url = url
+ while True:
+ try:
+ ff = get_url(url + '/.bzr/branch-format')
+ ff.close()
+ return url
+ except urllib.URLError:
+ pass
+
+ try:
+ idx = url.rindex('/')
+ except ValueError:
+ raise BzrError('no branch root found for URL %s' % orig_url)
+
+ url = url[:idx]
+
+
+
class RemoteBranch(Branch):
- def __init__(self, baseurl):
+ def __init__(self, baseurl, find_root=False, lock_mode='r'):
"""Create new proxy for a remote branch."""
+ if lock_mode not in ('', 'r'):
+ raise BzrError('lock mode %r is not supported for remote branches'
+ % lock_mode)
+
self.baseurl = baseurl
self._check_format()
@@ -85,6 +110,13 @@
def _need_writelock(self):
raise BzrError("cannot get write lock on HTTP remote branch")
+ def relpath(self, path):
+ if not path.startswith(self.baseurl):
+ raise BzrError('path %r is not under base URL %r'
+ % (path, self.baseurl))
+ pl = len(self.baseurl)
+ return path[pl:].lstrip('/')
+
def get_revision(self, revision_id):
from revision import Revision
revf = get_url(self.baseurl + '/.bzr/revision-store/' + revision_id,
More information about the Pkg-bazaar-commits
mailing list