bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.155.2
by James Westby
Add a post_change_branch_tip hook to upload. |
1 |
# Copyright (C) 2008 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
import sys |
|
18 |
||
19 |
||
|
0.155.3
by James Westby
Add some tests for the hook, rename the option to "upload_auto" |
20 |
from bzrlib import branch, transport, urlutils |
21 |
||
22 |
||
23 |
from bzrlib.plugins.upload import ( |
|
24 |
BzrUploader, |
|
25 |
get_upload_location, |
|
26 |
get_upload_auto, |
|
27 |
)
|
|
28 |
||
29 |
||
30 |
def auto_upload_hook(params, quiet=False): |
|
|
0.155.2
by James Westby
Add a post_change_branch_tip hook to upload. |
31 |
source_branch = params.branch |
32 |
destination = get_upload_location(source_branch) |
|
33 |
if destination is None: |
|
34 |
return
|
|
|
0.155.3
by James Westby
Add some tests for the hook, rename the option to "upload_auto" |
35 |
auto_upload = get_upload_auto(source_branch) |
36 |
if not auto_upload: |
|
|
0.155.2
by James Westby
Add a post_change_branch_tip hook to upload. |
37 |
return
|
|
0.155.3
by James Westby
Add some tests for the hook, rename the option to "upload_auto" |
38 |
if not quiet: |
39 |
display_url = urlutils.unescape_for_display(destination, |
|
40 |
sys.stdout.encoding) |
|
41 |
print "Automatically uploading to %s" % display_url |
|
|
0.155.2
by James Westby
Add a post_change_branch_tip hook to upload. |
42 |
to_transport = transport.get_transport(destination) |
43 |
last_revision = source_branch.last_revision() |
|
44 |
last_tree = source_branch.repository.revision_tree(last_revision) |
|
45 |
uploader = BzrUploader(source_branch, to_transport, sys.stdout, |
|
|
0.155.3
by James Westby
Add some tests for the hook, rename the option to "upload_auto" |
46 |
last_tree, last_revision, quiet=quiet) |
|
0.155.2
by James Westby
Add a post_change_branch_tip hook to upload. |
47 |
uploader.upload_tree() |