~michael-ellerman/bzr/mpe

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# property.
28
28
 
29
29
# TODO: Nothing here so far assumes the lines are really \n newlines,
30
 
# rather than being split up in some other way.  We could accomodate
 
30
# rather than being split up in some other way.  We could accommodate
31
31
# binaries, perhaps by naively splitting on \n or perhaps using
32
32
# something like a rolling checksum.
33
33
 
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
231
235
 
232
236
    @deprecated_method(zero_eight)
233
237
    def lookup(self, name):
234
 
        """Backwards compatability thunk:
 
238
        """Backwards compatibility thunk:
235
239
 
236
240
        Return name, as name is valid in the api now, and spew deprecation
237
241
        warnings everywhere.
522
526
        if lines == basis_lines:
523
527
            return new_version            
524
528
 
525
 
        # add a sentinal, because we can also match against the final line
 
529
        # add a sentinel, because we can also match against the final line
526
530
        basis_lineno.append(len(self._weave))
527
531
 
528
532
        # XXX: which line of the weave should we really consider
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
1069
1073
 
1070
1074
    @deprecated_method(zero_eight)
1071
1075
    def reweave(self, other, pb=None, msg=None):
1072
 
        """reweave has been superceded by plain use of join."""
 
1076
        """reweave has been superseded by plain use of join."""
1073
1077
        return self.join(other, pb, msg)
1074
1078
 
1075
1079
    def _reweave(self, other, pb, msg):
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):