• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fs.check_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中svn.fs.check_path函数的典型用法代码示例。如果您正苦于以下问题:Python check_path函数的具体用法?Python check_path怎么用?Python check_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, path, rev, repos, pool=None, parent=None):
        self.path = path
        self.repos = repos
        self.fs_ptr = repos.fs_ptr
        self.scope = repos.scope
        self._scoped_svn_path = _to_svn(self.scope, path)
        self.pool = Pool(pool)
        self._requested_rev = rev
        pool = self.pool()
        
        if parent and parent._requested_rev == self._requested_rev:
            self.root = parent.root
        else:
            self.root = fs.revision_root(self.fs_ptr, rev, self.pool())
        node_type = fs.check_path(self.root, self._scoped_svn_path, pool)
        if not node_type in _kindmap:
            raise Exception('No such node')
        
        if _kindmap[node_type] == 'F':
            self.isdir = False
            self.isfile = True
        elif _kindmap[node_type] == 'D':
            self.isdir = True
            self.isfile = False

        
        cr = fs.node_created_rev(self.root, self._scoped_svn_path, pool)
        cp = fs.node_created_path(self.root, self._scoped_svn_path, pool)
        
        if _is_path_within_scope(self.scope, cp):
            self.created_rev = cr
            self.created_path = _path_within_scope(self.scope, _from_svn(cp))
        else:
            self.created_rev, self.created_path = rev, path
        self.rev = self.created_rev
开发者ID:damoxc,项目名称:snakepit,代码行数:35,代码来源:svnclient.py


示例2: has_node

 def has_node(self, path, rev=None, pool=None):
     if not pool:
         pool = self.pool
     rev = self.normalize_rev(rev)
     rev_root = fs.revision_root(self.fs_ptr, rev, pool())
     node_type = fs.check_path(rev_root, _to_svn(self.scope, path), pool())
     return node_type in _kindmap
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:7,代码来源:svn_fs.py


示例3: __init__

    def __init__(self, path, rev, authz, scope, fs_ptr):
        self.authz = authz
        self.scope = scope
        if scope != '/':
            self.scoped_path = scope + path
        else:
            self.scoped_path = path
        self.fs_ptr = fs_ptr
        self._requested_rev = rev

        self.root = fs.revision_root(fs_ptr, rev)
        node_type = fs.check_path(self.root, self.scoped_path)
        if not node_type in _kindmap:
            raise TracError, "No node at %s in revision %s" % (path, rev)
        self.created_rev = fs.node_created_rev(self.root, self.scoped_path)
        self.created_path = fs.node_created_path(self.root, self.scoped_path)
        # Note: 'created_path' differs from 'path' if the last change was a copy,
        #        and furthermore, 'path' might not exist at 'create_rev'.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # TODO: check node id
        self.rev = self.created_rev

        Node.__init__(self, path, self.rev, _kindmap[node_type])
开发者ID:vocho,项目名称:openqnx,代码行数:25,代码来源:svn_fs.py


示例4: putfile

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)
开发者ID:aosm,项目名称:subversion,代码行数:32,代码来源:putfile.py


示例5: _history

    def _history(self, path, start, end, pool):
        """`path` is a unicode path in the scope.

        Generator yielding `(path, rev)` pairs, where `path` is an `unicode`
        object. Must start with `(path, created rev)`.

        (wraps ``fs.node_history``)
        """
        path_utf8 = _to_svn(pool(), self.scope, path)
        if start < end:
            start, end = end, start
        if (start, end) == (1, 0): # only happens for empty repos
            return
        root = fs.revision_root(self.fs_ptr, start, pool())
        # fs.node_history leaks when path doesn't exist (#6588)
        if fs.check_path(root, path_utf8, pool()) == core.svn_node_none:
            return
        tmp1 = Pool(pool)
        tmp2 = Pool(pool)
        history_ptr = fs.node_history(root, path_utf8, tmp1())
        cross_copies = 1
        while history_ptr:
            history_ptr = fs.history_prev(history_ptr, cross_copies, tmp2())
            tmp1.clear()
            tmp1, tmp2 = tmp2, tmp1
            if history_ptr:
                path_utf8, rev = fs.history_location(history_ptr, tmp2())
                tmp2.clear()
                if rev < end:
                    break
                path = _from_svn(path_utf8)
                yield path, rev
        del tmp1
        del tmp2
开发者ID:thimalk,项目名称:bloodhound,代码行数:34,代码来源:svn_fs.py


示例6: __init__

    def __init__(self, path, rev, repos, pool=None, parent_root=None):
        self.fs_ptr = repos.fs_ptr
        self.scope = repos.scope
        self.pool = Pool(pool)
        pool = self.pool()
        self._scoped_path_utf8 = _to_svn(pool, self.scope, path)

        if parent_root:
            self.root = parent_root
        else:
            self.root = fs.revision_root(self.fs_ptr, rev, pool)
        node_type = fs.check_path(self.root, self._scoped_path_utf8, pool)
        if not node_type in _kindmap:
            raise NoSuchNode(path, rev)
        cp_utf8 = fs.node_created_path(self.root, self._scoped_path_utf8, pool)
        cp = _from_svn(cp_utf8)
        cr = fs.node_created_rev(self.root, self._scoped_path_utf8, pool)
        # Note: `cp` differs from `path` if the last change was a copy,
        #        In that case, `path` doesn't even exist at `cr`.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # Also, `cp` might well be out of the scope of the repository,
        # in this case, we _don't_ use the ''create'' information.
        if _is_path_within_scope(self.scope, cp):
            self.created_rev = cr
            self.created_path = _path_within_scope(self.scope, cp)
        else:
            self.created_rev, self.created_path = rev, path
        # TODO: check node id
        Node.__init__(self, repos, path, rev, _kindmap[node_type])
开发者ID:thimalk,项目名称:bloodhound,代码行数:31,代码来源:svn_fs.py


示例7: write

    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
开发者ID:mizuy,项目名称:mizwiki,代码行数:28,代码来源:svnrep.py


示例8: blame

def blame(path, filename, rev=None):

  annotresult = {}
  path = core.svn_path_canonicalize(path)

  repos_ptr = repos.open(path)
  fsob = repos.fs(repos_ptr)

  if rev is None:
    rev = fs.youngest_rev(fsob)
  filedata = ''
  for i in range(0, rev+1):
    root = fs.revision_root(fsob, i)
    if fs.check_path(root, filename) != core.svn_node_none:
      first = i
      break
  print("First revision is %d" % first)
  print("Last revision is %d" % rev)
  for i in range(first, rev+1):
    previousroot = root
    root = fs.revision_root(fsob, i)
    if i != first:
      if not fs.contents_changed(root, filename, previousroot, filename):
        continue

    file = fs.file_contents(root, filename)
    previousdata = filedata
    filedata = ''
    while True:
      data = core.svn_stream_read(file, CHUNK_SIZE)
      if not data:
        break
      filedata = filedata + data

    print("Current revision is %d" % i)
    diffresult = difflib.ndiff(previousdata.splitlines(1),
                               filedata.splitlines(1))
    #    print ''.join(diffresult)
    k = 0
    for j in diffresult:
      if j[0] == ' ':
        if k in annotresult:
          k = k + 1
          continue
        else:
          annotresult[k] = (i, j[2:])
          k = k + 1
          continue
      elif j[0] == '?':
        continue
      annotresult[k] = (i, j[2:])
      if j[0] != '-':
        k = k + 1
#    print ''.join(diffresult)
#  print annotresult
  for x in range(len(annotresult.keys())):
     sys.stdout.write("Line %d (r%d):%s" % (x,
                                            annotresult[x][0],
                                            annotresult[x][1]))
开发者ID:Ranga123,项目名称:test1,代码行数:59,代码来源:blame.py


示例9: get_changes

 def get_changes(self, old_path, old_rev, new_path, new_rev,
                 ignore_ancestry=0):
     old_node = new_node = None
     old_rev = self.normalize_rev(old_rev)
     new_rev = self.normalize_rev(new_rev)
     if self.has_node(old_path, old_rev):
         old_node = self.get_node(old_path, old_rev)
     else:
         raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
     if self.has_node(new_path, new_rev):
         new_node = self.get_node(new_path, new_rev)
     else:
         raise NoSuchNode(new_path, new_rev, 'The Target for Diff is invalid')
     if new_node.kind != old_node.kind:
         raise TracError('Diff mismatch: Base is a %s (%s in revision %s) '
                         'and Target is a %s (%s in revision %s).' \
                         % (old_node.kind, old_path, old_rev,
                            new_node.kind, new_path, new_rev))
     subpool = Pool(self.pool)
     if new_node.isdir:
         editor = DiffChangeEditor()
         e_ptr, e_baton = delta.make_editor(editor, subpool())
         old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
         new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
         def authz_cb(root, path, pool): return 1
         text_deltas = 0 # as this is anyway re-done in Diff.py...
         entry_props = 0 # "... typically used only for working copy updates"
         repos.svn_repos_dir_delta(old_root,
                                   _to_svn(self.scope + old_path), '',
                                   new_root,
                                   _to_svn(self.scope + new_path),
                                   e_ptr, e_baton, authz_cb,
                                   text_deltas,
                                   1, # directory
                                   entry_props,
                                   ignore_ancestry,
                                   subpool())
         for path, kind, change in editor.deltas:
             path = _from_svn(path)
             old_node = new_node = None
             if change != Changeset.ADD:
                 old_node = self.get_node(posixpath.join(old_path, path),
                                          old_rev)
             if change != Changeset.DELETE:
                 new_node = self.get_node(posixpath.join(new_path, path),
                                          new_rev)
             else:
                 kind = _kindmap[fs.check_path(old_root,
                                               _to_svn(self.scope,
                                                       old_node.path),
                                               subpool())]
             yield  (old_node, new_node, kind, change)
     else:
         old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
         new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
         if fs.contents_changed(old_root, _to_svn(self.scope, old_path),
                                new_root, _to_svn(self.scope, new_path),
                                subpool()):
             yield (old_node, new_node, Node.FILE, Changeset.EDIT)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:59,代码来源:svn_fs.py


示例10: _create_dirs

def _create_dirs(txn_root, cpath):
    if not cpath:
        return True
    kind = fs.check_path(txn_root,cpath)
    if kind == core.svn_node_dir:
        return True
    elif kind == core.svn_node_file:
        return False

    for dpath,p in misc.iterdir(cpath):
        dpath = _c(dpath)
        kind = fs.check_path(txn_root, dpath)
        if kind == core.svn_node_none:
            fs.make_dir(txn_root, dpath)
            continue
        pass
    return True
开发者ID:mizuy,项目名称:mizwiki,代码行数:17,代码来源:svnrep.py


示例11: has_node

 def has_node(self, path, rev=None, pool=None):
     """Check if `path` exists at `rev` (or latest if unspecified)"""
     if not pool:
         pool = self.pool
     rev = self.normalize_rev(rev)
     rev_root = fs.revision_root(self.fs_ptr, rev, pool())
     node_type = fs.check_path(rev_root, _to_svn(pool(), self.scope, path),
                               pool())
     return node_type in _kindmap
开发者ID:thimalk,项目名称:bloodhound,代码行数:9,代码来源:svn_fs.py


示例12: do_ls

  def do_ls(self, arg):
    """list the contents of the current directory or provided path"""
    parent = self.path
    if not len(arg):
      # no arg -- show a listing for the current directory.
      entries = fs.dir_entries(self.root, self.path)
    else:
      # arg?  show a listing of that path.
      newpath = self._parse_path(arg)
      kind = fs.check_path(self.root, newpath)
      if kind == core.svn_node_dir:
        parent = newpath
        entries = fs.dir_entries(self.root, parent)
      elif kind == core.svn_node_file:
        parts = self._path_to_parts(newpath)
        name = parts.pop(-1)
        parent = self._parts_to_path(parts)
        print(parent + ':' + name)
        tmpentries = fs.dir_entries(self.root, parent)
        if not tmpentries.get(name, None):
          return
        entries = {}
        entries[name] = tmpentries[name]
      else:
        print("Path '%s' not found." % newpath)
        return

    keys = sorted(entries.keys())

    print("   REV   AUTHOR  NODE-REV-ID     SIZE         DATE NAME")
    print("----------------------------------------------------------------------------")

    for entry in keys:
      fullpath = parent + '/' + entry
      size = ''
      is_dir = fs.is_dir(self.root, fullpath)
      if is_dir:
        name = entry + '/'
      else:
        size = str(fs.file_length(self.root, fullpath))
        name = entry
      node_id = fs.unparse_id(entries[entry].id)
      created_rev = fs.node_created_rev(self.root, fullpath)
      author = fs.revision_prop(self.fs_ptr, created_rev,
                                core.SVN_PROP_REVISION_AUTHOR)
      if not author:
        author = ""
      date = fs.revision_prop(self.fs_ptr, created_rev,
                              core.SVN_PROP_REVISION_DATE)
      if not date:
        date = ""
      else:
        date = self._format_date(date)

      print("%6s %8s %12s %8s %12s %s" % (created_rev, author[:8],
                                          node_id, size, date, name))
开发者ID:lysine,项目名称:wasp,代码行数:56,代码来源:svnshell.py


示例13: itemtype

 def itemtype(self, path_parts, rev):
   rev = self._getrev(rev)
   basepath = self._getpath(path_parts)
   kind = fs.check_path(self._getroot(rev), basepath, self.scratch_pool)
   self._scratch_clear()
   if kind == core.svn_node_dir:
     return vclib.DIR
   if kind == core.svn_node_file:
     return vclib.FILE
   raise vclib.ItemNotFound(path_parts)
开发者ID:meyersh,项目名称:gimli-public_html,代码行数:10,代码来源:__init__.py


示例14: do_cd

  def do_cd(self, arg):
    """change directory"""
    newpath = self._parse_path(arg)

    # make sure that path actually exists in the filesystem as a directory
    kind = fs.check_path(self.root, newpath)
    if kind != core.svn_node_dir:
      print("Path '%s' is not a valid filesystem directory." % newpath)
      return
    self.path = newpath
开发者ID:lysine,项目名称:wasp,代码行数:10,代码来源:svnshell.py


示例15: _gettype

 def _gettype(self, path, rev):
   # Similar to itemtype(), but without the authz check.  Returns
   # None for missing paths.
   try:
     kind = fs.check_path(self._getroot(rev), path)
   except:
     return None
   if kind == core.svn_node_dir:
     return vclib.DIR
   if kind == core.svn_node_file:
     return vclib.FILE
   return None
开发者ID:vitalif,项目名称:viewvc-4intranet,代码行数:12,代码来源:svn_repos.py


示例16: _do_path_landing

 def _do_path_landing(self):
   """try to land on self.path as a directory in root, failing up to '/'"""
   not_found = 1
   newpath = self.path
   while not_found:
     kind = fs.check_path(self.root, newpath)
     if kind == core.svn_node_dir:
       not_found = 0
     else:
       parts = self._path_to_parts(newpath)
       parts.pop(-1)
       newpath = self._parts_to_path(parts)
   self.path = newpath
开发者ID:lysine,项目名称:wasp,代码行数:13,代码来源:svnshell.py


示例17: get_entries

	def get_entries(self, path):
		# lots of conversions from and to utf-8
		disk_url = directory(self.name)
		root_path_utf8 = repos.svn_repos_find_root_path(disk_url)
		if root_path_utf8 is None or not os.path.exists(root_path_utf8):
			raise DoesNotExistError(disk_url)

		try:
			repository = repos.svn_repos_open(root_path_utf8)
		except SubversionException as e:
			# check for messages like the following:
			# "Expected FS Format 'x'; found format 'y'"
			# there are different errorcodes for each version, so do a string
			# match instead of errorcode match
			errstr = str(e)
			if "Expected" in errstr and "format" in errstr and "found" in errstr:
				raise VersionError

			raise PermissionError

		fs_ptr = repos.svn_repos_fs(repository)

		path_utf8 = uc_to_svn(uc_str(path))
		youngest_revision_number = fs.youngest_rev(fs_ptr)
		try:
			root = fs.revision_root(fs_ptr, youngest_revision_number)
		except SubversionException as e:
			raise PermissionError

		entries = fs.dir_entries(root, path_utf8)

		dirs = []
		for entry in entries.keys():
			d = {}
			node_type = fs.check_path(root, os.path.join(path_utf8, entry))
			if (node_type == core.svn_node_dir):
				d['kind'] = 'dir'
			elif (node_type == core.svn_node_file):
				d['kind'] = 'file'
			else:
				d['kind'] = 'unknown'
			d['name'] = uc_from_svn(entry)
			dirs.append(d)

		return dirs
开发者ID:andy-deng,项目名称:submin,代码行数:45,代码来源:repository.py


示例18: do_pcat

 def do_pcat(self, arg):
   """list the properties of a path"""
   catpath = self.path
   if len(arg):
     catpath = self._parse_path(arg)
   kind = fs.check_path(self.root, catpath)
   if kind == core.svn_node_none:
     print("Path '%s' does not exist." % catpath)
     return
   plist = fs.node_proplist(self.root, catpath)
   if not plist:
     return
   for pkey, pval in plist.items():
     print('K ' + str(len(pkey)))
     print(pkey)
     print('P ' + str(len(pval)))
     print(pval)
   print('PROPS-END')
开发者ID:lysine,项目名称:wasp,代码行数:18,代码来源:svnshell.py


示例19: add

    def add(self, deltas):
        """ Add the supplied set of deltas to the repository.  They will
        all be added with the same user name, date, and comment. """

        # Split up the deltas array into smaller sub-arrays, otherwise
        # we choke running out of memory due to really large changesets
        # like the CDDL 2005/06/08 putback in ON that touched every file
        while len(deltas):
	    if len(deltas) > 1000:
                print "partitioning deltas into smaller new_deltas"
            new_deltas = deltas[:1000]
	    deltas = deltas[1000:]

            # Add all of the directories first, or we will be trying
            # to cross transactions, which is bad.
            for delta in new_deltas:
                self._addDirectories(delta)
                print "preparing %s version %s (%s) by %s" % (delta.pathname, delta.version, delta.date, delta.author)

            subpool = core.svn_pool_create(self.pool)
            (revision, transaction, root) = self._revisionSetup(subpool,
                                                      new_deltas[0].author,
                                                      new_deltas[0].comment)

            for delta in new_deltas:
                subversionPath = delta.getRepositoryName()
                kind = fs.check_path(root, subversionPath, subpool)
                if kind == core.svn_node_none:
                    fs.make_file(root, subversionPath, subpool)
                elif kind == core.svn_node_dir:
                    raise EnvironmentError(subversionPath +
                                           " already present as a directory.")
                handler, baton = fs.apply_textdelta(root, subversionPath,
                                                    None, None, subpool)
                svn.delta.svn_txdelta_send_string(delta.getFileContents(),
                                                  handler, baton, subpool)
                if delta.version.isdigit:
                    fs.change_node_prop(root, subversionPath, 'sccs:sid', delta.version, subpool)
                print "sending ", subversionPath, delta.getDate(), "by", delta.author


            print "committing version ",
            print self._commit(revision, delta.getDate(), transaction, subpool)
            core.svn_pool_destroy(subpool)
开发者ID:cfuhrman,项目名称:sccs2svn,代码行数:44,代码来源:sccs2svn.py


示例20: _get_history

def _get_history(svnrepos, full_name, rev, options={}):
  fsroot = svnrepos._getroot(rev)
  show_all_logs = options.get('svn_show_all_dir_logs', 0)
  if not show_all_logs:
    # See if the path is a file or directory.
    kind = fs.check_path(fsroot, full_name, svnrepos.pool)
    if kind is core.svn_node_file:
      show_all_logs = 1
      
  # Instantiate a NodeHistory collector object.
  history = NodeHistory(svnrepos.fs_ptr, show_all_logs)

  # Do we want to cross copy history?
  cross_copies = options.get('svn_cross_copies', 0)

  # Get the history items for PATH.
  repos.svn_repos_history(svnrepos.fs_ptr, full_name, history.add_history,
                          1, rev, cross_copies, svnrepos.pool)
  return history.histories
开发者ID:pombredanne,项目名称:fusionforge,代码行数:19,代码来源:__init__.py



注:本文中的svn.fs.check_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fs.revision_root函数代码示例发布时间:2022-05-27
下一篇:
Python delta.make_editor函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap