Remove follow_history in favor of all_revision_ids().
authorJelmer Vernooij <jelmer@samba.org>
Sat, 29 Mar 2008 16:41:16 +0000 (17:41 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 29 Mar 2008 16:41:16 +0000 (17:41 +0100)
1  2 
layout.py
repository.py
tests/test_repos.py

diff --cc layout.py
index a576304369cf8a2afc0f21a147d28025f5dbbbe2,0000000000000000000000000000000000000000..08ccb836d03785a64fbac54f0631cf1ef8a54ca6
mode 100644,000000..100644
--- /dev/null
+++ b/layout.py
@@@ -1,53 -1,0 +1,57 @@@
-         :return: Tuple with type ('tag' or 'branch'), project name, branch name and path 
 +# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
 + 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
 +# the Free Software Foundation; either version 3 of the License, or
 +# (at your option) any later version.
 +
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +
 +# You should have received a copy of the GNU General Public License
 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +
 +class RepositoryLayout:
 +    """Describes a repository layout."""
 +    def get_tag_path(self, name, project=""):
 +        """Return the path at which the tag with specified name should be found.
 +
 +        :param name: Name of the tag. 
 +        :param project: Optional name of the project the tag is for. Can include slashes.
 +        :return: Path of the tag."
 +        """
 +        raise NotImplementedError
 +
 +    def get_branch_path(self, name, project=""):
 +        """Return the path at which the branch with specified name should be found.
 +
 +        :param name: Name of the branch. 
 +        :param project: Optional name of the project the branch is for. Can include slashes.
 +        :return: Path of the branch.
 +        """
 +        raise NotImplementedError
 +
 +    def parse(self, path):
 +        """Parse a path.
 +
++        :return: Tuple with type ('tag' or 'branch'), project name, branch path and path 
 +            inside the branch
 +        """
 +        raise NotImplementedError
 +
 +    def get_branches(self, project="", revnum=None):
 +        """Retrieve a list of paths that refer to branches in a specific revision.
++
++        :result: Iterator over tuples with (project, branch path)
 +        """
 +        raise NotImplementedError
 +
 +    def get_tags(self, project="", revnum=None):
 +        """Retrieve a list of paths that refer to tags in a specific revision.
++
++        :result: Iterator over tuples with (project, branch path)
 +        """
 +        raise NotImplementedError
diff --cc repository.py
index 526f7ee2ab33c474c9d6be44f3af6748ef47c2e4,eeadea1820c6d3c623eb867d20440754002fbf50..3e943042b78289f28109297217c52ab69aeaddb8
@@@ -311,9 -311,9 +311,20 @@@ class SvnRepository(Repository)
      def all_revision_ids(self, mapping=None):
          if mapping is None:
              mapping = self.get_mapping()
--        for (bp, rev) in self.follow_history(
--                self.transport.get_latest_revnum(), mapping):
--            yield self.generate_revision_id(rev, bp, mapping)
++        revnum = self.transport.get_latest_revnum()
++
++        for (_, paths, revnum) in self._log.iter_changes("", revnum):
++            yielded_paths = []
++            for p in paths:
++                try:
++                    bp = mapping.scheme.unprefix(p)[0]
++                    if not bp in yielded_paths:
++                        if not paths.has_key(bp) or paths[bp][0] != 'D':
++                            assert revnum > 0 or bp == ""
++                            yield self.generate_revision_id(revnum, bp, mapping)
++                        yielded_paths.append(bp)
++                except NotBranchError:
++                    pass
  
      def get_inventory_weave(self):
          """See Repository.get_inventory_weave()."""
          return self._serializer.write_revision_to_string(
              self.get_revision(revision_id))
  
--    def follow_history(self, revnum, mapping):
--        """Yield all the branches found between the start of history 
--        and a specified revision number.
--
--        :param revnum: Revision number up to which to search.
--        :return: iterator over branches in the range 0..revnum
--        """
--        assert mapping is not None
--
--        for (_, paths, revnum) in self._log.iter_changes("", revnum):
--            yielded_paths = []
--            for p in paths:
--                try:
--                    bp = mapping.scheme.unprefix(p)[0]
--                    if not bp in yielded_paths:
--                        if not paths.has_key(bp) or paths[bp][0] != 'D':
--                            assert revnum > 0 or bp == ""
--                            yield (bp, revnum)
--                        yielded_paths.append(bp)
--                except NotBranchError:
--                    pass
-     def get_lhs_parent(self, revid):
-         (branch_path, revnum, mapping) = self.lookup_revision_id(revid)
-         parent_revid = self.lhs_revision_parent(branch_path, revnum, mapping)
-         if parent_revid is None:
-             return NULL_REVISION
-         return parent_revid
--
      def follow_branch(self, branch_path, revnum, mapping):
          """Follow the history of a branch. Will yield all the 
          left-hand side ancestors of a specified revision.
  
          return ret
  
-     def find_branches(self, using=False):
 -    def find_branches(self, using=False, scheme=None):
++    def find_branches(self, using=False, layout=None):
          """Find branches underneath this repository.
  
          This will include branches inside other branches.
          """
          # All branches use this repository, so the using argument can be 
          # ignored.
-         layout = self.get_layout()
 -        if scheme is None:
 -            scheme = self.get_scheme()
 -
 -        existing_branches = [bp for (bp, revnum, _) in 
 -                filter(lambda (bp, rev, exists): exists,
 -                       self.find_branchpaths(scheme))]
++        if layout is None:
++            layout = self.get_layout()
  
-         for project, bp in layout.get_branches():
+         branches = []
 -        for bp in existing_branches:
++        for project, bp, nick in layout.get_branches():
              try:
                  branches.append(Branch.open(urlutils.join(self.base, bp)))
              except NotBranchError: # Skip non-directories
index 712beeb26bb6feb8a2978c0a164f8a71675ce9fa,712beeb26bb6feb8a2978c0a164f8a71675ce9fa..298308ff1cc2704689ac4e2e7de6948bf44b428a
@@@ -203,7 -203,7 +203,7 @@@ class TestSubversionRepositoryWorks(Tes
          repos = Repository.open(repos_url)
  
          self.assertEqual(2, 
--                   len(list(repos.follow_history(1, repos.get_mapping()))))
++                   len(list(repos.all_revision_ids(repos.get_mapping()))))
  
      def test_all_revs_empty(self):
          repos_url = self.make_client("a", "dc")
      def test_follow_history_empty(self):
          repos_url = self.make_client("a", "dc")
          repos = Repository.open(repos_url)
--        self.assertEqual([('', 0)], 
--              list(repos.follow_history(0, 
--                  repos.get_mapping())))
++        self.assertEqual([repos.generate_revision_id(0, '', repos.get_mapping())], 
++              list(repos.all_revision_ids(repos.get_mapping())))
  
      def test_follow_history_empty_branch(self):
          repos_url = self.make_client("a", "dc")
          self.client_commit("dc", "My Message")
          repos = Repository.open(repos_url)
          repos.set_branching_scheme(TrunkBranchingScheme())
--        self.assertEqual([('trunk', 1)], 
--                list(repos.follow_history(1, repos.get_mapping())))
++        self.assertEqual([repos.generate_revision_id(1, 'trunk', repos.get_mapping())], 
++                list(repos.all_revision_ids(repos.get_mapping())))
  
      def test_follow_history_follow(self):
          repos_url = self.make_client("a", "dc")
          repos = Repository.open(repos_url)
          repos.set_branching_scheme(TrunkBranchingScheme())
  
--        items = list(repos.follow_history(2, repos.get_mapping()))
--        self.assertEqual([('branches/abranch', 2), 
--                          ('trunk', 1)], items)
++        items = list(repos.all_revision_ids(repos.get_mapping()))
++        self.assertEqual([repos.generate_revision_id(2, 'branches/abranch', repos.get_mapping()), 
++                          repos.generate_revision_id(1, 'trunk', repos.get_mapping())], items)
  
      def test_branch_log_specific(self):
          repos_url = self.make_client("a", "dc")