Merge 0.4.
[jelmer/subvertpy.git] / layout.py
1 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
2  
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.
7
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.
12
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/>.
15
16 from bzrlib.errors import NotBranchError
17
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.
22
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."
26         """
27         raise NotImplementedError
28
29     def get_branch_path(self, name, project=""):
30         """Return the path at which the branch with specified name should be found.
31
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.
35         """
36         raise NotImplementedError
37
38     def parse(self, path):
39         """Parse a path.
40
41         :return: Tuple with type ('tag', 'branch'), project name, branch path and path 
42             inside the branch
43         """
44         raise NotImplementedError
45
46     def is_branch(self, path):
47         """Check whether a specified path points at a branch."""
48         try:
49             (type, _, bp, rp) = self.parse(path)
50         except NotBranchError:
51             return False
52         if type == "branch" and rp == "":
53             return True
54         return False
55
56     def is_tag(self, path):
57         """Check whether a specified path points at a tag."""
58         try:
59             (type, _, bp, rp) = self.parse(path)
60         except NotBranchError:
61             return False
62         if type == "tag" and rp == "":
63             return True
64         return False
65
66     def get_branches(self, revnum, project=""):
67         """Retrieve a list of paths that refer to branches in a specific revision.
68
69         :result: Iterator over tuples with (project, branch path)
70         """
71         raise NotImplementedError
72
73     def get_tags(self, project="", revnum=None):
74         """Retrieve a list of paths that refer to tags in a specific revision.
75
76         :result: Iterator over tuples with (project, branch path)
77         """
78         raise NotImplementedError