~ubuntu-branches/ubuntu/raring/bzr-svn/raring

« back to all changes in this revision

Viewing changes to layout/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-07-30 23:14:36 UTC
  • mfrom: (1.1.28 upstream) (3.3.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100730231436-po8j0ibgjn2d6hy0
Tags: 1.0.3-1
* New upstream release.
 + Provides BranchConfig._get_change_editor. Closes: #572109
 + Supports more trunk layout levels. Closes: #573988
* Bump standards version to 3.9.1.
* Mark as supporting bzr 2.2.
* Suggest bzr-rewrite rather than bzr-rebase. LP: #481730

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
class RepositoryLayout(object):
33
33
    """Describes a repository layout."""
34
34
 
35
 
    def __init__(self):
36
 
        pass
37
 
 
38
35
    def get_project_prefixes(self, project):
39
36
        return [project]
40
37
 
129
126
    def get_branches(self, repository, revnum, project="", pb=None):
130
127
        """Retrieve a list of paths that refer to branches in a specific revision.
131
128
 
132
 
        :result: Iterator over tuples with (project, branch path)
 
129
        :return: Iterator over tuples with (project, branch path)
133
130
        """
134
131
        raise NotImplementedError(self.get_branches)
135
132
 
136
133
    def get_tags(self, repository, revnum, project="", pb=None):
137
134
        """Retrieve a list of paths that refer to tags in a specific revision.
138
135
 
139
 
        :result: Iterator over tuples with (project, branch path)
 
136
        :return: Iterator over tuples with (project, branch path)
140
137
        """
141
138
        raise NotImplementedError(self.get_tags)
142
139
 
195
192
    return ret
196
193
 
197
194
 
 
195
class RootPathFinder(object):
 
196
 
 
197
    def __init__(self, repository, revnum):
 
198
        self.repository = repository
 
199
        self.revnum = revnum
 
200
 
 
201
    def check_path(self, path):
 
202
        return self.repository.transport.check_path(path, self.revnum) == subvertpy.NODE_DIR
 
203
 
 
204
    def find_children(self, path):
 
205
        try:
 
206
            assert not path.startswith("/")
 
207
            dirents = self.repository.transport.get_dir(path, self.revnum, DIRENT_KIND|DIRENT_HAS_PROPS)[0]
 
208
        except subvertpy.SubversionException, (msg, num):
 
209
            if num in (subvertpy.ERR_FS_NOT_DIRECTORY,
 
210
                       subvertpy.ERR_FS_NOT_FOUND,
 
211
                       subvertpy.ERR_RA_DAV_PATH_NOT_FOUND,
 
212
                       ERR_RA_DAV_FORBIDDEN):
 
213
                return None
 
214
            raise
 
215
        return [(d, dirents[d]['has_props']) for d in dirents if dirents[d]['kind'] == subvertpy.NODE_DIR]
 
216
 
 
217
 
 
218
 
198
219
def get_root_paths(repository, itemlist, revnum, verify_fn, project=None, pb=None):
199
220
    """Find all the paths in the repository matching a list of items.
200
221
 
206
227
    :param pb: Optional progress bar.
207
228
    :return: Iterator over project, branch path, nick, has_props
208
229
    """
209
 
    def check_path(path):
210
 
        return repository.transport.check_path(path, revnum) == subvertpy.NODE_DIR
211
 
    def find_children(path):
212
 
        try:
213
 
            assert not path.startswith("/")
214
 
            dirents = repository.transport.get_dir(path, revnum, DIRENT_KIND|DIRENT_HAS_PROPS)[0]
215
 
        except subvertpy.SubversionException, (msg, num):
216
 
            if num in (subvertpy.ERR_FS_NOT_DIRECTORY,
217
 
                       subvertpy.ERR_FS_NOT_FOUND,
218
 
                       subvertpy.ERR_RA_DAV_PATH_NOT_FOUND,
219
 
                       ERR_RA_DAV_FORBIDDEN):
220
 
                return None
221
 
            raise
222
 
        return [(d, dirents[d]['has_props']) for d in dirents if dirents[d]['kind'] == subvertpy.NODE_DIR]
 
230
    rpf = RootPathFinder(repository, revnum)
223
231
 
224
232
    for idx, pattern in enumerate(itemlist):
225
233
        assert isinstance(pattern, str)
226
234
        if pb is not None:
227
235
            pb.update("finding branches", idx, len(itemlist))
228
 
        for bp, has_props in expand_branch_pattern([], pattern.strip("/").split("/"), check_path,
229
 
                find_children, project):
 
236
        for bp, has_props in expand_branch_pattern([],
 
237
                pattern.strip("/").split("/"), rpf.check_path,
 
238
                rpf.find_children, project):
230
239
            if verify_fn(bp, project):
231
240
                yield project, bp, bp.split("/")[-1], has_props
232
241
 
263
272
This would consider paths path/to/foo/bla, path/to/blie/bla and path/to/trunk
264
273
branches, if they existed. The key used (203a...) is the UUID of the Subversion
265
274
repository. The UUID for a repository can be found by running "svn info <url>"
266
 
or "bzr info <url>".
 
275
or "bzr info -v <url>".
267
276
 
268
277
"""
269
278
 
272
281
layout_registry.register_lazy("root", "bzrlib.plugins.svn.layout.standard", "RootLayout")
273
282
layout_registry.register_lazy("none", "bzrlib.plugins.svn.layout.standard", "RootLayout")
274
283
layout_registry.register_lazy("trunk", "bzrlib.plugins.svn.layout.standard", "TrunkLayout0")
275
 
layout_registry.register_lazy("trunk0", "bzrlib.plugins.svn.layout.standard", "TrunkLayout0")
276
 
layout_registry.register_lazy("trunk1", "bzrlib.plugins.svn.layout.standard", "TrunkLayout1")
277
 
layout_registry.register_lazy("trunk2", "bzrlib.plugins.svn.layout.standard", "TrunkLayout2")
278
 
layout_registry.register_lazy("trunk3", "bzrlib.plugins.svn.layout.standard", "TrunkLayout3")
 
284
for i in range(10):
 
285
    layout_registry.register_lazy("trunk%d" % i, "bzrlib.plugins.svn.layout.standard", "TrunkLayout%d" % i)
279
286
layout_registry.register_lazy("trunk-variable", "bzrlib.plugins.svn.layout.standard", "TrunkLayoutVariable")
280
287
 
281
288
layout_registry.register_lazy("itrunk1", "bzrlib.plugins.svn.layout.standard",
296
303
repository_registry = RepositoryRegistry()
297
304
repository_registry.register_lazy("283d02a7-25f6-0310-bc7c-ecb5cbfe19da",
298
305
        "bzrlib.plugins.svn.layout.custom", "KDELayout")
 
306
layout_registry.register_lazy("kde", "bzrlib.plugins.svn.layout.custom",
 
307
        "KDELayout")
299
308
repository_registry.register_lazy("13f79535-47bb-0310-9956-ffa450edef68",
300
309
        "bzrlib.plugins.svn.layout.custom", "ApacheLayout")