Rev 2103: Some formatting fixes. in http://people.samba.org/bzr/jelmer/bzr-svn/0.5

Jelmer Vernooij jelmer at samba.org
Sun Nov 30 15:28:32 GMT 2008


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

------------------------------------------------------------
revno: 2103
revision-id: jelmer at samba.org-20081130152828-9s2nbuh6xieq3kfy
parent: jelmer at samba.org-20081129162645-t7tmstaq00kk8lzw
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.5
timestamp: Sun 2008-11-30 16:28:28 +0100
message:
  Some formatting fixes.
modified:
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  revmeta.py                     revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
=== modified file 'repository.py'
--- a/repository.py	2008-11-28 17:23:10 +0000
+++ b/repository.py	2008-11-30 15:28:28 +0000
@@ -589,6 +589,7 @@
         return signature
 
     def add_signature_text(self, revision_id, signature):
+        """Add a signature text to an existing revision."""
         (uuid, path, revnum), mapping = self.lookup_revision_id(revision_id)
         try:
             self.transport.change_rev_prop(revnum, SVN_REVPROP_BZR_SIGNATURE, signature)
@@ -740,15 +741,18 @@
         return True
 
     def get_physical_lock_status(self):
+        """See Repository.get_physical_lock_status()."""
         return False
 
     def get_commit_builder(self, branch, parents, config, timestamp=None, 
                            timezone=None, committer=None, revprops=None, 
                            revision_id=None):
+        """See Repository.get_commit_builder()."""
         from bzrlib.plugins.svn.commit import SvnCommitBuilder
-        return SvnCommitBuilder(self, branch.get_branch_path(), parents, config, timestamp, 
-                timezone, committer, revprops, revision_id, 
-                append_revisions_only=True)
+        return SvnCommitBuilder(self, branch.get_branch_path(), parents, 
+                                config, timestamp, timezone, committer, 
+                                revprops, revision_id, 
+                                append_revisions_only=True)
 
     def find_fileprop_paths(self, layout, from_revnum, to_revnum, 
                                project=None, check_removed=False):
@@ -764,12 +768,15 @@
                 yield (branch, revno, exists)
 
     def abort_write_group(self, suppress_errors=False):
+        """See Repository.abort_write_group()."""
         self._write_group = None
 
     def commit_write_group(self):
+        """See Repository.commit_write_group()."""
         self._write_group = None
 
     def start_write_group(self):
+        """See Repository.commit_write_group()."""
         if not self.is_write_locked():
             raise bzr_errors.NotWriteLocked(self)
         self._write_group = None 

=== modified file 'revmeta.py'
--- a/revmeta.py	2008-11-29 05:14:28 +0000
+++ b/revmeta.py	2008-11-30 15:28:28 +0000
@@ -47,7 +47,8 @@
         )
 
 import bisect
-from itertools import ifilter
+from functools import partial
+from itertools import ifilter, imap
 
 
 class MetabranchHistoryIncomplete(Exception):
@@ -217,6 +218,10 @@
         return self._changed_fileprops
 
     def get_direct_lhs_parent_revmeta(self):
+        """Find the direct left hand side parent of this revision.
+        
+        This ignores mapping restrictions (invalid paths, hidden revisions).
+        """
         if self._direct_lhs_parent_known:
             return self._direct_lhs_parent_revmeta
         self._direct_lhs_parent_known = True
@@ -240,7 +245,8 @@
 
         :note: Returns None when there is no parent (parent is NULL_REVISION)
         """
-        assert mapping.is_branch_or_tag(self.branch_path), "%s not valid in %r" % (self.branch_path, mapping)
+        assert mapping.is_branch_or_tag(self.branch_path), \
+                "%s not valid in %r" % (self.branch_path, mapping)
         def get_next_parent(nm):
             pm = nm.get_direct_lhs_parent_revmeta()
             if pm is None or mapping.is_branch_or_tag(pm.branch_path):
@@ -274,7 +280,8 @@
     def get_lhs_parent(self, mapping):
         """Find the revid of the left hand side parent of this revision."""
         # Sometimes we can retrieve the lhs parent from the revprop data
-        lhs_parent = mapping.get_lhs_parent(self.branch_path, self.get_revprops(), self.get_changed_fileprops())
+        lhs_parent = mapping.get_lhs_parent(self.branch_path, 
+                            self.get_revprops(), self.get_changed_fileprops())
         if lhs_parent is not None:
             return lhs_parent
         parentrevmeta = self.get_lhs_parent_revmeta(mapping)
@@ -283,7 +290,7 @@
         return parentrevmeta.get_revision_id(mapping)
 
     def estimate_bzr_fileprop_ancestors(self):
-        """Estimate how many ancestors with bzr file properties this revision has.
+        """Estimate how many ancestors with bzr fileprops this revision has.
 
         """
         if not self.knows_fileprops() and not self.consider_bzr_fileprops():
@@ -320,7 +327,8 @@
         if not mapping.supports_hidden:
             return False
         if self.consider_bzr_fileprops() or self.check_revprops:
-            return mapping.is_bzr_revision_hidden(self.get_revprops(), self.get_changed_fileprops())
+            return mapping.is_bzr_revision_hidden(self.get_revprops(), 
+                                                  self.get_changed_fileprops())
         return False
 
     def is_bzr_revision(self):
@@ -357,8 +365,9 @@
 
         if not self.changes_branch_root():
             return ()
-
-        previous, current = self.get_changed_fileprops().get(SVN_PROP_SVK_MERGE, ("", ""))
+        
+        changed_fileprops = self.get_changed_fileprops()
+        previous, current = changed_fileprops.get(SVN_PROP_SVK_MERGE, ("", ""))
         if current == "":
             return ()
 
@@ -378,8 +387,9 @@
         side NULL_REVISION, if known.
         """
         if mapping.roundtripping:
-            (bzr_revno, _) = mapping.get_revision_id(self.branch_path, self.get_revprops(), 
-                                                             self.get_changed_fileprops())
+            (bzr_revno, _) = mapping.get_revision_id(self.branch_path, 
+                                                     self.get_revprops(), 
+                                                     self.get_changed_fileprops())
             if bzr_revno is not None:
                 return bzr_revno
         return None
@@ -471,28 +481,33 @@
     """Wrapper around RevisionMetadata that stores some results in a cache."""
 
     def __init__(self, repository, *args, **kwargs):
-        super(CachingRevisionMetadata, self).__init__(repository, *args, **kwargs)
-        self._parents_cache = getattr(self.repository._real_parents_provider, "_cache", None)
+        super(CachingRevisionMetadata, self).__init__(repository, *args, 
+            **kwargs)
+        self._parents_cache = getattr(self.repository._real_parents_provider, 
+                                      "_cache", None)
         self._revid_cache = self.repository.revmap.cache
         self._revid = None
 
     def get_revision_id(self, mapping):
-        """Find the revision id of a revision, optionally caching it in a sqlite database."""
+        """Find the revision id of a revision."""
         if self._revid is not None:
             return self._revid
         # Look in the cache to see if it already has a revision id
-        self._revid = self._revid_cache.lookup_branch_revnum(self.revnum, self.branch_path, mapping.name)
+        self._revid = self._revid_cache.lookup_branch_revnum(self.revnum, 
+                                                             self.branch_path, 
+                                                             mapping.name)
         if self._revid is not None:
             return self._revid
 
         self._revid = super(CachingRevisionMetadata, self).get_revision_id(mapping)
 
-        self._revid_cache.insert_revid(self._revid, self.branch_path, self.revnum, self.revnum, mapping.name)
+        self._revid_cache.insert_revid(self._revid, self.branch_path, 
+                                       self.revnum, self.revnum, mapping.name)
         self._revid_cache.commit_conditionally()
         return self._revid
 
     def get_parent_ids(self, mapping):
-        """Find the parent ids of a revision, optionally caching them in a sqlite database."""
+        """Find the parent ids of a revision."""
         myrevid = self.get_revision_id(mapping)
 
         if self._parents_cache is not None:
@@ -523,6 +538,11 @@
 
 
 class ListBuildingIterator(object):
+    """Simple iterator that iterates over a list, and calling an iterator 
+    once all items in the list have been iterated.
+
+    The list may be updated while the iterator is running.
+    """
 
     def __init__(self, base_list, it):
         self.base_list = base_list
@@ -530,6 +550,7 @@
         self.it = it
 
     def next(self):
+        """Return the next item."""
         self.i+=1
         try:
             return self.base_list[self.i]
@@ -640,13 +661,14 @@
 
     def get_metabranch(self, bp):
         if not bp in self._metabranches:
-            from functools import partial
             self._metabranches[bp] = RevisionMetadataBranch()
-            self._metabranches[bp]._get_next = partial(self._branch_next, self._metabranches[bp])
+            self._metabranches[bp]._get_next = partial(self._branch_next, 
+                                                       self._metabranches[bp])
             self._provider._open_metabranches.append(self._metabranches[bp])
         return self._metabranches[bp]
 
     def _branch_next(self, metabranch):
+        """Find the next revision in a metabranch."""
         # Walk over all revisions since the last one currently present 
         # in metabranch until one of the following conditions occurs:
         # - New revision is added to metabranch
@@ -677,7 +699,8 @@
             bps = {}
             deletes = []
             if pb:
-                pb.update("discovering revisions", revnum-self.to_revnum, self.from_revnum-self.to_revnum)
+                pb.update("discovering revisions", revnum-self.to_revnum, 
+                          self.from_revnum-self.to_revnum)
 
             self._metabranches.update(metabranches_history.get(revnum, {}))
             unusual.update(unusual_history.get(revnum, set()))
@@ -695,7 +718,9 @@
                 for u in unusual:
                     if p.startswith("%s/" % u):
                         bps[u] = self.get_metabranch(u)
-                if action in ('R', 'D') and (self.layout.is_branch_or_tag(p, project) or self.layout.is_branch_or_tag_parent(p, project)):
+                if action in ('R', 'D') and (
+                    self.layout.is_branch_or_tag(p, project) or 
+                    self.layout.is_branch_or_tag_parent(p, project)):
                     deletes.append(p)
 
             # Mention deletes
@@ -703,7 +728,8 @@
                 yield ("delete", p)
             
             # Apply renames and the like for the next round
-            for new_name, old_name, old_rev in changes.apply_reverse_changes(self._metabranches.keys(), paths):
+            for new_name, old_name, old_rev in changes.apply_reverse_changes(
+                self._metabranches.keys(), paths):
                 if new_name in unusual:
                     unusual.remove(new_name)
                 if old_name is None: 
@@ -746,13 +772,18 @@
         else:
             self._revmeta_cls = RevisionMetadata
 
-    def create_revision(self, path, revnum, changes=None, revprops=None, changed_fileprops=None, fileprops=None, metabranch=None):
-        return self._revmeta_cls(self.repository, self.check_revprops, self._get_fileprops_fn,
-                               self._log, self.repository.uuid, path, revnum, changes, revprops, 
-                               changed_fileprops=changed_fileprops, fileprops=fileprops,
-                               metabranch=metabranch)
+    def create_revision(self, path, revnum, changes=None, revprops=None, 
+                        changed_fileprops=None, fileprops=None, 
+                        metabranch=None):
+        return self._revmeta_cls(self.repository, self.check_revprops, 
+                                 self._get_fileprops_fn, self._log, 
+                                 self.repository.uuid, path, revnum, changes, 
+                                 revprops, changed_fileprops=changed_fileprops,
+                                 fileprops=fileprops, metabranch=metabranch)
 
     def lookup_revision(self, path, revnum, revprops=None):
+        """Lookup a revision, optionally checking whether there are any 
+        unchecked metabranches that perhaps contain the revision."""
         # finish fetching any open revisionmetadata branches for 
         # which the latest fetched revnum > revnum
         for mb in self._open_metabranches:
@@ -761,8 +792,8 @@
             mb.fetch_until(revnum)
         return self.get_revision(path, revnum, revprops=revprops)
 
-    def get_revision(self, path, revnum, changes=None, revprops=None, changed_fileprops=None, 
-                     fileprops=None, metabranch=None):
+    def get_revision(self, path, revnum, changes=None, revprops=None, 
+                     changed_fileprops=None, fileprops=None, metabranch=None):
         """Return a RevisionMetadata object for a specific svn (path,revnum)."""
         assert isinstance(path, str)
         assert isinstance(revnum, int)
@@ -779,11 +810,13 @@
                 cached.metabranch = metabranch
             return self._revmeta_cache[path,revnum]
 
-        ret = self.create_revision(path, revnum, changes, revprops, changed_fileprops, fileprops, metabranch)
+        ret = self.create_revision(path, revnum, changes, revprops, 
+                                   changed_fileprops, fileprops, metabranch)
         self._revmeta_cache[path,revnum] = ret
         return ret
 
-    def iter_changes(self, branch_path, from_revnum, to_revnum, pb=None, limit=0):
+    def iter_changes(self, branch_path, from_revnum, to_revnum, pb=None, 
+                     limit=0):
         """Iterate over all revisions backwards.
         
         :return: iterator that returns tuples with branch path, 
@@ -799,8 +832,8 @@
         # because we're skipping some revs
         # TODO: Rather than fetching everything if limit == 2, maybe just 
         # set specify an extra X revs just to be sure?
-        for (paths, revnum, revprops) in self._log.iter_changes([branch_path], from_revnum, to_revnum, 
-                                                                pb=pb):
+        for (paths, revnum, revprops) in self._log.iter_changes([branch_path], 
+            from_revnum, to_revnum, pb=pb):
             assert bp is not None
             next = changes.find_prev_location(paths, bp, revnum)
             assert revnum > 0 or bp == ""
@@ -841,11 +874,11 @@
                                               to_revnum, pb=pb, 
                                               limit=limit)
         def convert((bp, paths, revnum, revprops)):
-            ret = self.get_revision(bp, revnum, paths, revprops, metabranch=metabranch)
+            ret = self.get_revision(bp, revnum, paths, revprops, 
+                                    metabranch=metabranch)
             metabranch.append(ret)
             return ret
         metabranch = RevisionMetadataBranch(self, limit)
-        from itertools import imap
         metabranch._get_next = imap(convert, history_iter).next
         self._open_metabranches.append(metabranch)
         for ret in metabranch:
@@ -853,7 +886,8 @@
                 break
             yield ret
 
-    def iter_all_revisions(self, layout, check_unusual_path, from_revnum, to_revnum=0, project=None, pb=None):
+    def iter_all_revisions(self, layout, check_unusual_path, from_revnum, 
+                           to_revnum=0, project=None, pb=None):
         """Iterate over all RevisionMetadata objects in a repository.
 
         :param layout: Repository layout to use
@@ -861,12 +895,13 @@
 
         Layout decides which ones to pick up.
         """
-        for kind, rev in self.iter_all_changes(layout, check_unusual_path, from_revnum, to_revnum, project, pb):
+        for kind, rev in self.iter_all_changes(layout, check_unusual_path, 
+            from_revnum, to_revnum, project, pb):
             if kind == "revision":
                 yield rev
 
-    def iter_all_changes(self, layout, check_unusual_path, from_revnum, to_revnum=0, 
-                         project=None, pb=None):
+    def iter_all_changes(self, layout, check_unusual_path, from_revnum, 
+                         to_revnum=0, project=None, pb=None):
         """Iterate over all RevisionMetadata objects and branch removals 
         in a repository.
 




More information about the bazaar-commits mailing list