~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/devscripts/sourcecode.py

  • Committer: Michael Hudson
  • Date: 2009-09-25 00:07:53 UTC
  • mto: (9550.13.48 ami-from-scratch)
  • mto: This revision was merged to the branch mainline in revision 9574.
  • Revision ID: michael.hudson@canonical.com-20090925000753-24o2spqlqpp58rrv
gar, logic is hard

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    """
54
54
    config = {}
55
55
    for entry in config_entries:
56
 
        branch_name, branch_url, optional = interpret_config(entry)
57
 
        if not optional or public_only:
 
56
        branch_name, branch_url, optional = interpret_config_entry(entry)
 
57
        if not optional or not public_only:
58
58
            config[branch_name] = (branch_url, optional)
59
59
    return config
60
60
 
163
163
            os.unlink(destination)
164
164
 
165
165
 
166
 
def update_sourcecode(sourcecode_directory, config_filename, public_only):
 
166
def update_sourcecode(sourcecode_directory, config_filename, public_only,
 
167
                      dry_run):
167
168
    """Update the sourcecode."""
168
169
    config_file = open(config_filename)
169
170
    config = interpret_config(parse_config_file(config_file), public_only)
171
172
    branches = find_branches(sourcecode_directory)
172
173
    new, updated, removed = plan_update(branches, config)
173
174
    possible_transports = []
174
 
    get_branches(sourcecode_directory, new, possible_transports)
175
 
    update_branches(sourcecode_directory, updated, possible_transports)
176
 
    remove_branches(sourcecode_directory, removed)
 
175
    if dry_run:
 
176
        print 'Branches to fetch:', new.keys()
 
177
        print 'Branches to update:', updated.keys()
 
178
        print 'Branches to remove:', list(removed)
 
179
    else:
 
180
        get_branches(sourcecode_directory, new, possible_transports)
 
181
        update_branches(sourcecode_directory, updated, possible_transports)
 
182
        remove_branches(sourcecode_directory, removed)
177
183
 
178
184
 
179
185
def get_launchpad_root():
196
202
    parser.add_option(
197
203
        '--public-only', action='store_true',
198
204
        help='Only fetch/update the public sourcecode branches.')
 
205
    parser.add_option(
 
206
        '--dry-run', action='store_true',
 
207
        help='Only fetch/update the public sourcecode branches.')
199
208
    options, args = parser.parse_args(args)
200
209
    root = get_launchpad_root()
201
210
    if len(args) > 1:
212
221
    print 'Config: %s' % (config_filename,)
213
222
    load_plugins()
214
223
    update_sourcecode(
215
 
        sourcecode_directory, config_filename, options.public_early)
 
224
        sourcecode_directory, config_filename,
 
225
        options.public_only, options.dry_run)
216
226
    return 0