Mike Bayer committed 9b1cd68

add hg

Comments (0)

Files changed (2)


 import os
-from subprocess import check_call
+from subprocess import check_call, CalledProcessError
 import sys
 import contextlib
         check_call(["git", "remote", "update", "--prune", origin])
+def update_hg_mirror(path):
+    """Update an hg repo
+    """
+    with chdir_as(path):
+        check_call(["hg", "pull"])
 def chdir_as(path):
     currdir = os.getcwd()
             os.path.exists(os.path.join(path, "refs"))
+def is_hg(path):
+    return os.path.exists(os.path.join(path, ".hg")) or \
+            os.path.exists(os.path.join(path, "hgrc"))
 def log(msg, *args):
     print(msg % args)


 """Update every DVCS in a directory.
 import os
-from core import update_git_mirror, is_git, log
+from core import update_git_mirror, is_git, log, \
+        CalledProcessError, is_hg, update_hg_mirror
 import argparse
 def main(argv=None):
         fullpath = os.path.join(basepath, dirname)
         if is_git(fullpath):
             log("Updating git repo: %s", dirname)
-            update_git_mirror(fullpath, "origin")
+            try:
+                update_git_mirror(fullpath, "origin")
+            except CalledProcessError, e:
+                log("Error occurred: %s", e)
+        elif is_hg(fullpath):
+            log("Updating hg repo: %s", dirname)
+            try:
+                update_hg_mirror(fullpath)
+            except CalledProcessError, e:
+                log("Error occurred: %s", e)
             log("Skipping path: %s", dirname)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.