Esempio n. 1
0
    def branch_iterator(self, target_root=None):
        if len(self.config) == 0:
            # branch not have externals configuration
            return

        self.bound = True
        if not target_root:
            target_root = self.branch.get_bound_location()
            if not target_root:
                self.bound = False
                target_root = self.branch.get_parent()
                if not target_root:
                    # support new braches with no parent yet
                    target_root = self.branch.base

        for arg in self.config: # url directory [revisionspec]
            location = self._relurljoin(target_root, arg[0])
            if target_root.startswith('file:///'):
                # try to pull externals from the parent for the feature branch
                path = pathjoin(local_path_from_url(target_root), arg[1])
                if isdir(path):
                    location = self._relpath(path)
                else:
                    # parent is local master branch
                    if location.startswith('file:///'):
                        location = self._relpath(local_path_from_url(location))

            check_legal_path(arg[1])
            rel_path = self._relpath(pathjoin(self.root, arg[1]))

            revision = None
            if len(arg) > 2:
                revision = arg[2]
            yield location, rel_path, revision
Esempio n. 2
0
 def writeChunk(self, name, offset, data):
     """Write a chunk of data to file `name` at `offset`."""
     abspath = self._abspath(name)
     osutils.check_legal_path(abspath)
     try:
         chunk_file = os.open(abspath, os.O_CREAT | os.O_WRONLY)
     except OSError as e:
         if e.errno != errno.EISDIR:
             raise
         raise FileIsADirectory(name)
     os.lseek(chunk_file, offset, 0)
     os.write(chunk_file, data)
     os.close(chunk_file)
Esempio n. 3
0
    def put_bytes(self, relpath, bytes, mode=None):
        """Copy the string into the location.

        :param relpath: Location to put the contents, relative to base.
        :param bytes:   String
        """

        path = relpath
        try:
            path = self._abspath(relpath)
            osutils.check_legal_path(path)
            fp = atomicfile.AtomicFile(path, 'wb', new_mode=mode)
        except (IOError, OSError),e:
            self._translate_error(e, path)
Esempio n. 4
0
    def put_file(self, relpath, f, mode=None):
        """Copy the file-like object into the location.

        :param relpath: Location to put the contents, relative to base.
        :param f:       File-like object.
        :param mode: The mode for the newly created file,
                     None means just use the default
        """

        path = relpath
        try:
            path = self._abspath(relpath)
            osutils.check_legal_path(path)
            fp = atomicfile.AtomicFile(path, 'wb', new_mode=mode)
        except (IOError, OSError),e:
            self._translate_error(e, path)