271
274
# Uncomment this for testing, it basically just has baz2bzr only update
272
275
# 5 patches at a time
273
#ancestors = ancestors[:5]
277
ancestors = ancestors[:max_count]
279
# Not sure if I want this output. basically it tells you ahead of time
280
# what it is going to do, but then later it tells you as it is doing it.
281
# what probably would be best would be to collapse it into ranges, so that
282
# this gives the simple view, and then later it gives the blow by blow.
284
# print 'Adding the following revisions:'
285
# for a in ancestors:
288
previous_version=None
275
290
for i in range(len(ancestors)):
276
291
revision = ancestors[i]
277
yield Progress("revisions", i, len(ancestors))
293
version = str(revision.version)
294
if version != previous_version:
296
print '\rOn version: %s' % version
297
yield Progress(str(revision.patchlevel), i, len(ancestors))
298
previous_version = version
300
yield Progress("revisions", i, len(ancestors))
278
301
if revdir is None:
279
302
revdir = os.path.join(tempdir, "rd")
280
303
baz_inv, log = get_revision(revdir, revision, skip_symlink=True)
300
323
yield Progress("revisions", len(ancestors), len(ancestors))
301
324
unlink_unversioned(branch, revdir)
326
print '**Dry run, not modifying output_dir'
302
328
if os.path.exists(output_dir):
303
329
# Move the bzr control directory back, and update the working tree
304
330
tmp_bzr_dir = os.path.join(tempdir, '.bzr')
391
if len(sys.argv) == 2 and sys.argv[1] == "test":
392
print "Running tests"
395
elif len(sys.argv) == 3:
397
output_dir = os.path.realpath(sys.argv[2])
398
import_version(output_dir, pybaz.Version(sys.argv[1]))
401
except KeyboardInterrupt:
404
print "usage: %s VERSION OUTDIR" % os.path.basename(sys.argv[0])
418
"""Just the main() function for this script.
420
By separating it into a function, this can be called as a child from some other
423
:param args: The arguments to this script. Essentially sys.argv[1:]
426
parser = optparse.OptionParser(usage='%prog [options] VERSION OUTDIR'
427
'\n VERSION is the arch version to import.'
428
'\n OUTDIR can be an existing directory to be updated'
429
'\n or a new directory which will be created from scratch.')
430
parser.add_option('--verbose', action='store_true'
433
g = optparse.OptionGroup(parser, 'Progress options', 'Control how progress is given')
434
g.add_option('--not-fancy', dest='fancy', action='store_false')
435
g.add_option('--fancy', dest='fancy', action='store_true', default=True
436
, help='Fancy or simple progress bar. (default: fancy)')
437
parser.add_option_group(g)
439
g = optparse.OptionGroup(parser, 'Test options', 'Options useful while testing process.')
440
g.add_option('--test', action='store_true'
441
, help='Run the self-tests and exit.')
442
g.add_option('--dry-run', action='store_true'
443
, help='Do the update, but don\'t copy the result to OUTDIR')
444
g.add_option('--max-count', type='int', metavar='COUNT', default=None
445
, help='At most, add COUNT patches.')
446
g.add_option('--safe', action='store_false', dest='fast')
447
g.add_option('--fast', action='store_true', default=False
448
, help='By default the .bzr control directory will be copied, so that an error'
449
' does not modify the original. --fast allows the directory to be renamed instead.')
450
parser.add_option_group(g)
452
(opts, args) = parser.parse_args(args)
455
print "Running tests"
457
nfail, ntests = doctest.testmod(verbose=opts.verbose)
464
print 'Invalid number of arguments, try --help for more info'
468
output_dir = os.path.realpath(args[1])
469
import_version(output_dir, pybaz.Version(args[0]),
470
verbose=opts.verbose, fast=opts.fast,
471
fancy=opts.fancy, dry_run=opts.dry_run,
472
max_count=opts.max_count)
477
except KeyboardInterrupt:
482
if __name__ == '__main__':
483
sys.exit(main(sys.argv[1:]))