Merge upstream.
[jelmer/subvertpy.git] / branch.py
index bb029ef967f2c6f58d7dfe64f5c99a6e00c2bc3e..70240027203a8747cd36debcf70e782f8e25715a 100644 (file)
--- a/branch.py
+++ b/branch.py
@@ -79,6 +79,19 @@ class SvnBranch(Branch):
         checkout_branch.pull(self, stop_revision=revision_id)
         return checkout.create_workingtree(revision_id)
 
+    """Look up the matching revision number on the mainline of the 
+    branch.
+
+    :param revid: Revision id to look up.
+    :return: Revision number on the branch. 
+    :raises NoSuchRevision: If the revision id was not found.
+    """
+    def lookup_revision_id(self, revid):
+        (bp, revnum) = self.repository.lookup_revision_id(revid)
+        assert bp.strip("/") == self.branch_path.strip("/"), \
+                "Got %r, expected %r" % (bp, self.branch_path)
+        return revnum
+
     def _create_lightweight_checkout(self, to_location, revision_id=None):
         peg_rev = svn.core.svn_opt_revision_t()
         peg_rev.kind = svn.core.svn_opt_revision_head
@@ -87,8 +100,7 @@ class SvnBranch(Branch):
         if revision_id is None:
             rev.kind = svn.core.svn_opt_revision_head
         else:
-            assert revision_id in self.revision_history()
-            (_, revnum) = self.repository.parse_revision_id(revision_id)
+            revnum = self.lookup_revision_id(revision_id)
             rev.kind = svn.core.svn_opt_revision_number
             rev.value.number = revnum
             mutter('hist: %r' % self.revision_history())