75
75
show_one_log(revno, rev, delta, verbose, sys.stdout, 'original')
79
def find_unmerged(local_branch, remote_branch):
80
progress = ui_factory.progress_bar()
81
local_branch.lock_read()
83
remote_branch.lock_read()
85
local_rev_history, local_rev_history_map = \
86
_get_history(local_branch, progress, "local", 0)
87
remote_rev_history, remote_rev_history_map = \
88
_get_history(remote_branch, progress, "remote", 1)
89
result = _shortcut(local_rev_history, remote_rev_history)
90
if result is not None:
91
local_extra, remote_extra = result
92
local_extra = sorted_revisions(local_extra,
93
local_rev_history_map)
94
remote_extra = sorted_revisions(remote_extra,
95
remote_rev_history_map)
96
return local_extra, remote_extra
98
local_ancestry = _get_ancestry(local_branch, progress, "local",
100
remote_ancestry = _get_ancestry(remote_branch, progress, "remote",
101
3, remote_rev_history)
102
progress.update('pondering', 4, 5)
103
extras = local_ancestry.symmetric_difference(remote_ancestry)
104
local_extra = extras.intersection(set(local_rev_history))
105
remote_extra = extras.intersection(set(remote_rev_history))
106
local_extra = sorted_revisions(local_extra, local_rev_history_map)
107
remote_extra = sorted_revisions(remote_extra,
108
remote_rev_history_map)
111
remote_branch.unlock()
113
local_branch.unlock()
115
return (local_extra, remote_extra)
117
def _shortcut(local_rev_history, remote_rev_history):
118
local_history = set(local_rev_history)
119
remote_history = set(remote_rev_history)
120
if len(local_rev_history) == 0:
121
return set(), remote_history
122
elif len(remote_rev_history) == 0:
123
return local_history, set()
124
elif local_rev_history[-1] in remote_history:
125
return set(), _after(remote_rev_history, local_rev_history)
126
elif remote_rev_history[-1] in local_history:
127
return _after(local_rev_history, remote_rev_history), set()
131
def _after(larger_history, smaller_history):
132
return set(larger_history[larger_history.index(smaller_history[-1])+1:])
134
def _get_history(branch, progress, label, step):
135
progress.update('%s history' % label, step, 5)
136
rev_history = branch.revision_history()
137
rev_history_map = dict(
138
[(rev, rev_history.index(rev) + 1)
139
for rev in rev_history])
140
return rev_history, rev_history_map
142
def _get_ancestry(branch, progress, label, step, rev_history):
143
progress.update('%s ancestry' % label, step, 5)
144
if len(rev_history) > 0:
145
ancestry = set(branch.get_ancestry(rev_history[-1]))
151
def sorted_revisions(revisions, history_map):
152
revisions = [(history_map[r],r) for r in revisions]