~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/missing.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-29 05:21:36 UTC
  • mfrom: (3921.3.14 bzr.missing_revision)
  • mto: This revision was merged to the branch mainline in revision 3970.
  • Revision ID: ian.clatworthy@canonical.com-20090129052136-1a0ue2k2rhxznu23
Add local & remote revision filtering to missing (Marius Kruger)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
 
55
55
def find_unmerged(local_branch, remote_branch, restrict='all',
56
 
                  include_merges=False, backward=False):
 
56
                  include_merges=False, backward=False,
 
57
                  local_revid_range=None, remote_revid_range=None):
57
58
    """Find revisions from each side that have not been merged.
58
59
 
59
60
    :param local_branch: Compare the history of local_branch
66
67
    :param include_merges: Show mainline revisions only if False,
67
68
        all revisions otherwise.
68
69
    :param backward: Show oldest versions first when True, newest versions
69
 
        first when False. 
 
70
        first when False.
 
71
    :param local_revid_range: Revision-id range for filtering local_branch
 
72
        revisions (lower bound, upper bound)
 
73
    :param remote_revid_range: Revision-id range for filtering remote_branch
 
74
        revisions (lower bound, upper bound)
70
75
 
71
76
    :return: A list of [(revno, revision_id)] for the mainline revisions on
72
77
        each side.
77
82
        try:
78
83
            return _find_unmerged(
79
84
                local_branch, remote_branch, restrict=restrict,
80
 
                include_merges=include_merges, backward=backward)
 
85
                include_merges=include_merges, backward=backward,
 
86
                local_revid_range=local_revid_range,
 
87
                remote_revid_range=remote_revid_range)
81
88
        finally:
82
89
            remote_branch.unlock()
83
90
    finally:
174
181
    return revline
175
182
 
176
183
 
 
184
def _filter_revs(graph, revs, revid_range):
 
185
    if revid_range is None or revs is None:
 
186
        return revs
 
187
    return [rev for rev in revs
 
188
        if graph.is_between(rev[1], revid_range[0], revid_range[1])]
 
189
 
 
190
 
177
191
def _find_unmerged(local_branch, remote_branch, restrict,
178
 
                   include_merges, backward):
 
192
                   include_merges, backward,
 
193
                   local_revid_range=None, remote_revid_range=None):
179
194
    """See find_unmerged.
180
195
 
181
196
    The branches should already be locked before entering.
214
229
                                     local_revision_id, backward)
215
230
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
216
231
                                      remote_revision_id, backward)
217
 
    return locals, remotes
 
232
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
 
233
        remotes, remote_revid_range)
218
234
 
219
235
 
220
236
def sorted_revisions(revisions, history_map):