~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Martin Pool
  • Date: 2005-06-22 06:37:43 UTC
  • Revision ID: mbp@sourcefrog.net-20050622063743-e395f04c4db8977f
- move old blackbox code from testbzr into bzrlib.selftest.blackbox

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.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
97
92
                # there should be *some* way of making old entries have
98
93
                # the full meta information.
99
94
                import tempfile, os, errno
100
 
                from bzrlib.xml import pack_xml
101
 
                
102
95
                rev_tmp = tempfile.TemporaryFile()
103
 
                pack_xml(rev, rev_tmp)
 
96
                rev.write_xml(rev_tmp)
104
97
                rev_tmp.seek(0)
105
98
 
106
99
                tmpfd, tmp_path = tempfile.mkstemp(prefix=rev_id, suffix='.gz',