~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Robert Collins
  • Date: 2005-09-13 16:52:44 UTC
  • mto: (147.2.6) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20050913165244-2c4a9223d286580c
handle missing ancestry

Show diffs side-by-side

added added

removed removed

Lines of Context:
263
263
    >>> result_path = os.path.join(q, "result")
264
264
    >>> commit_test_revisions()
265
265
    >>> version = pybaz.Version("test@example.com/test--test--0.1")
266
 
    >>> import_version('/', version, fancy=False, dry_run=True)
 
266
    >>> def printer(message): print message
 
267
    >>> import_version('/', version, printer, fancy=False, dry_run=True)
267
268
    Traceback (most recent call last):
268
269
    UserError: / exists, but is not a bzr branch.
269
 
    >>> import_version(result_path, version, fancy=False, dry_run=True)
 
270
    >>> import_version(result_path, version, printer, fancy=False, dry_run=True)
270
271
    Traceback (most recent call last):
271
272
    UserError: The version test@example.com/test--test--0.1 does not exist.
272
273
    >>> version = pybaz.Version("test@example.com/test--test--0")
273
 
    >>> import_version(result_path, version, fancy=False, dry_run=True)
 
274
    >>> import_version(result_path, version, printer, fancy=False, dry_run=True)
274
275
    not fancy
275
276
    ....
276
277
    Dry run, not modifying output_dir
277
278
    Cleaning up
278
 
    >>> import_version(result_path, version, fancy=False)
 
279
    >>> import_version(result_path, version, printer, fancy=False)
279
280
    not fancy
280
281
    ....
281
282
    Cleaning up
282
283
    Import complete.
283
 
    >>> import_version(result_path, version, fancy=False)
 
284
    >>> import_version(result_path, version, printer, fancy=False)
284
285
    Tree is up-to-date with test@example.com/test--test--0--patch-2
285
286
    >>> commit_more_test_revisions()
286
 
    >>> import_version(result_path, version, fancy=False)
 
287
    >>> import_version(result_path, version, printer, fancy=False)
287
288
    not fancy
288
289
    ..
289
290
    Cleaning up
416
417
    #        print '\t%s' % a
417
418
 
418
419
    previous_version=None
 
420
    missing_ancestor = None
419
421
 
420
422
    for i in range(len(ancestors)):
421
423
        revision = ancestors[i]
431
433
            yield Progress("revisions", i, len(ancestors))
432
434
        if revdir is None:
433
435
            revdir = os.path.join(tempdir, "rd")
434
 
            baz_inv, log = get_revision(revdir, revision)
 
436
            try:
 
437
                baz_inv, log = get_revision(revdir, revision)
 
438
            except pybaz.errors.ExecProblem, e:
 
439
                if ("%s" % e.args).find('could not connect') == -1:
 
440
                    raise
 
441
                missing_ancestor = revision
 
442
                revdir = None
 
443
                print ("unable to access ancestor %s, making into a merge."
 
444
                       % missing_ancestor)
 
445
                continue
435
446
            # cached so we can delete the log
436
447
            log_date = log.date
437
448
            log_summary = log.summary
464
475
        rev_id = revision_id(revision)
465
476
        branch.lock_write()
466
477
        try:
 
478
            if missing_ancestor:
 
479
                # if we want it to be in revision-history, do that here.
 
480
                branch.add_pending_merge(revision_id(missing_ancestor))
 
481
                missing_ancestor = None
467
482
            for merge in direct_merges:
468
483
                branch.add_pending_merge(revision_id(merge.revision))
469
484
            branch.set_inventory(baz_inv)