Rev 3325: * ``VersionedFile.get_sha1`` is deprecated, please use in http://people.ubuntu.com/~robertc/baz2.0/versioned_files
Robert Collins
robertc at robertcollins.net
Tue Apr 8 04:39:56 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/versioned_files
------------------------------------------------------------
revno: 3325
revision-id: robertc at robertcollins.net-20080408033943-ihbgs5wyqnh61bit
parent: robertc at robertcollins.net-20080408023132-krhhq7sn52hff1tc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: api-cleanup
timestamp: Tue 2008-04-08 13:39:43 +1000
message:
* ``VersionedFile.get_sha1`` is deprecated, please use
``VersionedFile.get_sha1s``. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/tests/repository_implementations/test_check_reconcile.py test_broken.py-20070928125406-62236394w0jpbpd6-2
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/tests/test_weave.py testknit.py-20050627023648-9833cc5562ffb785
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
=== modified file 'NEWS'
--- a/NEWS 2008-04-08 02:31:32 +0000
+++ b/NEWS 2008-04-08 03:39:43 +0000
@@ -154,6 +154,9 @@
* ``VersionedFile.get_parents`` is deprecated, please use
``VersionedFile.get_parent_map``. (Robert Collins)
+ * ``VersionedFile.get_sha1`` is deprecated, please use
+ ``VersionedFile.get_sha1s``. (Robert Collins)
+
* ``VersionedFile.has_ghost`` is now deprecated, as it is both expensive
and unused outside of a single test. (Robert Collins)
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2008-01-28 16:59:52 +0000
+++ b/bzrlib/inventory.py 2008-04-08 03:39:43 +0000
@@ -595,7 +595,7 @@
# We can't check the length, because Weave doesn't store that
# information, and the whole point of looking at the weave's
# sha1sum is that we don't have to extract the text.
- if self.text_sha1 != w.get_sha1(self.revision):
+ if self.text_sha1 != w.get_sha1s([self.revision])[0]:
raise BzrCheckError('text {%s} version {%s} wrong sha1'
% (self.file_id, self.revision))
checker.checked_texts[t] = self.text_sha1
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2008-04-08 02:31:32 +0000
+++ b/bzrlib/knit.py 2008-04-08 03:39:43 +0000
@@ -777,11 +777,8 @@
"""See VersionedFile.get_graph_with_ghosts()."""
return self.get_parent_map(self.versions())
- def get_sha1(self, version_id):
- return self.get_sha1s([version_id])[0]
-
def get_sha1s(self, version_ids):
- """See VersionedFile.get_sha1()."""
+ """See VersionedFile.get_sha1s()."""
record_map = self._get_record_map(version_ids)
# record entry 2 is the 'digest'.
return [record_map[v][2] for v in version_ids]
@@ -834,7 +831,7 @@
# Also check the SHA-1 of the fulltext this content will
# produce.
raw_data = reader_callable(length)
- my_fulltext_sha1 = self.get_sha1(version_id)
+ my_fulltext_sha1 = self.get_sha1s([version_id])[0]
df, rec = self._data._parse_record_header(version_id, raw_data)
stream_fulltext_sha1 = rec[3]
if my_fulltext_sha1 != stream_fulltext_sha1:
=== modified file 'bzrlib/tests/repository_implementations/test_check_reconcile.py'
--- a/bzrlib/tests/repository_implementations/test_check_reconcile.py 2008-03-19 04:39:04 +0000
+++ b/bzrlib/tests/repository_implementations/test_check_reconcile.py 2008-04-08 03:39:43 +0000
@@ -153,7 +153,7 @@
:returns: A dict of `{version: hash}`.
"""
vf = repo.weave_store.get_weave('a-file-id', repo.get_transaction())
- return dict((v, vf.get_sha1(v)) for v in versions)
+ return dict(zip(versions, vf.get_sha1s(versions)))
def test_reconcile_behaviour(self):
"""Populate a repository and reconcile it, verifying the state before
=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py 2008-04-08 02:31:32 +0000
+++ b/bzrlib/tests/test_versionedfile.py 2008-04-08 03:39:43 +0000
@@ -247,7 +247,7 @@
for version in multiparent.topo_iter(vf):
mpdiff = vf.make_mpdiffs([version])[0]
new_vf.add_mpdiffs([(version, vf.get_parent_map([version])[version],
- vf.get_sha1(version), mpdiff)])
+ vf.get_sha1s([version])[0], mpdiff)])
self.assertEqualDiff(vf.get_text(version),
new_vf.get_text(version))
@@ -706,7 +706,7 @@
self.assertRaises(errors.ReadOnlyError, vf.join, 'base')
self.assertRaises(errors.ReadOnlyError, vf.clone_text, 'base', 'bar', ['foo'])
- def test_get_sha1(self):
+ def test_get_sha1s(self):
# check the sha1 data is available
vf = self.get_file()
# a simple file
@@ -715,13 +715,16 @@
vf.add_lines('b', ['a'], ['a\n'])
# a file differing only in last newline.
vf.add_lines('c', [], ['a'])
- self.assertEqual(
- '3f786850e387550fdab836ed7e6dc881de23001b', vf.get_sha1('a'))
- self.assertEqual(
- '3f786850e387550fdab836ed7e6dc881de23001b', vf.get_sha1('b'))
- self.assertEqual(
- '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', vf.get_sha1('c'))
-
+ # Deprecasted single-version API.
+ self.assertEqual(
+ '3f786850e387550fdab836ed7e6dc881de23001b',
+ self.applyDeprecated(one_four, vf.get_sha1, 'a'))
+ self.assertEqual(
+ '3f786850e387550fdab836ed7e6dc881de23001b',
+ self.applyDeprecated(one_four, vf.get_sha1, 'b'))
+ self.assertEqual(
+ '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8',
+ self.applyDeprecated(one_four, vf.get_sha1, 'c'))
self.assertEqual(['3f786850e387550fdab836ed7e6dc881de23001b',
'86f7e437faa5a7fce15d1ddcb9eaeaea377667b8',
'3f786850e387550fdab836ed7e6dc881de23001b'],
=== modified file 'bzrlib/tests/test_weave.py'
--- a/bzrlib/tests/test_weave.py 2008-04-04 00:06:58 +0000
+++ b/bzrlib/tests/test_weave.py 2008-04-08 03:39:43 +0000
@@ -84,18 +84,6 @@
[('text0', TEXT_0[0])])
-class GetSha1(TestBase):
- def test_get_sha1(self):
- k = Weave()
- k.add_lines('text0', [], 'text0')
- self.assertEqual('34dc0e430c642a26c3dd1c2beb7a8b4f4445eb79',
- k.get_sha1('text0'))
- self.assertRaises(errors.RevisionNotPresent,
- k.get_sha1, 0)
- self.assertRaises(errors.RevisionNotPresent,
- k.get_sha1, 'text1')
-
-
class InvalidAdd(TestBase):
"""Try to use invalid version number during add."""
def runTest(self):
=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py 2008-04-08 02:31:32 +0000
+++ b/bzrlib/versionedfile.py 2008-04-08 03:39:43 +0000
@@ -271,12 +271,13 @@
if expected_sha1 != sha1:
raise errors.VersionedFileInvalidChecksum(version)
+ @deprecated_method(one_four)
def get_sha1(self, version_id):
"""Get the stored sha1 sum for the given revision.
:param version_id: The name of the version to lookup
"""
- raise NotImplementedError(self.get_sha1)
+ return self.get_sha1s([version_id])[0]
def get_sha1s(self, version_ids):
"""Get the stored sha1 sums for the given revisions.
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2008-04-07 21:52:08 +0000
+++ b/bzrlib/weave.py 2008-04-08 03:39:43 +0000
@@ -688,10 +688,6 @@
expected_sha1, measured_sha1))
return result
- def get_sha1(self, version_id):
- """See VersionedFile.get_sha1()."""
- return self._sha1s[self._lookup(version_id)]
-
def get_sha1s(self, version_ids):
"""See VersionedFile.get_sha1s()."""
return [self._sha1s[self._lookup(v)] for v in version_ids]
More information about the bazaar-commits
mailing list