def GetSVNBranch(self):
    if (self.svn_branch is None):
        if (not self.GetIsGitSvn()):
            DieWithError("Repo doesn't appear to be a git-svn repo.")
        git_svn_re = re.compile('^\\s*git-svn-id: (\\S+)@', re.MULTILINE)
        cmd = ['git', 'log', '-100', '--pretty=medium']
        proc = subprocess2.Popen(cmd, stdout=subprocess2.PIPE, env=GetNoGitPagerEnv())
        url = None
        for line in proc.stdout:
            match = git_svn_re.match(line)
            if match:
                url = match.group(1)
                proc.stdout.close()
                break
        if url:
            svn_remote_re = re.compile('^svn-remote\\.([^.]+)\\.url (.*)$')
            remotes = RunGit(['config', '--get-regexp', '^svn-remote\\..*\\.url']).splitlines()
            for remote in remotes:
                match = svn_remote_re.match(remote)
                if match:
                    remote = match.group(1)
                    base_url = match.group(2)
                    rewrite_root = RunGit(['config', ('svn-remote.%s.rewriteRoot' % remote)], error_ok=True).strip()
                    if rewrite_root:
                        base_url = rewrite_root
                    fetch_spec = RunGit(['config', ('svn-remote.%s.fetch' % remote)], error_ok=True).strip()
                    if fetch_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, fetch_spec, False)
                        if self.svn_branch:
                            break
                    branch_spec = RunGit(['config', ('svn-remote.%s.branches' % remote)], error_ok=True).strip()
                    if branch_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, branch_spec, True)
                        if self.svn_branch:
                            break
                    tag_spec = RunGit(['config', ('svn-remote.%s.tags' % remote)], error_ok=True).strip()
                    if tag_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, tag_spec, True)
                        if self.svn_branch:
                            break
        if (not self.svn_branch):
            DieWithError("Can't guess svn branch -- try specifying it on the command line")
    return self.svn_branch
def GetSVNBranch(self):
    if (self.svn_branch is None):
        if (not self.GetIsGitSvn()):
            DieWithError("Repo doesn't appear to be a git-svn repo.")
        git_svn_re = re.compile('^\\s*git-svn-id: (\\S+)@', re.MULTILINE)
        cmd = ['git', 'log', '-100', '--pretty=medium']
        proc = subprocess2.Popen(cmd, stdout=subprocess2.PIPE, env=GetNoGitPagerEnv())
        url = None
        for line in proc.stdout:
            match = git_svn_re.match(line)
            if match:
                url = match.group(1)
                proc.stdout.close()
                break
        if url:
            svn_remote_re = re.compile('^svn-remote\\.([^.]+)\\.url (.*)$')
            remotes = RunGit(['config', '--get-regexp', '^svn-remote\\..*\\.url']).splitlines()
            for remote in remotes:
                match = svn_remote_re.match(remote)
                if match:
                    remote = match.group(1)
                    base_url = match.group(2)
                    rewrite_root = RunGit(['config', ('svn-remote.%s.rewriteRoot' % remote)], error_ok=True).strip()
                    if rewrite_root:
                        base_url = rewrite_root
                    fetch_spec = RunGit(['config', ('svn-remote.%s.fetch' % remote)], error_ok=True).strip()
                    if fetch_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, fetch_spec, False)
                        if self.svn_branch:
                            break
                    branch_spec = RunGit(['config', ('svn-remote.%s.branches' % remote)], error_ok=True).strip()
                    if branch_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, branch_spec, True)
                        if self.svn_branch:
                            break
                    tag_spec = RunGit(['config', ('svn-remote.%s.tags' % remote)], error_ok=True).strip()
                    if tag_spec:
                        self.svn_branch = MatchSvnGlob(url, base_url, tag_spec, True)
                        if self.svn_branch:
                            break
        if (not self.svn_branch):
            DieWithError("Can't guess svn branch -- try specifying it on the command line")
    return self.svn_branch