[MERGE] revision-info fixes
Matthew D. Fuller
fullermd at over-yonder.net
Wed Jun 6 13:33:32 BST 2007
This fixes a few issues in the revision-info command.
- It demands a working tree, though it has no particular use for one
(x-ref bug 90048).
- It doesn't deal well with dotted revnos.
- It bleats at the user when called with no revision number. I can't
think of any good reason that 'testament' and 'revno' can default to
the head of the branch but revision-info can't.
Bundle attached. Tests included and passing. Running the full test
suit shows up some errors with the smart server taking interrupted
system calls, but I can't see how that's related to any of this.
--
Matthew Fuller (MF4839) | fullermd at over-yonder.net
Systems/Network Administrator | http://www.over-yonder.net/~fullermd/
On the Internet, nobody can hear you scream.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Rewrite revision-info blackbox tests to test:
#
# - Support for dotted revnos
# - Defaulting to head of branch if no rev given
# - Functioning without working tree
#
# committer: Matthew Fuller <fullermd at over-yonder.net>
# date: Wed 2007-06-06 06:34:02.984999895 -0500
=== modified file bzrlib/builtins.py // last-changed:fullermd at over-yonder.net-2
... 0070606105410-b7gb18p3qw8vrzk8
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -45,6 +45,7 @@
osutils,
registry,
repository,
+ revisionspec,
symbol_versioning,
transport,
tree as _mod_tree,
@@ -304,15 +305,18 @@
if revision_info_list is not None:
for rev in revision_info_list:
revs.append(RevisionSpec.from_string(rev))
+
+ b = Branch.open_containing(u'.')[0]
+
if len(revs) == 0:
- raise errors.BzrCommandError('You must supply a revision identifier')
-
- b = WorkingTree.open_containing(u'.')[0].branch
+ revs.append(RevisionSpec.from_string('-1'))
for rev in revs:
revinfo = rev.in_history(b)
if revinfo.revno is None:
- print ' %s' % revinfo.rev_id
+ dotted_map = b.get_revision_id_to_revno_map()
+ revno = '.'.join(str(i) for i in dotted_map[revinfo.rev_id])
+ print '%s %s' % (revno, revinfo.rev_id)
else:
print '%4d %s' % (revinfo.revno, revinfo.rev_id)
=== modified file bzrlib/tests/blackbox/test_revision_info.py
--- bzrlib/tests/blackbox/test_revision_info.py
+++ bzrlib/tests/blackbox/test_revision_info.py
@@ -35,40 +35,51 @@
"""Test that 'bzr revision-info' reports the correct thing."""
wt = self.make_branch_and_tree('.')
+ # Make history with a non-mainline rev
wt.commit('Commit one', rev_id='a at r-0-1')
- wt.commit('Commit two', rev_id='a at r-0-2')
- wt.commit('Commit three', rev_id='a at r-0-3')
-
- # Make sure revision-info without any arguments throws an exception
- self.check_error('bzr: ERROR: '
- 'You must supply a revision identifier\n',
- 'revision-info')
-
+ wt.commit('Commit two', rev_id='a at r-0-1.1.1')
+ wt.set_parent_ids(['a at r-0-1', 'a at r-0-1.1.1'])
+ wt.branch.set_last_revision_info(1, 'a at r-0-1')
+ wt.commit('Commit three', rev_id='a at r-0-2')
+
+ # This is expected to work even if the working tree is removed
+ wt.bzrdir.destroy_workingtree()
+
+ # Expected return values
values = {
- 1:' 1 a at r-0-1\n',
- 2:' 2 a at r-0-2\n',
- 3:' 3 a at r-0-3\n'
+ '1' : ' 1 a at r-0-1\n',
+ '1.1.1': '1.1.1 a at r-0-1.1.1\n',
+ '2' : ' 2 a at r-0-2\n'
}
+ # Make sure with no arg it defaults to the head
+ self.check_output(values['2'], 'revision-info')
+
# Check the results of just specifying a numeric revision
- self.check_output(values[1], 'revision-info', '1')
- self.check_output(values[2], 'revision-info', '2')
- self.check_output(values[3], 'revision-info', '3')
- self.check_output(values[1]+values[2], 'revision-info', '1', '2')
- self.check_output(values[1]+values[2]+values[3], 'revision-info', '1', '2', '3')
- self.check_output(values[2]+values[1], 'revision-info', '2', '1')
+ self.check_output(values['1'], 'revision-info', '1')
+ self.check_output(values['1.1.1'], 'revision-info', '1.1.1')
+ self.check_output(values['2'], 'revision-info', '2')
+ self.check_output(values['1']+values['2'], 'revision-info', '1', '2')
+ self.check_output(values['1']+values['1.1.1']+values['2'],
+ 'revision-info', '1', '1.1.1', '2')
+ self.check_output(values['2']+values['1'], 'revision-info', '2', '1')
# Check as above, only using the '--revision' syntax
- self.check_output(' 1 a at r-0-1\n', 'revision-info', '-r', '1')
- self.check_output(' 2 a at r-0-2\n', 'revision-info', '--revision', '2')
- self.check_output(' 3 a at r-0-3\n', 'revision-info', '-r', '3')
- self.check_output(' 1 a at r-0-1\n 2 a at r-0-2\n', 'revision-info', '-r', '1..2')
- self.check_output(' 1 a at r-0-1\n 2 a at r-0-2\n 3 a at r-0-3\n'
- , 'revision-info', '-r', '1..2..3')
- self.check_output(' 2 a at r-0-2\n 1 a at r-0-1\n', 'revision-info', '-r', '2..1')
+ self.check_output(values['1'], 'revision-info', '-r', '1')
+ self.check_output(values['1.1.1'], 'revision-info', '--revision',
+ '1.1.1')
+ self.check_output(values['2'], 'revision-info', '-r', '2')
+ self.check_output(values['1']+values['2'], 'revision-info',
+ '-r', '1..2')
+ self.check_output(values['1']+values['1.1.1']+values['2'],
+ 'revision-info', '-r', '1..1.1.1..2')
+ self.check_output(values['2']+values['1'], 'revision-info',
+ '-r', '2..1')
# Now try some more advanced revision specifications
- self.check_output(' 1 a at r-0-1\n', 'revision-info', '-r', 'revid:a at r-0-1')
- self.check_output(' 2 a at r-0-2\n', 'revision-info', '--revision', 'revid:a at r-0-2')
+ self.check_output(values['1'], 'revision-info', '-r',
+ 'revid:a at r-0-1')
+ self.check_output(values['1.1.1'], 'revision-info', '--revision',
+ 'revid:a at r-0-1.1.1')
=== modified directory // last-changed:fullermd at over-yonder.net-20070606113402
... -gyuk793gumqrfjrm
# revision id: fullermd at over-yonder.net-20070606113402-gyuk793gumqrfjrm
# sha1: 659b295f4aea97f7b62449a9e77f49a7793e603a
# inventory sha1: baf10db7ae774e15aa9d3c2bd858961e773f3156
# parent ids:
# fullermd at over-yonder.net-20070606105410-b7gb18p3qw8vrzk8
# base id: pqm at pqm.ubuntu.com-20070606083714-rt2za45t9gt5nqqh
# properties:
# branch-nick: revision-info
# message:
# Default revision-info to the head of the branch when no revision is
# given.
#
# committer: Matthew Fuller <fullermd at over-yonder.net>
# date: Wed 2007-06-06 05:54:10.342999935 -0500
=== modified file bzrlib/builtins.py // encoding:base64
LS0tIGJ6cmxpYi9idWlsdGlucy5weQorKysgYnpybGliL2J1aWx0aW5zLnB5CkBAIC00NSw2ICs0
NSw3IEBACiAgICAgb3N1dGlscywKICAgICByZWdpc3RyeSwKICAgICByZXBvc2l0b3J5LAorICAg
IHJldmlzaW9uc3BlYywKICAgICBzeW1ib2xfdmVyc2lvbmluZywKICAgICB0cmFuc3BvcnQsCiAg
ICAgdHJlZSBhcyBfbW9kX3RyZWUsCkBAIC0zMDQsMTAgKzMwNSwxMSBAQAogICAgICAgICBpZiBy
ZXZpc2lvbl9pbmZvX2xpc3QgaXMgbm90IE5vbmU6CiAgICAgICAgICAgICBmb3IgcmV2IGluIHJl
dmlzaW9uX2luZm9fbGlzdDoKICAgICAgICAgICAgICAgICByZXZzLmFwcGVuZChSZXZpc2lvblNw
ZWMuZnJvbV9zdHJpbmcocmV2KSkKKworICAgICAgICBiID0gQnJhbmNoLm9wZW5fY29udGFpbmlu
Zyh1Jy4nKVswXQorCiAgICAgICAgIGlmIGxlbihyZXZzKSA9PSAwOgotICAgICAgICAgICAgcmFp
c2UgZXJyb3JzLkJ6ckNvbW1hbmRFcnJvcignWW91IG11c3Qgc3VwcGx5IGEgcmV2aXNpb24gaWRl
bnRpZmllcicpCi0KLSAgICAgICAgYiA9IEJyYW5jaC5vcGVuX2NvbnRhaW5pbmcodScuJylbMF0K
KyAgICAgICAgICAgIHJldnMuYXBwZW5kKFJldmlzaW9uU3BlYy5mcm9tX3N0cmluZygnLTEnKSkK
IAogICAgICAgICBmb3IgcmV2IGluIHJldnM6CiAgICAgICAgICAgICByZXZpbmZvID0gcmV2Lmlu
X2hpc3RvcnkoYikKCg==
=== modified directory // last-changed:fullermd at over-yonder.net-20070606105410
... -b7gb18p3qw8vrzk8
# revision id: fullermd at over-yonder.net-20070606105410-b7gb18p3qw8vrzk8
# sha1: df907907ae5702262764d905ef2d9632b27e7b71
# inventory sha1: e23e1f8fba61e03c6d8eeb92f239301008198fa1
# parent ids:
# fullermd at over-yonder.net-20070606104510-75dot0o1k4n396ju
# properties:
# branch-nick: revision-info
# message:
# Update revision-info to show dotted revnos.
#
# committer: Matthew Fuller <fullermd at over-yonder.net>
# date: Wed 2007-06-06 05:45:10.427999973 -0500
=== modified file bzrlib/builtins.py // encoding:base64
LS0tIGJ6cmxpYi9idWlsdGlucy5weQorKysgYnpybGliL2J1aWx0aW5zLnB5CkBAIC0zMTIsNyAr
MzEyLDkgQEAKICAgICAgICAgZm9yIHJldiBpbiByZXZzOgogICAgICAgICAgICAgcmV2aW5mbyA9
IHJldi5pbl9oaXN0b3J5KGIpCiAgICAgICAgICAgICBpZiByZXZpbmZvLnJldm5vIGlzIE5vbmU6
Ci0gICAgICAgICAgICAgICAgcHJpbnQgJyAgICAgJXMnICUgcmV2aW5mby5yZXZfaWQKKyAgICAg
ICAgICAgICAgICBkb3R0ZWRfbWFwID0gYi5nZXRfcmV2aXNpb25faWRfdG9fcmV2bm9fbWFwKCkK
KyAgICAgICAgICAgICAgICByZXZubyA9ICcuJy5qb2luKHN0cihpKSBmb3IgaSBpbiBkb3R0ZWRf
bWFwW3JldmluZm8ucmV2X2lkXSkKKyAgICAgICAgICAgICAgICBwcmludCAnJXMgJXMnICUgKHJl
dm5vLCByZXZpbmZvLnJldl9pZCkKICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAg
cHJpbnQgJyU0ZCAlcycgJSAocmV2aW5mby5yZXZubywgcmV2aW5mby5yZXZfaWQpCiAKCg==
=== modified directory // last-changed:fullermd at over-yonder.net-20070606104510
... -75dot0o1k4n396ju
# revision id: fullermd at over-yonder.net-20070606104510-75dot0o1k4n396ju
# sha1: 1e4a19dad94bae42b7044905dc6e6c314447068d
# inventory sha1: 3efb0f2fa55d37cd2511e2711a736379f7d03636
# parent ids:
# fullermd at over-yonder.net-20070606102332-i7n2yh30rh8noob7
# properties:
# branch-nick: revision-info
# message:
# revision-info has no call to need a WorkingTree, so don't demand one.
#
# committer: Matthew Fuller <fullermd at over-yonder.net>
# date: Wed 2007-06-06 05:23:32.154000044 -0500
=== modified file bzrlib/builtins.py // encoding:base64
LS0tIGJ6cmxpYi9idWlsdGlucy5weQorKysgYnpybGliL2J1aWx0aW5zLnB5CkBAIC0zMDcsNyAr
MzA3LDcgQEAKICAgICAgICAgaWYgbGVuKHJldnMpID09IDA6CiAgICAgICAgICAgICByYWlzZSBl
cnJvcnMuQnpyQ29tbWFuZEVycm9yKCdZb3UgbXVzdCBzdXBwbHkgYSByZXZpc2lvbiBpZGVudGlm
aWVyJykKIAotICAgICAgICBiID0gV29ya2luZ1RyZWUub3Blbl9jb250YWluaW5nKHUnLicpWzBd
LmJyYW5jaAorICAgICAgICBiID0gQnJhbmNoLm9wZW5fY29udGFpbmluZyh1Jy4nKVswXQogCiAg
ICAgICAgIGZvciByZXYgaW4gcmV2czoKICAgICAgICAgICAgIHJldmluZm8gPSByZXYuaW5faGlz
dG9yeShiKQoK
=== modified directory // last-changed:fullermd at over-yonder.net-20070606102332
... -i7n2yh30rh8noob7
# revision id: fullermd at over-yonder.net-20070606102332-i7n2yh30rh8noob7
# sha1: 8f8fc99e42c8a6f83acb9718af9e4193488ebcc6
# inventory sha1: 2926c9a5ec214628fdb1c76600ce4b12743f92c3
# parent ids:
# pqm at pqm.ubuntu.com-20070606083714-rt2za45t9gt5nqqh
# properties:
# branch-nick: revision-info
# bugs: https://launchpad.net/bugs/90048 fixed
More information about the bazaar
mailing list