Rev 1323: Use iter_changes() from lhs_revision_parent. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Mon Jun 23 19:16:03 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1323
revision-id: jelmer at samba.org-20080623181602-myyeb6mkzqqz2lup
parent: jelmer at samba.org-20080623181542-w17ofdsh92qjarfq
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-06-23 20:16:02 +0200
message:
Use iter_changes() from lhs_revision_parent.
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_logwalker.py test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
tests/test_repository.py test_repos.py-20060508151940-ddc49a59257ca712
=== modified file 'repository.py'
--- a/repository.py 2008-06-22 23:25:42 +0000
+++ b/repository.py 2008-06-23 18:16:02 +0000
@@ -348,7 +348,8 @@
if revision_id in (None, NULL_REVISION):
return
(branch_path, revnum, mapping) = self.lookup_revision_id(revision_id)
- for revmeta in self.iter_reverse_branch_changes(branch_path, revnum, mapping, pb=pb, limit=limit):
+ for revmeta in self.iter_reverse_branch_changes(branch_path, revnum, mapping, pb=pb,
+ limit=limit):
yield revmeta.get_revision_id(mapping)
def get_ancestry(self, revision_id, topo_sorted=True):
@@ -408,33 +409,15 @@
assert isinstance(path, str)
assert isinstance(revnum, int)
- if not mapping.is_branch(path) and \
- not mapping.is_tag(path):
- raise NoSuchRevision(self,
- self.generate_revision_id(revnum, path, mapping))
-
- # Make sure the specified revision actually exists
- changes = self._log.get_revision_paths(revnum)
- if not changes_path(changes, path):
- # the specified revno should be changing the branch or
- # otherwise it is invalid
- raise NoSuchRevision(self,
- self.generate_revision_id(revnum, path, mapping))
-
- while True:
- next = find_prev_location(changes, path, revnum)
- if next is None:
- break
- (path, revnum) = next
- changes = self._log.get_revision_paths(revnum)
-
- if changes_path(changes, path):
- revid = self.generate_revision_id(revnum, path, mapping)
- if not mapping.is_branch(path) and \
- not mapping.is_tag(path):
- return NULL_REVISION
- return revid
- return NULL_REVISION
+ iterator = self.iter_reverse_branch_changes(path, revnum, mapping=mapping,
+ limit=2)
+ revmeta = iterator.next()
+ assert revmeta.branch_path == path
+ assert revmeta.revnum == revnum
+ try:
+ return iterator.next().get_revision_id(mapping)
+ except StopIteration:
+ return NULL_REVISION
def get_parent_map(self, revids):
parent_map = {}
@@ -488,7 +471,7 @@
(path, revnum, mapping) = self.lookup_revision_id(revision_id)
- svn_revprops = self._log.revprop_list(revnum)
+ svn_revprops = self.transport.revprop_list(revnum)
svn_fileprops = logwalker.lazy_dict({}, self.branchprop_list.get_changed_properties, path, revnum)
revmeta = RevisionMetadata(self, path, None, revnum, svn_revprops, svn_fileprops)
@@ -578,8 +561,13 @@
"Mapping %r doesn't accept %s as branch or tag" % (mapping, branch_path)
bp = branch_path
+ i = 0
- for (paths, revnum, revprops) in self._log.iter_changes([branch_path], revnum, pb=pb, limit=limit):
+ # Limit can't be passed on directly to LogWalker.iter_changes()
+ # because we're skipping some revs
+ # TODO: Rather than fetching everything if limit == 2, maybe just
+ # set specify an extra X revs just to be sure?
+ for (paths, revnum, revprops) in self._log.iter_changes([branch_path], revnum, pb=pb):
assert bp is not None
next = find_prev_location(paths, bp, revnum)
assert revnum > 0 or bp == ""
@@ -595,7 +583,11 @@
yield (bp, lazypaths, revnum, revprops)
return
- yield (bp, paths, revnum, revprops)
+ if changes_path(paths, bp, False):
+ yield (bp, paths, revnum, revprops)
+ i += 1
+ if limit != 0 and limit == i:
+ break
if next is None:
bp = None
=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py 2008-06-23 13:59:19 +0000
+++ b/tests/test_logwalker.py 2008-06-23 18:16:02 +0000
@@ -591,6 +591,22 @@
props = walker.revprop_list(0)
self.assertEquals(set(["svn:date"]), set(props.keys()))
+ def test_set_revprop(self):
+ repos_url = self.make_repository("a")
+
+ cb = self.get_commit_editor(repos_url)
+ cb.add_dir("trunk")
+ cb.close()
+
+ transport = SvnRaTransport(repos_url)
+
+ transport.change_rev_prop(1, "foo", "blaaa")
+
+ walker = self.get_log_walker(transport=transport)
+
+ props = walker.revprop_list(1)
+ self.assertEquals("blaaa", props["foo"])
+
def test_find_children_copy(self):
repos_url = self.make_repository("a")
=== modified file 'tests/test_repository.py'
--- a/tests/test_repository.py 2008-06-23 02:23:10 +0000
+++ b/tests/test_repository.py 2008-06-23 18:16:02 +0000
@@ -200,7 +200,6 @@
('pygments/trunk', {'pygments': (u'A', 'pykleur', 1),
'pygments/trunk': (u'R', 'pykleur/trunk', 2),
'pykleur': (u'D', None, -1)}, 3),
- ('pykleur/trunk', {'pykleur/trunk/pykleur/afile': (u'A', None, -1)}, 2),
('pykleur/trunk',
{'pykleur': (u'A', None, -1),
'pykleur/trunk': (u'A', None, -1),
@@ -209,7 +208,7 @@
)
else:
self.assertEquals(
- [('pygments/trunk', {'pygments': (u'A', 'pykleur', 1), 'pykleur': (u'D', None, -1)}, 3),
+ [
('pykleur/trunk', {'pykleur': (u'A', None, -1),
'pykleur/trunk': (u'A', None, -1),
'pykleur/trunk/pykleur': (u'A', None, -1)},
@@ -1109,16 +1108,6 @@
self.assertEquals(repos.generate_revision_id(1, "py/trunk", mapping), \
repos.lhs_revision_parent("de/trunk", 3, mapping))
- def test_mainline_revision_missing(self):
- repos_url = self.make_client('d', 'dc')
- repos = Repository.open(repos_url)
- self.build_tree({'dc/py/trunk/adir/afile': "data",
- 'dc/py/trunk/adir/stationary': None})
- self.client_add("dc/py")
- self.client_commit("dc", "Initial commit")
- self.assertRaises(NoSuchRevision,
- lambda: repos.lhs_revision_parent("trunk", 2, repos.get_mapping()))
-
class TestSvnRevisionTree(TestCaseWithSubversionRepository):
def setUp(self):
More information about the bazaar-commits
mailing list