示例#1
0
def putfile(fname, rpath, uname="", commitmsg=""):
    rpath = core.svn_path_canonicalize(rpath)
    repos_ptr = repos.open(rpath)
    fsob = repos.fs(repos_ptr)

    # open a transaction against HEAD
    rev = fs.youngest_rev(fsob)

    txn = repos.fs_begin_txn_for_commit(repos_ptr, rev, uname, commitmsg)

    root = fs.txn_root(txn)
    rev_root = fs.revision_root(fsob, rev)

    kind = fs.check_path(root, fname)
    if kind == core.svn_node_none:
        print("file '%s' does not exist, creating..." % fname)
        fs.make_file(root, fname)
    elif kind == core.svn_node_dir:
        print("File '%s' is a dir." % fname)
        return
    else:
        print("Updating file '%s'" % fname)

    handler, baton = fs.apply_textdelta(root, fname, None, None)

    ### it would be nice to get an svn_stream_t. for now, just load in the
    ### whole file and shove it into the FS.
    delta.svn_txdelta_send_string(open(fname, 'rb').read(), handler, baton)

    newrev = repos.fs_commit_txn(repos_ptr, txn)
    print("revision: %s" % newrev)
示例#2
0
def putfile(fname, rpath, uname="", commitmsg=""):
  rpath = core.svn_path_canonicalize(rpath)
  repos_ptr = repos.open(rpath)
  fsob = repos.fs(repos_ptr)

  # open a transaction against HEAD
  rev = fs.youngest_rev(fsob)

  txn = repos.fs_begin_txn_for_commit(repos_ptr, rev, uname, commitmsg)

  root = fs.txn_root(txn)
  rev_root = fs.revision_root(fsob, rev)

  kind = fs.check_path(root, fname)
  if kind == core.svn_node_none:
    print("file '%s' does not exist, creating..." % fname)
    fs.make_file(root, fname)
  elif kind == core.svn_node_dir:
    print("File '%s' is a dir." % fname)
    return
  else:
    print("Updating file '%s'" % fname)

  handler, baton = fs.apply_textdelta(root, fname, None, None)

  ### it would be nice to get an svn_stream_t. for now, just load in the
  ### whole file and shove it into the FS.
  delta.svn_txdelta_send_string(open(fname, 'rb').read(),
                                handler, baton)

  newrev = repos.fs_commit_txn(repos_ptr, txn)
  print("revision: %s" % newrev)
示例#3
0
文件: svnrep.py 项目: mizuy/mizwiki
    def write(self, data, uname='', commitmsg='',istext=False):
        txn = repos.fs_begin_txn_for_commit(self._repo.repos_ptr, self.revno, uname, commitmsg)
        r = None
        try:
            txn_root = fs.txn_root(txn)

            kind = fs.check_path(txn_root, self.path)

            if kind == core.svn_node_none:
                if not _create_file(txn_root, self.path):
                    raise 'attempt to create file, but file creation error: %s'%path
                pass

            elif kind == core.svn_node_dir:
                raise 'attempt to create file, but directory already exists: %s'%self.path

            if istext:
                fs.change_node_prop(txn_root, self.path, 'svn:eol-style', 'native')
                pass


            handler, baton = fs.apply_textdelta(txn_root, self.path, None, None)
            delta.svn_txdelta_send_string(data, handler, baton)

            r = repos.fs_commit_txn(self._repo.repos_ptr, txn)
        except Exception, a:
            fs.abort_txn(txn)
            raise