~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai.py

  • Committer: Robert Collins
  • Date: 2005-10-24 07:01:08 UTC
  • mto: (147.1.42) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20051024070108-f85025066b05f809
use sets and strings to optimise finding indirect merges somewhat

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    :return: The direct merges
31
31
    :rtype: list of `pybaz.Patchlog`
32
32
    """
33
 
    indirect = []
34
 
    direct = []
 
33
    indirect = set()
35
34
    logs = list(merges)
36
35
    if not logs:
37
36
        return []
38
37
    for log in logs:
39
38
        try:
40
 
            this_indirect = [f for f in log.new_patches if f != log.revision]
 
39
            this_indirect = set([str(f) for f in log.new_patches 
 
40
                                 if f != log.revision and 
 
41
                                     str(f) not in indirect])
41
42
        except pybaz.errors.NamespaceError:
42
43
            print
43
44
            print "log ", log, " unusable, attempting to use archive copy."
44
45
            log = pybaz.Revision(str(log.revision)).patchlog
45
 
            this_indirect = [f for f in log.new_patches if f != log.revision]
46
 
        indirect.extend(this_indirect)
 
46
            this_indirect = set([str(f) for f in log.new_patches 
 
47
                                 if f != log.revision and 
 
48
                                     str(f) not in indirect])
 
49
        indirect.update(this_indirect)
47
50
        if log.continuation_of is not None:
48
51
            # continuations list everything in new_patches
49
52
            continue
68
71
                        found = True
69
72
                print "ancestor of %s is %s" % (log.revision, ancestor)
70
73
        if ancestor is not None:
71
 
            indirect.append(ancestor)
72
 
    return [log.revision for log in logs if not log.revision in indirect and 
73
 
            log.revision not in excludes]
 
74
            indirect.add(str(ancestor))
 
75
    return [log.revision for log in logs if not str(log.revision) in indirect
 
76
            and log.revision not in excludes]
 
77
 
74
78
 
75
79
def namespace_previous(revision):
76
80
    if revision.patchlevel == 'base-0':