changeset 32:fa1fe03ad924

STUB: silvermirror/hg.py
author Jeff Hammel <k0scist@gmail.com>
date Fri, 31 Jan 2014 21:05:34 -0800
parents 2adda506392b
children d5e0bce5e411
files silvermirror/hg.py
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/silvermirror/hg.py	Fri Jan 31 20:34:34 2014 -0800
+++ b/silvermirror/hg.py	Fri Jan 31 21:05:34 2014 -0800
@@ -8,6 +8,7 @@
 import os
 import sys
 import argparse
+from hglib.error import ServerError
 
 _import_error = None
 try:
@@ -16,21 +17,18 @@
     pass
 
 
-def update(host, path):
+def update(source, path):
     """
     get changes from host on path
     """
-    url = '%s/%s' % (host, path)
     try:
-        repo = hg.repository(path)
+        repo = hglib.open(path)
         print ('Updating {}:'.format(path))
-    except Exception, e:
-        repo = hg.repository(_ui, url)
+        repo.pull(host, update=True, insecure=True)
+    except ServerError:
         print ('Cloning {} -> {}'.format(url, path))
-        commands.clone(_ui, repo, pull=False, uncompressed=False, rev=None, noupdate=False)
-        return
+        repo = hglib.clone(source, path)
 
-    commands.pull(_ui, repo, url, rev=None, force=False, update=True)
 
 # TODO: local repository
 # def repositories(path):
@@ -93,7 +91,8 @@
     if not os.path.exists(options.directory):
         os.mkdir(options.directory)
     for repo in repos:
-        update(options.host, repo)
+        dest = os.path.join(options.directory, repo)
+        update(options.host, dest)
 
 if __name__ == '__main__':
     main()