~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/missing.py

  • Committer: Aaron Bentley
  • Date: 2005-11-29 18:17:21 UTC
  • mto: (1185.72.2 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1525.
  • Revision ID: abentley@panoramicfeedback.com-20051129181721-b7818abfc198e50a
Factored out find_unmerged

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""\
2
2
A plugin for displaying what revisions are in 'other' but not in local.
3
3
"""
4
 
 
 
4
from bzrlib.ui import ui_factory
5
5
def show_missing(br_local, br_remote, verbose=False, quiet=False):
6
6
    """Show the revisions which exist in br_remote, that 
7
7
    do not exist in br_local.
75
75
        show_one_log(revno, rev, delta, verbose, sys.stdout, 'original')
76
76
    return 1
77
77
 
 
78
def find_unmerged(local_branch, remote_branch):
 
79
    local_branch.lock_read()
 
80
    try:
 
81
        remote_branch.lock_read()
 
82
        try:
 
83
            progress = ui_factory.progress_bar()
 
84
            progress.update('local history', 0, 5)
 
85
            local_rev_history = local_branch.revision_history()
 
86
            local_rev_history_map = dict(
 
87
                [(rev, local_rev_history.index(rev))
 
88
                 for rev in local_rev_history])
 
89
            progress.update('local ancestry', 1, 5)
 
90
            local_ancestry = set(local_branch.get_ancestry(
 
91
                local_rev_history[-1]))
 
92
            progress.update('remote history', 2, 5)
 
93
            remote_rev_history = remote_branch.revision_history()
 
94
            remote_rev_history_map = dict(
 
95
                [(rev, remote_rev_history.index(rev))
 
96
                 for rev in remote_rev_history])
 
97
            progress.update('remote ancestry', 3, 5)
 
98
            remote_ancestry = set(remote_branch.get_ancestry(
 
99
                remote_rev_history[-1]))
 
100
            progress.update('pondering', 4, 5)
 
101
            local_extra = set()
 
102
            remote_extra = set()
 
103
            for elem in local_ancestry.union(remote_ancestry):
 
104
                if ((elem in local_ancestry) and
 
105
                    (elem not in remote_ancestry)):
 
106
                    if elem in local_rev_history:
 
107
                        local_extra.add(elem)
 
108
                elif ((elem not in local_ancestry) and
 
109
                      (elem in remote_ancestry)):
 
110
                    if elem in remote_rev_history:
 
111
                        remote_extra.add(elem)
 
112
            progress.clear()
 
113
            local_extra = list(local_extra)
 
114
            local_extra.sort(key=local_rev_history_map.get)
 
115
            remote_extra = list(remote_extra)
 
116
            remote_extra.sort(key=remote_rev_history_map.get)
 
117
                    
 
118
        finally:
 
119
            remote_branch.unlock()
 
120
    finally:
 
121
        local_branch.unlock()
 
122
    return (local_extra, local_rev_history_map, remote_extra, 
 
123
            remote_rev_history_map)