[Pkg-bazaar-commits] ./bzr-git/unstable r44: Merge new upstream snapshot.
Jelmer Vernooij
jelmer at samba.org
Tue May 12 00:20:59 UTC 2009
------------------------------------------------------------
revno: 44
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: unstable
timestamp: Tue 2009-05-12 02:20:59 +0200
message:
Merge new upstream snapshot.
modified:
NEWS
__init__.py
branch.py
debian/changelog
debian/control
fetch.py
object_store.py
push.py
repository.py
setup.py
shamap.py
tests/test_blackbox.py
tests/test_shamap.py
------------------------------------------------------------
revno: 17.1.457
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sun 2009-05-10 16:15:58 +0200
message:
Start working on 0.3.1.
modified:
NEWS
__init__.py
setup.py
------------------------------------------------------------
revno: 17.1.458
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 13:22:19 +0200
message:
Add Tdb database backend.
modified:
shamap.py
tests/test_shamap.py
------------------------------------------------------------
revno: 17.1.459
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 13:51:52 +0200
message:
Fix Tdb backend, use tdb if possible by default.
modified:
object_store.py
shamap.py
------------------------------------------------------------
revno: 17.1.460
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 13:57:25 +0200
message:
More tests for sha maps, fix cache misses in tdb.
modified:
shamap.py
tests/test_shamap.py
------------------------------------------------------------
revno: 17.1.461
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 14:17:14 +0200
message:
Cope with disappeared revisions.
modified:
object_store.py
------------------------------------------------------------
revno: 17.1.462
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 14:39:52 +0200
message:
Version tdb sha map.
modified:
shamap.py
------------------------------------------------------------
revno: 17.1.463
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 21:28:08 +0200
message:
Cope with API changes in Dulwich.
modified:
branch.py
push.py
repository.py
shamap.py
tests/test_blackbox.py
------------------------------------------------------------
revno: 17.1.464
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2009-05-11 21:32:52 +0200
message:
Depend on a newer dulwich.
modified:
__init__.py
------------------------------------------------------------
revno: 17.1.465
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2009-05-12 00:11:04 +0200
message:
Use tdb file in the config dir if it's remote.
modified:
shamap.py
------------------------------------------------------------
revno: 17.1.466
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2009-05-12 02:16:19 +0200
message:
Add NEWS entry about sha map.
modified:
NEWS
fetch.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-05-10 14:09:35 +0000
+++ b/NEWS 2009-05-12 00:16:19 +0000
@@ -1,3 +1,12 @@
+0.3.1 UNRELEASED
+
+ FEATURES
+
+ * Alternative (faster) storage for SHA map using the TDB library
+ (http://tdb.samba.org/). This will automatically be used if you have
+ TDB and its Python bindings installed. In all other situations the previous
+ (slower) Sqlite database format will be used.
+
0.3.0 2009-05-10
FEATURES
=== modified file '__init__.py'
--- a/__init__.py 2009-05-10 14:09:35 +0000
+++ b/__init__.py 2009-05-11 19:32:52 +0000
@@ -55,7 +55,7 @@
# versions ending in 'exp' mean experimental mappings
# versions ending in 'dev' mean development version
# versions ending in 'final' mean release (well tested, etc)
-version_info = (0, 3, 0, 'final', 0)
+version_info = (0, 3, 1, 'dev', 0)
if version_info[3] == 'final':
version_string = '%d.%d.%d' % version_info[:3]
@@ -63,7 +63,7 @@
version_string = '%d.%d.%d%s%d' % version_info
__version__ = version_string
-MINIMUM_DULWICH_VERSION = (0, 3, 0)
+MINIMUM_DULWICH_VERSION = (0, 3, 1)
COMPATIBLE_BZR_VERSIONS = [(1, 14, 0), (1, 15, 0)]
if getattr(sys, "frozen", None):
=== modified file 'branch.py'
--- a/branch.py 2009-05-10 14:07:50 +0000
+++ b/branch.py 2009-05-11 19:28:08 +0000
@@ -91,7 +91,7 @@
def get_tag_dict(self):
ret = {}
- for k,v in self.repository._git.tags.iteritems():
+ for k,v in self.repository._git.refs.as_dict("refs/tags").iteritems():
obj = self.repository._git.get_object(v)
while isinstance(obj, Tag):
v = obj.object[1]
@@ -104,7 +104,7 @@
return ret
def set_tag(self, name, revid):
- self.repository._git.tags[name], _ = \
+ self.repository._git.refs["refs/tags/%s" % name], _ = \
self.branch.mapping.revision_id_bzr_to_foreign(revid)
@@ -250,11 +250,14 @@
return ret
def _get_head(self):
- return self.repository._git.ref(self.name)
+ try:
+ return self.repository._git.ref(self.name)
+ except KeyError:
+ return None
def _set_head(self, value):
self._head = value
- self.repository._git.set_ref(self.name, self._head)
+ self.repository._git.refs[self.name] = self._head
self._clear_cached_state()
head = property(_get_head, _set_head)
=== modified file 'debian/changelog'
--- a/debian/changelog 2009-05-10 14:42:24 +0000
+++ b/debian/changelog 2009-05-12 00:20:59 +0000
@@ -1,3 +1,9 @@
+bzr-git (0.3.0-2) unstable; urgency=low
+
+ * 0.3.1~bzr483-1 New upstream snapshot.
+
+ -- Jelmer Vernooij <jelmer at debian.org> Tue, 12 May 2009 02:20:29 +0200
+
bzr-git (0.3.0-1) unstable; urgency=low
* New upstream release.
=== modified file 'debian/control'
--- a/debian/control 2009-05-10 14:42:24 +0000
+++ b/debian/control 2009-05-12 00:20:59 +0000
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Debian Bazaar Maintainers <pkg-bazaar-maint at lists.alioth.debian.org>
Uploaders: Jelmer Vernooij <jelmer at debian.org>
-Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.43), python, python-central (>= 0.5), python-dulwich (>= 0.2.0~)
+Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.43), python, python-central (>= 0.5), python-dulwich (>= 0.2.0~), python-tdb
Build-Depends-Indep: bzr (>= 1.14~)
Standards-Version: 3.8.1
Homepage: http://bazaar-vcs.org/BzrForeignBranches/Git
@@ -12,11 +12,11 @@
Package: bzr-git
Architecture: all
-Depends: bzr (>= 1.14~), ${python:Depends}, ${misc:Depends}, python-dulwich (>= 0.3.0~)
+Depends: bzr (>= 1.14~), ${python:Depends}, ${misc:Depends}, python-dulwich (>= 0.3.0~), python-tdb
XB-Python-Version: ${python:Versions}
Description: Bazaar plugin providing readonly Git integration
- This is a plugin for Bazaar that adds the ability to partially read Git
+ This is a plugin for Bazaar that adds the ability to read and write Git
repositories.
.
- At the moment most read-only operations work against git repositories,
- including cloning local and remote git branches.
+ Also included is a Bazaar subcommand that allows importing Git
+ repositories.
=== modified file 'fetch.py'
--- a/fetch.py 2009-05-10 04:23:17 +0000
+++ b/fetch.py 2009-05-12 00:16:19 +0000
@@ -242,7 +242,7 @@
heads, pb=None):
"""Import a set of git objects into a bzr repository.
- :param repo: Bazaar repository
+ :param repo: Target Bazaar repository
:param mapping: Mapping to use
:param object_iter: Iterator over Git objects.
"""
=== modified file 'object_store.py'
--- a/object_store.py 2009-05-09 18:24:58 +0000
+++ b/object_store.py 2009-05-11 12:17:14 +0000
@@ -29,6 +29,7 @@
from bzrlib import (
debug,
errors,
+ trace,
ui,
)
@@ -44,6 +45,7 @@
)
from bzrlib.plugins.git.shamap import (
SqliteGitShaMap,
+ TdbGitShaMap,
)
@@ -63,7 +65,10 @@
self.mapping = default_mapping
else:
self.mapping = mapping
- self._idmap = SqliteGitShaMap.from_repository(repository)
+ try:
+ self._idmap = TdbGitShaMap.from_repository(repository)
+ except ImportError:
+ self._idmap = SqliteGitShaMap.from_repository(repository)
def _update_sha_map(self, stop_revision=None):
if stop_revision is None:
@@ -218,8 +223,12 @@
(type, type_data) = self._lookup_git_sha(sha)
# convert object to git object
if type == "commit":
- return self._get_commit(type_data[0], type_data[1],
- expected_sha=sha)
+ try:
+ return self._get_commit(type_data[0], type_data[1],
+ expected_sha=sha)
+ except errors.NoSuchRevision:
+ trace.mutter('entry for %s %s in shamap: %r, but not found in repository', type, sha, type_data)
+ raise KeyError(sha)
elif type == "blob":
return self._get_blob(type_data[0], type_data[1], expected_sha=sha)
elif type == "tree":
=== modified file 'push.py'
--- a/push.py 2009-05-09 06:18:10 +0000
+++ b/push.py 2009-05-11 19:28:08 +0000
@@ -167,7 +167,7 @@
gitid = newgitidmap[revid]
else:
gitid, _ = self.mapping.revision_id_bzr_to_foreign(revid)
- self.target._git.set_ref(name, gitid)
+ self.target._git.refs[name] = gitid
new_refs[name] = gitid
return revidmap, new_refs
=== modified file 'repository.py'
--- a/repository.py 2009-05-08 19:29:21 +0000
+++ b/repository.py 2009-05-11 19:28:08 +0000
@@ -58,15 +58,6 @@
)
-class GitTags(object):
-
- def __init__(self, tags):
- self._tags = tags
-
- def __iter__(self):
- return iter(self._tags)
-
-
class GitRepository(ForeignRepository):
"""An adapter to git repositories for bzr."""
@@ -125,11 +116,10 @@
self.revisions = versionedfiles.VirtualRevisionTexts(self)
self.inventories = versionedfiles.VirtualInventoryTexts(self)
self.texts = GitTexts(self)
- self.tags = GitTags(self._git.get_tags())
def all_revision_ids(self):
ret = set([revision.NULL_REVISION])
- heads = self._git.heads()
+ heads = self._git.refs.as_dict('refs/heads')
if heads == {}:
return ret
bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in heads.itervalues()]
=== modified file 'setup.py'
--- a/setup.py 2009-05-10 14:09:35 +0000
+++ b/setup.py 2009-05-10 14:15:58 +0000
@@ -2,7 +2,7 @@
from distutils.core import setup
-version = (0, 3, 0)
+version = (0, 3, 1)
version_string = ".".join([str(x) for x in version])
setup(name='bzr-git',
=== modified file 'shamap.py'
--- a/shamap.py 2009-05-10 14:42:24 +0000
+++ b/shamap.py 2009-05-12 00:20:59 +0000
@@ -77,6 +77,7 @@
raise NotImplementedError(self.lookup_tree)
def lookup_blob(self, fileid, revid):
+ """Lookup a blob by the fileid it has in a bzr revision."""
raise NotImplementedError(self.lookup_blob)
def lookup_git_sha(self, sha):
@@ -241,3 +242,84 @@
for table in ("blobs", "commits", "trees"):
for row in self.db.execute("select sha1 from %s" % table).fetchall():
yield row[0].encode("utf-8")
+
+
+TDB_MAP_VERSION = 1
+
+
+class TdbGitShaMap(GitShaMap):
+ """SHA Map that uses a TDB database.
+
+ Entries:
+
+ "git <sha1>" -> "<type> <type-data1> <type-data2>"
+ "commit revid" -> "<sha1> <tree-id>"
+ "tree fileid revid" -> "<sha1>"
+ "blob fileid revid" -> "<sha1>"
+ """
+
+ def __init__(self, path=None):
+ import tdb
+ self.path = path
+ if path is None:
+ self.db = {}
+ else:
+ if not mapdbs().has_key(path):
+ mapdbs()[path] = tdb.open(path, 0, tdb.DEFAULT,
+ os.O_RDWR|os.O_CREAT)
+ self.db = mapdbs()[path]
+ if not "version" in self.db:
+ self.db["version"] = str(TDB_MAP_VERSION)
+ else:
+ assert int(self.db["version"]) == TDB_MAP_VERSION
+
+ @classmethod
+ def from_repository(cls, repository):
+ try:
+ return cls(os.path.join(repository._transport.local_abspath("."), "git.tdb"))
+ except bzrlib.errors.NotLocalUrl:
+ from bzrlib.config import config_dir
+ return cls(os.path.join(config_dir(), "remote-git.tdb"))
+
+ def _parent_lookup(self, revid):
+ return self.db["commit %s" % revid].split(" ")[0]
+
+ def commit(self):
+ pass
+
+ def add_entry(self, sha, type, type_data):
+ """Add a new entry to the database.
+ """
+ self.db["git %s" % sha] = "%s %s %s" % (type, type_data[0], type_data[1])
+ if type == "commit":
+ self.db["commit %s" % type_data[0]] = "%s %s" % (sha, type_data[1])
+ else:
+ self.db["%s %s %s" % (type, type_data[0], type_data[1])] = sha
+
+ def lookup_tree(self, fileid, revid):
+ return self.db["tree %s %s" % (fileid, revid)]
+
+ def lookup_blob(self, fileid, revid):
+ return self.db["blob %s %s" % (fileid, revid)]
+
+ def lookup_git_sha(self, sha):
+ """Lookup a Git sha in the database.
+
+ :param sha: Git object sha
+ :return: (type, type_data) with type_data:
+ revision: revid, tree sha
+ """
+ data = self.db["git %s" % sha].split(" ")
+ return (data[0], (data[1], data[2]))
+
+ def revids(self):
+ """List the revision ids known."""
+ for key in self.db.iterkeys():
+ if key.startswith("commit "):
+ yield key.split(" ")[1]
+
+ def sha1s(self):
+ """List the SHA1s."""
+ for key in self.db.iterkeys():
+ if key.startswith("git "):
+ yield key.split(" ")[1]
=== modified file 'tests/test_blackbox.py'
--- a/tests/test_blackbox.py 2009-05-06 02:08:57 +0000
+++ b/tests/test_blackbox.py 2009-05-11 19:28:08 +0000
@@ -112,7 +112,7 @@
def test_tags(self):
git_repo, commit_sha1 = self.simple_commit()
- git_repo.set_ref("refs/tags/foo", commit_sha1)
+ git_repo.refs["refs/tags/foo"] = commit_sha1
output, error = self.run_bzr(['tags'])
self.assertEquals(error, '')
=== modified file 'tests/test_shamap.py'
--- a/tests/test_shamap.py 2009-03-22 01:11:53 +0000
+++ b/tests/test_shamap.py 2009-05-11 11:57:25 +0000
@@ -16,11 +16,18 @@
"""Tests for GitShaMap."""
-from bzrlib.tests import TestCase
+import os
+
+from bzrlib.tests import (
+ TestCase,
+ TestCaseInTempDir,
+ UnavailableFeature,
+ )
from bzrlib.plugins.git.shamap import (
DictGitShaMap,
SqliteGitShaMap,
+ TdbGitShaMap,
)
class TestGitShaMap:
@@ -37,18 +44,21 @@
self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301")
def test_blob(self):
- self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301",
- "blob", ("myfileid", "myrevid"))
+ thesha = "5686645d49063c73d35436192dfc9a160c672301"
+ self.map.add_entry(thesha, "blob", ("myfileid", "myrevid"))
self.assertEquals(
("blob", ("myfileid", "myrevid")),
- self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
+ self.map.lookup_git_sha(thesha))
+ self.assertEquals(thesha, self.map.lookup_blob("myfileid", "myrevid"))
def test_tree(self):
- self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301",
+ thesha = "5686645d49063c73d35436192dfc9a160c672301"
+ self.map.add_entry(thesha,
"tree", ("somepath", "myrevid"))
self.assertEquals(
("tree", ("somepath", "myrevid")),
- self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
+ self.map.lookup_git_sha(thesha))
+ self.assertEquals(thesha, self.map.lookup_tree("somepath", "myrevid"))
def test_revids(self):
self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301",
@@ -69,3 +79,12 @@
TestCase.setUp(self)
self.map = SqliteGitShaMap()
+
+class TdbGitShaMapTests(TestCaseInTempDir,TestGitShaMap):
+
+ def setUp(self):
+ TestCaseInTempDir.setUp(self)
+ try:
+ self.map = TdbGitShaMap(os.path.join(self.test_dir, 'foo.tdb'))
+ except ImportError:
+ raise UnavailableFeature("Missing tdb")
More information about the Pkg-bazaar-commits
mailing list