changeset 4789:c5dd8e184279

convert: svn: add function to get the latest revision touching a path Make it work for HTTP URLs
author Brendan Cully <brendan@kublai.com>
date Tue, 03 Jul 2007 12:44:04 -0700
parents 62e1b6412b62
children c2ef09a35c53
files hgext/convert/subversion.py
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/subversion.py	Tue Jul 03 11:36:06 2007 -0700
+++ b/hgext/convert/subversion.py	Tue Jul 03 12:44:04 2007 -0700
@@ -120,12 +120,7 @@
         except IOError, e:
             pass
 
-        if not latest:
-            latest = svn.ra.get_latest_revnum(self.ra)
-        dirent = svn.ra.stat(self.ra, self.module, latest)
-        if not dirent:
-            raise util.Abort('module %s not found in revision %d' % (self.module, latest))
-        self.last_changed = dirent.created_rev
+        self.last_changed = self.latest(self.module, latest)
 
         self.head = self.rev(self.last_changed)
 
@@ -134,7 +129,23 @@
 
     def revnum(self, rev):
         return int(rev.split('@')[-1])
-            
+
+    def latest(self, path, revnum, stop=0):
+        'find the latest revision affecting path, up to stop'
+        if not stop:
+            stop = svn.ra.get_latest_revnum(self.ra)
+        try:
+            self.reparent('')
+            dirent = svn.ra.stat(self.ra, path.strip('/'), stop)
+            self.reparent(self.module)
+        except SubversionException:
+            dirent = None
+        if not dirent:
+            raise util.Abort('module %s not found up to revision %d' \
+                             % (self.module, stop))
+
+        return dirent.created_rev
+
     def get_blacklist(self):
         """Avoid certain revision numbers.
         It is not uncommon for two nearby revisions to cancel each other