1 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 from bzrlib.errors import NotBranchError
18 class RepositoryLayout:
19 """Describes a repository layout."""
20 def get_tag_path(self, name, project=""):
21 """Return the path at which the tag with specified name should be found.
23 :param name: Name of the tag.
24 :param project: Optional name of the project the tag is for. Can include slashes.
25 :return: Path of the tag."
27 raise NotImplementedError
29 def get_branch_path(self, name, project=""):
30 """Return the path at which the branch with specified name should be found.
32 :param name: Name of the branch.
33 :param project: Optional name of the project the branch is for. Can include slashes.
34 :return: Path of the branch.
36 raise NotImplementedError
38 def parse(self, path):
41 :return: Tuple with type ('tag', 'branch'), project name, branch path and path
44 raise NotImplementedError
46 def is_branch(self, path):
47 """Check whether a specified path points at a branch."""
49 (type, _, bp, rp) = self.parse(path)
50 except NotBranchError:
52 if type == "branch" and rp == "":
56 def is_tag(self, path):
57 """Check whether a specified path points at a tag."""
59 (type, _, bp, rp) = self.parse(path)
60 except NotBranchError:
62 if type == "tag" and rp == "":
66 def get_branches(self, revnum, project=""):
67 """Retrieve a list of paths that refer to branches in a specific revision.
69 :result: Iterator over tuples with (project, branch path)
71 raise NotImplementedError
73 def get_tags(self, project="", revnum=None):
74 """Retrieve a list of paths that refer to tags in a specific revision.
76 :result: Iterator over tuples with (project, branch path)
78 raise NotImplementedError