/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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 bzrlib import (
 
19
from . import (
 
20
    errors,
20
21
    log,
21
22
    )
22
 
import bzrlib.revision as _mod_revision
23
 
 
24
 
 
25
 
def iter_log_revisions(revisions, revision_source, verbose):
26
 
    last_tree = revision_source.revision_tree(_mod_revision.NULL_REVISION)
27
 
    last_rev_id = None
28
 
    for rev in revisions:
29
 
        # We need the following for backward compatibilty (hopefully
30
 
        # this will be deprecated soon :-/) -- vila 080911
31
 
        if len(rev) == 2:
32
 
            revno, rev_id = rev
33
 
            merge_depth = 0
34
 
        else:
35
 
            revno, rev_id, merge_depth = rev
 
23
 
 
24
 
 
25
def iter_log_revisions(revisions, revision_source, verbose, rev_tag_dict=None):
 
26
    if rev_tag_dict is None:
 
27
        rev_tag_dict = {}
 
28
    for revno, rev_id, merge_depth in revisions:
36
29
        rev = revision_source.get_revision(rev_id)
37
30
        if verbose:
38
31
            delta = revision_source.get_revision_delta(rev_id)
39
32
        else:
40
33
            delta = None
41
 
        yield log.LogRevision(rev, revno, merge_depth, delta=delta)
 
34
        yield log.LogRevision(rev, revno, merge_depth, delta=delta,
 
35
                              tags=rev_tag_dict.get(rev_id))
42
36
 
43
37
 
44
38
def find_unmerged(local_branch, remote_branch, restrict='all',
45
 
                  include_merges=False, backward=False,
 
39
                  include_merged=None, backward=False,
46
40
                  local_revid_range=None, remote_revid_range=None):
47
41
    """Find revisions from each side that have not been merged.
48
42
 
53
47
        unique revisions from both sides. If 'local', we will return None
54
48
        for the remote revisions, similarly if 'remote' we will return None for
55
49
        the local revisions.
56
 
    :param include_merges: Show mainline revisions only if False,
 
50
    :param include_merged: Show mainline revisions only if False,
57
51
        all revisions otherwise.
58
52
    :param backward: Show oldest versions first when True, newest versions
59
53
        first when False.
65
59
    :return: A list of [(revno, revision_id)] for the mainline revisions on
66
60
        each side.
67
61
    """
68
 
    local_branch.lock_read()
69
 
    try:
70
 
        remote_branch.lock_read()
71
 
        try:
72
 
            return _find_unmerged(
73
 
                local_branch, remote_branch, restrict=restrict,
74
 
                include_merges=include_merges, backward=backward,
75
 
                local_revid_range=local_revid_range,
76
 
                remote_revid_range=remote_revid_range)
77
 
        finally:
78
 
            remote_branch.unlock()
79
 
    finally:
80
 
        local_branch.unlock()
 
62
    if include_merged is None:
 
63
        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)
81
70
 
82
71
 
83
72
def _enumerate_mainline(ancestry, graph, tip_revno, tip, backward=True):
89
78
    :param tip: The tip of mainline
90
79
    :param backward: Show oldest versions first when True, newest versions
91
80
        first when False.
92
 
    :return: [(revno, revision_id)] for all revisions in ancestry that
 
81
    :return: [(revno, revision_id, 0)] for all revisions in ancestry that
93
82
        are left-hand parents from tip, or None if ancestry is None.
94
83
    """
95
84
    if ancestry is None:
96
85
        return None
97
 
    if not ancestry: #Empty ancestry, no need to do any work
 
86
    if not ancestry:  # Empty ancestry, no need to do any work
98
87
        return []
99
88
 
100
89
    # Optionally, we could make 1 call to graph.get_parent_map with all
108
97
        parent_map = graph.get_parent_map([cur])
109
98
        parents = parent_map.get(cur)
110
99
        if not parents:
111
 
            break # Ghost, we are done
112
 
        mainline.append((str(cur_revno), cur))
 
100
            break  # Ghost, we are done
 
101
        mainline.append(
 
102
            (str(cur_revno) if cur_revno is not None else None, cur, 0))
113
103
        cur = parents[0]
114
 
        cur_revno -= 1
 
104
        if cur_revno is not None:
 
105
            cur_revno -= 1
115
106
    if not backward:
116
107
        mainline.reverse()
117
108
    return mainline
133
124
    """
134
125
    if ancestry is None:
135
126
        return None
136
 
    if not ancestry: #Empty ancestry, no need to do any work
 
127
    if not ancestry:  # Empty ancestry, no need to do any work
137
128
        return []
138
129
 
139
130
    merge_sorted_revisions = branch.iter_merge_sorted_revisions()
156
147
    if revid_range is None or revs is None:
157
148
        return revs
158
149
    return [rev for rev in revs
159
 
        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])]
160
151
 
161
152
 
162
153
def _find_unmerged(local_branch, remote_branch, restrict,
163
 
                   include_merges, backward,
 
154
                   include_merged, backward,
164
155
                   local_revid_range=None, remote_revid_range=None):
165
156
    """See find_unmerged.
166
157
 
167
158
    The branches should already be locked before entering.
168
159
    """
169
 
    local_revno, local_revision_id = local_branch.last_revision_info()
170
 
    remote_revno, remote_revision_id = remote_branch.last_revision_info()
171
 
    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:
172
172
        # A simple shortcut when the tips are at the same point
173
173
        return [], []
174
174
    graph = local_branch.repository.get_graph(remote_branch.repository)
186
186
                             ' "remote": %r' % (restrict,))
187
187
        local_extra, remote_extra = graph.find_difference(local_revision_id,
188
188
                                                          remote_revision_id)
189
 
    if include_merges:
 
189
    if include_merged:
190
190
        locals = _enumerate_with_merges(local_branch, local_extra,
191
191
                                        graph, local_revno,
192
192
                                        local_revision_id, backward)
200
200
                                     local_revision_id, backward)
201
201
        remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
202
202
                                      remote_revision_id, backward)
203
 
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
204
 
        remotes, remote_revid_range)
 
203
    return _filter_revs(graph, locals, local_revid_range), _filter_revs(
 
204
        graph, remotes, remote_revid_range)
205
205
 
206
206
 
207
207
def sorted_revisions(revisions, history_map):
208
 
    revisions = [(history_map[r],r) for r in revisions]
209
 
    revisions.sort()
 
208
    revisions = sorted([(history_map[r], r) for r in revisions])
210
209
    return revisions