Rev 3: Start working on database layer. in file:///data/jelmer/bzr-global-log/trunk/

Jelmer Vernooij jelmer at samba.org
Tue Nov 20 18:22:45 GMT 2007


At file:///data/jelmer/bzr-global-log/trunk/

------------------------------------------------------------
revno: 3
revision-id:jelmer at samba.org-20071105014851-f5hfe4lagabj4ga5
parent: jelmer at samba.org-20071103220227-i8pshd0fprcui4hz
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2007-11-05 02:48:51 +0100
message:
  Start working on database layer.
added:
  IDEAS                          ideas-20071103220320-a6g5upkxb8l0nyqt-1
  db.py                          db.py-20071105012118-v51dlgcjf12dagnc-1
modified:
  __init__.py                    __init__.py-20071029004222-avdgq0mc7n1q6q8f-1
=== added file 'IDEAS'
--- a/IDEAS	1970-01-01 00:00:00 +0000
+++ b/IDEAS	2007-11-05 01:48:51 +0000
@@ -0,0 +1,4 @@
+- use bzr-stats plugin to group different authors
+- support log-author command
+- support recursively specifying branches on the command-line
+- eliminate revisions that have the "rebase-of" revision property set

=== added file 'db.py'
--- a/db.py	1970-01-01 00:00:00 +0000
+++ b/db.py	2007-11-05 01:48:51 +0000
@@ -0,0 +1,58 @@
+# Copyright (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from bzrlib.log import LogRevision
+
+class GlobalLogRevision(LogRevision):
+
+    def __init__(self, rev=None, branch=None):
+        super(GlobalLogRevision, self).__init__(rev=rev)
+        self.branch = branch
+
+    def __eq___(self, other):
+        if not isinstance(other, GlobalLogRevision):
+            return False
+        return self.rev == other.rev
+
+    def __cmp__(self, other):
+        return cmp(other.rev.timestamp, self.rev.timestamp)
+
+
+class RevisionCache:
+
+    def __init__(self):
+        self.db.executescript("""
+            CREATE TABLE revision (revid text, author text, committer text, 
+                                   date date, message text);
+            CREATE TABLE revision_location (revid text, branch text);
+            CREATE TABLE revision_parent (child_revid text, parent_revid text);
+            CREATE TABLE revision_property (revid text, name text, value text);
+        """)
+
+    def get_parents(self, revid):
+        raise NotImplementedError(self.get_parents)
+
+    def add_revision_location(self, revid, repository_location):
+        raise NotImplementedError(self.add_revision_location)
+
+    def add_revision(self, rev):
+        raise NotImplementedError(self.add_revision)
+
+    def get_revision(self, rev):
+        raise NotImplementedError(self.get_revision)
+
+    def get_log_revision(self, rev):
+        raise NotImplementedError(self.get_log_revision)

=== modified file '__init__.py'
--- a/__init__.py	2007-11-03 22:02:27 +0000
+++ b/__init__.py	2007-11-05 01:48:51 +0000
@@ -1,25 +1,24 @@
-#!/usr/bin/python
+# Copyright (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib import ui
 from bzrlib.branch import Branch
 from bzrlib.commands import Command, register_command
 from bzrlib.log import (log_formatter, log_formatter_registry, show_log, 
-                        LogRevision, LineLogFormatter)
-
-
-def revcmp(x, y):
-    return cmp(y.rev.timestamp, x.rev.timestamp)
-
-
-class GlobalLogRevision(LogRevision):
-    def __init__(self, rev=None, branch=None):
-        super(GlobalLogRevision, self).__init__(rev=rev)
-        self.branch = branch
-
-    def __eq___(self, other):
-        if not isinstance(other, GlobalLogRevision):
-            return False
-        return self.rev == other.rev
+                        LineLogFormatter)
 
 
 class cmd_global_log(Command):
@@ -29,7 +28,10 @@
     takes_args = ["location*"]
 
     def run(self, location_list, log_format=None):
+        from bzrlib.plugins.global_log.db import GlobalLogRevision
         pb = ui.ui_factory.nested_progress_bar()
+        if location_list is None:
+            location_list = ["."]
         try:
             revs = set()
             for location in location_list:
@@ -42,7 +44,7 @@
             pb.finished()
 
         revs = list(revs)
-        revs.sort(revcmp)
+        revs.sort()
 
         if log_format is None:
             log_format = LineLogFormatter




More information about the bazaar-commits mailing list