~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Robert Collins
  • Date: 2005-09-13 14:14:22 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-20050913141422-e391cb880f6920df
make feedback be callback based - really

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
        ancestors = ancestors[i+1:]
257
257
    return ancestors, old_revno
258
258
 
259
 
def import_version(output_dir, version, fancy=True, fast=False, verbose=False, 
260
 
                   dry_run=False, max_count=None):
 
259
def import_version(output_dir, version, printer, fancy=True, fast=False,
 
260
                   verbose=False, dry_run=False, max_count=None):
261
261
    """
262
262
    >>> q = test_environ()
263
263
    >>> result_path = os.path.join(q, "result")
345
345
            os.rename(revdir, output_dir)
346
346
 
347
347
    finally:
348
 
        print 'Cleaning up'
 
348
        printer('Cleaning up')
349
349
        shutil.rmtree(tempdir)
350
 
    print "Import complete."
 
350
    printer("Import complete.")
351
351
            
352
352
class UserError(Exception):
353
353
    def __init__(self, message):
562
562
    takes_args = ['to_location', 'from_branch?']
563
563
    takes_options = ['verbose']
564
564
 
 
565
    def printer(self, name):
 
566
        print name
 
567
 
565
568
    def run(self, to_location, from_branch=None, fast=False, max_count=None,
566
569
            verbose=False, dry_run=False):
567
570
        to_location = os.path.realpath(str(to_location))
571
574
            except pybaz.errors.NamespaceError:
572
575
                print "%s is not a valid Arch branch." % from_branch
573
576
                return 1
574
 
        import_version(to_location, from_branch)
 
577
        import_version(to_location, from_branch, printer)
575
578
 
576
579
class cmd_baz_import(Command):
577
580
    """Import an Arch or Baz archive into bzr branches."""
592
595
        target = os.path.join(to_root, map_namespace(version))
593
596
        printer("importing %s into %s" % (version, target))
594
597
        os.makedirs(os.path.dirname(target))
595
 
        import_version(target, version)
 
598
        import_version(target, version, printer)
596
599
 
597
600
def map_namespace(a_version):
598
601
    a_version = pybaz.Version("%s" % a_version)