Rev 2972: (Adeodato Simó) show (possibly dotted) rev in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Nov 6 10:18:53 GMT 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2972
revision-id: pqm at pqm.ubuntu.com-20071106101850-9tqmz90mna2r67zk
parent: pqm at pqm.ubuntu.com-20071106093253-8f3a6b1nhw56f3mk
parent: bialix at ukr.net-20071106074044-lt7zr7deya5vjzom
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-11-06 10:18:50 +0000
message:
(Adeodato =?UTF-8?B?U2ltw7MpIHNob3cgKHBvc3NpYmx5IGRvdHRlZCkgcmV2?=
=?UTF-8?B?bm9zIGluIGBienIgdGFnc2AsIGFsbG93IHRvIHNvcnQgdGhlbSBieSB0aW1l?=
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_tags.py test_tags.py-20070116132048-5h4qak2cm22jlb9e-1
------------------------------------------------------------
revno: 2968.1.1
merged: bialix at ukr.net-20071106074044-lt7zr7deya5vjzom
parent: pqm at pqm.ubuntu.com-20071106070621-hu1s7o5fphvhxw8m
parent: dato at net.com.org.es-20071026152518-yt6a4k92r4e9h6t7
committer: Alexander Belchenko <bialix at ukr.net>
branch nick: tags
timestamp: Tue 2007-11-06 09:40:44 +0200
message:
(Adeodato Simó) show (possibly dotted) revnos in `bzr tags`, allow to sort them by time
------------------------------------------------------------
revno: 2805.8.7
merged: dato at net.com.org.es-20071026152518-yt6a4k92r4e9h6t7
parent: dato at net.com.org.es-20071026104921-zfwb0z5iqu36xm3a
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Fri 2007-10-26 17:25:18 +0200
message:
Note in NEWS that #120231 gets closed.
------------------------------------------------------------
revno: 2805.8.6
merged: dato at net.com.org.es-20071026104921-zfwb0z5iqu36xm3a
parent: dato at net.com.org.es-20071026084758-q0anjasztm0s3rpc
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Fri 2007-10-26 12:49:21 +0200
message:
Don't sort by revno; only by time if --sort=time is passed.
------------------------------------------------------------
revno: 2805.8.5
merged: dato at net.com.org.es-20071026084758-q0anjasztm0s3rpc
parent: dato at net.com.org.es-20070920112253-17jrj6y4fa8nqm77
parent: pqm at pqm.ubuntu.com-20071026074806-v0hw6v1dbm6hu9oj
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Fri 2007-10-26 10:47:58 +0200
message:
Merge bzr.dev.
------------------------------------------------------------
revno: 2805.8.4
merged: dato at net.com.org.es-20070920112253-17jrj6y4fa8nqm77
parent: dato at net.com.org.es-20070918113304-rn9k1hmwkrjhm4n1
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Thu 2007-09-20 13:22:53 +0200
message:
Only show revid with --show-ids.
------------------------------------------------------------
revno: 2805.8.3
merged: dato at net.com.org.es-20070918113304-rn9k1hmwkrjhm4n1
parent: dato at net.com.org.es-20070918104353-ey9qeixahfe3cslz
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Tue 2007-09-18 13:33:04 +0200
message:
Show dotted revnos, and revids only with --show-ids.
------------------------------------------------------------
revno: 2805.8.2
merged: dato at net.com.org.es-20070918104353-ey9qeixahfe3cslz
parent: dato at net.com.org.es-20070908144435-js2ca9y9k1fyky1g
parent: pqm at pqm.ubuntu.com-20070918045733-es6jch43pxvogvhj
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Tue 2007-09-18 12:43:53 +0200
message:
Merge bzr.dev.
------------------------------------------------------------
revno: 2805.8.1
merged: dato at net.com.org.es-20070908144435-js2ca9y9k1fyky1g
parent: pqm at pqm.ubuntu.com-20070907145828-hjh5941jv7y8d9z8
committer: Adeodato Simó <dato at net.com.org.es>
branch nick: bzr.revno_in_tags
timestamp: Sat 2007-09-08 16:44:35 +0200
message:
Show revnos in `bzr tags`.
=== modified file 'NEWS'
--- a/NEWS 2007-11-06 06:19:19 +0000
+++ b/NEWS 2007-11-06 07:40:44 +0000
@@ -33,6 +33,11 @@
IMPROVEMENTS:
+ * ``bzr tags`` now prints the revision number for each tag, instead of
+ the revision id, unless --show-ids is passed. In addition, tags can be
+ sorted chronologically instead of lexicographically with --sort=time.
+ (Adeodato Simó, #120231)
+
DOCUMENTATION:
BUG FIXES:
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-11-05 21:11:56 +0000
+++ b/bzrlib/builtins.py 2007-11-06 07:40:44 +0000
@@ -4196,15 +4196,42 @@
short_name='d',
type=unicode,
),
+ RegistryOption.from_kwargs('sort',
+ 'Sort tags by different criteria.', title='Sorting',
+ alpha='Sort tags lexicographically (default).',
+ time='Sort tags chronologically.',
+ ),
+ 'show-ids',
]
@display_command
def run(self,
directory='.',
+ sort='alpha',
+ show_ids=False,
):
branch, relpath = Branch.open_containing(directory)
- for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
- self.outf.write('%-20s %s\n' % (tag_name, target))
+ tags = branch.tags.get_tag_dict().items()
+ if sort == 'alpha':
+ tags.sort()
+ elif sort == 'time':
+ timestamps = {}
+ for tag, revid in tags:
+ try:
+ revobj = branch.repository.get_revision(revid)
+ except errors.NoSuchRevision:
+ timestamp = sys.maxint # place them at the end
+ else:
+ timestamp = revobj.timestamp
+ timestamps[revid] = timestamp
+ tags.sort(key=lambda x: timestamps[x[1]])
+ if not show_ids:
+ # [ (tag, revid), ... ] -> [ (tag, dotted_revno), ... ]
+ revno_map = branch.get_revision_id_to_revno_map()
+ tags = [ (tag, '.'.join(map(str, revno_map.get(revid, ('?',)))))
+ for tag, revid in tags ]
+ for tag, revspec in tags:
+ self.outf.write('%-20s %s\n' % (tag, revspec))
class cmd_reconfigure(Command):
=== modified file 'bzrlib/tests/blackbox/test_tags.py'
--- a/bzrlib/tests/blackbox/test_tags.py 2007-07-31 22:08:47 +0000
+++ b/bzrlib/tests/blackbox/test_tags.py 2007-10-26 10:49:21 +0000
@@ -105,14 +105,60 @@
self.assertEquals(b3.tags.lookup_tag('tag1'), 'first-revid')
def test_list_tags(self):
- t = self.make_branch_and_tree('branch1')
- b1 = t.branch
- tagname = u'\u30d0zaar'
- b1.tags.set_tag(tagname, 'revid-1')
- out, err = self.run_bzr('tags -d branch1', encoding='utf-8')
- self.assertEquals(err, '')
- self.assertContainsRe(out,
- u'^\u30d0zaar *revid-1\n'.encode('utf-8'))
+ tree1 = self.make_branch_and_tree('branch1')
+ tree1.commit(allow_pointless=True, message='revision 1',
+ rev_id='revid-1', timestamp=10)
+ tree1.commit(allow_pointless=True, message='revision 2',
+ rev_id='revid-2', timestamp=15)
+
+ b1 = tree1.branch
+ # note how the tag for revid-1 sorts after the one for revid-2
+ b1.tags.set_tag(u'tagA\u30d0', 'revid-2')
+ b1.tags.set_tag(u'tagB\u30d0', 'missing') # not present in repository
+ b1.tags.set_tag(u'tagC\u30d0', 'revid-1')
+
+ # lexicographical order
+ out, err = self.run_bzr('tags -d branch1', encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, (u'^tagA\u30d0 *2\ntagB\u30d0 *\\?\n' +
+ u'tagC\u30d0 *1\n').encode('utf-8'))
+
+ out, err = self.run_bzr('tags --show-ids -d branch1', encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, (u'^tagA\u30d0 *revid-2\n' +
+ u'tagB\u30d0 *missing\ntagC\u30d0 *revid-1\n').encode('utf-8'))
+
+ # chronological order
+ out, err = self.run_bzr('tags --sort=time -d branch1',
+ encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, (u'^tagC\u30d0 *1\ntagA\u30d0 *2\n' +
+ u'tagB\u30d0 *\\?\n').encode('utf-8'))
+
+ out, err = self.run_bzr('tags --sort=time --show-ids -d branch1',
+ encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, (u'^tagC\u30d0 *revid-1\n' +
+ u'tagA\u30d0 *revid-2\ntagB\u30d0 *missing\n').encode('utf-8'))
+
+ # now test dotted revnos
+ tree2 = tree1.bzrdir.sprout('branch2').open_workingtree()
+ tree1.commit(allow_pointless=True, message='revision 3 in branch1',
+ rev_id='revid-3a')
+ tree2.commit(allow_pointless=True, message='revision 3 in branch2',
+ rev_id='revid-3b')
+
+ b2 = tree2.branch
+ b2.tags.set_tag('tagD', 'revid-3b')
+ self.run_bzr('merge -d branch1 branch2')
+ tree1.commit('merge', rev_id='revid-4')
+
+ out, err = self.run_bzr('tags -d branch1', encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, r'tagD *2\.1\.1\n')
+ out, err = self.run_bzr('tags -d branch2', encoding='utf-8')
+ self.assertEquals(err, '')
+ self.assertContainsRe(out, r'tagD *3\n')
def test_conflicting_tags(self):
# setup two empty branches with different tags
More information about the bazaar-commits
mailing list