Rev 412: Bring in the merge_point_config code. in http://bazaar.launchpad.net/~jameinel/loggerhead/all

John Arbash Meinel john at arbash-meinel.com
Mon Apr 26 22:29:13 BST 2010


At http://bazaar.launchpad.net/~jameinel/loggerhead/all

------------------------------------------------------------
revno: 412 [merge]
revision-id: john at arbash-meinel.com-20100426212836-hmdswqil8zh528xy
parent: mnordhoff at mattnordhoff.com-20100424124017-do5wupmzlkmejtvk
parent: john at arbash-meinel.com-20100426181726-qvz8oroi9dxqk6ck
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: all
timestamp: Mon 2010-04-26 16:28:36 -0500
message:
  Bring in the merge_point_config code.
modified:
  loggerhead/apps/branch.py      wsgiapp.py-20080612051902-5y0zpdi6fhxgun6z-2
  loggerhead/apps/transport.py   wsgitest.py-20080612051902-5y0zpdi6fhxgun6z-1
  loggerhead/config.py           config.py-20090331163436-x6habdrjtdq2pvxg-1
  loggerhead/history.py          history.py-20061211064342-102iqirsciyvgtcf-5
-------------- next part --------------
=== modified file 'loggerhead/apps/branch.py'
--- a/loggerhead/apps/branch.py	2010-04-14 17:54:32 +0000
+++ b/loggerhead/apps/branch.py	2010-04-26 18:17:26 +0000
@@ -49,6 +49,10 @@
     def __init__(self, branch, friendly_name=None, config={},
                  graph_cache=None, branch_link=None, is_root=False,
                  served_url=_DEFAULT, use_cdn=False):
+        # XXX: Why is config here a simple dictionary (which only ever has a
+        #      single item that I can find), while every other 'self._config'
+        #      is a LoggerheadConfig object. The latter seems a lot more
+        #      useful.
         self.branch = branch
         self._config = config
         self.friendly_name = friendly_name
@@ -64,6 +68,7 @@
     def get_history(self):
         file_cache = None
         revinfo_disk_cache = None
+        show_merge_points = self._config.get('show_merge_points', True)
         cache_path = self._config.get('cachepath', None)
         if cache_path is not None:
             # Only import the cache if we're going to use it.
@@ -79,7 +84,9 @@
                 revinfo_disk_cache = RevInfoDiskCache(cache_path)
         return History(
             self.branch, self.graph_cache, file_cache=file_cache,
-            revinfo_disk_cache=revinfo_disk_cache, cache_key=self.friendly_name)
+            revinfo_disk_cache=revinfo_disk_cache,
+            cache_key=self.friendly_name,
+            show_merge_points=show_merge_points)
 
     def url(self, *args, **kw):
         if isinstance(args[0], list):

=== modified file 'loggerhead/apps/transport.py'
--- a/loggerhead/apps/transport.py	2010-03-25 16:19:24 +0000
+++ b/loggerhead/apps/transport.py	2010-04-26 18:17:26 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, 2009 Canonical Ltd.
+# Copyright (C) 2008, 2009, 2010 Canonical Ltd.
 #
 # 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
@@ -18,7 +18,7 @@
 
 import threading
 
-from bzrlib import branch, errors, lru_cache, urlutils
+from bzrlib import branch, errors, lru_cache, ui, urlutils
 from bzrlib.config import LocationConfig
 from bzrlib.smart import request
 from bzrlib.transport import get_transport
@@ -55,10 +55,15 @@
         else:
             name = self.name
             is_root = False
+        show_merge_points = self._config.get_option('show_merge_points')
+        show_merge_points = ui.bool_from_string(show_merge_points)
+        if show_merge_points is None:
+            show_merge_points = True
         branch_app = BranchWSGIApp(
             branch,
             name,
-            {'cachepath': self._config.SQL_DIR},
+            {'cachepath': self._config.SQL_DIR,
+             'show_merge_points': show_merge_points},
             self.root.graph_cache,
             is_root=is_root,
             use_cdn=self._config.get_option('use_cdn'),

=== modified file 'loggerhead/config.py'
--- a/loggerhead/config.py	2010-04-13 23:35:01 +0000
+++ b/loggerhead/config.py	2010-04-26 18:17:26 +0000
@@ -24,6 +24,9 @@
 def _get_temporary_sql_dir():
     global _temporary_sql_dir
     if _temporary_sql_dir is None:
+        # XXX: Shouldn't this be registering an atexit hook to delete the
+        #      directory? Otherwise we fill up /tmp with caches that we won't
+        #      ever use again...
         _temporary_sql_dir = tempfile.mkdtemp(prefix='loggerhead-cache-')
     return _temporary_sql_dir
 
@@ -69,6 +72,12 @@
                       help="The directory to place the SQL cache in")
     parser.add_option("--allow-writes", action="store_true",
                       help="Allow writing to the Bazaar server.")
+    parser.add_option("--show-merge-points", action="store_true", default=True,
+                      help="When showing a revision, show where it"
+                           " was merged.")
+    parser.add_option("--no-show-merge-points", action="store_false",
+                      dest='show_merge_points',
+                      help="Do not show where revisions are merged")
     return parser
 
 
@@ -92,7 +101,7 @@
         All loggerhead-specific settings start with 'http_'
         """
         global_config = config.GlobalConfig().get_user_option('http_'+option)
-        cmd_config = getattr(self._options, option)
+        cmd_config = getattr(self._options, option, None)
         if global_config is not None and (
             cmd_config is None or cmd_config is False):
             return global_config

=== modified file 'loggerhead/history.py'
--- a/loggerhead/history.py	2010-04-14 17:54:32 +0000
+++ b/loggerhead/history.py	2010-04-26 18:17:26 +0000
@@ -274,7 +274,8 @@
                 self._revno_revid[revno_str] = revid
 
     def __init__(self, branch, whole_history_data_cache, file_cache=None,
-                 revinfo_disk_cache=None, cache_key=None):
+                 revinfo_disk_cache=None, cache_key=None,
+                 show_merge_points=True):
         assert branch.is_locked(), (
             "Can only construct a History object with a read-locked branch.")
         if file_cache is not None:
@@ -285,6 +286,7 @@
         self._branch = branch
         self._inventory_cache = {}
         self._branch_nick = self._branch.get_config().get_nickname()
+        self._show_merge_points = show_merge_points
         self.log = logging.getLogger('loggerhead.%s' % (self._branch_nick,))
 
         self.last_revid = branch.last_revision()
@@ -614,12 +616,17 @@
 
         # some data needs to be recalculated each time, because it may
         # change as new revisions are added.
-        for change in changes:
+        def merge_points_callback(a_change, attr):
             merge_revids = self.simplify_merge_point_list(
-                               self.get_merge_point_list(change.revid))
-            change.merge_points = [
-                util.Container(revid=r,
-                revno=self.get_revno(r)) for r in merge_revids]
+                               self.get_merge_point_list(a_change.revid))
+            return [util.Container(revid=r, revno=self.get_revno(r))
+                    for r in merge_revids]
+
+        for change in changes:
+            if self._show_merge_points:
+                change._set_property('merge_points', merge_points_callback)
+            else:
+                change.merge_points = []
             if len(change.parents) > 0:
                 change.parents = [util.Container(revid=r,
                     revno=self.get_revno(r)) for r in change.parents]



More information about the bazaar-commits mailing list