~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-22 18:24:25 UTC
  • mfrom: (1803 +trunk)
  • mto: (1793.3.6 bundle-fixes)
  • mto: This revision was merged to the branch mainline in revision 1806.
  • Revision ID: john@arbash-meinel.com-20060622182425-6f45cb7acd587216
[merge] bzr.dev 1804 and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
import os
74
74
import sha
75
75
import time
 
76
import warnings
76
77
 
77
78
from bzrlib.trace import mutter
78
79
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
84
85
import bzrlib.errors as errors
85
86
from bzrlib.osutils import sha_strings
86
87
import bzrlib.patiencediff
87
 
from bzrlib.symbol_versioning import *
 
88
from bzrlib.symbol_versioning import (deprecated_method,
 
89
        deprecated_function,
 
90
        zero_eight,
 
91
        )
88
92
from bzrlib.tsort import topo_sort
89
93
from bzrlib.versionedfile import VersionedFile, InterVersionedFile
90
94
from bzrlib.weavefile import _read_weave_v5, write_weave_v5
635
639
 
636
640
    def annotate(self, version_id):
637
641
        if isinstance(version_id, int):
638
 
            warn('Weave.annotate(int) is deprecated. Please use version names'
 
642
            warnings.warn('Weave.annotate(int) is deprecated. Please use version names'
639
643
                 ' in all circumstances as of 0.8',
640
644
                 DeprecationWarning,
641
645
                 stacklevel=2
1239
1243
    from bzrlib.weavefile import read_weave
1240
1244
 
1241
1245
    wf = file(weave_file, 'rb')
1242
 
    w = read_weave(wf, WeaveVersionedFile)
 
1246
    w = read_weave(wf)
1243
1247
    # FIXME: doesn't work on pipes
1244
1248
    weave_size = wf.tell()
1245
1249
 
1419
1423
        raise ValueError('unknown command %r' % cmd)
1420
1424
    
1421
1425
 
1422
 
 
1423
 
def profile_main(argv):
1424
 
    import tempfile, hotshot, hotshot.stats
1425
 
 
1426
 
    prof_f = tempfile.NamedTemporaryFile()
1427
 
 
1428
 
    prof = hotshot.Profile(prof_f.name)
1429
 
 
1430
 
    ret = prof.runcall(main, argv)
1431
 
    prof.close()
1432
 
 
1433
 
    stats = hotshot.stats.load(prof_f.name)
1434
 
    #stats.strip_dirs()
1435
 
    stats.sort_stats('cumulative')
1436
 
    ## XXX: Might like to write to stderr or the trace file instead but
1437
 
    ## print_stats seems hardcoded to stdout
1438
 
    stats.print_stats(20)
1439
 
            
1440
 
    return ret
1441
 
 
1442
 
 
1443
 
def lsprofile_main(argv): 
1444
 
    from bzrlib.lsprof import profile
1445
 
    ret,stats = profile(main, argv)
1446
 
    stats.sort()
1447
 
    stats.pprint()
1448
 
    return ret
1449
 
 
1450
 
 
1451
1426
if __name__ == '__main__':
1452
1427
    import sys
1453
 
    if '--profile' in sys.argv:
1454
 
        args = sys.argv[:]
1455
 
        args.remove('--profile')
1456
 
        sys.exit(profile_main(args))
1457
 
    elif '--lsprof' in sys.argv:
1458
 
        args = sys.argv[:]
1459
 
        args.remove('--lsprof')
1460
 
        sys.exit(lsprofile_main(args))
1461
 
    else:
1462
 
        sys.exit(main(sys.argv))
 
1428
    sys.exit(main(sys.argv))
1463
1429
 
1464
1430
 
1465
1431
class InterWeave(InterVersionedFile):