]> asedeno.scripts.mit.edu Git - git-svn-keywords.git/commitdiff
Add exception handling for stale files master
authorAlejandro R. Sedeño <asedeno@mit.edu>
Wed, 21 Mar 2012 15:59:41 +0000 (11:59 -0400)
committerAlejandro R. Sedeño <asedeno@mit.edu>
Wed, 21 Mar 2012 16:01:10 +0000 (12:01 -0400)
git-svn-keywords.py

index 4624e2f26fe55a3cda30c510dbb97aeec6700093..b130d131673228393da0a0d601441e0a84bc5b3d 100755 (executable)
@@ -146,7 +146,11 @@ def get_path_info(g, path):
     write_config = False
 
     # parse ls-tree output and get a blob id for path
-    blob = g.git.ls_tree('HEAD', path).split(' ')[2].split("\t")[0]
+    try:
+        blob = g.git.ls_tree('HEAD', path).split(' ')[2].split("\t")[0]
+    except IndexError:
+        print "%s may be a stale file in your workspace." %  path
+        return None
 
     # translate that to a commit id
     if not CONFIG.has_option('BlobToCommit', blob):
@@ -240,7 +244,10 @@ def smudge(g, options):
 
         info_dict = {}
         if not options.clean:
-            info_dict.update(get_path_info(g, path))
+            update_dict = get_path_info(g, path)
+            if not update_dict:
+                continue
+            info_dict.update(update_dict)
             info_dict['URL'] = '/'.join([url_base, path])
             info_dict['Name'] = os.path.basename(path)
             info_dict['Revision'] = str(max(kw_rev, info_dict['Revision']))