45
45
def find_unmerged(local_branch, remote_branch, restrict='all'):
46
"""Find revisions from each side that have not been merged.
48
:param local_branch: Compare the history of local_branch
49
:param remote_branch: versus the history of remote_branch, and determine
50
mainline revisions which have not been merged.
51
:param restrict: ('all', 'local', 'remote') If 'all', we will return the
52
unique revisions from both sides. If 'local', we will return None
53
for the remote revisions, similarly if 'remote' we will return None for
56
:return: A list of [(revno, revision_id)] for the mainline revisions on
46
59
local_branch.lock_read()
48
61
remote_branch.lock_read()
61
74
:param ancestry: A set of revisions that we care about
62
75
:param graph: A Graph which lets us find the parents for a revision
63
76
:param tip_revno: The revision number for the tip revision
64
:param tip: The tip of mailine
77
:param tip: The tip of mainline
65
78
:return: [(revno, revision_id)] for all revisions in ancestry that
66
left-hand parents from tip
79
are left-hand parents from tip, or None if ancestry is None.
68
81
if ancestry is None:
92
105
def _find_unmerged(local_branch, remote_branch, restrict):
93
"""Find revisions from each side that have not been merged.
95
Both branches should already be locked.
97
:param local_branch: Compare the history of local_branch
98
:param remote_branch: versus the history of remote_branch, and determine
99
mainline revisions which have not been merged.
100
:param restrict: ('all', 'local', 'remote') If 'all', we will return the
101
unique revisions from both sides. If 'local', we will return None
102
for the remote revisions, similarly if 'remote' we will return None for
105
:return: A list of [(revno, revision_id)] for the mainline revisions on
106
"""See find_unmerged.
108
The branches should already be locked before entering.
108
graph = local_branch.repository.get_graph(
109
remote_branch.repository)
110
110
local_revno, local_revision_id = local_branch.last_revision_info()
111
111
remote_revno, remote_revision_id = remote_branch.last_revision_info()
112
112
if local_revno == remote_revno and local_revision_id == remote_revision_id:
113
113
# A simple shortcut when the tips are at the same point
115
graph = local_branch.repository.get_graph(
116
remote_branch.repository)
115
117
if restrict == 'remote':
116
118
local_extra = None
117
119
remote_extra = graph.find_unique_ancestors(