Merge lp:~jameinel/bzr/2.4-testament-binary-1010339 into lp:bzr/2.4

Proposed by John A Meinel
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6071
Proposed branch: lp:~jameinel/bzr/2.4-testament-binary-1010339
Merge into: lp:bzr/2.4
Diff against target: 91 lines (+24/-2)
4 files modified
bzrlib/btree_index.py (+6/-0)
bzrlib/builtins.py (+3/-2)
bzrlib/tests/blackbox/test_testament.py (+11/-0)
doc/en/release-notes/bzr-2.4.txt (+4/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.4-testament-binary-1010339
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Information
Alexander Belchenko Approve
Review via email: mp+109301@code.launchpad.net

Commit message

Fix bug #1010339, use encoding_type='exact' for bzr testament

Description of the change

A bugfix for bug #1010339. Basically, we weren't setting O_BINARY for sys.stdout for 'bzr testament'.

The test here isn't quite good enough, because it doesn't spawn a subprocess to actually test the output. However, that is only useful on Windows.

The difference is that if you do change sys.stdout to self.outf, then the test will fail because of double encoding. So it does push us towards using encoding_type = 'exact'.

I'm targetting 2.4, because this seems a simple bugfix. We don't have to backport it, because it certainly isn't a regression, but the number of touched lines is quite small.

To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

John A Meinel пишет:
> John A Meinel has proposed merging lp:~jameinel/bzr/2.4-testament-binary-1010339 into lp:bzr/2.4.
>
> A bugfix for bug #1010339. Basically, we weren't setting O_BINARY for sys.stdout for 'bzr testament'.

The first hunk (changes in btree_index.py re new_leaf) looks suspicious
because it does not fit your description. Maybe it's also important fix,
but seems unrelated to stdout.

--
All the dude wanted was his rug back

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/8/2012 9:21 AM, Alexander Belchenko wrote:
> John A Meinel пишет:
>> John A Meinel has proposed merging
>> lp:~jameinel/bzr/2.4-testament-binary-1010339 into lp:bzr/2.4.
>>
>> A bugfix for bug #1010339. Basically, we weren't setting O_BINARY
>> for sys.stdout for 'bzr testament'.
>
> The first hunk (changes in btree_index.py re new_leaf) looks
> suspicious because it does not fit your description. Maybe it's
> also important fix, but seems unrelated to stdout.
>

It is. '...' is invalid syntax, and causes problems on python-2.7. It
might just be a warning, but we need to fix it.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/RqkYACgkQJdeBCYSNAAPnxwCfS6xj1HDP92RlC0ib/at3X1rc
OTwAoM2D+0xzR9o0d1S+VHXjk9jVPWwk
=NRUF
-----END PGP SIGNATURE-----

Revision history for this message
Alexander Belchenko (bialix) :
review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

What the rationale for submitting against 2.4 when the windows stable series is 2.5 ? We won't ever release a 2.4.3 for windows.

review: Needs Information
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/8/2012 9:40 AM, Vincent Ladeuil wrote:
> Review: Needs Information
>
> What the rationale for submitting against 2.4 when the windows
> stable series is 2.5 ? We won't ever release a 2.4.3 for windows.

Its been a bug for a while, and so I picked something older. No
particular reason.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/RvNIACgkQJdeBCYSNAAPINwCgsn30zC4+Rf3S66qyVMuXRpW0
srAAnjYifIrnu94ewXvgxb4/8KBxT9UZ
=TwV5
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/btree_index.py'
2--- bzrlib/btree_index.py 2011-05-19 09:32:38 +0000
3+++ bzrlib/btree_index.py 2012-06-08 07:06:21 +0000
4@@ -294,7 +294,9 @@
5 flag when writing out. This is used by the _spill_mem_keys_to_disk
6 functionality.
7 """
8+ new_leaf = False
9 if rows[-1].writer is None:
10+ new_leaf = True
11 # opening a new leaf chunk;
12 for pos, internal_row in enumerate(rows[:-1]):
13 # flesh out any internal nodes that are needed to
14@@ -320,6 +322,10 @@
15 optimize_for_size=self._optimize_for_size)
16 rows[-1].writer.write(_LEAF_FLAG)
17 if rows[-1].writer.write(line):
18+ if new_leaf:
19+ # We just created this leaf, and now the line doesn't fit.
20+ # Clearly it will never fit, so punt.
21+ raise errors.BadIndexKey(line)
22 # this key did not fit in the node:
23 rows[-1].finish_node()
24 key_line = string_key + "\n"
25
26=== modified file 'bzrlib/builtins.py'
27--- bzrlib/builtins.py 2011-09-26 08:48:20 +0000
28+++ bzrlib/builtins.py 2012-06-08 07:06:21 +0000
29@@ -4718,6 +4718,7 @@
30 Option('strict',
31 help='Produce a strict-format testament.')]
32 takes_args = ['branch?']
33+ encoding_type = 'exact'
34 @display_command
35 def run(self, branch=u'.', revision=None, long=False, strict=False):
36 from bzrlib.testament import Testament, StrictTestament
37@@ -4736,9 +4737,9 @@
38 rev_id = revision[0].as_revision_id(b)
39 t = testament_class.from_revision(b.repository, rev_id)
40 if long:
41- sys.stdout.writelines(t.as_text_lines())
42+ self.outf.writelines(t.as_text_lines())
43 else:
44- sys.stdout.write(t.as_short_text())
45+ self.outf.write(t.as_short_text())
46
47
48 class cmd_annotate(Command):
49
50=== modified file 'bzrlib/tests/blackbox/test_testament.py'
51--- bzrlib/tests/blackbox/test_testament.py 2009-03-23 14:59:43 +0000
52+++ bzrlib/tests/blackbox/test_testament.py 2012-06-08 07:06:21 +0000
53@@ -16,8 +16,10 @@
54
55 """Blackbox tests for the 'bzr testament' command"""
56
57+import re
58
59 from bzrlib.tests.test_testament import (
60+ osutils,
61 REV_1_SHORT,
62 REV_1_SHORT_STRICT,
63 REV_2_TESTAMENT,
64@@ -46,3 +48,12 @@
65 self.assertEqualDiff(err, '')
66 self.assertEqualDiff(out, REV_1_SHORT_STRICT)
67
68+ def test_testament_non_ascii(self):
69+ self.wt.commit(u"Non \xe5ssci message")
70+ long_out, err = self.run_bzr('testament --long')
71+ self.assertEqualDiff(err, '')
72+ short_out, err = self.run_bzr('testament')
73+ self.assertEqualDiff(err, '')
74+ sha1_re = re.compile('sha1: (?P<sha1>[a-f0-9]+)$', re.M)
75+ sha1 = sha1_re.search(short_out).group('sha1')
76+ self.assertEqual(sha1, osutils.sha_string(long_out))
77
78=== modified file 'doc/en/release-notes/bzr-2.4.txt'
79--- doc/en/release-notes/bzr-2.4.txt 2012-03-28 14:04:31 +0000
80+++ doc/en/release-notes/bzr-2.4.txt 2012-06-08 07:06:21 +0000
81@@ -55,6 +55,10 @@
82 * Prevent a traceback being printed to stderr when logging has problems and
83 accept utf-8 byte string without breaking. (Martin Packman, #714449)
84
85+* Use ``encoding_type='exact'`` for ``bzr testament`` so that on Windows
86+ the sha hash of the long testament matches the sha hash in the short
87+ form. (John Arbash Meinel, #1010339)
88+
89 * _Win32Stat object provides members st_uid and st_gid, those are present
90 in Python's os.stat object. These members required for external tools like
91 bzr-git and dulwich. (Alexander Belchenko, #967060)

Subscribers

People subscribed via source and target branches