Morpheus / Mbed OS mbed-Client-Morpheus-hg

Dependencies:   mbed-os

Revision:
47:386f8c519142
Parent:
46:915be4b5a8f0
Child:
48:6cb5440dd984
--- a/neo.py	Fri Apr 01 00:33:14 2016 +0100
+++ b/neo.py	Fri Apr 01 00:45:22 2016 +0100
@@ -10,6 +10,10 @@
 from collections import *
 from itertools import *
 
+# Default paths to Mercurial and Git
+hg_cmd = "hg"
+git_cmd = r"C:\Program Files\Git\bin\git.exe"
+
 # Subparser handling
 parser = argparse.ArgumentParser()
 subparsers = parser.add_subparsers()
@@ -86,7 +90,7 @@
 @staticclass
 class Hg(object):
     def clone(url, name=None, hash=None):
-        popen(['hg', 'clone', url, name] + (['-u', hash] if hash else []))
+        popen([hg_cmd, 'clone', url, name] + (['-u', hash] if hash else []))
 
         # add exclude file
         with cd(name):
@@ -94,22 +98,22 @@
                 f.write('[ui]\n')
                 f.write('ignore.local = .hg/hgignore\n')
 
-    def add(file): popen(['hg', 'add', file])
+    def add(file): popen([hg_cmd, 'add', file])
     def remove(file):
-        popen(['hg', 'rm', '-f', file])
+        popen([hg_cmd, 'rm', '-f', file])
         try:
             os.remove(file)
         except OSError:
             pass
 
-    def commit(): popen(['hg', 'commit'])
-    def push(): popen(['hg', 'push'])
+    def commit(): popen([hg_cmd, 'commit'])
+    def push(): popen([hg_cmd, 'push'])
     def pull(hash=None):
-        popen(['hg', 'pull'])
-        popen(['hg', 'update'] + (['-r', hash] if hash else []))
+        popen([hg_cmd, 'pull'])
+        popen([hg_cmd, 'update'] + (['-r', hash] if hash else []))
 
-    def hash(): return pquery(['hg', 'id', '-i']).strip().strip('+')
-    def dirty(): return pquery(['hg', 'status', '-q'])
+    def hash(): return pquery([hg_cmd, 'id', '-i']).strip().strip('+')
+    def dirty(): return pquery([hg_cmd, 'status', '-q'])
 
     def ignore(file):
         file = '^%s/' % file
@@ -138,22 +142,22 @@
 @staticclass
 class Git(object):
     def clone(url, name=None, hash=None):
-        popen(['git', 'clone', url, name])
+        popen([git_cmd, 'clone', url, name])
         if hash:
             with cd(name):
-                popen(['git', 'checkout', '-q', hash])
+                popen([git_cmd, 'checkout', '-q', hash])
 
-    def add(file): popen(['git', 'add', file])
-    def remove(file): popen(['git', 'rm', '-f', file])
+    def add(file): popen([git_cmd, 'add', file])
+    def remove(file): popen([git_cmd, 'rm', '-f', file])
 
-    def commit(): popen(['git', 'commit', '-a'])
-    def push(): popen(['git', 'push', '--all'])
+    def commit(): popen([git_cmd, 'commit', '-a'])
+    def push(): popen([git_cmd, 'push', '--all'])
     def pull(hash=None):
-        popen(['git', 'fetch', 'origin'])
-        popen(['git', 'merge'] + ([hash] if hash else []))
+        popen([git_cmd, 'fetch', 'origin'])
+        popen([git_cmd, 'merge'] + ([hash] if hash else []))
 
-    def hash(): return pquery(['git', 'rev-parse', '--short', 'HEAD']).strip()
-    def dirty(): return pquery(['git', 'diff', '--name-only', 'HEAD'])
+    def hash(): return pquery([git_cmd, 'rev-parse', '--short', 'HEAD']).strip()
+    def dirty(): return pquery([git_cmd, 'diff', '--name-only', 'HEAD'])
 
     def ignore(file):
         exclude = '.git/info/exclude'