def list_directory(url, peg_rev, rev, flag, ctx):
  try:
    dirents, locks = client.svn_client_ls3(url, peg_rev, rev, flag, ctx)
  except TypeError: # 1.4.x bindings are goofed
    dirents = client.svn_client_ls3(None, url, peg_rev, rev, flag, ctx)
    locks = {}
  return dirents, locks  
예제 #2
0
def list_directory(url, peg_rev, rev, flag, ctx):
    try:
        dirents, locks = client.svn_client_ls3(url, peg_rev, rev, flag, ctx)
    except TypeError:  # 1.4.x bindings are goofed
        dirents = client.svn_client_ls3(None, url, peg_rev, rev, flag, ctx)
        locks = {}
    return dirents, locks
예제 #3
0
  def _get_dirents(self, path, rev):
    """Return a 2-type of dirents and locks, possibly reading/writing
    from a local cache of that information.  This functions performs
    authz checks, stripping out unreadable dirents."""

    dir_url = self._geturl(path)
    path_parts = _path_parts(path)
    if path:
      key = str(rev) + '/' + path
    else:
      key = str(rev)

    # Ensure that the cache gets filled...
    dirents_locks = self._dirent_cache.get(key)
    if not dirents_locks:
      tmp_dirents, locks = client.svn_client_ls3(dir_url, _rev2optrev(rev),
                                                 _rev2optrev(rev), 0, self.ctx)
      dirents = {}
      for name, dirent in tmp_dirents.items():
        dirent_parts = path_parts + [_to_str(name)]
        kind = dirent.kind
        if ((kind == core.svn_node_dir or kind == core.svn_node_file)
            and vclib.check_path_access(self, dirent_parts,
                                        (kind == core.svn_node_dir
                                         and vclib.DIR or vclib.FILE),
                                        rev)):
          lh_rev, c_rev = self._get_last_history_rev(dirent_parts, rev)
          dirent.created_rev = lh_rev
          dirents[_to_str(name)] = dirent
      dirents_locks = [dirents, locks]
      self._dirent_cache[key] = dirents_locks

    # ...then return the goodies from the cache.
    return dirents_locks[0], dirents_locks[1]
예제 #4
0
    def itemlog(self, path_parts, rev, sortby, first, limit, options):
        assert sortby == vclib.SORTBY_DEFAULT or sortby == vclib.SORTBY_REV
        path_type = self.itemtype(path_parts, rev)  # does auth-check
        path = self._getpath(path_parts)
        rev = self._getrev(rev)
        url = self._geturl(path)

        # If this is a file, fetch the lock status and size (as of REV)
        # for this item.
        lockinfo = size_in_rev = None
        if path_type == vclib.FILE:
            basename = path_parts[-1].encode(self.encoding, 'surrogateescape')
            list_url = self._geturl(self._getpath(path_parts[:-1]))
            dirents, locks = client.svn_client_ls3(list_url, _rev2optrev(rev),
                                                   _rev2optrev(rev), 0,
                                                   self.ctx)
            if basename in locks:
                lockinfo = locks[basename].owner
            if basename in dirents:
                size_in_rev = dirents[basename].size

        # Special handling for the 'svn_latest_log' scenario.
        ### FIXME: Don't like this hack.  We should just introduce
        ### something more direct in the vclib API.
        if options.get('svn_latest_log', 0):
            dir_lh_rev, dir_c_rev = self._get_last_history_rev(path_parts, rev)
            date, author, log, revprops, changes = self._revinfo(dir_lh_rev)
            return [
                vclib.Revision(dir_lh_rev, str(dir_lh_rev), date, author, None,
                               log, size_in_rev, lockinfo)
            ]

        def _access_checker(check_path, check_rev):
            return vclib.check_path_access(self, _path_parts(check_path),
                                           path_type, check_rev)

        # It's okay if we're told to not show all logs on a file -- all
        # the revisions should match correctly anyway.
        lc = LogCollector(path, options.get('svn_show_all_dir_logs', 0),
                          lockinfo, _access_checker)

        cross_copies = options.get('svn_cross_copies', 0)
        log_limit = 0
        if limit:
            log_limit = first + limit
        client_log(url, _rev2optrev(rev), _rev2optrev(1), log_limit, 1,
                   cross_copies, lc.add_log, self.ctx)
        revs = lc.logs
        revs.sort()
        prev = None
        for rev in revs:
            # Swap out revision info with stuff from the cache (which is
            # authz-sanitized).
            rev.date, rev.author, rev.log, revprops, changes \
                      = self._revinfo(rev.number)
            rev.prev = prev
            prev = rev
        revs.reverse()

        if len(revs) < first:
            return []
        if limit:
            return revs[first:first + limit]
        return revs