]> asedeno.scripts.mit.edu Git - git-svn-keywords.git/commitdiff
Just scan the entire .git/svn tree for 'unhandled.log's
authorAlejandro R. Sedeño <asedeno@mit.edu>
Wed, 10 Feb 2010 16:47:00 +0000 (11:47 -0500)
committerAlejandro R. Sedeño <asedeno@mit.edu>
Wed, 10 Feb 2010 16:47:00 +0000 (11:47 -0500)
git-svn-keywords.py

index dd2ec130dd77c6227b934ddc798ba049312574da..761b10883e10c0b4d4368edb6af4f1145748c471 100755 (executable)
@@ -67,30 +67,38 @@ def get_svn_keyword_re(s):
     return svn_keywords_re[s]
 
 # Parse the unhandled log.
-def _do_parse_unhandled(f, lastrev=None):
-    # Compile the regular expressions we'll be using here.
-    re_rev = re.compile("^r(\d+)$")
-    re_keywords = re.compile("^\s+[-+]file_prop: (\S+) svn:keywords ?(\S*)$")
-
+def _do_parse_unhandled(directory, lastrev=None):
+    base = os.path.join(directory)
     rev = None
-    for line in f:
-        m = re_rev.match(line)
-        if m:
-            rev = m.group(1)
-            continue
-
-        if (lastrev >= int(rev)):
-            continue
-
-        m = re_keywords.match(line)
-        if m:
-            path = urllib.unquote(m.group(1))
-            keywords = set(urllib.unquote(m.group(2)).split(' '))
-            if not FILES.has_section(path):
-                FILES.add_section(path)
-            FILES.set(path, rev, keywords)
-
-    lastrev = max(int(rev), lastrev)
+    for d in os.listdir(base):
+        subent = os.path.join(base, d)
+        if (d == 'unhandled.log' and os.path.isfile(subent)):
+            with open(subent, 'r') as f:
+                # Compile the regular expressions we'll be using here.
+                re_rev = re.compile("^r(\d+)$")
+                re_keywords = re.compile("^\s+[-+]file_prop: (\S+) svn:keywords ?(\S*)$")
+
+                for line in f:
+                    m = re_rev.match(line)
+                    if m:
+                        rev = m.group(1)
+                        continue
+
+                    if (lastrev >= int(rev)):
+                        continue
+
+                    m = re_keywords.match(line)
+                    if m:
+                        path = urllib.unquote(m.group(1))
+                        keywords = set(urllib.unquote(m.group(2)).split(' '))
+                        if not FILES.has_section(path):
+                            FILES.add_section(path)
+                        FILES.set(path, rev, keywords)
+        elif (os.path.isdir(subent)):
+            _do_parse_unhandled(subent, lastrev=lastrev)
+
+    if rev:
+        lastrev = max(int(rev), lastrev)
     CONFIG.set('core', 'lastrev', lastrev)
     CONFIG.set('core', 'version', VERSION)
 
@@ -111,14 +119,7 @@ def parse_svn_unhandled(g):
         if CONFIG.has_option('core', 'lastrev'):
             lastrev = CONFIG.getint('core', 'lastrev')
 
-    for remote in ['svn', 'svn/refs/remotes']:
-        base = os.path.join(g.path,remote)
-        for d in os.listdir(base):
-            if os.path.isdir(os.path.join(base,d)):
-                unhandled = os.path.join(base,d,'unhandled.log')
-                if os.path.isfile(unhandled):
-                    with open(unhandled, 'r') as f:
-                        _do_parse_unhandled(f, lastrev=lastrev)
+    _do_parse_unhandled(os.path.join(g.path, 'svn'), lastrev=lastrev)
 
     with open(FILES_PATH, 'wb') as f:
         FILES.write(f)