~bzr-upload-devs/bzr-upload/trunk

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-15 20:53:45 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20120315205345-6ilssa714tfcrntk
Migrate to config stacks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
152
152
# scary for the user when we say 'Deleting <path>' and are referring to
153
153
# remote files...
154
154
 
 
155
 
155
156
import bzrlib
156
 
import bzrlib.api
157
 
 
158
157
from bzrlib import (
 
158
    api,
159
159
    branch,
 
160
    commands,
 
161
    config,
160
162
    )
161
163
 
162
164
from info import (
170
172
    version_string = '%d.%d.%d%s%d' % version_info
171
173
__version__ = version_string
172
174
 
173
 
bzrlib.api.require_any_api(bzrlib, bzr_compatible_versions)
174
 
 
175
 
from bzrlib.commands import plugin_cmds
176
 
 
177
 
plugin_cmds.register_lazy('cmd_upload', [], 'bzrlib.plugins.upload.cmds')
 
175
api.require_any_api(bzrlib, bzr_compatible_versions)
 
176
 
 
177
 
 
178
def register_lazy_option(key, member):
 
179
    config.option_registry.register_lazy(
 
180
        key, 'bzrlib.plugins.upload.cmds', member)
 
181
 
 
182
 
 
183
register_lazy_option('upload_auto', 'auto_option')
 
184
register_lazy_option('upload_auto_quiet', 'auto_quiet_option')
 
185
register_lazy_option('upload_location', 'location_option')
 
186
register_lazy_option('upload_revid_location', 'revid_location_option')
 
187
 
 
188
 
 
189
commands.plugin_cmds.register_lazy(
 
190
    'cmd_upload', [], 'bzrlib.plugins.upload.cmds')
 
191
 
178
192
 
179
193
def auto_upload_hook(params):
180
194
    from bzrlib import (
185
199
        )
186
200
    from bzrlib.plugins.upload.cmds import (
187
201
        BzrUploader,
188
 
        get_upload_location,
189
 
        get_upload_auto,
190
 
        get_upload_auto_quiet,
191
202
        )
192
203
    import sys
193
204
    source_branch = params.branch
194
 
    destination = get_upload_location(source_branch)
 
205
    conf = source_branch.get_config_stack()
 
206
    destination = conf.get('upload_location')
195
207
    if destination is None:
196
208
        return
197
 
    auto_upload = get_upload_auto(source_branch)
 
209
    auto_upload = conf.get('upload_auto')
198
210
    if not auto_upload:
199
211
        return
200
 
    quiet = get_upload_auto_quiet(source_branch)
 
212
    quiet = conf.get('upload_auto_quiet')
201
213
    if not quiet:
202
214
        display_url = urlutils.unescape_for_display(
203
215
            destination, osutils.get_terminal_encoding())