Example #1
0
#! /usr/bin/env python

# Copyright (C) 2005 Canonical Ltd
"""Print to stdout a description of the current directory,
formatted as a Python data structure.

This can be useful in tests that need to recreate directory
contents."""

import os
import sys

from breezy.trace import enable_default_logging

enable_default_logging()
from breezy.selftest.treeshape import capture_tree_contents


def main(argv):
    # a lame reimplementation of pformat that splits multi-line
    # strings into concatenated string literals.
    print('[')
    for tt in capture_tree_contents('.'):
        assert isinstance(tt, tuple)
        print('    (', repr(tt[0]) + ',', end=' ')
        if len(tt) == 1:
            print('),')
        else:
            assert len(tt) == 2
            val = tt[1]
            print()
Example #2
0
    graph,
    osutils,
    ui,
    trace,
    _known_graph_py,
    _known_graph_pyx,
)
from breezy.ui import text

p = optparse.OptionParser()
p.add_option('--quick', default=False, action='store_true')
p.add_option('--max-combinations', default=500, type=int)
p.add_option('--lsprof', default=None, type=str)
opts, args = p.parse_args(sys.argv[1:])

trace.enable_default_logging()
ui.ui_factory = text.TextUIFactory()

begin = osutils.perf_counter()
if len(args) >= 1:
    b = branch.Branch.open(args[0])
else:
    b = branch.Branch.open('.')
with b.lock_read():
    g = b.repository.get_graph()
    parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
                      if p[1] is not None)
end = osutils.perf_counter()

print('Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin))