Rev 410: Implement get_revision_graph(None). in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Sat Jan 20 23:01:30 GMT 2007


------------------------------------------------------------
revno: 410
revision-id: jelmer at samba.org-20070120230110-3qrbo5iqx7z56sdl
parent: jelmer at samba.org-20070120224027-8bmtpksroz7awkla
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Sun 2007-01-21 00:01:10 +0100
message:
  Implement get_revision_graph(None).
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  TODO                           todo-20060729211917-2kpobww0zyvvo0j2-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
=== modified file 'NEWS'
--- a/NEWS	2007-01-20 22:40:27 +0000
+++ b/NEWS	2007-01-20 23:01:10 +0000
@@ -8,6 +8,8 @@
    * Fixed error raised during version incompatibility. (Wouter van Heyst, 
                                                          #80467)
 
+   * Implemented Repository.get_revision_graph(None)
+
   IMPROVEMENTS
 
    * A proper warning will now be printed if no sqlite implementation is 

=== modified file 'TODO'
--- a/TODO	2007-01-15 03:15:21 +0000
+++ b/TODO	2007-01-20 23:01:10 +0000
@@ -16,3 +16,4 @@
 - support multiple branching schemes per repository
 - more efficient implementation for applying txdeltas to weaves. perhaps convert svn deltas to bzr deltas?
 - free memory!
+- implement BzrDirFormat.get_converter()

=== modified file 'repository.py'
--- a/repository.py	2007-01-18 13:19:14 +0000
+++ b/repository.py	2007-01-20 23:01:10 +0000
@@ -529,10 +529,21 @@
         # SVN doesn't store GPG signatures
         raise NoSuchRevision(self, revision_id)
 
-    def get_revision_graph(self, revision_id):
+    def _full_revision_graph(self):
+        graph = {}
+        for (branch, revnum) in self.follow_history(self._latest_revnum):
+            mutter('%r, %r' % (branch, revnum))
+            revid = self.generate_revision_id(revnum, branch)
+            graph[revid] = self.revision_parents(revid)
+        return graph
+
+    def get_revision_graph(self, revision_id=None):
         if revision_id == NULL_REVISION:
             return {}
 
+        if revision_id is None:
+            return self._full_revision_graph()
+
         (path, revnum) = self.parse_revision_id(revision_id)
 
         self._previous = revision_id

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2007-01-14 01:56:13 +0000
+++ b/tests/test_repos.py	2007-01-20 23:01:10 +0000
@@ -414,6 +414,26 @@
         self.assertRaises(NoSuchRevision, repository.get_revision_graph, 
                           "nonexisting")
 
+    def test_get_revision_graph_all_empty(self):
+        repos_url = self.make_client('d', 'dc')
+        repository = Repository.open(repos_url)
+        self.assertEqual({}, repository.get_revision_graph())
+
+    def test_get_revision_graph_all(self):
+        repos_url = self.make_client('d', 'dc')
+        self.build_tree({'dc/trunk/a': 'data', 'dc/branches/foo/b': 'alsodata'})
+        self.client_add("dc/trunk")
+        self.client_add("dc/branches")
+        self.client_commit("dc", "initial commit")
+        self.build_tree({'dc/trunk/a': "bloe"})
+        self.client_commit("dc", "second commit")
+        repository = Repository.open(repos_url)
+        repository.set_branching_scheme(TrunkBranchingScheme())
+        self.assertEqual({repository.generate_revision_id(1, "trunk"): [],
+                          repository.generate_revision_id(2, "trunk"): [repository.generate_revision_id(1, "trunk")],
+                          repository.generate_revision_id(1, "branches/foo"): []
+                          }, repository.get_revision_graph())
+
     def test_get_revision_graph(self):
         repos_url = self.make_client('d', 'dc')
         repository = Repository.open("svn+%s" % repos_url)




More information about the bazaar-commits mailing list