Rev 62: Fix bug #423331 by adding a way to configure the path used to in http://bazaar.launchpad.net/~bzr-upload-devs/bzr-upload/trunk
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Sep 2 23:31:09 BST 2009
At http://bazaar.launchpad.net/~bzr-upload-devs/bzr-upload/trunk
------------------------------------------------------------
revno: 62
revision-id: v.ladeuil+lp at free.fr-20090902223106-u93g8rhrh3fexczr
parent: v.ladeuil+lp at free.fr-20090902170527-cdn8mcnhvk5gd6rl
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Thu 2009-09-03 00:31:06 +0200
message:
Fix bug #423331 by adding a way to configure the path used to
store the revid.
* tests/test_upload.py:
(TestUploadMixin.test_upload_revid_path_in_dir): Smoke test that
we can force a different path.
(TestFullUpload.test_full_upload_empty_tree,
TestIncrementalUpload.test_upload_for_the_first_time_do_a_full_upload):
Update references to the revid path.
* __init__.py:
(get_upload_revid_location, set_upload_revid_location): New config
variable.
(BzrUploader.set_uploaded_revid, BzrUploader.get_uploaded_revid):
Use the config variable defining the path.
* README:
Document the .bzr-upload.revid file and upload_revid_location
configuration variable.
-------------- next part --------------
=== modified file 'README'
--- a/README 2009-09-02 17:05:27 +0000
+++ b/README 2009-09-02 22:31:06 +0000
@@ -28,8 +28,9 @@
bzr upload sftp://user@host/location/on/webserver
This will initially upload the whole working tree, and leave a file on the
-remote location indicating the last revision that was uploaded, in order to
-avoid uploading unnecessary information the next time.
+remote location indicating the last revision that was uploaded
+(.bzr-upload.revid), in order to avoid uploading unnecessary information
+the next time.
If you would like to upload a specific revision, you just do:
@@ -43,6 +44,25 @@
bzr upload --full sftp://user@host/location/on/webserver
+If the layout of your remote server is such that you can't write in the
+root directory but only in the directories inside that root, you will need
+to use the 'upload_revid_location' configuration variable to specify the
+relative path to be used. That configuration variable can be specified in
+locations.conf or branch.conf.
+
+For example, given the following layout:
+
+ Project/
+ private/
+ public/
+
+you may have write access in 'private' and 'public' but in 'Project'
+itself. In that case, you can add the following in your locations.conf or
+branch.conf file:
+
+ upload_revid_location = private/.bzr-upload.revid
+
+
Automatically Uploading
-----------------------
=== modified file '__init__.py'
--- a/__init__.py 2009-09-02 17:05:27 +0000
+++ b/__init__.py 2009-09-02 22:31:06 +0000
@@ -79,6 +79,19 @@
_set_branch_option(branch, 'upload_location', location)
+# FIXME: Add more tests around invalid paths used here or relative paths that
+# doesn't exist on remote (if only to get proper error messages)
+def get_upload_revid_location(branch):
+ loc = _get_branch_option(branch, 'upload_revid_location')
+ if loc is None:
+ loc = '.bzr-upload.revid'
+ return loc
+
+
+def set_upload_revid_location(branch, location):
+ _set_branch_option(branch, 'upload_revid_location', location)
+
+
def get_upload_auto(branch):
auto = branch.get_config().get_user_option_as_bool('upload_auto')
if auto is None:
@@ -110,7 +123,7 @@
class BzrUploader(object):
def __init__(self, branch, to_transport, outf, tree, rev_id,
- quiet=False):
+ quiet=False):
self.branch = branch
self.to_transport = to_transport
self.outf = outf
@@ -120,14 +133,14 @@
self._pending_deletions = []
self._pending_renames = []
- bzr_upload_revid_file_name = '.bzr-upload.revid'
-
def set_uploaded_revid(self, rev_id):
# XXX: Add tests for concurrent updates, etc.
- self.to_transport.put_bytes(self.bzr_upload_revid_file_name, rev_id)
+ revid_path = get_upload_revid_location(self.branch)
+ self.to_transport.put_bytes(revid_path, rev_id)
def get_uploaded_revid(self):
- return self.to_transport.get_bytes(self.bzr_upload_revid_file_name)
+ revid_path = get_upload_revid_location(self.branch)
+ return self.to_transport.get_bytes(revid_path)
def upload_file(self, relpath, id, mode=None):
if mode is None:
@@ -429,7 +442,7 @@
tree = branch.repository.revision_tree(rev_id)
uploader = BzrUploader(branch, to_transport, self.outf, tree,
- rev_id, quiet=quiet)
+ rev_id, quiet=quiet)
if full:
uploader.upload_full_tree()
=== modified file 'tests/test_upload.py'
--- a/tests/test_upload.py 2009-07-10 12:45:57 +0000
+++ b/tests/test_upload.py 2009-09-02 22:31:06 +0000
@@ -38,9 +38,9 @@
)
+from bzrlib.plugins import upload
from bzrlib.plugins.upload import (
cmd_upload,
- BzrUploader,
get_upload_auto,
CannotUploadToWorkingTreeError,
)
@@ -426,6 +426,25 @@
self.tree.commit("Add directory")
self.do_full_upload(directory='branch/foo')
+ def test_upload_revid_path_in_dir(self):
+ self.make_branch_and_working_tree()
+ self.add_dir('dir')
+ self.add_file('dir/goodbye', 'baz')
+
+ revid_path = 'dir/revid-path'
+ upload.set_upload_revid_location(self.tree.branch, revid_path)
+ self.failIfUpFileExists(revid_path)
+
+ self.do_full_upload()
+
+ self.add_file('dir/hello', 'foo')
+
+ self.do_upload()
+
+ self.failUnlessUpFileExists(revid_path)
+ self.assertUpFileEqual('baz', 'dir/goodbye')
+ self.assertUpFileEqual('foo', 'dir/hello')
+
class TestFullUpload(tests.TestCaseWithTransport, TestUploadMixin):
@@ -436,7 +455,8 @@
self.do_full_upload()
- self.failUnlessUpFileExists(BzrUploader.bzr_upload_revid_file_name)
+ revid_path = upload.get_upload_revid_location(self.tree.branch)
+ self.failUnlessUpFileExists(revid_path)
def test_invalid_revspec(self):
self.make_branch_and_working_tree()
@@ -532,7 +552,8 @@
self.make_branch_and_working_tree()
self.add_file('hello', 'bar')
- self.failIfUpFileExists(BzrUploader.bzr_upload_revid_file_name)
+ revid_path = upload.get_upload_revid_location(self.tree.branch)
+ self.failIfUpFileExists(revid_path)
self.do_upload()
More information about the bazaar-commits
mailing list