Ejemplo n.º 1
0
    def __init__(self, ui, repotype, path):

        converter_sink.__init__(self, ui, repotype, path)
        commandline.__init__(self, ui, "svn")
        self.delete = []
        self.setexec = []
        self.delexec = []
        self.copies = []
        self.wc = None
        self.cwd = pycompat.getcwd()

        created = False
        if os.path.isfile(os.path.join(path, ".svn", "entries")):
            self.wc = os.path.realpath(path)
            self.run0("update")
        else:
            if not re.search(r"^(file|http|https|svn|svn\+ssh)\://", path):
                path = os.path.realpath(path)
                if os.path.isdir(os.path.dirname(path)):
                    if not os.path.exists(os.path.join(path, "db", "fs-type")):
                        ui.status(
                            _("initializing svn repository %r\n")
                            % os.path.basename(path)
                        )
                        commandline(ui, "svnadmin").run0("create", path)
                        created = path
                    path = util.normpath(path)
                    if not path.startswith("/"):
                        path = "/" + path
                    path = "file://" + path

            wcpath = os.path.join(pycompat.getcwd(), os.path.basename(path) + "-wc")
            ui.status(
                _("initializing svn working copy %r\n") % os.path.basename(wcpath)
            )
            self.run0("checkout", path, wcpath)

            self.wc = wcpath
        self.opener = vfsmod.vfs(self.wc)
        self.wopener = vfsmod.vfs(self.wc)
        self.childmap = mapfile(ui, self.join("hg-childmap"))
        if util.checkexec(self.wc):
            self.is_exec = util.isexec
        else:
            self.is_exec = None

        if created:
            hook = os.path.join(created, "hooks", "pre-revprop-change")
            fp = open(hook, "w")
            fp.write(pre_revprop_change)
            fp.close()
            util.setflags(hook, False, True)

        output = self.run0("info")
        self.uuid = self.uuid_re.search(output).group(1).strip()
Ejemplo n.º 2
0
    def putfile(self, filename, flags, data):
        if "l" in flags:
            self.wopener.symlink(data, filename)
        else:
            try:
                if os.path.islink(self.wjoin(filename)):
                    os.unlink(filename)
            except OSError:
                pass
            self.wopener.write(filename, data)

            if self.is_exec:
                if self.is_exec(self.wjoin(filename)):
                    if "x" not in flags:
                        self.delexec.append(filename)
                else:
                    if "x" in flags:
                        self.setexec.append(filename)
                util.setflags(self.wjoin(filename), False, "x" in flags)