Rev 312: Fix bug in new follow_branch functions. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Tue Dec 26 23:38:05 GMT 2006


------------------------------------------------------------
revno: 312
revision-id: jelmer at samba.org-20061226233735-g1nn2zjwz9kf2v3u
parent: jelmer at samba.org-20061226222529-x4ch5ttzqw6apc84
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Wed 2006-12-27 00:37:35 +0100
message:
  Fix bug in new follow_branch functions.
modified:
  logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_logwalker.py        test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
=== modified file 'logwalker.py'
--- a/logwalker.py	2006-12-26 22:04:29 +0000
+++ b/logwalker.py	2006-12-26 23:37:35 +0000
@@ -130,8 +130,7 @@
         pool = Pool()
         try:
             try:
-                mutter('getting log %r:%r' % (self.saved_revnum, to_revnum))
-                self.transport.get_log(["/"], self.saved_revnum, to_revnum, 
+                self.transport.get_log("/", self.saved_revnum, to_revnum, 
                                0, True, True, rcvr, pool)
             finally:
                 pb.clear()
@@ -161,26 +160,24 @@
 
         path = path.strip("/")
 
-        i = revnum
-        while i > 0:
-            revpaths = self.get_revision_paths(i, path)
-            yield (path, revpaths, i)
-
-            if (revpaths.has_key(path) and
-                revpaths[path][0] in ('A', 'R') and
-                revpaths[path][1] is None):
-               # this path didn't exist before this revision
-               return
-
-            if (not path is None and 
-                path in revpaths and 
-                not revpaths[path][1] is None):
-                # In this revision, this path was copied from 
-                # somewhere else
-                i = revpaths[path][2]
-                path = revpaths[path][1]
-            else:
-                i-=1
+        while revnum > 0:
+            revpaths = self.get_revision_paths(revnum, path)
+
+            if revpaths != {}:
+                yield (path, revpaths, revnum)
+
+            if revpaths.has_key(path):
+                if revpaths[path][1] is None:
+                    if revpaths[path][0] in ('A', 'R'):
+                        # this path didn't exist before this revision
+                        return
+                else:
+                    # In this revision, this path was copied from 
+                    # somewhere else
+                    revnum = revpaths[path][2]
+                    path = revpaths[path][1]
+                    continue
+            revnum-=1
 
     def get_revision_paths(self, revnum, path=None):
         """Obtain dictionary with all the changes in a particular revision.

=== modified file 'repository.py'
--- a/repository.py	2006-12-26 22:25:29 +0000
+++ b/repository.py	2006-12-26 23:37:35 +0000
@@ -513,6 +513,7 @@
                     # FIXME: if copyfrom_path is not a branch path, 
                     # should simulate a reverse "split" of a branch
                     # For now, just make it look like the branch originated here.
+                    mutter('breaking off "split"')
                     for c in self._log.find_children(changed_paths[bp][bp][1], changed_paths[bp][bp][2]):
                         path = c.replace(changed_paths[bp][bp][1], bp+"/", 1).replace("//", "/")
                         changed_paths[bp][path] = ('A', None, -1)

=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py	2006-12-26 22:04:29 +0000
+++ b/tests/test_logwalker.py	2006-12-26 23:37:35 +0000
@@ -65,7 +65,6 @@
         self.assertRaises(NoSuchRevision, list, 
                           walker.follow_path("/", 20))
 
-
     def test_branch_log_all(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({'dc/trunk/file': "data", "dc/foo/file":"data"})
@@ -93,6 +92,26 @@
         self.assertEqual(1, len(list(walker.follow_path("branches/brancha",
             1))))
 
+    def test_follow_path_ignore_unchanged(self):
+        repos_url = self.make_client("a", "dc")
+        self.build_tree({'dc/branches': None})
+        self.client_add("dc/branches")
+        self.build_tree({
+            'dc/branches/brancha': None,
+            'dc/branches/branchab': None,
+            'dc/branches/brancha/data': "data", 
+            "dc/branches/branchab/data":"data"})
+        self.client_add("dc/branches/brancha")
+        self.client_commit("dc", "My Message")
+
+        self.client_add("dc/branches/branchab")
+        self.client_commit("dc", "My Message2")
+
+        walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
+
+        self.assertEqual(1, len(list(walker.follow_path("branches/brancha",
+            2))))
+
     def test_find_latest_none(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({'dc/branches': None})
@@ -239,7 +258,9 @@
         walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
 
         items = list(walker.follow_path("branches/abranch", 2))
-        self.assertEqual(2, len(items))
+        self.assertEqual([('branches/abranch', {'branches/abranch': ('A', 'trunk', 1)}, 2), 
+                          ('trunk', {'trunk/afile': ('A', None, -1), 
+                                     'trunk': (u'A', None, -1)}, 1)], items)
 
     def test_touches_path(self):
         repos_url = self.make_client("a", "dc")

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2006-12-26 22:25:29 +0000
+++ b/tests/test_repos.py	2006-12-26 23:37:35 +0000
@@ -78,6 +78,24 @@
 
         self.assertEqual(1, len(list(repos.follow_history(1))))
 
+    def test_follow_history_follow(self):
+        repos_url = self.make_client("a", "dc")
+        self.build_tree({'dc/trunk/afile': "data", "dc/branches": None})
+        self.client_add("dc/trunk")
+        self.client_add("dc/branches")
+        self.client_commit("dc", "My Message")
+
+        self.client_copy("dc/trunk", "dc/branches/abranch")
+        self.client_commit("dc", "Create branch")
+
+        repos = Repository.open(repos_url)
+        repos.set_branching_scheme(TrunkBranchingScheme())
+
+        items = list(repos.follow_history(2))
+        self.assertEqual([('branches/abranch', {'branches/abranch': ('A', 'trunk', 1)}, 2), 
+                          ('trunk', {'trunk/afile': ('A', None, -1), 
+                                     'trunk': (u'A', None, -1)}, 1)], items)
+
     def test_branch_log_specific(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({
@@ -95,6 +113,27 @@
         self.assertEqual(1, len(list(repos.follow_branch_history("branches/brancha",
             1))))
 
+    def test_branch_log_specific_ignore(self):
+        repos_url = self.make_client("a", "dc")
+        self.build_tree({'dc/branches': None})
+        self.client_add("dc/branches")
+        self.build_tree({
+            'dc/branches/brancha': None,
+            'dc/branches/branchab': None,
+            'dc/branches/brancha/data': "data", 
+            "dc/branches/branchab/data":"data"})
+        self.client_add("dc/branches/brancha")
+        self.client_commit("dc", "My Message")
+
+        self.client_add("dc/branches/branchab")
+        self.client_commit("dc", "My Message2")
+
+        repos = Repository.open(repos_url)
+        repos.set_branching_scheme(TrunkBranchingScheme())
+
+        self.assertEqual(1, len(list(repos.follow_branch_history("branches/brancha",
+            2))))
+
     def test_find_branches_no(self):
         repos_url = self.make_client("a", "dc")
 

=== modified file 'transport.py'
--- a/transport.py	2006-12-26 19:58:41 +0000
+++ b/transport.py	2006-12-26 23:37:35 +0000
@@ -142,15 +142,17 @@
 
     @need_lock
     def get_uuid(self):
+        mutter('svn get-uuid')
         return svn.ra.get_uuid(self._ra)
 
     @need_lock
     def get_repos_root(self):
+        mutter("svn get-repos-root")
         return svn.ra.get_repos_root(self._ra)
 
     @need_lock
     def get_latest_revnum(self):
-        mutter("svn latest-revnum")
+        mutter("svn get-latest-revnum")
         return svn.ra.get_latest_revnum(self._ra)
 
     @need_lock
@@ -159,8 +161,9 @@
         return svn.ra.do_switch(self._ra, switch_rev, switch_target, *args, **kwargs)
 
     @need_lock
-    def get_log(self, *args, **kwargs):
-        return svn.ra.get_log(self._ra, *args, **kwargs)
+    def get_log(self, path, from_revnum, to_revnum, *args, **kwargs):
+        mutter('svn log %r:%r %r' % (from_revnum, to_revnum, path))
+        return svn.ra.get_log(self._ra, [path], from_revnum, to_revnum, *args, **kwargs)
 
     @need_lock
     def reparent(self, url):
@@ -170,6 +173,7 @@
         self.base = url
         self.svn_url = url
         if hasattr(svn.ra, 'reparent'):
+            mutter('svn reparent %r' % url)
             svn.ra.reparent(self._ra, url, self.pool)
         else:
             self._ra = svn.client.open_ra_session(self.svn_url.encode('utf8'), 




More information about the bazaar-commits mailing list