44
def _get_branch_option(branch, option):
45
return branch.get_config().get_user_option(option)
47
# FIXME: Get rid of that as soon as we depend on a bzr API that includes
48
# get_user_option_as_bool
49
def _get_branch_bool_option(branch, option):
50
conf = branch.get_config()
51
if hasattr(conf, 'get_user_option_as_bool'):
52
value = conf.get_user_option_as_bool(option)
54
value = conf.get_user_option(option)
56
if value.lower().strip() == 'true':
62
def _set_branch_option(branch, option, value):
63
branch.get_config().set_user_option(option, value)
66
def get_upload_location(branch):
67
return _get_branch_option(branch, 'upload_location')
70
def set_upload_location(branch, location):
71
_set_branch_option(branch, 'upload_location', location)
74
# FIXME: Add more tests around invalid paths used here or relative paths that
75
# doesn't exist on remote (if only to get proper error messages)
76
def get_upload_revid_location(branch):
77
loc = _get_branch_option(branch, 'upload_revid_location')
79
loc = '.bzr-upload.revid'
83
def set_upload_revid_location(branch, location):
84
_set_branch_option(branch, 'upload_revid_location', location)
87
def get_upload_auto(branch):
88
auto = _get_branch_bool_option(branch, 'upload_auto')
90
auto = False # Default to False if not specified
94
def set_upload_auto(branch, auto):
95
# FIXME: What's the point in allowing a boolean here instead of requiring
96
# the callers to use strings instead ?
101
_set_branch_option(branch, 'upload_auto', auto_str)
104
def get_upload_auto_quiet(branch):
105
quiet = _get_branch_bool_option(branch, 'upload_auto_quiet')
107
quiet = False # Default to False if not specified
111
def set_upload_auto_quiet(branch, quiet):
112
_set_branch_option(branch, 'upload_auto_quiet', quiet)
45
auto_option = config.Option(
46
'upload_auto', default=False, from_unicode=config.bool_from_store,
48
Whether upload should occur when the tip of the branch changes.
50
auto_quiet_option = config.Option(
51
'upload_auto_quiet', default=False, from_unicode=config.bool_from_store,
53
Whether upload should occur quietly.
55
location_option = config.Option(
56
'upload_location', default=None,
58
The url to upload the working tree to.
60
revid_location_option = config.Option(
61
'upload_revid_location', default=u'.bzr-upload.revid',
63
The relative path to be used to store the uploaded revid.
65
The only bzr-related info uploaded with the working tree is the corresponding
66
revision id. The uploaded working tree is not linked to any other bzr data.
68
If the layout of your remote server is such that you can't write in the
69
root directory but only in the directories inside that root, you will need
70
to use the 'upload_revid_location' configuration variable to specify the
71
relative path to be used. That configuration variable can be specified in
72
locations.conf or branch.conf.
74
For example, given the following layout:
80
you may have write access in 'private' and 'public' but in 'Project'
81
itself. In that case, you can add the following in your locations.conf or
84
upload_revid_location = private/.bzr-upload.revid
88
# FIXME: Add more tests around invalid paths or relative paths that doesn't
89
# exist on remote (if only to get proper error messages) for
90
# 'upload_revid_location'
115
93
class BzrUploader(object):
155
133
def set_uploaded_revid(self, rev_id):
156
134
# XXX: Add tests for concurrent updates, etc.
157
revid_path = get_upload_revid_location(self.branch)
135
revid_path = self.branch.get_config_stack().get('upload_revid_location')
158
136
self.to_transport.put_bytes(urlutils.escape(revid_path), rev_id)
159
137
self._uploaded_revid = rev_id
161
139
def get_uploaded_revid(self):
162
140
if self._uploaded_revid is None:
163
revid_path = get_upload_revid_location(self.branch)
141
revid_path = self.branch.get_config_stack(
142
).get('upload_revid_location')
165
144
self._uploaded_revid = self._up_get_bytes(revid_path)
166
145
except errors.NoSuchFile:
167
# We have not upload to here.
146
# We have not uploaded to here.
168
147
self._uploaded_revid = revision.NULL_REVISION
169
148
return self._uploaded_revid