Merge lp:~jelmer/bzr/nomoregetrevision into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Martin Pool
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr/nomoregetrevision
Merge into: lp:bzr
Diff against target: 154 lines (+45/-47)
5 files modified
NEWS (+2/-0)
bzrlib/builtins.py (+33/-16)
bzrlib/foreign.py (+0/-9)
bzrlib/repository.py (+0/-17)
bzrlib/tests/blackbox/test_cat_revision.py (+10/-5)
To merge this branch: bzr merge lp:~jelmer/bzr/nomoregetrevision
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+19359@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This removes another method from Repository, get_revision_xml(). I've
changed cat-revision to look at Repository.revisions directly rather
than reserializing revisions returned by Repository.get_revision().

Cheers,

Jelmer

Revision history for this message
Martin Pool (mbp) :
review: Approve
Revision history for this message
Aaron Bentley (abentley) wrote :

The NEWS entry appears to be duplicated by this change.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-02-12 15:15:24 +0000
+++ NEWS 2010-02-15 20:36:24 +0000
@@ -20,6 +20,8 @@
2020
21* ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij)21* ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij)
2222
23* ``Repository.get_revision_xml()`` has been removed. (Jelmer Vernooij)
24
23* All test servers have been moved out of the bzrlib.transport hierarchy to25* All test servers have been moved out of the bzrlib.transport hierarchy to
24 bzrlib.tests.test_server *except* for MemoryServer, ChrootServer and26 bzrlib.tests.test_server *except* for MemoryServer, ChrootServer and
25 PathFilteringServer. ``bzrlib`` users may encounter test failures that can27 PathFilteringServer. ``bzrlib`` users may encounter test failures that can
2628
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-02-12 04:33:05 +0000
+++ bzrlib/builtins.py 2010-02-15 20:36:24 +0000
@@ -340,6 +340,14 @@
340 # cat-revision is more for frontends so should be exact340 # cat-revision is more for frontends so should be exact
341 encoding = 'strict'341 encoding = 'strict'
342342
343 def print_revision(self, revisions, revid):
344 stream = revisions.get_record_stream([(revid,)], 'unordered', True)
345 record = stream.next()
346 if record.storage_kind == 'absent':
347 raise errors.NoSuchRevision(revisions, revid)
348 revtext = record.get_bytes_as('fulltext')
349 self.outf.write(revtext.decode('utf-8'))
350
343 @display_command351 @display_command
344 def run(self, revision_id=None, revision=None):352 def run(self, revision_id=None, revision=None):
345 if revision_id is not None and revision is not None:353 if revision_id is not None and revision is not None:
@@ -350,23 +358,32 @@
350 ' --revision or a revision_id')358 ' --revision or a revision_id')
351 b = WorkingTree.open_containing(u'.')[0].branch359 b = WorkingTree.open_containing(u'.')[0].branch
352360
353 # TODO: jam 20060112 should cat-revision always output utf-8?361 revisions = b.repository.revisions
354 if revision_id is not None:362 if revisions is None:
355 revision_id = osutils.safe_revision_id(revision_id, warn=False)363 raise errors.BzrCommandError('Repository %r does not support '
356 try:364 'access to raw revision texts')
357 self.outf.write(b.repository.get_revision_xml(revision_id).decode('utf-8'))
358 except errors.NoSuchRevision:
359 msg = "The repository %s contains no revision %s." % (b.repository.base,
360 revision_id)
361 raise errors.BzrCommandError(msg)
362 elif revision is not None:
363 for rev in revision:
364 if rev is None:
365 raise errors.BzrCommandError('You cannot specify a NULL'
366 ' revision.')
367 rev_id = rev.as_revision_id(b)
368 self.outf.write(b.repository.get_revision_xml(rev_id).decode('utf-8'))
369365
366 b.repository.lock_read()
367 try:
368 # TODO: jam 20060112 should cat-revision always output utf-8?
369 if revision_id is not None:
370 revision_id = osutils.safe_revision_id(revision_id, warn=False)
371 try:
372 self.print_revision(revisions, revision_id)
373 except errors.NoSuchRevision:
374 msg = "The repository %s contains no revision %s." % (
375 b.repository.base, revision_id)
376 raise errors.BzrCommandError(msg)
377 elif revision is not None:
378 for rev in revision:
379 if rev is None:
380 raise errors.BzrCommandError(
381 'You cannot specify a NULL revision.')
382 rev_id = rev.as_revision_id(b)
383 self.print_revision(revisions, rev_id)
384 finally:
385 b.repository.unlock()
386
370387
371class cmd_dump_btree(Command):388class cmd_dump_btree(Command):
372 """Dump the contents of a btree index file to stdout.389 """Dump the contents of a btree index file to stdout.
373390
=== modified file 'bzrlib/foreign.py'
--- bzrlib/foreign.py 2010-02-04 16:06:36 +0000
+++ bzrlib/foreign.py 2010-02-15 20:36:24 +0000
@@ -229,15 +229,6 @@
229 """See Repository._get_inventory_xml()."""229 """See Repository._get_inventory_xml()."""
230 return self._serialise_inventory(self.get_inventory(revision_id))230 return self._serialise_inventory(self.get_inventory(revision_id))
231231
232 def get_revision_xml(self, revision_id):
233 """Return the XML representation of a revision.
234
235 :param revision_id: Revision for which to return the XML.
236 :return: XML string
237 """
238 return self._serializer.write_revision_to_string(
239 self.get_revision(revision_id))
240
241232
242class ForeignBranch(Branch):233class ForeignBranch(Branch):
243 """Branch that exists in a foreign version control system."""234 """Branch that exists in a foreign version control system."""
244235
=== modified file 'bzrlib/repository.py'
--- bzrlib/repository.py 2010-02-10 18:29:50 +0000
+++ bzrlib/repository.py 2010-02-15 20:36:24 +0000
@@ -1901,23 +1901,6 @@
1901 rev = self._serializer.read_revision_from_string(text)1901 rev = self._serializer.read_revision_from_string(text)
1902 yield (revid, rev)1902 yield (revid, rev)
19031903
1904 @needs_read_lock
1905 def get_revision_xml(self, revision_id):
1906 # TODO: jam 20070210 This shouldn't be necessary since get_revision
1907 # would have already do it.
1908 # TODO: jam 20070210 Just use _serializer.write_revision_to_string()
1909 # TODO: this can't just be replaced by:
1910 # return self._serializer.write_revision_to_string(
1911 # self.get_revision(revision_id))
1912 # as cStringIO preservers the encoding unlike write_revision_to_string
1913 # or some other call down the path.
1914 rev = self.get_revision(revision_id)
1915 rev_tmp = cStringIO.StringIO()
1916 # the current serializer..
1917 self._serializer.write_revision(rev, rev_tmp)
1918 rev_tmp.seek(0)
1919 return rev_tmp.getvalue()
1920
1921 def get_deltas_for_revisions(self, revisions, specific_fileids=None):1904 def get_deltas_for_revisions(self, revisions, specific_fileids=None):
1922 """Produce a generator of revision deltas.1905 """Produce a generator of revision deltas.
19231906
19241907
=== modified file 'bzrlib/tests/blackbox/test_cat_revision.py'
--- bzrlib/tests/blackbox/test_cat_revision.py 2009-03-23 14:59:43 +0000
+++ bzrlib/tests/blackbox/test_cat_revision.py 2010-02-15 20:36:24 +0000
@@ -36,11 +36,16 @@
36 wt.commit('Commit two', rev_id='a@r-0-2')36 wt.commit('Commit two', rev_id='a@r-0-2')
37 wt.commit('Commit three', rev_id='a@r-0-3')37 wt.commit('Commit three', rev_id='a@r-0-3')
3838
39 revs = {39 r.lock_read()
40 1:r.get_revision_xml('a@r-0-1'),40 try:
41 2:r.get_revision_xml('a@r-0-2'),41 revs = {}
42 3:r.get_revision_xml('a@r-0-3'),42 for i in (1, 2, 3):
43 }43 revid = "a@r-0-%d" % i
44 stream = r.revisions.get_record_stream([(revid,)], 'unordered',
45 False)
46 revs[i] = stream.next().get_bytes_as('fulltext')
47 finally:
48 r.unlock()
4449
45 self.check_output(revs[1], 'cat-revision a@r-0-1')50 self.check_output(revs[1], 'cat-revision a@r-0-1')
46 self.check_output(revs[2], 'cat-revision a@r-0-2')51 self.check_output(revs[2], 'cat-revision a@r-0-2')