/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: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

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
 
    for revno, rev_id, merge_depth in revisions:
 
33
    for rev in revisions:
 
34
        # We need the following for backward compatibilty (hopefully
 
35
        # this will be deprecated soon :-/) -- vila 080911
 
36
        if len(rev) == 2:
 
37
            revno, rev_id = rev
 
38
            merge_depth = 0
 
39
        else:
 
40
            revno, rev_id, merge_depth = rev
29
41
        rev = revision_source.get_revision(rev_id)
30
42
        if verbose:
31
43
            delta = revision_source.get_revision_delta(rev_id)
61
73
    """
62
74
    if include_merged is None:
63
75
        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)
 
76
    local_branch.lock_read()
 
77
    try:
 
78
        remote_branch.lock_read()
 
79
        try:
 
80
            return _find_unmerged(
 
81
                local_branch, remote_branch, restrict=restrict,
 
82
                include_merged=include_merged, backward=backward,
 
83
                local_revid_range=local_revid_range,
 
84
                remote_revid_range=remote_revid_range)
 
85
        finally:
 
86
            remote_branch.unlock()
 
87
    finally:
 
88
        local_branch.unlock()
70
89
 
71
90
 
72
91
def _enumerate_mainline(ancestry, graph, tip_revno, tip, backward=True):
78
97
    :param tip: The tip of mainline
79
98
    :param backward: Show oldest versions first when True, newest versions
80
99
        first when False.
81
 
    :return: [(revno, revision_id, 0)] for all revisions in ancestry that
 
100
    :return: [(revno, revision_id)] for all revisions in ancestry that
82
101
        are left-hand parents from tip, or None if ancestry is None.
83
102
    """
84
103
    if ancestry is None:
85
104
        return None
86
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
105
    if not ancestry: #Empty ancestry, no need to do any work
87
106
        return []
88
107
 
89
108
    # Optionally, we could make 1 call to graph.get_parent_map with all
97
116
        parent_map = graph.get_parent_map([cur])
98
117
        parents = parent_map.get(cur)
99
118
        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))
 
119
            break # Ghost, we are done
 
120
        mainline.append((str(cur_revno), cur))
103
121
        cur = parents[0]
104
 
        if cur_revno is not None:
105
 
            cur_revno -= 1
 
122
        cur_revno -= 1
106
123
    if not backward:
107
124
        mainline.reverse()
108
125
    return mainline
124
141
    """
125
142
    if ancestry is None:
126
143
        return None
127
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
144
    if not ancestry: #Empty ancestry, no need to do any work
128
145
        return []
129
146
 
130
147
    merge_sorted_revisions = branch.iter_merge_sorted_revisions()
147
164
    if revid_range is None or revs is None:
148
165
        return revs
149
166
    return [rev for rev in revs
150
 
            if graph.is_between(rev[1], revid_range[0], revid_range[1])]
 
167
        if graph.is_between(rev[1], revid_range[0], revid_range[1])]
151
168
 
152
169
 
153
170
def _find_unmerged(local_branch, remote_branch, restrict,
157
174
 
158
175
    The branches should already be locked before entering.
159
176
    """
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:
 
177
    local_revno, local_revision_id = local_branch.last_revision_info()
 
178
    remote_revno, remote_revision_id = remote_branch.last_revision_info()
 
179
    if local_revno == remote_revno and local_revision_id == remote_revision_id:
172
180
        # A simple shortcut when the tips are at the same point
173
181
        return [], []
174
182
    graph = local_branch.repository.get_graph(remote_branch.repository)
200
208
                                     local_revision_id, backward)
201
209
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
202
210
                                      remote_revision_id, backward)
203
 
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(
204
 
        graph, remotes, remote_revid_range)
 
211
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
 
212
        remotes, remote_revid_range)
205
213
 
206
214
 
207
215
def sorted_revisions(revisions, history_map):
208
 
    revisions = sorted([(history_map[r], r) for r in revisions])
 
216
    revisions = sorted([(history_map[r],r) for r in revisions])
209
217
    return revisions