/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 bzrlib/missing.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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 . import (
20
 
    errors,
 
19
from __future__ import absolute_import
 
20
 
 
21
from bzrlib import (
21
22
    log,
 
23
    symbol_versioning,
22
24
    )
 
25
import bzrlib.revision as _mod_revision
23
26
 
24
27
 
25
28
def iter_log_revisions(revisions, revision_source, verbose, rev_tag_dict=None):
 
29
    last_tree = revision_source.revision_tree(_mod_revision.NULL_REVISION)
 
30
    last_rev_id = None
 
31
 
26
32
    if rev_tag_dict is None:
27
33
        rev_tag_dict = {}
28
 
    for revno, rev_id, merge_depth in revisions:
 
34
    for rev in revisions:
 
35
        # We need the following for backward compatibilty (hopefully
 
36
        # this will be deprecated soon :-/) -- vila 080911
 
37
        if len(rev) == 2:
 
38
            revno, rev_id = rev
 
39
            merge_depth = 0
 
40
        else:
 
41
            revno, rev_id, merge_depth = rev
29
42
        rev = revision_source.get_revision(rev_id)
30
43
        if verbose:
31
44
            delta = revision_source.get_revision_delta(rev_id)
37
50
 
38
51
def find_unmerged(local_branch, remote_branch, restrict='all',
39
52
                  include_merged=None, backward=False,
40
 
                  local_revid_range=None, remote_revid_range=None):
 
53
                  local_revid_range=None, remote_revid_range=None,
 
54
                  include_merges=symbol_versioning.DEPRECATED_PARAMETER):
41
55
    """Find revisions from each side that have not been merged.
42
56
 
43
57
    :param local_branch: Compare the history of local_branch
55
69
        revisions (lower bound, upper bound)
56
70
    :param remote_revid_range: Revision-id range for filtering remote_branch
57
71
        revisions (lower bound, upper bound)
 
72
    :param include_merges: Deprecated historical alias for include_merged
58
73
 
59
74
    :return: A list of [(revno, revision_id)] for the mainline revisions on
60
75
        each side.
61
76
    """
 
77
    if symbol_versioning.deprecated_passed(include_merges):
 
78
        symbol_versioning.warn(
 
79
            'include_merges was deprecated in 2.5.'
 
80
            ' Use include_merged instead.',
 
81
            DeprecationWarning, stacklevel=2)
 
82
        if include_merged is None:
 
83
            include_merged = include_merges
62
84
    if include_merged is None:
63
85
        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)
 
86
    local_branch.lock_read()
 
87
    try:
 
88
        remote_branch.lock_read()
 
89
        try:
 
90
            return _find_unmerged(
 
91
                local_branch, remote_branch, restrict=restrict,
 
92
                include_merged=include_merged, backward=backward,
 
93
                local_revid_range=local_revid_range,
 
94
                remote_revid_range=remote_revid_range)
 
95
        finally:
 
96
            remote_branch.unlock()
 
97
    finally:
 
98
        local_branch.unlock()
70
99
 
71
100
 
72
101
def _enumerate_mainline(ancestry, graph, tip_revno, tip, backward=True):
78
107
    :param tip: The tip of mainline
79
108
    :param backward: Show oldest versions first when True, newest versions
80
109
        first when False.
81
 
    :return: [(revno, revision_id, 0)] for all revisions in ancestry that
 
110
    :return: [(revno, revision_id)] for all revisions in ancestry that
82
111
        are left-hand parents from tip, or None if ancestry is None.
83
112
    """
84
113
    if ancestry is None:
85
114
        return None
86
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
115
    if not ancestry: #Empty ancestry, no need to do any work
87
116
        return []
88
117
 
89
118
    # Optionally, we could make 1 call to graph.get_parent_map with all
97
126
        parent_map = graph.get_parent_map([cur])
98
127
        parents = parent_map.get(cur)
99
128
        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))
 
129
            break # Ghost, we are done
 
130
        mainline.append((str(cur_revno), cur))
103
131
        cur = parents[0]
104
 
        if cur_revno is not None:
105
 
            cur_revno -= 1
 
132
        cur_revno -= 1
106
133
    if not backward:
107
134
        mainline.reverse()
108
135
    return mainline
124
151
    """
125
152
    if ancestry is None:
126
153
        return None
127
 
    if not ancestry:  # Empty ancestry, no need to do any work
 
154
    if not ancestry: #Empty ancestry, no need to do any work
128
155
        return []
129
156
 
130
157
    merge_sorted_revisions = branch.iter_merge_sorted_revisions()
147
174
    if revid_range is None or revs is None:
148
175
        return revs
149
176
    return [rev for rev in revs
150
 
            if graph.is_between(rev[1], revid_range[0], revid_range[1])]
 
177
        if graph.is_between(rev[1], revid_range[0], revid_range[1])]
151
178
 
152
179
 
153
180
def _find_unmerged(local_branch, remote_branch, restrict,
157
184
 
158
185
    The branches should already be locked before entering.
159
186
    """
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:
 
187
    local_revno, local_revision_id = local_branch.last_revision_info()
 
188
    remote_revno, remote_revision_id = remote_branch.last_revision_info()
 
189
    if local_revno == remote_revno and local_revision_id == remote_revision_id:
172
190
        # A simple shortcut when the tips are at the same point
173
191
        return [], []
174
192
    graph = local_branch.repository.get_graph(remote_branch.repository)
200
218
                                     local_revision_id, backward)
201
219
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
202
220
                                      remote_revision_id, backward)
203
 
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(
204
 
        graph, remotes, remote_revid_range)
 
221
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
 
222
        remotes, remote_revid_range)
205
223
 
206
224
 
207
225
def sorted_revisions(revisions, history_map):
208
 
    revisions = sorted([(history_map[r], r) for r in revisions])
 
226
    revisions = [(history_map[r],r) for r in revisions]
 
227
    revisions.sort()
209
228
    return revisions