Rev 5852: (jelmer) Use osutils.sha_string / osutils.sha_strings in a couple more in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 12 07:53:58 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5852 [merge]
revision-id: pqm at pqm.ubuntu.com-20110512075355-oukrddgzhx2xkkfi
parent: pqm at pqm.ubuntu.com-20110511163534-yz28ddqwa5cicukr
parent: jelmer at samba.org-20110512070553-x70rfcavxm3zumad
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-05-12 07:53:55 +0000
message:
  (jelmer) Use osutils.sha_string / osutils.sha_strings in a couple more
   places. (Jelmer Vernooij)
modified:
  bzrlib/testament.py            testament.py-20051011100429-6d319a18183b13c8
  bzrlib/tests/per_repository_vf/test_check_reconcile.py test_broken.py-20070928125406-62236394w0jpbpd6-2
  bzrlib/tests/test_hashcache.py testhashcache.py-20050706091800-0288ab2659338981
  bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
  bzrlib/tests/test_testament.py testtestament.py-20051011100429-5df1657310caa929
  bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
=== modified file 'bzrlib/testament.py'
--- a/bzrlib/testament.py	2011-04-19 08:28:04 +0000
+++ b/bzrlib/testament.py	2011-05-11 14:28:36 +0000
@@ -74,7 +74,7 @@
 from bzrlib.osutils import (
     contains_whitespace,
     contains_linebreaks,
-    sha,
+    sha_strings,
     )
 from bzrlib.tree import Tree
 
@@ -209,9 +209,7 @@
         return r
 
     def as_sha1(self):
-        s = sha()
-        map(s.update, self.as_text_lines())
-        return s.hexdigest()
+        return sha_strings(self.as_text_lines())
 
 
 class StrictTestament(Testament):

=== modified file 'bzrlib/tests/per_repository_vf/test_check_reconcile.py'
--- a/bzrlib/tests/per_repository_vf/test_check_reconcile.py	2011-03-08 17:51:43 +0000
+++ b/bzrlib/tests/per_repository_vf/test_check_reconcile.py	2011-05-11 14:26:41 +0000
@@ -855,7 +855,7 @@
         entry.text_size = 0
         if file_contents is None:
             file_contents = '%sline\n' % entry.revision
-        entry.text_sha1 = osutils.sha(file_contents).hexdigest()
+        entry.text_sha1 = osutils.sha_string(file_contents)
         inv.add(entry)
         if make_file_version:
             repo.texts.add_lines((file_id, revision),

=== modified file 'bzrlib/tests/test_hashcache.py'
--- a/bzrlib/tests/test_hashcache.py	2011-01-12 01:01:53 +0000
+++ b/bzrlib/tests/test_hashcache.py	2011-05-11 14:26:41 +0000
@@ -27,8 +27,7 @@
     )
 
 
-def sha1(t):
-    return osutils.sha(t).hexdigest()
+sha1 = osutils.sha_string
 
 
 def pause():

=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py	2011-05-11 11:35:28 +0000
+++ b/bzrlib/tests/test_knit.py	2011-05-12 07:53:55 +0000
@@ -732,7 +732,7 @@
 
     def make_multiple_records(self):
         """Create the content for multiple records."""
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         total_txt = []
         gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
                                         'foo\n'
@@ -741,7 +741,7 @@
                                         % (sha1sum,))
         record_1 = (0, len(gz_txt), sha1sum)
         total_txt.append(gz_txt)
-        sha1sum = osutils.sha('baz\n').hexdigest()
+        sha1sum = osutils.sha_string('baz\n')
         gz_txt = self.create_gz_content('version rev-id-2 1 %s\n'
                                         'baz\n'
                                         'end rev-id-2\n'
@@ -751,7 +751,7 @@
         return total_txt, record_1, record_2
 
     def test_valid_knit_data(self):
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
                                         'foo\n'
                                         'bar\n'
@@ -788,7 +788,7 @@
                          raw_contents)
 
     def test_not_enough_lines(self):
-        sha1sum = osutils.sha('foo\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\n')
         # record says 2 lines data says 1
         gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
                                         'foo\n'
@@ -806,7 +806,7 @@
         self.assertEqual([(('rev-id-1',),  gz_txt, sha1sum)], raw_contents)
 
     def test_too_many_lines(self):
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         # record says 1 lines data says 2
         gz_txt = self.create_gz_content('version rev-id-1 1 %s\n'
                                         'foo\n'
@@ -825,7 +825,7 @@
         self.assertEqual([(('rev-id-1',), gz_txt, sha1sum)], raw_contents)
 
     def test_mismatched_version_id(self):
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
                                         'foo\n'
                                         'bar\n'
@@ -844,7 +844,7 @@
             knit._read_records_iter_raw(records))
 
     def test_uncompressed_data(self):
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         txt = ('version rev-id-1 2 %s\n'
                'foo\n'
                'bar\n'
@@ -864,7 +864,7 @@
             knit._read_records_iter_raw(records))
 
     def test_corrupted_data(self):
-        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        sha1sum = osutils.sha_string('foo\nbar\n')
         gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
                                         'foo\n'
                                         'bar\n'
@@ -2439,7 +2439,7 @@
         key_basis = ('bar',)
         key_missing = ('missing',)
         test.add_lines(key, (), ['foo\n'])
-        key_sha1sum = osutils.sha('foo\n').hexdigest()
+        key_sha1sum = osutils.sha_string('foo\n')
         sha1s = test.get_sha1s([key])
         self.assertEqual({key: key_sha1sum}, sha1s)
         self.assertEqual([], basis.calls)
@@ -2447,7 +2447,7 @@
         # directly (rather than via text reconstruction) so that remote servers
         # etc don't have to answer with full content.
         basis.add_lines(key_basis, (), ['foo\n', 'bar\n'])
-        basis_sha1sum = osutils.sha('foo\nbar\n').hexdigest()
+        basis_sha1sum = osutils.sha_string('foo\nbar\n')
         basis.calls = []
         sha1s = test.get_sha1s([key, key_missing, key_basis])
         self.assertEqual({key: key_sha1sum,

=== modified file 'bzrlib/tests/test_testament.py'
--- a/bzrlib/tests/test_testament.py	2011-04-18 14:27:40 +0000
+++ b/bzrlib/tests/test_testament.py	2011-05-11 14:26:41 +0000
@@ -223,21 +223,21 @@
 bazaar-ng testament short form 1
 revision-id: test at user-1
 sha1: %s
-""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
+""" % osutils.sha_string(REV_1_TESTAMENT)
 
 
 REV_1_SHORT_STRICT = """\
 bazaar-ng testament short form 2.1
 revision-id: test at user-1
 sha1: %s
-""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
+""" % osutils.sha_string(REV_1_STRICT_TESTAMENT)
 
 
 REV_1_SHORT_STRICT3 = """\
 bazaar testament short form 3 strict
 revision-id: test at user-1
 sha1: %s
-""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
+""" % osutils.sha_string(REV_1_STRICT_TESTAMENT3)
 
 
 REV_2_TESTAMENT = """\
@@ -305,21 +305,21 @@
 bazaar-ng testament short form 1
 revision-id: test at user-2
 sha1: %s
-""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
+""" % osutils.sha_string(REV_2_TESTAMENT)
 
 
 REV_2_SHORT_STRICT = """\
 bazaar-ng testament short form 2.1
 revision-id: test at user-2
 sha1: %s
-""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
+""" % osutils.sha_string(REV_2_STRICT_TESTAMENT)
 
 
 REV_2_SHORT_STRICT3 = """\
 bazaar testament short form 3 strict
 revision-id: test at user-2
 sha1: %s
-""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
+""" % osutils.sha_string(REV_2_STRICT_TESTAMENT3)
 
 
 REV_PROPS_TESTAMENT = """\

=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2011-05-11 11:35:28 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2011-05-12 07:53:55 +0000
@@ -1393,7 +1393,7 @@
     if algorithm == 'MD5':
         H = lambda x: osutils.md5(x).hexdigest()
     elif algorithm == 'SHA':
-        H = lambda x: osutils.sha(x).hexdigest()
+        H = osutils.sha_string
     if H is not None:
         KD = lambda secret, data: H("%s:%s" % (secret, data))
     return H, KD
@@ -1402,7 +1402,7 @@
 def get_new_cnonce(nonce, nonce_count):
     raw = '%s:%d:%s:%s' % (nonce, nonce_count, time.ctime(),
                            urllib2.randombytes(8))
-    return osutils.sha(raw).hexdigest()[:16]
+    return osutils.sha_string(raw)[:16]
 
 
 class DigestAuthHandler(AbstractAuthHandler):




More information about the bazaar-commits mailing list