~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/__init__.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# TODO: Could remember a bias towards whether a particular store is typically
18
18
# compressed or not.
42
42
 
43
43
class Store(object):
44
44
    """This class represents the abstract storage layout for saving information.
45
 
    
 
45
 
46
46
    Files can be added, but not modified once they are in.  Typically
47
47
    the hash is used as the name, or something else known to be unique,
48
48
    such as a UUID.
53
53
 
54
54
    def get(self, fileid, suffix=None):
55
55
        """Returns a file reading from a particular entry.
56
 
        
 
56
 
57
57
        If suffix is present, retrieve the named suffix for fileid.
58
58
        """
59
59
        raise NotImplementedError
71
71
 
72
72
    def has_id(self, fileid, suffix=None):
73
73
        """Return True or false for the presence of fileid in the store.
74
 
        
75
 
        suffix, if present, is a per file suffix, i.e. for digital signature 
 
74
 
 
75
        suffix, if present, is a per file suffix, i.e. for digital signature
76
76
        data."""
77
77
        raise NotImplementedError
78
78
 
102
102
 
103
103
        :param other: Another Store object
104
104
        :param ids: A list of entry ids to be copied
105
 
        :param pb: A ProgressBar object, if none is given, the default will be created.
 
105
        :param pb: A ProgressTask object, if none is given, the default will be created.
106
106
        :param permit_failure: Allow missing entries to be ignored
107
107
        :return: (n_copied, [failed]) The number of entries copied successfully,
108
108
            followed by a list of entries which could not be copied (because they
136
136
 
137
137
    def _copy_one(self, fileid, suffix, other, pb):
138
138
        """Most generic copy-one object routine.
139
 
        
 
139
 
140
140
        Subclasses can override this to provide an optimised
141
141
        copy between their own instances. Such overriden routines
142
 
        should call this if they have no optimised facility for a 
 
142
        should call this if they have no optimised facility for a
143
143
        specific 'other'.
144
144
        """
145
145
        mutter('Store._copy_one: %r', fileid)
158
158
        mutter("add store entry %r", fileid)
159
159
        names = self._id_to_names(fileid, suffix)
160
160
        if self._transport.has_any(names):
161
 
            raise BzrError("store %r already contains id %r" 
 
161
            raise BzrError("store %r already contains id %r"
162
162
                           % (self._transport.base, fileid))
163
163
 
164
164
        # Most of the time, just adding the file will work
199
199
 
200
200
    def _get_name(self, fileid, suffix=None):
201
201
        """A special check, which returns the name of an existing file.
202
 
        
 
202
 
203
203
        This is similar in spirit to 'has_id', but it is designed
204
204
        to return information about which file the store has.
205
205
        """
211
211
    def _get(self, filename):
212
212
        """Return an vanilla file stream for clients to read from.
213
213
 
214
 
        This is the body of a template method on 'get', and should be 
 
214
        This is the body of a template method on 'get', and should be
215
215
        implemented by subclasses.
216
216
        """
217
217
        raise NotImplementedError
317
317
        for relpath in self._transport.iter_files_recursive():
318
318
            count += 1
319
319
            total += self._transport.stat(relpath).st_size
320
 
                
 
320
 
321
321
        return count, total