Commits

Stefan Scherfke committed 7e64b41

Rewrote update_vim.py and renamed it to update_subrepos.py.

Comments (0)

Files changed (2)

update_subrepos.py

+#!/usr/bin/env python3
+import re
+import subprocess
+
+
+repo = re.compile(r'\[(\w+)\](.*)')
+commands = {
+    'hg': 'hg pull -u',
+    'git': 'git pull',
+    'svn': 'svn up',
+}
+
+for line in open('.hgsub'):
+    if not line.strip():
+        continue
+
+    local_dir, repo_def = line.split(' = ')
+    repo_type, repo_url = repo.match(repo_def).groups()
+
+    print('- Updating %s ...' % local_dir)
+    subprocess.call(commands[repo_type], cwd=local_dir, shell=True)

update_vim.py

-#!/usr/bin/env python3
-import os
-import os.path
-import subprocess
-
-
-BUNDLE_DIR = '_vim/bundle'
-
-
-def update():
-    repo_types = {
-        '.git': 'git pull',
-        '.hg': 'hg pull -u',
-        '.svn': 'svn up',
-    }
-    for entry in os.listdir(BUNDLE_DIR):
-        for rtype, cmd in repo_types.items():
-            path = os.path.join(BUNDLE_DIR, entry)
-            if os.path.isdir(os.path.join(path, rtype)):
-                print('- Updating %s ...' % entry)
-                subprocess.call(cmd, cwd=path, shell=True)
-
-
-if __name__ == '__main__':
-    update()