Example #1
0
    def __init__(self, ui, path, branchincludelist=None):
        if not os.path.exists(os.path.join(path, ".repo")):
            raise common.NoRepo(
                _("%s does not look like a repo repository") % path)

        self.ui = ui
        self.path = path
        self.branches = None
        self.repocommandline = repo_commandline(ui, path)
        self.gitcommandline = common.commandline(ui, "git")
        self._branchincludelist = branchincludelist

        self.repobranchsingleregex = re.compile(
            r"^(?P<checkedout>[* ])(?P<published>[pP ]) (?P<name>\S+)\s+|"
            r" in\ (?P<project>\S+)$")
        self.repobranchmultistartregex = re.compile(
            r"^(?P<checkedout>[* ])(?P<published>[pP ]) (?P<name>\S+)\s+\| in:$"
        )

        self.projectpathindex = self._buildprojectmap()

        self.manifestprojectpath = os.path.dirname(
            os.path.realpath(os.path.join(path, ".repo/manifest.xml")))
        if not os.path.exists(self.manifestprojectpath):
            raise error.Abort(
                _('Could not find manifest project path "%s"') %
                self.manifestprojectpath)

        self._fetchmanifestdata(self.manifestprojectpath)
Example #2
0
    def __init__(self, ui, repotype, path, revs=None):
        """
        raises common.NoRepo if the directory doesn't exist or isn't a Google repo
        """

        super(repo_source, self).__init__(ui, repotype, path, revs=revs)

        self._fullmergeenabled = self.ui.configbool(
            self.CONFIG_NAMESPACE, self.CONFIG_FULL_MERGE, default=True
        )
        self._difftreecacheenabled = self.ui.configbool(
            self.CONFIG_NAMESPACE, self.CONFIG_DIFFTREE_CACHE_ENABLED, default=True
        )
        self._dirredenabled = self.ui.configbool(
            self.CONFIG_NAMESPACE, self.CONFIG_DIRRED_ENABLED, default=True
        )
        self._branchincludelist = self.ui.configlist(
            self.CONFIG_NAMESPACE, self.CONFIG_BRANCH_WHITELIST, default=None
        )

        self.srcencoding = "utf-8"  # TODO: Read from git source projects
        self.pprinter = pprint.PrettyPrinter()
        self.repo = repo(ui, path, branchincludelist=self._branchincludelist)
        self.repocommandline = repo_commandline(ui, path)
        self.gitcommandline = common.commandline(ui, "git")

        self.pathprojectindex = self.repo._buildprojectmap()
        self.projectpathindex = {
            project: path for path, project in pycompat.iteritems(self.pathprojectindex)
        }
        self.commitprojectindex = self._buildcommitprojectmap()
        self.objecthashprojectindex = {}
        self.filecache = {}
        self._difftreecache = {}
        self._filemodecache = {}
Example #3
0
 def _createdifftreepipe(cls, ui, path):
     """
     path:
     returns: (in, out, err)
     """
     pipecommandline = common.commandline(ui, "git")
     pipein, pipeout, pipeerr = pipecommandline._run3(
         "-C", path, "diff-tree", "--stdin", "--root", "-z", "-m", "-r")
     return pipein, pipeout, pipeerr
Example #4
0
 def fetchfromgit(filename: str) -> str:
     commandline = common.commandline(ui, "git")
     output, exitcode = commandline.run(
         "-C", gitpath, "show", "%s:%s" % (version, filename)
     )
     commandline.checkexit(
         exitcode, _("Failed to get manifest %s:%s") % (version, filename)
     )
     return output
Example #5
0
    def _createcatfilepipe(cls, ui, path):
        """Initializes a catfile batch process for a particular git repository, complete
        with input, output and error pipes.

        path: the repo-relative path of the git repository
        return value: a tuple of the input, output and error streams for the catfile
        process
        """

        pipecommandline = common.commandline(ui, "git")
        catfilein, catfileout, catfileerr = pipecommandline._run3(
            "-C", path, "cat-file", "--batch")
        return (catfilein, catfileout, catfileerr)