/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/missing.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Display what revisions are missing in 'other' from 'this' and vice versa."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from . import (
20
 
    errors,
21
22
    log,
22
23
    )
 
24
from . import revision as _mod_revision
23
25
 
24
26
 
25
27
def iter_log_revisions(revisions, revision_source, verbose, rev_tag_dict=None):
 
28
    last_tree = revision_source.revision_tree(_mod_revision.NULL_REVISION)
 
29
    last_rev_id = None
 
30
 
26
31
    if rev_tag_dict is None:
27
32
        rev_tag_dict = {}
28
33
    for revno, rev_id, merge_depth in revisions:
61
66
    """
62
67
    if include_merged is None:
63
68
        include_merged = False
64
 
    with local_branch.lock_read(), remote_branch.lock_read():
65
 
        return _find_unmerged(
66
 
            local_branch, remote_branch, restrict=restrict,
67
 
            include_merged=include_merged, backward=backward,
68
 
            local_revid_range=local_revid_range,
69
 
            remote_revid_range=remote_revid_range)
 
69
    local_branch.lock_read()
 
70
    try:
 
71
        remote_branch.lock_read()
 
72
        try:
 
73
            return _find_unmerged(
 
74
                local_branch, remote_branch, restrict=restrict,
 
75
                include_merged=include_merged, backward=backward,
 
76
                local_revid_range=local_revid_range,
 
77
                remote_revid_range=remote_revid_range)
 
78
        finally:
 
79
            remote_branch.unlock()
 
80
    finally:
 
81
        local_branch.unlock()
70
82
 
71
83
 
72
84
def _enumerate_mainline(ancestry, graph, tip_revno, tip, backward=True):
83
95
    """
84
96
    if ancestry is None:
85
97
        return None
86
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
98
    if not ancestry: #Empty ancestry, no need to do any work
87
99
        return []
88
100
 
89
101
    # Optionally, we could make 1 call to graph.get_parent_map with all
97
109
        parent_map = graph.get_parent_map([cur])
98
110
        parents = parent_map.get(cur)
99
111
        if not parents:
100
 
            break  # Ghost, we are done
101
 
        mainline.append(
102
 
            (str(cur_revno) if cur_revno is not None else None, cur, 0))
 
112
            break # Ghost, we are done
 
113
        mainline.append((str(cur_revno), cur, 0))
103
114
        cur = parents[0]
104
 
        if cur_revno is not None:
105
 
            cur_revno -= 1
 
115
        cur_revno -= 1
106
116
    if not backward:
107
117
        mainline.reverse()
108
118
    return mainline
124
134
    """
125
135
    if ancestry is None:
126
136
        return None
127
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
137
    if not ancestry: #Empty ancestry, no need to do any work
128
138
        return []
129
139
 
130
140
    merge_sorted_revisions = branch.iter_merge_sorted_revisions()
147
157
    if revid_range is None or revs is None:
148
158
        return revs
149
159
    return [rev for rev in revs
150
 
            if graph.is_between(rev[1], revid_range[0], revid_range[1])]
 
160
        if graph.is_between(rev[1], revid_range[0], revid_range[1])]
151
161
 
152
162
 
153
163
def _find_unmerged(local_branch, remote_branch, restrict,
157
167
 
158
168
    The branches should already be locked before entering.
159
169
    """
160
 
    try:
161
 
        local_revno, local_revision_id = local_branch.last_revision_info()
162
 
    except (errors.UnsupportedOperation, errors.GhostRevisionsHaveNoRevno):
163
 
        local_revno = None
164
 
        local_revision_id = local_branch.last_revision()
165
 
    try:
166
 
        remote_revno, remote_revision_id = remote_branch.last_revision_info()
167
 
    except (errors.UnsupportedOperation, errors.GhostRevisionsHaveNoRevno):
168
 
        remote_revision_id = remote_branch.last_revision()
169
 
        remote_revno = None
170
 
 
171
 
    if local_revision_id == remote_revision_id:
 
170
    local_revno, local_revision_id = local_branch.last_revision_info()
 
171
    remote_revno, remote_revision_id = remote_branch.last_revision_info()
 
172
    if local_revno == remote_revno and local_revision_id == remote_revision_id:
172
173
        # A simple shortcut when the tips are at the same point
173
174
        return [], []
174
175
    graph = local_branch.repository.get_graph(remote_branch.repository)
200
201
                                     local_revision_id, backward)
201
202
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
202
203
                                      remote_revision_id, backward)
203
 
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(
204
 
        graph, remotes, remote_revid_range)
 
204
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
 
205
        remotes, remote_revid_range)
205
206
 
206
207
 
207
208
def sorted_revisions(revisions, history_map):