bf2c74655b2f

Merge.
[view raw] [browse files]
author Steve Losh <steve@dwaiter.com>
date Wed, 28 Jul 2010 01:26:38 -0400
parents 1d9c439bfe54 (diff) 46a08d99f9b9 (current diff)
children 580225427d99 5a30d0a6ca83 543110450d50
branches/tags (none)
files

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/windows/update_tortoisehg_libs.py	Wed Jul 28 01:26:38 2010 -0400
@@ -0,0 +1,57 @@
+# this script will update tortoisehgs python libs to include the missing libs that hg-review needs
+# (tested with Python 2.6 and Tortoisehg 1.1)
+#
+# Daniel Newton <djpnewton@gmail.com>
+#
+# Version 1.0 (2010/07/28)
+
+import sys
+import os
+
+# check python version
+if sys.version[:3] != '2.6':
+    sys.exit('Need Python 2.6')
+
+# check for windows
+if sys.platform != 'win32':
+    sys.exit('Script only works on win32')
+
+# list of libs to add
+libs = ('Cookie.py', 'decimal.py', 'htmlentitydefs.py', 'code.py', 'codeop.py', 'compiler', 'numbers.py', 'symbol.py', 'uuid.py')
+
+# find python lib path
+pylib_path = os.path.join(os.path.dirname(sys.executable), 'lib')
+
+# find tortoisehg libary.zip
+import _winreg
+hKey = _winreg.OpenKey (_winreg.HKEY_CURRENT_USER, r"Software\TortoiseHg")
+value, type = _winreg.QueryValueEx (hKey, "") # default key value
+hKey.Close()
+torthg_lib_path = os.path.join(value, "library.zip")
+
+# check validity of paths
+if not os.path.exists(pylib_path):
+    sys.exit("%s does not exist" % pylib_path)
+if not os.path.exists(torthg_lib_path):
+    sys.exit("%s does not exist" % torthg_lib_path)
+
+# backup tortoisehg lib
+import shutil
+shutil.copyfile(torthg_lib_path, torthg_lib_path + ".bak")
+
+# add libs to tortoisehg
+import zipfile
+zip = zipfile.ZipFile(torthg_lib_path, 'a')
+for lib in libs:
+    lib_path = os.path.join(pylib_path, lib)
+    lib_path_arcname = os.path.basename(lib_path)
+    zip.write(lib_path, lib_path_arcname)
+    if os.path.isdir(lib_path):
+        child_paths = os.listdir(lib_path)
+        for lib_path_child in child_paths:
+            lib_path_child_arcname = os.path.join(lib_path_arcname, lib_path_child)
+            lib_path_child = os.path.join(lib_path, lib_path_child)
+            zip.write(lib_path_child, lib_path_child_arcname)
+zip.close()
+
+print 'all done'