~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/devscripts/sourcecode.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-09 13:17:35 UTC
  • mfrom: (13168.7.3 fix-update-cache)
  • Revision ID: launchpad@pqm.canonical.com-20110609131735-1nz2kelmcuh54hf6
[r=gmb][bug=794088] Fix stale cache detection

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        optional = False
64
64
    return branch_name, branch_url, revision, optional
65
65
 
 
66
 
66
67
def load_cache(cache_filename):
67
68
    try:
68
69
        cache_file = open(cache_filename, 'rb')
74
75
    with cache_file:
75
76
        return json.load(cache_file)
76
77
 
 
78
 
77
79
def interpret_config(config_entries, public_only):
78
80
    """Interpret a configuration stream, as parsed by 'parse_config_file'.
79
81
 
214
216
 
215
217
def update_cache(cache, cache_filename, changed, sourcecode_directory, quiet):
216
218
    """Update the cache with the changed branches."""
217
 
    if len(changed) == 0:
218
 
        return
219
 
    if not quiet:
220
 
        print 'Cache updated.  Please commit "%s".' % cache_filename
 
219
    old_cache = dict(cache)
221
220
    for project, (branch_url, revision, optional) in changed.iteritems():
222
221
        destination = os.path.join(sourcecode_directory, project)
223
222
        branch = Branch.open(destination)
224
 
        cache[project] = branch.last_revision_info()
 
223
        cache[project] = list(branch.last_revision_info())
 
224
    if cache == old_cache:
 
225
        return
225
226
    with open(cache_filename, 'wb') as cache_file:
226
227
        json.dump(cache, cache_file, indent=4)
 
228
    if not quiet:
 
229
        print 'Cache updated.  Please commit "%s".' % cache_filename
227
230
 
228
231
 
229
232
def update_branches(sourcecode_directory, update_branches,
258
261
                remote_branch, stop_revision=revision_id, overwrite=True,
259
262
                possible_transports=possible_transports)
260
263
        except IncompatibleRepositories:
261
 
            # XXX JRV 20100407: Ideally remote_branch.bzrdir._format 
 
264
            # XXX JRV 20100407: Ideally remote_branch.bzrdir._format
262
265
            # should be passed into upgrade() to ensure the format is the same
263
 
            # locally and remotely. Unfortunately smart server branches 
264
 
            # have their _format set to RemoteFormat rather than an actual 
 
266
            # locally and remotely. Unfortunately smart server branches
 
267
            # have their _format set to RemoteFormat rather than an actual
265
268
            # format instance.
266
269
            upgrade(destination)
267
270
            # Upgraded, repoen working tree