~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz2bzr

  • Committer: Aaron Bentley
  • Date: 2005-06-03 13:07:41 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050603130741-81b47e614120f6d9
Applied John Meinel's 'update' patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
def iter_import_version(output_dir, version, tempdir):
227
227
    revdir = None
228
228
    ancestors = version_ancestry(version)
 
229
    last_patch = None
 
230
    if os.path.exists(output_dir):
 
231
        # We are starting from an existing directory, figure out what
 
232
        # the current version is
 
233
        branch = bzrlib.Branch(output_dir)
 
234
        last_patch = branch.last_patch()
 
235
        if last_patch is not None:
 
236
            if last_patch[:7] != 'Arch-x:':
 
237
                raise UserError("Directory \"%s\" already exists, and the last patch is not an arch patch (%s)" % (output_dir, last_patch))
 
238
            else:
 
239
                last_patch = last_patch[7:].replace('%', '/')
 
240
 
 
241
    if last_patch:
 
242
        for i in range(len(ancestors)):
 
243
            if str(ancestors[i]) == last_patch:
 
244
                break
 
245
        else:
 
246
            raise UserError("Directory \"%s\" already exists, and the last patch (%s) is not in the revision history" % (output_dir, last_patch))
 
247
        # Strip off all of the ancestors which are already present
 
248
        ancestors = ancestors[i+1:]
 
249
        revdir = output_dir
 
250
        if len(ancestors) == 0:
 
251
            print '* Tree is up-to-date with %s' % last_patch
 
252
            return
 
253
    # Uncomment this for testing, it basically just has baz2bzr only update
 
254
    # 5 patches at a time
 
255
    #ancestors = ancestors[:5]
 
256
 
229
257
    for i in range(len(ancestors)):
230
258
        revision = ancestors[i]
231
259
        yield Progress("revisions", i, len(ancestors))
252
280
            bzrlib.trace.silent = False   
253
281
            branch.unlock()
254
282
    yield Progress("revisions", len(ancestors), len(ancestors))
255
 
    unlink_unversioned(branch, revdir)
 
283
    # If you want to update this later, you cannot unlink the {arch} directory.
 
284
    # unlink_unversioned(branch, revdir)
256
285
    os.rename(revdir, output_dir)   
257
286
 
258
287
def unlink_unversioned(branch, revdir):
329
358
elif len(sys.argv) == 3:
330
359
    try:
331
360
        output_dir = os.path.realpath(sys.argv[2])
332
 
        if os.path.exists(output_dir):
333
 
            raise UserError("Directory \"%s\" already exists" % output_dir)
334
361
        import_version(output_dir, pybaz.Version(sys.argv[1]))
335
362
    except UserError, e:
336
363
        print e