Rev 90: A bit of lovin' for the database commands. in http://bzr.arbash-meinel.com/plugins/history_db
John Arbash Meinel
john at arbash-meinel.com
Mon Apr 12 22:40:33 BST 2010
At http://bzr.arbash-meinel.com/plugins/history_db
------------------------------------------------------------
revno: 90
revision-id: john at arbash-meinel.com-20100412214025-ucgtxocg3sfvotfc
parent: john at arbash-meinel.com-20100412210405-8wmoz2e7rqhmg6zy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: history_db
timestamp: Mon 2010-04-12 16:40:25 -0500
message:
A bit of lovin' for the database commands.
Now that we have a config setting, use it if it is available.
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2010-04-12 21:04:05 +0000
+++ b/__init__.py 2010-04-12 21:40:25 +0000
@@ -32,6 +32,16 @@
""")
+def _ensure_db_for_command(db, b):
+ if db is not None:
+ return db
+ db = _get_history_db_path(b)
+ if db is None:
+ raise BzrCommandError('No --db supplied and no default'
+ ' db configured as "history_db_path"')
+ return db
+
+
class cmd_create_history_db(commands.Command):
"""Create and populate the history database for this branch.
"""
@@ -54,6 +64,7 @@
b = branch.Branch.open(directory)
b.lock_read()
try:
+ db = _ensure_db_for_command(db, b)
importer = _mod_history_db.Importer(db, b, incremental=incremental,
validate=validate)
importer.do_import(expand_all=expand_all)
@@ -93,6 +104,7 @@
raise errors.BzrCommandError('You must supply --revision')
b.lock_read()
try:
+ db = _ensure_db_for_command(db, b)
rev_ids = [rspec.as_revision_id(b) for rspec in revision]
t = time.time()
if method == 'bzr':
@@ -166,6 +178,7 @@
b = branch.Branch.open(directory)
b.lock_read()
try:
+ db = _ensure_db_for_command(db, b)
# Map back into integer dotted revnos
revno_list = [tuple(map(int, r.split('.'))) for r in revno_list]
t = time.time()
@@ -232,6 +245,7 @@
b = branch.Branch.open(directory)
b.lock_read()
self.add_cleanup(b.unlock)
+ db = _ensure_db_for_command(db, b)
t = time.time()
if method.startswith('db'):
query = _mod_history_db.Querier(db, b)
@@ -287,6 +301,7 @@
b = branch.Branch.open(directory)
b.lock_read()
self.add_cleanup(b.unlock)
+ db = _ensure_db_for_command(db, b)
t = time.time()
if method.startswith('db'):
query = _mod_history_db.Querier(db, b)
More information about the bazaar-commits
mailing list