/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: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

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
 
 
21
19
from . import (
 
20
    errors,
22
21
    log,
23
22
    )
24
 
from . import revision as _mod_revision
25
23
 
26
24
 
27
25
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
 
 
31
26
    if rev_tag_dict is None:
32
27
        rev_tag_dict = {}
33
28
    for revno, rev_id, merge_depth in revisions:
66
61
    """
67
62
    if include_merged is None:
68
63
        include_merged = False
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()
 
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)
82
70
 
83
71
 
84
72
def _enumerate_mainline(ancestry, graph, tip_revno, tip, backward=True):
95
83
    """
96
84
    if ancestry is None:
97
85
        return None
98
 
    if not ancestry: #Empty ancestry, no need to do any work
 
86
    if not ancestry:  # Empty ancestry, no need to do any work
99
87
        return []
100
88
 
101
89
    # Optionally, we could make 1 call to graph.get_parent_map with all
109
97
        parent_map = graph.get_parent_map([cur])
110
98
        parents = parent_map.get(cur)
111
99
        if not parents:
112
 
            break # Ghost, we are done
113
 
        mainline.append((str(cur_revno), cur, 0))
 
100
            break  # Ghost, we are done
 
101
        mainline.append(
 
102
            (str(cur_revno) if cur_revno is not None else None, cur, 0))
114
103
        cur = parents[0]
115
 
        cur_revno -= 1
 
104
        if cur_revno is not None:
 
105
            cur_revno -= 1
116
106
    if not backward:
117
107
        mainline.reverse()
118
108
    return mainline
134
124
    """
135
125
    if ancestry is None:
136
126
        return None
137
 
    if not ancestry: #Empty ancestry, no need to do any work
 
127
    if not ancestry:  # Empty ancestry, no need to do any work
138
128
        return []
139
129
 
140
130
    merge_sorted_revisions = branch.iter_merge_sorted_revisions()
157
147
    if revid_range is None or revs is None:
158
148
        return revs
159
149
    return [rev for rev in revs
160
 
        if graph.is_between(rev[1], revid_range[0], revid_range[1])]
 
150
            if graph.is_between(rev[1], revid_range[0], revid_range[1])]
161
151
 
162
152
 
163
153
def _find_unmerged(local_branch, remote_branch, restrict,
167
157
 
168
158
    The branches should already be locked before entering.
169
159
    """
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:
 
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:
173
172
        # A simple shortcut when the tips are at the same point
174
173
        return [], []
175
174
    graph = local_branch.repository.get_graph(remote_branch.repository)
201
200
                                     local_revision_id, backward)
202
201
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
203
202
                                      remote_revision_id, backward)
204
 
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
205
 
        remotes, remote_revid_range)
 
203
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(
 
204
        graph, remotes, remote_revid_range)
206
205
 
207
206
 
208
207
def sorted_revisions(revisions, history_map):