def parse(self, path): """Parse a path. :return: Tuple with type ('tag', 'branch'), project name, branch path and path inside the branch """ assert isinstance(path, text_type) path = path.strip(u"/") parts = path.split(u"/") if len(parts) == 0: raise svn_errors.NotSvnBranchPath(path) if parts[0] == u"trunk": if len(parts) < (self.level + 1): raise svn_errors.NotSvnBranchPath(path) return ("branch", u"/".join(parts[1:self.level + 2]), u"/".join(parts[:self.level + 1]), u"/".join(parts[self.level + 1:])) elif parts[0] in (u"branches", u"tags"): if len(parts) < (self.level + 2): raise svn_errors.NotSvnBranchPath(path) if parts[0] == u"branches": t = "branch" else: t = "tag" return (t, u"/".join(parts[1:self.level + 1]), u"/".join(parts[:self.level + 2]), u"/".join(parts[self.level + 2:])) raise svn_errors.NotSvnBranchPath(path)
def parse(self, path): """Parse a path. :return: Tuple with type ('tag', 'branch'), project name, branch path and path inside the branch """ assert isinstance(path, text_type) path = path.strip(u"/") parts = path.split(u"/") for i, p in enumerate(parts): if (i > 0 and parts[i - 1] in (u"branches", u"tags")) or p == u"trunk": if i > 0 and parts[i - 1] == u"tags": t = "tag" j = i - 1 elif i > 0 and parts[i - 1] == u"branches": t = "branch" j = i - 1 else: t = "branch" j = i if self.level in (j, None): return (t, u"/".join(parts[:j]).strip(u"/"), u"/".join(parts[:i + 1]).strip(u"/"), u"/".join(parts[i + 1:]).strip(u"/")) raise svn_errors.NotSvnBranchPath(path, self)
def parse(self, path): assert isinstance(path, text_type) try: (proj, bp, rp) = self.scheme.unprefix(path) except InvalidSvnBranchPath as e: raise errors.NotSvnBranchPath(e.path) if self.scheme.is_tag(bp): type = "tag" else: type = "branch" return (type, proj, bp, rp)
def parse(self, path): """Parse a path. :return: Tuple with type ('tag', 'branch'), project name, branch path and path inside the branch """ assert isinstance(path, text_type) path = path.strip(u"/") parts = path.split(u"/") for i in range(len(parts) + 1): bp = u"/".join(parts[:i]) if self.is_branch(bp): return ("branch", bp, bp, path[len(bp):].strip(u"/")) if self.is_tag(bp): return ("tag", bp, bp, path[len(bp):].strip(u"/")) raise svn_errors.NotSvnBranchPath(path)
def parse(self, path): """Parse a path. :return: Tuple with type ('tag', 'branch'), project name, branch path and path inside the branch """ assert isinstance(path, text_type) path = path.strip(u"/") for bp in sorted(self.branches): if path.startswith(u"%s/" % bp) or bp == path: return ("branch", bp, bp, path[len(bp):].strip(u"/")) for tp in sorted(self.tags): if path.startswith(u"%s/" % tp) or tp == path: return ("tag", tp, tp, path[len(tp):].strip(u"/")) raise svn_errors.NotSvnBranchPath(path)