예제 #1
0
    def __init__(self, tests_root, rel_path, url_base, use_committed=False):
        """Object representing a file in a source tree.

        :param tests_root: Path to the root of the source tree
        :param rel_path: File path relative to tests_root
        :param url_base: Base URL used when converting file paths to urls
        :param use_committed: Work with the last committed version of the file
                              rather than the on-disk version.
        """

        self.tests_root = tests_root
        self.rel_path = rel_path
        self.url_base = url_base
        self.use_committed = use_committed

        self.url = rel_path_to_url(rel_path, url_base)
        self.path = os.path.join(tests_root, rel_path)

        self.dir_path, self.filename = os.path.split(self.path)
        self.name, self.ext = os.path.splitext(self.filename)

        self.type_flag = None
        if "-" in self.name:
            self.type_flag = self.name.rsplit("-", 1)[1]

        self.meta_flags = self.name.split(".")[1:]
예제 #2
0
파일: sourcefile.py 프로젝트: 0X1A/servo
    def __init__(self, tests_root, rel_path, url_base, use_committed=False):
        """Object representing a file in a source tree.

        :param tests_root: Path to the root of the source tree
        :param rel_path: File path relative to tests_root
        :param url_base: Base URL used when converting file paths to urls
        :param use_committed: Work with the last committed version of the file
                              rather than the on-disk version.
        """

        self.tests_root = tests_root
        self.rel_path = rel_path
        self.url_base = url_base
        self.use_committed = use_committed

        self.url = rel_path_to_url(rel_path, url_base)
        self.path = os.path.join(tests_root, rel_path)

        self.dir_path, self.filename = os.path.split(self.path)
        self.name, self.ext = os.path.splitext(self.filename)

        self.type_flag = None
        if "-" in self.name:
            self.type_flag = self.name.rsplit("-", 1)[1]

        self.meta_flags = self.name.split(".")[1:]
예제 #3
0
파일: tree.py 프로젝트: 0X1A/servo
    def local_changes(self):
        # Put all files into local_changes and rely on Manifest.update to de-dupe
        # changes that in fact committed at the base rev.

        rv = []
        for dir_path, dir_names, filenames in os.walk(self.tests_root):
            for filename in filenames:
                if any(fnmatch(filename, pattern) for pattern in self.ignore):
                    continue
                rel_path = os.path.relpath(os.path.join(dir_path, filename),
                                           self.tests_root)
                if is_blacklisted(rel_path_to_url(rel_path, self.url_base)):
                    continue
                rv.append((rel_path, "modified"))
        return dict(rv)
예제 #4
0
파일: tree.py 프로젝트: 0X1A/servo
    def committed_changes(self, base_rev=None):
        if base_rev is None:
            self.logger.debug("Adding all changesets to the manifest")
            return [(item, "modified") for item in self.paths()]

        self.logger.debug("Updating the manifest from %s to %s" % (base_rev, self.current_rev()))
        rv = []
        data  = self.git("diff", "-z", "--name-status", base_rev + "..HEAD")
        items = data.split("\0")
        for status, filename in chunks(items, 2):
            if is_blacklisted(rel_path_to_url(filename, self.url_base)):
                continue
            if status == "D":
                rv.append((filename, "deleted"))
            else:
                rv.append((filename, "modified"))
        return rv
예제 #5
0
파일: tree.py 프로젝트: 0X1A/servo
    def local_changes(self, path=None):
        # -z is stable like --porcelain; see the git status documentation for details
        cmd = ["status", "-z", "--ignore-submodules=all"]
        if path is not None:
            cmd.extend(["--", path])

        rv = {}

        data = self.git(*cmd)
        if data == "":
            return rv

        assert data[-1] == "\0"
        f = StringIO(data)

        while f.tell() < len(data):
            # First two bytes are the status in the stage (index) and working tree, respectively
            staged = f.read(1)
            worktree = f.read(1)
            assert f.read(1) == " "

            if staged == "R":
                # When a file is renamed, there are two files, the source and the destination
                files = 2
            else:
                files = 1

            filenames = []

            for i in range(files):
                filenames.append("")
                char = f.read(1)
                while char != "\0":
                    filenames[-1] += char
                    char = f.read(1)

            if not is_blacklisted(rel_path_to_url(filenames[0], self.url_base)):
                rv.update(self.local_status(staged, worktree, filenames))

        return rv