~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai.py

  • Committer: Aaron Bentley
  • Date: 2005-10-28 03:01:02 UTC
  • mfrom: (147.4.13)
  • mto: (147.4.24 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: aaron.bentley@utoronto.ca-20051028030102-eead1e484007de74
Merged lifeless

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
__docformat__ = "restructuredtext"
23
23
__doc__ = "Utility functions to be used by commands"
24
24
 
25
 
def direct_merges(merges):
 
25
def direct_merges(merges, excludes=[]):
26
26
    """Get a list of direct merges, from a list of direct and indirect
27
27
    
28
28
    :param merges: Iterator of merge patchlogs
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 for log in logs if not log.revision in indirect]
 
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
 
73
78
 
74
79
def namespace_previous(revision):
75
80
    if revision.patchlevel == 'base-0':