~jelmer/brz/merge-3.3

« back to all changes in this revision

Viewing changes to crates/bazaar/src/repository.rs

  • Committer: The Breezy Bot
  • Author(s): Jelmer Vernooij, Jelmer Vernooij
  • Date: 2023-11-17 14:41:17 UTC
  • mfrom: (7883.6.4 remote)
  • Revision ID: the_breezy_bot-20231117144117-rmvcbx6ntiui70zl
Add baisc smart modules

by jelmer review by jelmer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/// A repository format.
 
2
///
 
3
/// Formats provide four things:
 
4
///  * An initialization routine to construct repository data on disk.
 
5
///  * a optional format string which is used when the BzrDir supports
 
6
///    versioned children.
 
7
///  * an open routine which returns a Repository instance.
 
8
///  * A network name for referring to the format in smart server RPC
 
9
///    methods.
 
10
///
 
11
/// There is one and only one Format subclass for each on-disk format. But
 
12
/// there can be one Repository subclass that is used for several different
 
13
/// formats. The _format attribute on a Repository instance can be used to
 
14
/// determine the disk format.
 
15
///
 
16
/// Formats are placed in a registry by their format string for reference
 
17
/// during opening. These should be subclasses of RepositoryFormat for
 
18
/// consistency.
 
19
///
 
20
/// Once a format is deprecated, just deprecate the initialize and open
 
21
/// methods on the format class. Do not deprecate the object, as the
 
22
/// object may be created even when a repository instance hasn't been
 
23
/// created.
 
24
///
 
25
/// Common instance attributes:
 
26
/// _matchingcontroldir - the controldir format that the repository format was
 
27
/// originally written to work with. This can be used if manually
 
28
/// constructing a bzrdir and repository, or more commonly for test suite
 
29
/// parameterization.
 
30
pub trait RepositoryFormat {
 
31
    fn get_format_description(&self) -> String;
 
32
 
 
33
    /// Is this format supported?
 
34
    ///
 
35
    /// Supported formats must be initializable and openable.
 
36
    /// Unsupported formats may not support initialization or committing or
 
37
    /// some other features depending on the reason for not being supported.
 
38
    fn is_supported(&self) -> bool;
 
39
 
 
40
    /// Is this format deprecated?
 
41
    ///
 
42
    /// Deprecated formats may trigger a user-visible warning recommending
 
43
    /// the user to upgrade. They are still fully supported.
 
44
    fn is_deprecated(&self) -> bool;
 
45
 
 
46
    /// A simple byte string uniquely identifying this format for RPC calls.
 
47
    ///
 
48
    /// MetaDir repository formats use their disk format string to identify the
 
49
    /// repository over the wire. All in one formats such as bzr < 0.8, and
 
50
    /// foreign formats like svn/git and hg should use some marker which is
 
51
    /// unique and immutable.
 
52
    fn network_name(&self) -> Vec<u8>;
 
53
}