~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

Handled more pipe errors for display commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
#
1
3
# Copyright (C) 2005 Canonical Ltd
2
4
#
3
5
# This program is free software; you can redistribute it and/or modify
66
68
# versions.
67
69
 
68
70
 
 
71
# TODO: Don't create a progress bar here, have it passed by the caller.  
 
72
# At least do it from the UI factory.
 
73
 
 
74
if False:
 
75
    try:
 
76
        import psyco
 
77
        psyco.full()
 
78
    except ImportError:
 
79
        pass
 
80
 
 
81
 
69
82
import os
70
83
import tempfile
71
84
import sys
 
85
import logging
72
86
import shutil
73
87
 
74
88
from bzrlib.branch import Branch, find_branch
75
89
from bzrlib.branch import BZR_BRANCH_FORMAT_5, BZR_BRANCH_FORMAT_6
76
90
import bzrlib.hashcache as hashcache
 
91
from bzrlib.revfile import Revfile
77
92
from bzrlib.weave import Weave
78
93
from bzrlib.weavefile import read_weave, write_weave
79
94
from bzrlib.ui import ui_factory
80
95
from bzrlib.atomicfile import AtomicFile
81
96
from bzrlib.xml4 import serializer_v4
82
97
from bzrlib.xml5 import serializer_v5
83
 
from bzrlib.trace import mutter, note, warning
84
 
from bzrlib.osutils import sha_strings, sha_string, pathjoin, abspath
 
98
from bzrlib.trace import mutter, note, warning, enable_default_logging
 
99
from bzrlib.osutils import sha_strings, sha_string
85
100
 
86
101
 
87
102
class Convert(object):
108
123
            note('starting upgrade from format 5 to 6')
109
124
            self._convert_to_prefixed()
110
125
            self._open_branch()
111
 
        cache = hashcache.HashCache(abspath(self.base))
 
126
        cache = hashcache.HashCache(os.path.abspath(self.base))
112
127
        cache.clear()
113
128
        cache.write()
114
129
        note("finished")
118
133
        from bzrlib.store import hash_prefix
119
134
        for store_name in ["weaves", "revision-store"]:
120
135
            note("adding prefixes to %s" % store_name) 
121
 
            store_dir = pathjoin(self.base, ".bzr", store_name)
 
136
            store_dir = os.path.join(self.base, ".bzr", store_name)
122
137
            for filename in os.listdir(store_dir):
123
138
                if filename.endswith(".weave") or filename.endswith(".gz"):
124
139
                    file_id = os.path.splitext(filename)[0]
125
140
                else:
126
141
                    file_id = filename
127
 
                prefix_dir = pathjoin(store_dir, hash_prefix(file_id))
 
142
                prefix_dir = os.path.join(store_dir, hash_prefix(file_id))
128
143
                if not os.path.isdir(prefix_dir):
129
144
                    os.mkdir(prefix_dir)
130
 
                os.rename(pathjoin(store_dir, filename),
131
 
                          pathjoin(prefix_dir, filename))
 
145
                os.rename(os.path.join(store_dir, filename),
 
146
                          os.path.join(prefix_dir, filename))
132
147
        self._set_new_format(BZR_BRANCH_FORMAT_6)
133
148
 
134
149