예제 #1
0
파일: svn_fs.py 프로젝트: t2y/trac
    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
예제 #2
0
    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
예제 #3
0
    def load(self, repo_path):
	repo_path = core.svn_path_canonicalize(repo_path)
	repos_ptr = repos.open(repo_path)
	fs_ptr = repos.fs(repos_ptr)
	rev = fs.youngest_rev(fs_ptr)
	base_root = fs.revision_root(fs_ptr, 0)
	root = fs.revision_root(fs_ptr, rev)
	hist = fs.node_history(root, self.root)
	while hist is not None:
	    hist = fs.history_prev(hist,0)
	    dummy,rev = fs.history_location(hist)
	    d = fs.revision_prop(fs_ptr, rev, core.SVN_PROP_REVISION_DATE)
	    author = fs.revision_prop(fs_ptr, rev, \
		    core.SVN_PROP_REVISION_AUTHOR)
	    if author == 'svnadmin':
		continue
	    self.last_author = author
	    self.last_date = core.svn_time_from_cstring(d) / 1000000
	    self.last_rev = rev
	    def authz_cb(root, path, pool):
		return 1
	    editor = SvnDumperEditor(self)
	    e_ptr, e_baton = delta.make_editor(editor)
	    repos.dir_delta(base_root, '', '', root, self.root, e_ptr, e_baton,
		authz_cb, 0, 1, 0, 0)
	    break
예제 #4
0
    def load(self, repo_path):
        repo_path = core.svn_path_canonicalize(repo_path)
        repos_ptr = repos.open(repo_path)
        fs_ptr = repos.fs(repos_ptr)
        rev = fs.youngest_rev(fs_ptr)
        base_root = fs.revision_root(fs_ptr, 0)
        root = fs.revision_root(fs_ptr, rev)
        hist = fs.node_history(root, self.root)
        while hist is not None:
            hist = fs.history_prev(hist, 0)
            dummy, rev = fs.history_location(hist)
            d = fs.revision_prop(fs_ptr, rev, core.SVN_PROP_REVISION_DATE)
            author = fs.revision_prop(fs_ptr, rev, \
                    core.SVN_PROP_REVISION_AUTHOR)
            if author == 'svnadmin':
                continue
            self.last_author = author
            self.last_date = core.svn_time_from_cstring(d) / 1000000
            self.last_rev = rev

            def authz_cb(root, path, pool):
                return 1

            editor = SvnDumperEditor(self)
            e_ptr, e_baton = delta.make_editor(editor)
            repos.dir_delta(base_root, '', '', root, self.root, e_ptr, e_baton,
                            authz_cb, 0, 1, 0, 0)
            break
예제 #5
0
 def _history(self, svn_path, start, end, pool):
     """`svn_path` must be a full scope path, UTF-8 encoded string.
     
     Generator yielding `(path, rev)` pairs, where `path` is an `unicode`
     object.
     Must start with `(path, created_rev)`.
     """
     
     if start < end:
         start, end = end, start
     
     root = fs.revision_root(self.fs_ptr, start, pool())
     tmp1 = Pool(pool)
     tmp2 = Pool(pool)
     history_ptr = fs.node_history(root, svn_path, 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, rev = fs.history_location(history_ptr, tmp2())
             tmp2.clear()
             if rev < end:
                 break
             path = _from_svn(path)
             yield path, rev
     del tmp1
     del tmp2
예제 #6
0
파일: svnrep.py 프로젝트: mizuy/mizwiki
 def lastmodified(self,cross_copy=False):
     if not self.exist:
         return None
     oh = fs.node_history(self._revision._root,self.path)
     oh = fs.history_prev(oh,cross_copy)
     assert oh
     hpath,hrevno = fs.history_location(oh)
     return self.repository.get_file(hrevno,hpath)
예제 #7
0
파일: svnrep.py 프로젝트: mizuy/mizwiki
 def history(self,cross_copy=False):
     oh = fs.node_history(self._revision._root,self.path)
     while 1:
         oh = fs.history_prev(oh,cross_copy)
         if not oh:
             break
         hpath, hrevno = fs.history_location(oh)
         yield self.repository.get_file(hrevno, hpath)
예제 #8
0
def last_rev(svnrepos, path, peg_revision, limit_revision=None):
    """Given PATH, known to exist in PEG_REVISION, find the youngest
  revision older than, or equal to, LIMIT_REVISION in which path
  exists.  Return that revision, and the path at which PATH exists in
  that revision."""

    # Here's the plan, man.  In the trivial case (where PEG_REVISION is
    # the same as LIMIT_REVISION), this is a no-brainer.  If
    # LIMIT_REVISION is older than PEG_REVISION, we can use Subversion's
    # history tracing code to find the right location.  If, however,
    # LIMIT_REVISION is younger than PEG_REVISION, we suffer from
    # Subversion's lack of forward history searching.  Our workaround,
    # ugly as it may be, involves a binary search through the revisions
    # between PEG_REVISION and LIMIT_REVISION to find our last live
    # revision.
    peg_revision = svnrepos._getrev(peg_revision)
    limit_revision = svnrepos._getrev(limit_revision)
    try:
        if peg_revision == limit_revision:
            return peg_revision, path
        elif peg_revision > limit_revision:
            fsroot = svnrepos._getroot(peg_revision)
            history = fs.node_history(fsroot, path, svnrepos.scratch_pool)
            while history:
                path, peg_revision = fs.history_location(
                    history, svnrepos.scratch_pool)
                if peg_revision <= limit_revision:
                    return max(peg_revision,
                               limit_revision), _cleanup_path(path)
                history = fs.history_prev(history, 1, svnrepos.scratch_pool)
            return peg_revision, _cleanup_path(path)
        else:
            ### Warning: this is *not* an example of good pool usage.
            orig_id = fs.node_id(svnrepos._getroot(peg_revision), path,
                                 svnrepos.scratch_pool)
            while peg_revision != limit_revision:
                mid = (peg_revision + 1 + limit_revision) / 2
                try:
                    mid_id = fs.node_id(svnrepos._getroot(mid), path,
                                        svnrepos.scratch_pool)
                except core.SubversionException, e:
                    if e.apr_err == core.SVN_ERR_FS_NOT_FOUND:
                        cmp = -1
                    else:
                        raise
                else:
                    ### Not quite right.  Need a comparison function that only returns
                    ### true when the two nodes are the same copy, not just related.
                    cmp = fs.compare_ids(orig_id, mid_id)

                if cmp in (0, 1):
                    peg_revision = mid
                else:
                    limit_revision = mid - 1

            return peg_revision, path
    finally:
        svnrepos._scratch_clear()
예제 #9
0
def last_rev(svnrepos, path, peg_revision, limit_revision=None):
  """Given PATH, known to exist in PEG_REVISION, find the youngest
  revision older than, or equal to, LIMIT_REVISION in which path
  exists.  Return that revision, and the path at which PATH exists in
  that revision."""
  
  # Here's the plan, man.  In the trivial case (where PEG_REVISION is
  # the same as LIMIT_REVISION), this is a no-brainer.  If
  # LIMIT_REVISION is older than PEG_REVISION, we can use Subversion's
  # history tracing code to find the right location.  If, however,
  # LIMIT_REVISION is younger than PEG_REVISION, we suffer from
  # Subversion's lack of forward history searching.  Our workaround,
  # ugly as it may be, involves a binary search through the revisions
  # between PEG_REVISION and LIMIT_REVISION to find our last live
  # revision.
  peg_revision = svnrepos._getrev(peg_revision)
  limit_revision = svnrepos._getrev(limit_revision)
  try:
    if peg_revision == limit_revision:
      return peg_revision, path
    elif peg_revision > limit_revision:
      fsroot = svnrepos._getroot(peg_revision)
      history = fs.node_history(fsroot, path, svnrepos.scratch_pool)
      while history:
        path, peg_revision = fs.history_location(history,
                                                 svnrepos.scratch_pool);
        if peg_revision <= limit_revision:
          return max(peg_revision, limit_revision), _cleanup_path(path)
        history = fs.history_prev(history, 1, svnrepos.scratch_pool)
      return peg_revision, _cleanup_path(path)
    else:
      ### Warning: this is *not* an example of good pool usage.
      orig_id = fs.node_id(svnrepos._getroot(peg_revision), path,
                           svnrepos.scratch_pool)
      while peg_revision != limit_revision:
        mid = (peg_revision + 1 + limit_revision) / 2
        try:
          mid_id = fs.node_id(svnrepos._getroot(mid), path,
                              svnrepos.scratch_pool)
        except core.SubversionException, e:
          if e.apr_err == core.SVN_ERR_FS_NOT_FOUND:
            cmp = -1
          else:
            raise
        else:
          ### Not quite right.  Need a comparison function that only returns
          ### true when the two nodes are the same copy, not just related.
          cmp = fs.compare_ids(orig_id, mid_id)

        if cmp in (0, 1):
          peg_revision = mid
        else:
          limit_revision = mid - 1

      return peg_revision, path
  finally:
    svnrepos._scratch_clear()
예제 #10
0
파일: svnrep.py 프로젝트: mizuy/mizwiki
 def previous(self,cross_copy=False):
     if not self.exist:
         return None
     oh = fs.node_history(self._revision._root,self.path)
     oh = fs.history_prev(oh,cross_copy)
     oh = fs.history_prev(oh,cross_copy)
     if not oh:
         return None
     else:
         hpath,hrevno = fs.history_location(oh)
         return self.repository.get_file(hrevno,hpath)
예제 #11
0
    def _history(self, svn_path, start, end, pool):
        """`svn_path` must be a full scope path, UTF-8 encoded string.

        Generator yielding `(path, rev)` pairs, where `path` is an `unicode`
        object.
        Must start with `(path, created rev)`.
        """
        if start < end:
            start, end = end, start
        root = fs.revision_root(self.fs_ptr, start, pool())
        history_ptr = fs.node_history(root, svn_path, pool())
        cross_copies = 1
        while history_ptr:
            history_ptr = fs.history_prev(history_ptr, cross_copies, pool())
            if history_ptr:
                path, rev = fs.history_location(history_ptr, pool())
                if rev < end:
                    break
                path = _from_svn(path)
                if not self.authz.has_permission(path):
                    break
                yield path, rev
예제 #12
0
    def _history(self, svn_path, start, end, pool):
        """`svn_path` must be a full scope path, UTF-8 encoded string.

        Generator yielding `(path, rev)` pairs, where `path` is an `unicode`
        object.
        Must start with `(path, created rev)`.
        """
        if start < end:
            start, end = end, start
        root = fs.revision_root(self.fs_ptr, start, pool())
        history_ptr = fs.node_history(root, svn_path, pool())
        cross_copies = 1
        while history_ptr:
            history_ptr = fs.history_prev(history_ptr, cross_copies, pool())
            if history_ptr:
                path, rev = fs.history_location(history_ptr, pool())
                if rev < end:
                    break
                path = _from_svn(path)
                if not self.authz.has_permission(path):
                    break
                yield path, rev
예제 #13
0
def _get_last_history_rev(fsroot, path):
    history = fs.node_history(fsroot, path)
    history = fs.history_prev(history, 0)
    history_path, history_rev = fs.history_location(history)
    return history_rev
예제 #14
0
def _get_last_history_rev(fsroot, path):
  history = fs.node_history(fsroot, path)
  history = fs.history_prev(history, 0)
  history_path, history_rev = fs.history_location(history)
  return history_rev
예제 #15
0
def _get_last_history_rev(fsroot, path, pool):
  history = fs.node_history(fsroot, path, pool)
  history = fs.history_prev(history, 0, pool)
  history_path, history_rev = fs.history_location(history, pool);
  return history_rev