13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Display what revisions are missing in 'other' from 'this' and vice versa."""
37
37
revno, rev_id, merge_depth = rev
38
38
rev = revision_source.get_revision(rev_id)
40
delta = revision_source.get_revision_delta(rev_id)
40
remote_tree = revision_source.revision_tree(rev_id)
41
parent_rev_id = rev.parent_ids[0]
42
if last_rev_id == parent_rev_id:
43
parent_tree = last_tree
45
parent_tree = revision_source.revision_tree(parent_rev_id)
46
revision_tree = revision_source.revision_tree(rev_id)
48
last_tree = revision_tree
49
delta = revision_tree.changes_from(parent_tree)
43
52
yield log.LogRevision(rev, revno, merge_depth, delta=delta)
46
55
def find_unmerged(local_branch, remote_branch, restrict='all',
47
include_merges=False, backward=False,
48
local_revid_range=None, remote_revid_range=None):
56
include_merges=False, backward=False):
49
57
"""Find revisions from each side that have not been merged.
51
59
:param local_branch: Compare the history of local_branch
58
66
:param include_merges: Show mainline revisions only if False,
59
67
all revisions otherwise.
60
68
:param backward: Show oldest versions first when True, newest versions
62
:param local_revid_range: Revision-id range for filtering local_branch
63
revisions (lower bound, upper bound)
64
:param remote_revid_range: Revision-id range for filtering remote_branch
65
revisions (lower bound, upper bound)
67
71
:return: A list of [(revno, revision_id)] for the mainline revisions on
74
78
return _find_unmerged(
75
79
local_branch, remote_branch, restrict=restrict,
76
include_merges=include_merges, backward=backward,
77
local_revid_range=local_revid_range,
78
remote_revid_range=remote_revid_range)
80
include_merges=include_merges, backward=backward)
80
82
remote_branch.unlock()
90
92
:param tip_revno: The revision number for the tip revision
91
93
:param tip: The tip of mainline
92
94
:param backward: Show oldest versions first when True, newest versions
94
96
:return: [(revno, revision_id)] for all revisions in ancestry that
95
97
are left-hand parents from tip, or None if ancestry is None.
129
131
:param tip_revno: The revision number for the tip revision
130
132
:param tip: The tip of the ancsetry
131
133
:param backward: Show oldest versions first when True, newest versions
133
135
:return: [(revno, revision_id)] for all revisions in ancestry that
134
136
are parents from tip, or None if ancestry is None.
138
140
if not ancestry: #Empty ancestry, no need to do any work
141
merge_sorted_revisions = branch.iter_merge_sorted_revisions()
143
mainline_revs, rev_nos, start_rev_id, end_rev_id = log._get_mainline_revs(
144
branch, None, tip_revno)
145
if not mainline_revs:
148
# This asks for all mainline revisions, which is size-of-history and
149
# should be addressed (but currently the only way to get correct
152
# mainline_revisions always includes an extra revision at the
153
# beginning, so don't request it.
154
parent_map = dict(((key, value) for key, value
155
in graph.iter_ancestry(mainline_revs[1:])
156
if value is not None))
157
# filter out ghosts; merge_sort errors on ghosts.
158
# XXX: is this needed here ? -- vila080910
159
rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
160
# XXX: what if rev_graph is empty now ? -- vila080910
161
merge_sorted_revisions = tsort.merge_sort(rev_graph, tip,
142
164
# Now that we got the correct revnos, keep only the relevant
144
166
merge_sorted_revisions = [
145
# log.reverse_by_depth expects seq_num to be present, but it is
146
# stripped by iter_merge_sorted_revisions()
147
(0, revid, n, d, e) for revid, n, d, e in merge_sorted_revisions
167
(s, revid, n, d, e) for s, revid, n, d, e in merge_sorted_revisions
148
168
if revid in ancestry]
150
170
merge_sorted_revisions = log.reverse_by_depth(merge_sorted_revisions)
157
def _filter_revs(graph, revs, revid_range):
158
if revid_range is None or revs is None:
160
return [rev for rev in revs
161
if graph.is_between(rev[1], revid_range[0], revid_range[1])]
164
177
def _find_unmerged(local_branch, remote_branch, restrict,
165
include_merges, backward,
166
local_revid_range=None, remote_revid_range=None):
178
include_merges, backward):
167
179
"""See find_unmerged.
169
181
The branches should already be locked before entering.
202
214
local_revision_id, backward)
203
215
remotes = _enumerate_mainline(remote_extra, graph, remote_revno,
204
216
remote_revision_id, backward)
205
return _filter_revs(graph, locals, local_revid_range), _filter_revs(graph,
206
remotes, remote_revid_range)
217
return locals, remotes
209
220
def sorted_revisions(revisions, history_map):