[merge] make RevisionSpec_revid always return a str
Marien Zwart
marienz at gentoo.org
Thu Mar 8 19:02:32 GMT 2007
On Thu, Mar 08, 2007 at 12:20:36AM +0100, Marien Zwart wrote:
> running "bzr tag
> -rrevid:marienz at gentoo.org-20070307230802-7glsfkyy5fazrb91 tag" in a
> freshly created standalone dirstate-with-subtree branch with 0.15rc1
> fails with the following in bzr.log (reformatted for linewrapping):
This is caused by RevisionSpec_revid returning a unicode object from
the user unchanged instead as revid instead of utf-8 encoding it.
Making it encode its input makes it work.
The %s to %r changes in the formatting string in the testcase were
necessary to prevent this from happening:
File "/usr/lib/python2.5/unittest.py", line 263, in run
result.addFailure(self, self._exc_info())
File "/home/marienz/src/bzr.dev/bzrlib/tests/__init__.py", line 243,
in addFailure
self.report_failure(test, err)
File "/home/marienz/src/bzr.dev/bzrlib/tests/__init__.py", line 349,
in report_failure
err[1],
File "/home/marienz/src/bzr.dev/bzrlib/progress.py", line 197, in note
self.to_messages_file.write(fmt_string % args)
UnicodeEncodeError:
'ascii' codec can't encode character u'\u2603' in position 21:
ordinal not in range(128)
which crashed "bzr selftest". Should I file a bug for that or is this
specific (symptom) fix sufficient?
--
Marien.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Make the revid RevisionSpec always return a str object, not a unicode object.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2007-03-08 19:51:09.529000044 +0100
=== modified file bzrlib/revisionspec.py
--- bzrlib/revisionspec.py
+++ bzrlib/revisionspec.py
@@ -379,7 +379,8 @@
prefix = 'revid:'
def _match_on(self, branch, revs):
- return RevisionInfo.from_revision_id(branch, self.spec, revs)
+ return RevisionInfo.from_revision_id(branch, self.spec.encode('utf-8'),
+ revs)
SPEC_TYPES.append(RevisionSpec_revid)
=== modified file bzrlib/tests/blackbox/test_tags.py
--- bzrlib/tests/blackbox/test_tags.py
+++ bzrlib/tests/blackbox/test_tags.py
@@ -60,6 +60,11 @@
# can also create tags using -r
self.run_bzr('tag', '-d', 'branch', 'tag2', '-r1')
self.assertEquals(t.branch.tags.lookup_tag('tag2'), 'first-revid')
+ # regression test: make sure a unicode revision from the user
+ # gets turned into a str object properly. The use of a unicode
+ # object for the revid is intentional.
+ self.run_bzr('tag', '-d', 'branch', 'tag3', u'-rrevid:first-revid')
+ self.assertEquals(t.branch.tags.lookup_tag('tag3'), 'first-revid')
# can also delete an existing tag
out, err = self.run_bzr('tag', '--delete', '-d', 'branch', 'tag2')
# cannot replace an existing tag normally
=== modified file bzrlib/tests/test_revisionnamespaces.py
--- bzrlib/tests/test_revisionnamespaces.py
+++ bzrlib/tests/test_revisionnamespaces.py
@@ -67,11 +67,11 @@
def assertInHistoryIs(self, exp_revno, exp_revision_id, revision_spec):
rev_info = self.get_in_history(revision_spec)
self.assertEqual(exp_revno, rev_info.revno,
- 'Revision spec: %s returned wrong revno: %s != %s'
+ 'Revision spec: %r returned wrong revno: %r != %r'
% (revision_spec, exp_revno, rev_info.revno))
self.assertEqual(exp_revision_id, rev_info.rev_id,
- 'Revision spec: %s returned wrong revision id:'
- ' %s != %s'
+ 'Revision spec: %r returned wrong revision id:'
+ ' %r != %r'
% (revision_spec, exp_revision_id, rev_info.rev_id))
def assertInvalid(self, revision_spec, extra=''):
@@ -277,6 +277,12 @@
revision_id='alt_r3')
self.assertInHistoryIs(None, 'alt_r3', 'revid:alt_r3')
+ def test_unicode(self):
+ """We correctly convert a unicode ui string to an encoded revid."""
+ rev_id = u'\N{SNOWMAN}'.encode('utf-8')
+ self.tree.commit('unicode', rev_id=rev_id)
+ self.assertInHistoryIs(3, rev_id, u'revid:\N{SNOWMAN}')
+
class TestRevisionSpec_last(TestRevisionSpec):
=== modified directory // last-changed:marienz at gentoo.org-20070308185109-wdlc2
... 839v8qcuqhc
# revision id: marienz at gentoo.org-20070308185109-wdlc2839v8qcuqhc
# sha1: ff356dbcd78a26ffd1f71b7a16d9811c72eb7f98
# inventory sha1: b8f9bffaeb2ae6b2c1e5968b7255846a4ed29249
# parent ids:
# marienz at gentoo.org-20070308171357-7u3cn4ra7m2zhw0w
# base id: pqm at pqm.ubuntu.com-20070307233124-ad2724bf65e09035
# properties:
# branch-nick: bzr.dev
# message:
# Make the test suite failure reporting a bit more robust.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Thu 2007-03-08 18:13:57.055000067 +0100
=== modified file bzrlib/tests/test_revisionnamespaces.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy90ZXN0X3JldmlzaW9ubmFtZXNwYWNlcy5weQorKysgYnpybGliL3Rl
c3RzL3Rlc3RfcmV2aXNpb25uYW1lc3BhY2VzLnB5CkBAIC02NywxMSArNjcsMTEgQEAKICAgICBk
ZWYgYXNzZXJ0SW5IaXN0b3J5SXMoc2VsZiwgZXhwX3Jldm5vLCBleHBfcmV2aXNpb25faWQsIHJl
dmlzaW9uX3NwZWMpOgogICAgICAgICByZXZfaW5mbyA9IHNlbGYuZ2V0X2luX2hpc3RvcnkocmV2
aXNpb25fc3BlYykKICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChleHBfcmV2bm8sIHJldl9pbmZv
LnJldm5vLAotICAgICAgICAgICAgICAgICAgICAgICAgICdSZXZpc2lvbiBzcGVjOiAlcyByZXR1
cm5lZCB3cm9uZyByZXZubzogJXMgIT0gJXMnCisgICAgICAgICAgICAgICAgICAgICAgICAgJ1Jl
dmlzaW9uIHNwZWM6ICVyIHJldHVybmVkIHdyb25nIHJldm5vOiAlciAhPSAlcicKICAgICAgICAg
ICAgICAgICAgICAgICAgICAlIChyZXZpc2lvbl9zcGVjLCBleHBfcmV2bm8sIHJldl9pbmZvLnJl
dm5vKSkKICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChleHBfcmV2aXNpb25faWQsIHJldl9pbmZv
LnJldl9pZCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAnUmV2aXNpb24gc3BlYzogJXMgcmV0
dXJuZWQgd3JvbmcgcmV2aXNpb24gaWQ6JwotICAgICAgICAgICAgICAgICAgICAgICAgICcgJXMg
IT0gJXMnCisgICAgICAgICAgICAgICAgICAgICAgICAgJ1JldmlzaW9uIHNwZWM6ICVyIHJldHVy
bmVkIHdyb25nIHJldmlzaW9uIGlkOicKKyAgICAgICAgICAgICAgICAgICAgICAgICAnICVyICE9
ICVyJwogICAgICAgICAgICAgICAgICAgICAgICAgICUgKHJldmlzaW9uX3NwZWMsIGV4cF9yZXZp
c2lvbl9pZCwgcmV2X2luZm8ucmV2X2lkKSkKIAogICAgIGRlZiBhc3NlcnRJbnZhbGlkKHNlbGYs
IHJldmlzaW9uX3NwZWMsIGV4dHJhPScnKToKCg==
=== modified directory // last-changed:marienz at gentoo.org-20070308171357-7u3cn
... 4ra7m2zhw0w
# revision id: marienz at gentoo.org-20070308171357-7u3cn4ra7m2zhw0w
# sha1: f328afbb811fdab2302089ecec80da565a3cc9f7
# inventory sha1: 45aee296700b39f2d26efcb9274689f842df4633
# parent ids:
# pqm at pqm.ubuntu.com-20070307233124-ad2724bf65e09035
# properties:
# branch-nick: bzr.dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070308/11b87723/attachment.pgp
More information about the bazaar
mailing list