Logo Search packages:      
Sourcecode: hgsubversion version File versions  Download package

def hgsubversion::svnmeta::SVNMeta::split_branch_path (   self,
  path,
  existing = True 
)
Figure out which branch inside our repo this path represents, and
also figure out which path inside that branch it is.

Returns a tuple of (path within branch, local branch name, server-side
branch path).

Note that tag paths can also be matched: assuming tags/tag-1.1
is a tag then:
tags/tag-1.1 => ('', '../tags/tag-1.1', 'tags/tag-1.1')
tags/tag-1.1/file => ('file', '../tags/tag-1.1', 'tags/tag-1.1')
tags/tag-1.2 => (None, None, None)

If existing=True, will return None, None, None if the file isn't on
some known branch. If existing=False, then it will guess what the
branch would be if it were known. Server-side branch path should be
relative to our subdirectory.

Definition at line 311 of file svnmeta.py.

                                                    :
        """Figure out which branch inside our repo this path represents, and
        also figure out which path inside that branch it is.

        Returns a tuple of (path within branch, local branch name, server-side
        branch path).

        Note that tag paths can also be matched: assuming tags/tag-1.1
        is a tag then:
        tags/tag-1.1 => ('', '../tags/tag-1.1', 'tags/tag-1.1')
        tags/tag-1.1/file => ('file', '../tags/tag-1.1', 'tags/tag-1.1')
        tags/tag-1.2 => (None, None, None)

        If existing=True, will return None, None, None if the file isn't on
        some known branch. If existing=False, then it will guess what the
        branch would be if it were known. Server-side branch path should be
        relative to our subdirectory.
        """
        path = self.normalize(path)
        if self.layout == 'single':
            return (path, None, '')
        tag = self.get_path_tag(path)
        if tag:
            # consider the new tags when dispatching entries
            matched = []
            for tags in (self.tags, self.addedtags):
                matched += [t for t in tags
                            if (tag == t or tag.startswith(t + '/'))]
            if not matched:
                return None, None, None
            matched.sort(key=len, reverse=True)
            if tag == matched[0]:
                brpath = ''
                svrpath = path
            else:
                brpath = tag[len(matched[0])+1:]
                svrpath = path[:-(len(brpath)+1)]
            ln = self.localname(svrpath)
            return brpath, ln, svrpath
        test = ''
        path_comps = path.split('/')
        while self.localname(test) not in self.branches and len(path_comps):
            if not test:
                test = path_comps.pop(0)
            else:
                test += '/%s' % path_comps.pop(0)
        if self.localname(test) in self.branches:
            return path[len(test)+1:], self.localname(test), test
        if existing:
            return None, None, None
        if path == 'trunk' or path.startswith('trunk/'):
            path = path.split('/')[1:]
            test = 'trunk'
        elif path.startswith('branches/'):
            elts = path.split('/')
            test = '/'.join(elts[:2])
            path = '/'.join(elts[2:])
        else:
            path = test.split('/')[-1]
            test = '/'.join(test.split('/')[:-1])
        ln =  self.localname(test)
        if ln and ln.startswith('../'):
            return None, None, None
        return path, ln, test


Generated by  Doxygen 1.6.0   Back to index