]> asedeno.scripts.mit.edu Git - git-svn-keywords.git/commitdiff
Don't cache information about revisions that are not from svn
authorAlejandro R. Sedeño <asedeno@mit.edu>
Fri, 19 Feb 2010 18:51:46 +0000 (13:51 -0500)
committerAlejandro R. Sedeño <asedeno@mit.edu>
Fri, 19 Feb 2010 18:51:46 +0000 (13:51 -0500)
git-svn-keywords.py

index 4abf3b76c6ae97c75e2ede359f5f51c05d1cd461..838e4276113d0e003d9448da53c9bac8c04af7c3 100755 (executable)
@@ -156,28 +156,32 @@ def get_path_info(g, path):
 
     # tranlsate that into an svn revision id
     if not CONFIG.has_option('CommitToRev', commit):
-        CONFIG.set('CommitToRev',commit,g.git.svn('find-rev', commit))
-        write_config = True
-    file_rev = CONFIG.get('CommitToRev', commit)
+        file_rev = g.git.svn('find-rev', commit)
+        if file_rev:
+            CONFIG.set('CommitToRev', commit, file_rev)
+            write_config = True
+    else:
+        file_rev = CONFIG.get('CommitToRev', commit)
 
     # get information about that revision
     info_dict = {}
-    if not CONFIG.has_option('RevInfo', file_rev):
-        for line in g.git.svn('info', path).split("\n"):
-            k, v = line.split(": ", 1)
-            if k == 'Last Changed Date':
-                info_dict['Date'] = v
-            elif k == 'Last Changed Author':
-                info_dict['Author'] = v
-        CONFIG.set('RevInfo', file_rev, info_dict)
-        write_config = True
-    else:
-        info = CONFIG.get('RevInfo', file_rev)
-        info_dict.update(info if type(info) is dict else eval(info))
-
-    if write_config:
-        with open(CONFIG_PATH, 'wb') as f:
-            CONFIG.write(f)
+    if file_rev:
+        if not CONFIG.has_option('RevInfo', file_rev):
+            for line in g.git.svn('info', path).split("\n"):
+                k, v = line.split(": ", 1)
+                if k == 'Last Changed Date':
+                    info_dict['Date'] = v
+                elif k == 'Last Changed Author':
+                    info_dict['Author'] = v
+            CONFIG.set('RevInfo', file_rev, info_dict)
+            write_config = True
+        else:
+            info = CONFIG.get('RevInfo', file_rev)
+            info_dict.update(info if type(info) is dict else eval(info))
+
+        if write_config:
+            with open(CONFIG_PATH, 'wb') as f:
+                CONFIG.write(f)
 
     info_dict['Revision'] = file_rev
     return info_dict