/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Aaron Bentley
  • Date: 2007-02-09 07:16:20 UTC
  • mfrom: (2272 +trunk)
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070209071620-gp2n7vtjyb0f2x1e
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
        return self.control_files.get_physical_lock_status()
245
245
 
246
246
    @needs_read_lock
 
247
    def gather_stats(self, revid=None, committers=None):
 
248
        """Gather statistics from a revision id.
 
249
 
 
250
        :param revid: The revision id to gather statistics from, if None, then
 
251
            no revision specific statistics are gathered.
 
252
        :param committers: Optional parameter controlling whether to grab
 
253
            a count of committers from the revision specific statistics.
 
254
        :return: A dictionary of statistics. Currently this contains:
 
255
            committers: The number of committers if requested.
 
256
            firstrev: A tuple with timestamp, timezone for the penultimate left
 
257
                most ancestor of revid, if revid is not the NULL_REVISION.
 
258
            latestrev: A tuple with timestamp, timezone for revid, if revid is
 
259
                not the NULL_REVISION.
 
260
            revisions: The total revision count in the repository.
 
261
            size: An estimate disk size of the repository in bytes.
 
262
        """
 
263
        result = {}
 
264
        if revid and committers:
 
265
            result['committers'] = 0
 
266
        if revid and revid != _mod_revision.NULL_REVISION:
 
267
            if committers:
 
268
                all_committers = set()
 
269
            revisions = self.get_ancestry(revid)
 
270
            # pop the leading None
 
271
            revisions.pop(0)
 
272
            first_revision = None
 
273
            if not committers:
 
274
                # ignore the revisions in the middle - just grab first and last
 
275
                revisions = revisions[0], revisions[-1]
 
276
            for revision in self.get_revisions(revisions):
 
277
                if not first_revision:
 
278
                    first_revision = revision
 
279
                if committers:
 
280
                    all_committers.add(revision.committer)
 
281
            last_revision = revision
 
282
            if committers:
 
283
                result['committers'] = len(all_committers)
 
284
            result['firstrev'] = (first_revision.timestamp,
 
285
                first_revision.timezone)
 
286
            result['latestrev'] = (last_revision.timestamp,
 
287
                last_revision.timezone)
 
288
 
 
289
        # now gather global repository information
 
290
        if self.bzrdir.root_transport.listable():
 
291
            c, t = self._revision_store.total_size(self.get_transaction())
 
292
            result['revisions'] = c
 
293
            result['size'] = t
 
294
        return result
 
295
 
 
296
    @needs_read_lock
247
297
    def missing_revision_ids(self, other, revision_id=None):
248
298
        """Return the revision ids that other has that this does not.
249
299
        
1200
1250
            raise errors.UnknownFormatError(format=format_string)
1201
1251
 
1202
1252
    @classmethod
1203
 
    @deprecated_method(symbol_versioning.zero_fourteen)
1204
 
    def set_default_format(klass, format):
1205
 
        klass._set_default_format(format)
1206
 
 
1207
 
    @classmethod
1208
 
    def _set_default_format(klass, format):
1209
 
        """Set the default format for new Repository creation.
1210
 
 
1211
 
        The format must already be registered.
1212
 
        """
1213
 
        format_registry.default_key = format.get_format_string()
1214
 
 
1215
 
    @classmethod
1216
1253
    def register_format(klass, format):
1217
1254
        format_registry.register(format.get_format_string(), format)
1218
1255
 
1223
1260
    @classmethod
1224
1261
    def get_default_format(klass):
1225
1262
        """Return the current default format."""
1226
 
        return format_registry.get(format_registry.default_key)
 
1263
        from bzrlib import bzrdir
 
1264
        return bzrdir.format_registry.make_bzrdir('default').repository_format
1227
1265
 
1228
1266
    def _get_control_store(self, repo_transport, control_files):
1229
1267
        """Return the control store for this repository."""
1871
1909
# formats which have no format string are not discoverable
1872
1910
# and not independently creatable, so are not registered.
1873
1911
RepositoryFormat.register_format(RepositoryFormat7())
1874
 
# KEEP in sync with bzrdir.format_registry default, which controls the overall
1875
 
# default control directory format
1876
 
_default_format = RepositoryFormatKnit1()
1877
 
RepositoryFormat.register_format(_default_format)
 
1912
# KEEP in sync with bzrdir.format_registry default
 
1913
RepositoryFormat.register_format(RepositoryFormatKnit1())
1878
1914
RepositoryFormat.register_format(RepositoryFormatKnit2())
1879
1915
RepositoryFormat.register_format(RepositoryFormatKnit3())
1880
 
RepositoryFormat._set_default_format(_default_format)
1881
1916
_legacy_formats = [RepositoryFormat4(),
1882
1917
                   RepositoryFormat5(),
1883
1918
                   RepositoryFormat6()]