[merge] make RevisionSpec_revid always return a str

Marien Zwart marienz at gentoo.org
Sun Mar 11 18:18:34 GMT 2007


On Sun, Mar 11, 2007 at 11:49:07AM -0400, John Arbash Meinel wrote:
> John Arbash Meinel has voted +1 (conditional).
> Status is now: Conditionally approved
> Comment:
> I would change this to:

Changed. I did not know osutils.safe_revision_id exists or I probably
would have used it in the previous version of the patch too.

-- 
Marien.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
#   Call osutils.safe_revision_id instead of duplicating it.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Sun 2007-03-11 19:14:44.042000055 +0100

=== modified file bzrlib/revisionspec.py
--- bzrlib/revisionspec.py
+++ bzrlib/revisionspec.py
@@ -21,6 +21,7 @@
 
 from bzrlib import (
     errors,
+    osutils,
     revision,
     symbol_versioning,
     trace,
@@ -379,7 +380,11 @@
     prefix = 'revid:'
 
     def _match_on(self, branch, revs):
-        return RevisionInfo.from_revision_id(branch, self.spec, revs)
+        # self.spec comes straight from parsing the command line arguments,
+        # so we expect it to be a Unicode string. Switch it to the internal
+        # representation.
+        revision_id = osutils.safe_revision_id(self.spec, warn=False)
+        return RevisionInfo.from_revision_id(branch, revision_id, revs)
 
 SPEC_TYPES.append(RevisionSpec_revid)
 

=== modified file bzrlib/tests/blackbox/test_tags.py // last-changed:marienz at ge
... ntoo.org-20070308185109-wdlc2839v8qcuqhc
--- 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 // last-changed:marie
... nz at gentoo.org-20070309042901-n5sben4mqbf6iwgj
--- 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,13 @@
                                           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."""
+        revision_id = u'\N{SNOWMAN}'.encode('utf-8')
+        self.tree.commit('unicode', rev_id=revision_id)
+        self.assertInHistoryIs(3, revision_id, u'revid:\N{SNOWMAN}')
+        self.assertInHistoryIs(3, revision_id, 'revid:' + revision_id)
+
 
 class TestRevisionSpec_last(TestRevisionSpec):
 

=== modified directory  // last-changed:marienz at gentoo.org-20070311181444-9p0nw
... valjp1h42xh
# revision id: marienz at gentoo.org-20070311181444-9p0nwvaljp1h42xh
# sha1: bf486098e145eacd0234dd6c1b8e45f6d22dd754
# inventory sha1: 41db76519beb247ea61bf41c601a258a86af05bb
# parent ids:
#   marienz at gentoo.org-20070309042901-n5sben4mqbf6iwgj
# base id: pqm at pqm.ubuntu.com-20070307233124-ad2724bf65e09035
# properties:
#   branch-nick: bzr.dev

# message:
#   Rename rev_id to revision_id because HACKING says so.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Fri 2007-03-09 05:29:01.007999897 +0100

=== modified file bzrlib/tests/test_revisionnamespaces.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy90ZXN0X3JldmlzaW9ubmFtZXNwYWNlcy5weQorKysgYnpybGliL3Rl
c3RzL3Rlc3RfcmV2aXNpb25uYW1lc3BhY2VzLnB5CkBAIC0yNzksMTAgKzI3OSwxMCBAQAogCiAg
ICAgZGVmIHRlc3RfdW5pY29kZShzZWxmKToKICAgICAgICAgIiIiV2UgY29ycmVjdGx5IGNvbnZl
cnQgYSB1bmljb2RlIHVpIHN0cmluZyB0byBhbiBlbmNvZGVkIHJldmlkLiIiIgotICAgICAgICBy
ZXZfaWQgPSB1J1xOe1NOT1dNQU59Jy5lbmNvZGUoJ3V0Zi04JykKLSAgICAgICAgc2VsZi50cmVl
LmNvbW1pdCgndW5pY29kZScsIHJldl9pZD1yZXZfaWQpCi0gICAgICAgIHNlbGYuYXNzZXJ0SW5I
aXN0b3J5SXMoMywgcmV2X2lkLCB1J3JldmlkOlxOe1NOT1dNQU59JykKLSAgICAgICAgc2VsZi5h
c3NlcnRJbkhpc3RvcnlJcygzLCByZXZfaWQsICdyZXZpZDonICsgcmV2X2lkKQorICAgICAgICBy
ZXZpc2lvbl9pZCA9IHUnXE57U05PV01BTn0nLmVuY29kZSgndXRmLTgnKQorICAgICAgICBzZWxm
LnRyZWUuY29tbWl0KCd1bmljb2RlJywgcmV2X2lkPXJldmlzaW9uX2lkKQorICAgICAgICBzZWxm
LmFzc2VydEluSGlzdG9yeUlzKDMsIHJldmlzaW9uX2lkLCB1J3JldmlkOlxOe1NOT1dNQU59JykK
KyAgICAgICAgc2VsZi5hc3NlcnRJbkhpc3RvcnlJcygzLCByZXZpc2lvbl9pZCwgJ3JldmlkOicg
KyByZXZpc2lvbl9pZCkKIAogCiBjbGFzcyBUZXN0UmV2aXNpb25TcGVjX2xhc3QoVGVzdFJldmlz
aW9uU3BlYyk6Cgo=

=== modified directory  // last-changed:marienz at gentoo.org-20070309042901-n5sbe
... n4mqbf6iwgj
# revision id: marienz at gentoo.org-20070309042901-n5sben4mqbf6iwgj
# sha1: a44b3391058028be15c42f912db368d17799f9aa
# inventory sha1: 945ca78d6d72f95308b93c61c91960a82cbd0f41
# parent ids:
#   marienz at gentoo.org-20070309042706-173aok1s5f30rcuj
# properties:
#   branch-nick: bzr.dev

# message:
#   Make the revid RevisionSpec also support utf8-encoded bytestrings.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Fri 2007-03-09 05:27:06.654999971 +0100

=== modified file bzrlib/revisionspec.py // encoding:base64
LS0tIGJ6cmxpYi9yZXZpc2lvbnNwZWMucHkKKysrIGJ6cmxpYi9yZXZpc2lvbnNwZWMucHkKQEAg
LTM3OSw4ICszNzksMTAgQEAKICAgICBwcmVmaXggPSAncmV2aWQ6JwogCiAgICAgZGVmIF9tYXRj
aF9vbihzZWxmLCBicmFuY2gsIHJldnMpOgotICAgICAgICByZXR1cm4gUmV2aXNpb25JbmZvLmZy
b21fcmV2aXNpb25faWQoYnJhbmNoLCBzZWxmLnNwZWMuZW5jb2RlKCd1dGYtOCcpLAotICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV2cykKKyAgICAgICAgcmV2
aXNpb25faWQgPSBzZWxmLnNwZWMKKyAgICAgICAgaWYgaXNpbnN0YW5jZShyZXZpc2lvbl9pZCwg
dW5pY29kZSk6CisgICAgICAgICAgICByZXZpc2lvbl9pZCA9IHJldmlzaW9uX2lkLmVuY29kZSgn
dXRmLTgnKQorICAgICAgICByZXR1cm4gUmV2aXNpb25JbmZvLmZyb21fcmV2aXNpb25faWQoYnJh
bmNoLCByZXZpc2lvbl9pZCwgcmV2cykKIAogU1BFQ19UWVBFUy5hcHBlbmQoUmV2aXNpb25TcGVj
X3JldmlkKQogCgo=

=== modified file bzrlib/tests/test_revisionnamespaces.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy90ZXN0X3JldmlzaW9ubmFtZXNwYWNlcy5weQorKysgYnpybGliL3Rl
c3RzL3Rlc3RfcmV2aXNpb25uYW1lc3BhY2VzLnB5CkBAIC0yODIsNiArMjgyLDcgQEAKICAgICAg
ICAgcmV2X2lkID0gdSdcTntTTk9XTUFOfScuZW5jb2RlKCd1dGYtOCcpCiAgICAgICAgIHNlbGYu
dHJlZS5jb21taXQoJ3VuaWNvZGUnLCByZXZfaWQ9cmV2X2lkKQogICAgICAgICBzZWxmLmFzc2Vy
dEluSGlzdG9yeUlzKDMsIHJldl9pZCwgdSdyZXZpZDpcTntTTk9XTUFOfScpCisgICAgICAgIHNl
bGYuYXNzZXJ0SW5IaXN0b3J5SXMoMywgcmV2X2lkLCAncmV2aWQ6JyArIHJldl9pZCkKIAogCiBj
bGFzcyBUZXN0UmV2aXNpb25TcGVjX2xhc3QoVGVzdFJldmlzaW9uU3BlYyk6Cgo=

=== modified directory  // last-changed:marienz at gentoo.org-20070309042706-173ao
... k1s5f30rcuj
# revision id: marienz at gentoo.org-20070309042706-173aok1s5f30rcuj
# sha1: d5d97306391e198bf213c848e57b0e30ce564ea9
# inventory sha1: acb805a09a69ef68bf97b80e504299c3e660e01d
# parent ids:
#   marienz at gentoo.org-20070308185109-wdlc2839v8qcuqhc
# properties:
#   branch-nick: bzr.dev

# 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 // encoding:base64
LS0tIGJ6cmxpYi9yZXZpc2lvbnNwZWMucHkKKysrIGJ6cmxpYi9yZXZpc2lvbnNwZWMucHkKQEAg
LTM3OSw3ICszNzksOCBAQAogICAgIHByZWZpeCA9ICdyZXZpZDonCiAKICAgICBkZWYgX21hdGNo
X29uKHNlbGYsIGJyYW5jaCwgcmV2cyk6Ci0gICAgICAgIHJldHVybiBSZXZpc2lvbkluZm8uZnJv
bV9yZXZpc2lvbl9pZChicmFuY2gsIHNlbGYuc3BlYywgcmV2cykKKyAgICAgICAgcmV0dXJuIFJl
dmlzaW9uSW5mby5mcm9tX3JldmlzaW9uX2lkKGJyYW5jaCwgc2VsZi5zcGVjLmVuY29kZSgndXRm
LTgnKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldnMp
CiAKIFNQRUNfVFlQRVMuYXBwZW5kKFJldmlzaW9uU3BlY19yZXZpZCkKIAoK

=== modified file bzrlib/tests/blackbox/test_tags.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy9ibGFja2JveC90ZXN0X3RhZ3MucHkKKysrIGJ6cmxpYi90ZXN0cy9i
bGFja2JveC90ZXN0X3RhZ3MucHkKQEAgLTYwLDYgKzYwLDExIEBACiAgICAgICAgICMgY2FuIGFs
c28gY3JlYXRlIHRhZ3MgdXNpbmcgLXIKICAgICAgICAgc2VsZi5ydW5fYnpyKCd0YWcnLCAnLWQn
LCAnYnJhbmNoJywgJ3RhZzInLCAnLXIxJykKICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbHModC5i
cmFuY2gudGFncy5sb29rdXBfdGFnKCd0YWcyJyksICdmaXJzdC1yZXZpZCcpCisgICAgICAgICMg
cmVncmVzc2lvbiB0ZXN0OiBtYWtlIHN1cmUgYSB1bmljb2RlIHJldmlzaW9uIGZyb20gdGhlIHVz
ZXIKKyAgICAgICAgIyBnZXRzIHR1cm5lZCBpbnRvIGEgc3RyIG9iamVjdCBwcm9wZXJseS4gVGhl
IHVzZSBvZiBhIHVuaWNvZGUKKyAgICAgICAgIyBvYmplY3QgZm9yIHRoZSByZXZpZCBpcyBpbnRl
bnRpb25hbC4KKyAgICAgICAgc2VsZi5ydW5fYnpyKCd0YWcnLCAnLWQnLCAnYnJhbmNoJywgJ3Rh
ZzMnLCB1Jy1ycmV2aWQ6Zmlyc3QtcmV2aWQnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFscyh0
LmJyYW5jaC50YWdzLmxvb2t1cF90YWcoJ3RhZzMnKSwgJ2ZpcnN0LXJldmlkJykKICAgICAgICAg
IyBjYW4gYWxzbyBkZWxldGUgYW4gZXhpc3RpbmcgdGFnCiAgICAgICAgIG91dCwgZXJyID0gc2Vs
Zi5ydW5fYnpyKCd0YWcnLCAnLS1kZWxldGUnLCAnLWQnLCAnYnJhbmNoJywgJ3RhZzInKQogICAg
ICAgICAjIGNhbm5vdCByZXBsYWNlIGFuIGV4aXN0aW5nIHRhZyBub3JtYWxseQoK

=== modified file bzrlib/tests/test_revisionnamespaces.py // encoding:base64
LS0tIGJ6cmxpYi90ZXN0cy90ZXN0X3JldmlzaW9ubmFtZXNwYWNlcy5weQorKysgYnpybGliL3Rl
c3RzL3Rlc3RfcmV2aXNpb25uYW1lc3BhY2VzLnB5CkBAIC0yNzcsNiArMjc3LDEyIEBACiAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXZpc2lvbl9pZD0nYWx0X3Iz
JykKICAgICAgICAgc2VsZi5hc3NlcnRJbkhpc3RvcnlJcyhOb25lLCAnYWx0X3IzJywgJ3Jldmlk
OmFsdF9yMycpCiAKKyAgICBkZWYgdGVzdF91bmljb2RlKHNlbGYpOgorICAgICAgICAiIiJXZSBj
b3JyZWN0bHkgY29udmVydCBhIHVuaWNvZGUgdWkgc3RyaW5nIHRvIGFuIGVuY29kZWQgcmV2aWQu
IiIiCisgICAgICAgIHJldl9pZCA9IHUnXE57U05PV01BTn0nLmVuY29kZSgndXRmLTgnKQorICAg
ICAgICBzZWxmLnRyZWUuY29tbWl0KCd1bmljb2RlJywgcmV2X2lkPXJldl9pZCkKKyAgICAgICAg
c2VsZi5hc3NlcnRJbkhpc3RvcnlJcygzLCByZXZfaWQsIHUncmV2aWQ6XE57U05PV01BTn0nKQor
CiAKIGNsYXNzIFRlc3RSZXZpc2lvblNwZWNfbGFzdChUZXN0UmV2aXNpb25TcGVjKToKIAoK

=== 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
# 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/20070311/4afa5bb2/attachment-0001.pgp 


More information about the bazaar mailing list