~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
import bzrlib.errors
19
 
import bzrlib.progress
 
18
 
20
19
 
21
20
 
22
21
def upgrade(branch):
35
34
 
36
35
    from bzrlib.trace import mutter
37
36
    from bzrlib.errors import BzrCheckError
38
 
    import bzrlib.ui
 
37
    from bzrlib.progress import ProgressBar
39
38
 
40
39
    branch.lock_write()
41
40
 
42
 
    pb = bzrlib.ui.ui_factory.progress_bar()
43
 
 
44
41
    try:
 
42
        pb = ProgressBar(show_spinner=True)
45
43
        last_rev_id = None
46
44
 
47
45
        history = branch.revision_history()
73
71
                mutter("  set inventory_sha1 on {%s}" % rev_id)
74
72
 
75
73
            for prr in rev.parents:
76
 
                try:
77
 
                    actual_sha1 = branch.get_revision_sha1(prr.revision_id)
78
 
                except bzrlib.errors.NoSuchRevision:
79
 
                    mutter("parent {%s} of {%s} not present in branch; skipped"
80
 
                           % (prr.revision_id, rev_id))
81
 
                    continue
82
 
                    
83
 
                if actual_sha1 != prr.revision_sha1:
84
 
                    mutter("parent {%s} of {%s} sha1 mismatch: "
85
 
                           "%s vs %s; fixed"
86
 
                           % (prr.revision_id, rev_id,
87
 
                              actual_sha1, prr.revision_sha1))
88
 
                    prr.revision_sha1 = actual_sha1
89
 
                    updated = True
 
74
                actual_sha1 = branch.get_revision_sha1(prr.revision_id)
 
75
                if (updated_previous_revision
 
76
                    or prr.revision_sha1 is None):
 
77
                    if prr.revision_sha1 != actual_sha1:
 
78
                        prr.revision_sha1 = actual_sha1
 
79
                        updated = True
 
80
                elif actual_sha1 != prr.revision_sha1:
 
81
                    raise BzrCheckError("parent {%s} of {%s} sha1 mismatch: "
 
82
                                        "%s vs %s"
 
83
                                        % (prr.revision_id, rev_id,
 
84
                                           actual_sha1, prr.revision_sha1))
90
85
 
91
86
            if updated:
92
87
                updated_previous_revision = True