示例#1
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args[0])
        if len(path) > 0:
            url = '/'.join((url, path))

        if len(args) > 1:
            rev = int(args[1][0])

        path, kind, size, changed, by, at = repos.stat(url, rev)

        if path is None:
            self.link.send_msg(gen.success(gen.list()))
            return

        props = repos.get_props(url, rev, False)

        if by is None:
            by = gen.list()
        else:
            by = gen.list(gen.string(by))

        ls_data = gen.list(kind, size, gen.bool(len(props) > 0), changed,
                           gen.list(gen.string(at)), by)

        self.link.send_msg(gen.success(gen.list(ls_data)))
示例#2
0
文件: stat.py 项目: qur/git-svnserver
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args[0])
        if len(path) > 0:
            url = '/'.join((url, path))

        if len(args) > 1:
            rev = int(args[1][0])

        path, kind, size, changed, by, at = repos.stat(url, rev)

        if path is None:
            self.link.send_msg(gen.success(gen.list()))
            return

        props = repos.get_props(url, rev, False)

        if by is None:
            by = gen.list()
        else:
            by = gen.list(gen.string(by))

        ls_data = gen.list(kind,
                           size,
                           gen.bool(len(props) > 0),
                           changed,
                           gen.list(gen.string(at)),
                           by)

        self.link.send_msg(gen.success(gen.list(ls_data)))
示例#3
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args[0])
        if len(path) > 0:
            url = '/'.join((url, path))

        if len(args[1]) > 0:
            rev = int(args[1][0])

        want_props = parse.bool(args[2])
        want_contents = parse.bool(args[3])

        print "props: %s, contents: %s" % (want_props, want_contents)

        rev, props, contents = repos.get_file(url, rev)

        p = []
        if want_props:
            for name, value in props:
                p.append(gen.list(gen.string(name), gen.string(value)))

        m = md5()
        data = contents.read(8192)
        total_len = len(data)
        while len(data) > 0:
            m.update(data)
            data = contents.read(8192)
            total_len += len(data)
        csum = gen.string(m.hexdigest())
        contents.close()

        response = (gen.list(csum), rev, gen.list(*p))

        self.link.send_msg(gen.success(*response))

        if want_contents:
            if total_len == len(data):
                self.link.send_msg(gen.string(data))
            else:
                rev, props, contents = repos.get_file(url, rev)
                data = contents.read(8192)
                while len(data) > 0:
                    self.link.send_msg(gen.string(data))
                    data = contents.read(8192)
            self.link.send_msg(gen.string(''))
            self.link.send_msg(gen.success())

        contents.close()
示例#4
0
    def get_edits(self):
        self.root = None
        self.aborted = False
        self.commit = self.link.repos.start_commit(self.link.url, self.link.user)

        self.link.send_msg(gen.success())
        raise ChangeMode("editor")
示例#5
0
    def do_commit(self):
        repos = self.link.repos

        msg = parse.string(self.args[0])

        self.commit_info = None

        if self.aborted:
            self.link.send_msg(gen.error(1, "aborted"))
            return

        try:
            rev, date, author, error = repos.complete_commit(self.commit, msg)
        except HookFailure as hf:
            err, msg = hooks.pre_commit(hf.code, hf.text)
            self.link.send_msg(gen.error(err, msg))
            return

        print rev, date, author, error

        if rev is None:
            self.link.send_msg(gen.error(1, "vcs error: %s" % error))
            return

        self.commit_info = gen.list(rev, gen.list(gen.string(date)), gen.list(gen.string(author)), gen.list())

        self.link.send_msg(gen.success())
        raise ChangeMode("auth", "command")
示例#6
0
    def do_commit(self):
        repos = self.link.repos

        msg = parse.string(self.args[0])

        self.commit_info = None

        if self.aborted:
            self.link.send_msg(gen.error(1, "aborted"))
            return

        try:
            rev, date, author, error = repos.complete_commit(self.commit, msg)
        except HookFailure as hf:
            err, msg = hooks.pre_commit(hf.code, hf.text)
            self.link.send_msg(gen.error(err, msg))
            return

        print rev, date, author, error

        if rev is None:
            self.link.send_msg(gen.error(1, "vcs error: %s" % error))
            return

        self.commit_info = gen.list(rev, gen.list(gen.string(date)),
                                    gen.list(gen.string(author)), gen.list())

        self.link.send_msg(gen.success())
        raise ChangeMode('auth', 'command')
示例#7
0
    def get_edits(self):
        self.root = None
        self.aborted = False
        self.commit = self.link.repos.start_commit(self.link.url, self.link.user)

        self.link.send_msg(gen.success())
        raise ChangeMode('editor')
示例#8
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        start_rev = None
        end_rev = None

        target_paths = [parse.string(x) for x in args.pop(0)]

        arg = args.pop(0)
        if len(arg) > 0:
            start_rev = int(arg[0])
            if start_rev == 0:
                start_rev = 1

        arg = args.pop(0)
        if len(arg) > 0:
            end_rev = int(arg[0])
            if end_rev == 0:
                end_rev = 1

        send_changed_paths = parse.bool(args.pop(0))

        strict_node = parse.bool(args.pop(0))

        limit = 0
        if len(args) > 0:
            limit = int(args.pop(0))

        include_merged_revisions = False
        if len(args) > 0:
            include_merged_revisions = parse.bool(args.pop(0))

        # all-revprops | revprops

        # ( revprop:string ... )

        for changes, rev, author, date, msg, has_children, revprops in repos.log(url, target_paths, start_rev, end_rev, limit):
            changed_paths = []
            if send_changed_paths:
                for path, data in sorted(changes.items()):
                    change, cp, cr, kind, tmod, pmod = data
                    copy = gen.list()
                    if cp is not None and cr is not None:
                        copy = gen.list(gen.string(cp), cr)
                    ct = gen.list(gen.string(kind), gen.bool(tmod),
                                  gen.bool(pmod))
                    changed_paths.append(gen.list(gen.string(path),
                                         change, copy, ct))
            log_entry = gen.list(gen.list(*changed_paths),
                                 rev,
                                 gen.list(gen.string(author)),
                                 gen.list(gen.string(date)),
                                 gen.list(gen.string(msg)))
            self.link.send_msg(log_entry)

        self.link.send_msg('done')

        self.link.send_msg(gen.success())
示例#9
0
    def do_cmd(self):
        repos = self.link.repos

        latest_rev = repos.get_latest_rev()

        if latest_rev is None:
            msg = gen.error(210005, "No repository found in '%s'" % self.link.url)
        else:
            msg = gen.success(latest_rev)

        self.link.send_msg(msg)
示例#10
0
    def do_cmd(self):
        repos = self.link.repos

        latest_rev = repos.get_latest_rev()

        if latest_rev is None:
            msg = gen.error(210005,
                            "No repository found in '%s'" % self.link.url)
        else:
            msg = gen.success(latest_rev)

        self.link.send_msg(msg)
示例#11
0
    def do_cmd(self):
        args = self.args

        url = parse.string(args.pop(0))

        if len(url) > 0:
            new_repo, path, base_url = self.link.server.find_repo(url)
            if new_repo != self.link.repos:
                self.link.send_msg(gen.error("URL %s is outside of repository %s" % url, self.link.base_url))
                return

            print "new url: %s" % url
            self.link.url = path

        self.link.send_msg(gen.success())
示例#12
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args.pop(0))
        if len(path) > 0:
            url = '/'.join((url, path))

        arg = args.pop(0)
        if len(arg) > 0:
            rev = int(arg[0])

        want_props = parse.bool(args.pop(0))

        want_contents = parse.bool(args.pop(0))

        fields = []
        if len(args) > 0:
            fields = args.pop(0)

        ls_data = []
        if want_contents:
            for path, kind, size, changed, by, at in repos.ls(url, rev):
                path_url = "%s/%s" % (url, path)
                has_props = len(repos.get_props(path_url, rev, False)) == 0
                if by is None:
                    by = gen.list()
                else:
                    by = gen.list(gen.string(by))

                ls_data.append(gen.list(gen.string(path),
                                        kind,
                                        size,
                                        gen.bool(has_props),
                                        changed,
                                        gen.list(gen.string(at)),
                                        by))

        p = []
        if want_props:
            for name, value in repos.get_props(url, rev):
                p.append(gen.list(gen.string(name), gen.string(value)))

        response = "%d %s %s" % (rev, gen.list(*p), gen.list(*ls_data))

        self.link.send_msg(gen.success(response))
示例#13
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args[0])
        if len(path) > 0:
            url = '/'.join((url, path))

        if len(args) > 1 and len(args[1]) > 0:
            rev = int(args[1][0])

        type = repos.check_path(url, rev)

        self.link.send_msg(gen.success(type))
示例#14
0
    def do_cmd(self):
        repos = self.link.repos
        args = self.args
        url = self.link.url
        rev = None

        path = parse.string(args.pop(0))
        if len(path) > 0:
            url = '/'.join((url, path))

        arg = args.pop(0)
        if len(arg) > 0:
            rev = int(arg[0])

        want_props = parse.bool(args.pop(0))

        want_contents = parse.bool(args.pop(0))

        fields = []
        if len(args) > 0:
            fields = args.pop(0)

        ls_data = []
        if want_contents:
            for path, kind, size, changed, by, at in repos.ls(url, rev):
                path_url = "%s/%s" % (url, path)
                has_props = len(repos.get_props(path_url, rev, False)) == 0
                if by is None:
                    by = gen.list()
                else:
                    by = gen.list(gen.string(by))

                ls_data.append(
                    gen.list(gen.string(path), kind, size, gen.bool(has_props),
                             changed, gen.list(gen.string(at)), by))

        p = []
        if want_props:
            for name, value in repos.get_props(url, rev):
                p.append(gen.list(gen.string(name), gen.string(value)))

        response = "%d %s %s" % (rev, gen.list(*p), gen.list(*ls_data))

        self.link.send_msg(gen.success(response))
示例#15
0
    def send_response(self, path, url, rev):
        repos = self.link.repos

        self.sendq = Queue.Queue()
        self.waitq = Queue.Queue()

        thread = threading.Thread(target=send_thread,
                                  args=(self.link, self.sendq, self.waitq))
        thread.start()

        import time

        t1 = time.time()
        print "get contents"
        contents = repos.get_files(url, rev)
        print len(contents)
        t2 = time.time()
        print t2 - t1
        print "start sending"
        self.update_dir('', rev, path, [], contents)
        print "all sends now queued"
        t3 = time.time()
        print t3 - t2
        print t3 - t1

        self.sendq.put(None)
        print "wait for sending thread"
        self.waitq.get()

        print "send close-edit message"
        self.link.send_msg(gen.tuple('close-edit'))
        msg = parse.msg(self.link.read_msg())
        if msg[0] != 'success':
            errno = msg[1][0][0]
            errmsg = parse.string(msg[1][0][1])
            self.link.send_msg(gen.tuple('abort-edit'))
            self.link.send_msg(gen.error(errno, errmsg))
        else:
            self.link.send_msg(gen.success())
示例#16
0
    def send_response(self, path, url, rev):
        repos = self.link.repos

        self.sendq = Queue.Queue()
        self.waitq = Queue.Queue()

        thread = threading.Thread(target=send_thread,
                                  args=(self.link, self.sendq, self.waitq))
        thread.start()

        import time

        t1 = time.time()
        print "get contents"
        contents = repos.get_files(url, rev)
        print len(contents)
        t2 = time.time()
        print t2 - t1
        print "start sending"
        self.update_dir('', rev, path, [], contents)
        print "all sends now queued"
        t3 = time.time()
        print t3 - t2
        print t3 - t1

        self.sendq.put(None)
        print "wait for sending thread"
        self.waitq.get()

        print "send close-edit message"
        self.link.send_msg(gen.tuple('close-edit'))
        msg = parse.msg(self.link.read_msg())
        if msg[0] != 'success':
            errno = msg[1][0][0]
            errmsg = parse.string(msg[1][0][1])
            self.link.send_msg(gen.tuple('abort-edit'))
            self.link.send_msg(gen.error(errno, errmsg))
        else:
            self.link.send_msg(gen.success())