~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai.py

  • Committer: Robert Collins
  • Date: 2005-10-22 13:40:09 UTC
  • mto: (147.1.39) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20051022134009-54f2d14b5fc1d2cb
dont block archive wide baz-imports when a single version fails dur to either an unbuildable revision or a diverged branch.

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, excludes=[]):
 
25
def direct_merges(merges):
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
29
29
    :type merges: iter of `pybaz.Patchlog`
30
30
    :return: The direct merges
31
31
    :rtype: list of `pybaz.Patchlog`
32
32
    """
33
 
    indirect = set()
 
33
    indirect = []
 
34
    direct = []
34
35
    logs = list(merges)
35
36
    if not logs:
36
37
        return []
37
38
    for log in logs:
38
 
        try:
39
 
            this_indirect = set([str(f) for f in log.new_patches
40
 
                                 if f != log.revision and
41
 
                                     str(f) not in indirect])
42
 
        except pybaz.errors.NamespaceError:
43
 
            print
44
 
            print "log ", log, " unusable, attempting to use archive copy."
45
 
            log = pybaz.Revision(str(log.revision)).patchlog
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)
 
39
        indirect.extend([f for f in log.new_patches if f != log.revision])
50
40
        if log.continuation_of is not None:
51
41
            # continuations list everything in new_patches
52
42
            continue
56
46
        except pybaz.errors.ExecProblem:
57
47
            # baz does not know
58
48
            # guess
59
 
            if log.revision.patchlevel != 'version-0':
 
49
            if log.revision.patchlevel != 'version-0': 
60
50
                ancestor = namespace_previous(log.revision)
61
51
            else:
62
52
                found = False
71
61
                        found = True
72
62
                print "ancestor of %s is %s" % (log.revision, ancestor)
73
63
        if ancestor is not None:
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
 
 
 
64
            indirect.append(ancestor)
 
65
    return [log for log in logs if not log.revision in indirect]
78
66
 
79
67
def namespace_previous(revision):
80
68
    if revision.patchlevel == 'base-0':
123
111
    :rtype: Iterator of str
124
112
    """
125
113
    args = [ 'new-merges', '--dir', directory ]
126
 
    if reverse:
 
114
    if reverse: 
127
115
        args.append('--reverse')
128
116
    args.append(version)
129
117
    return sequence_cmd(args)