Rev 1661: Implement much faster tags fetching. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Tue Aug 26 04:32:33 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1661
revision-id: jelmer at samba.org-20080826033223-axxs9zx9toa27sfa
parent: jelmer at samba.org-20080826015233-fy7euianwta3u82p
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Tue 2008-08-26 05:32:23 +0200
message:
  Implement much faster tags fetching.
modified:
  TODO                           todo-20060729211917-2kpobww0zyvvo0j2-1
  layout.py                      layout.py-20080323165407-y9qw8nx4oykvoe1k-1
  mapping3/__init__.py           __init__.py-20080502174630-9324zh25kka98vlw-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tags.py                        tags.py-20080822211316-scblu3akdvu0b64c-1
=== modified file 'TODO'
--- a/TODO	2008-07-04 04:46:58 +0000
+++ b/TODO	2008-08-26 03:32:23 +0000
@@ -1,6 +1,5 @@
 todo:
 - generate deltas rather than fulltexts when creating file id maps
-- BzrDir.create_branch() should set the revision id to NULL_REVISION
 - tests for setting svk:merge from .bzr checkout
 - tests for http-specific SvnRaTransport._request_path() code
 - tests for auth.py
@@ -8,8 +7,6 @@
  - svn-import without scheme specified should guess
  - bzr missing
 - transform file ids in workingtree in svn-upgrade
-- more efficient implementation of get_revision_delta() to speed up bzr log -v
-- nestedtree support
 - lookup_revision_id()'s result depends on the current branching scheme, 
   causing weird errors when pushing
 

=== modified file 'layout.py'
--- a/layout.py	2008-08-23 02:26:55 +0000
+++ b/layout.py	2008-08-26 03:32:23 +0000
@@ -26,6 +26,13 @@
         """
         raise NotImplementedError
 
+    def get_tag_name(self, path, project=""):
+        """Determine the tag name from a tag path.
+
+        :param path: Path inside the repository.
+        """
+        raise NotImplementedError
+
     def push_merged_revisions(self, project=""):
         """Determine whether or not right hand side (merged) revisions should be pushed.
 

=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py	2008-08-26 01:49:26 +0000
+++ b/mapping3/__init__.py	2008-08-26 03:32:23 +0000
@@ -89,6 +89,9 @@
             type = "branch"
         return (type, proj, bp, rp)
 
+    def get_tag_name(self, path, project=None):
+        return path.split("/")[-1]
+
     def _get_root_paths(self, itemlist, revnum, verify_fn, project=None, pb=None):
         def check_path(path):
             return self.repository.transport.check_path(path, revnum) == NODE_DIR

=== modified file 'repository.py'
--- a/repository.py	2008-08-26 01:03:55 +0000
+++ b/repository.py	2008-08-26 03:32:23 +0000
@@ -28,6 +28,7 @@
 from bzrlib.transport import Transport, get_transport
 from bzrlib.trace import info
 
+from copy import copy
 from itertools import chain
 import os
 
@@ -826,6 +827,38 @@
         return branches
 
     @needs_read_lock
+    def find_tags_between(self, project, layout, mapping, from_revnum, to_revnum, tags={}):
+        for (paths, revnum, revprops) in self._log.iter_changes(None, from_revnum, to_revnum):
+            for p in sorted(paths):
+                (action, cf, cr) = paths[p]
+                if layout.is_tag_parent(p, project) and cf is not None:
+                    pass # FIXME
+                else:
+                    try:
+                        (pt, proj, bp, rp) = layout.parse(p)
+                    except errors.InvalidSvnBranchPath:
+                        continue
+                    if pt != "tag" or (project is not None and proj != project):
+                        continue
+                    if action == "D" and rp == "":
+                        tags[p] = None
+                    elif rp == "" and cf is not None:
+                        # This tag was (recreated) here, so unless anything else under this 
+                        # tag changed
+                        tp = p
+                        tr = revnum
+                        newpaths = copy(paths)
+                        del newpaths[p]
+                        if not changes.changes_path(newpaths, p, False):
+                            tp = cf
+                            tr = cr
+                        tags[p] = self.generate_revision_id(tr, tp, mapping)
+                    else:
+                        tags[bp] = self.generate_revision_id(revnum, bp, mapping, revprops=revprops)
+
+        return dict([(layout.get_tag_name(p, project), revid) for (p, revid) in tags.items() if revid is not None])
+
+    @needs_read_lock
     def find_tags(self, project, layout=None, from_revnum=0, to_revnum=None):
         """Find tags underneath this repository for the specified project.
 

=== modified file 'tags.py'
--- a/tags.py	2008-08-25 01:32:46 +0000
+++ b/tags.py	2008-08-26 03:32:23 +0000
@@ -97,9 +97,11 @@
             raise NoSuchTag(tag_name)
 
     def get_tag_dict(self, _from_revnum=0):
-        return self.repository.find_tags(project=self.branch.project, 
+        return self.repository.find_tags_between(project=self.branch.project, 
                               layout=self.branch.layout,
-                              from_revnum=_from_revnum)
+                              mapping=self.branch.mapping,
+                              from_revnum=_from_revnum, 
+                              to_revnum=self.repository.get_latest_revnum())
 
     def get_reverse_tag_dict(self):
         """Returns a dict with revisions as keys




More information about the bazaar-commits mailing list