[cig-commits] commit: Updated the obtainRepositories script to handle multiple branches

Mercurial hg at geodynamics.org
Mon Nov 24 11:23:06 PST 2008


changeset:   84:1c784ffa5db0
branch:      v1.2.x
user:        www-data at csd.vpac.org
date:        Mon Nov 17 14:20:22 2008 +1100
files:       obtainRepositories.py
description:
Updated the obtainRepositories script to handle multiple branches


diff -r e730a8517bc8 -r 1c784ffa5db0 obtainRepositories.py
--- a/obtainRepositories.py	Mon Nov 17 14:11:30 2008 +1100
+++ b/obtainRepositories.py	Mon Nov 17 14:20:22 2008 +1100
@@ -4,6 +4,12 @@ import urllib2
 import urllib2
 import ConfigParser
 import os, errno
+
+# hacky way to find out what the name of the branch is
+branch = os.popen('hg branch').readlines()
+branch = branch[0].replace("\n","")
+cwd = os.getcwd()
+
 
 deps = [ \
 	['https://csd.vpac.org/hg/hgforest', '.hg/forest' ], \
@@ -27,6 +33,7 @@ except OSError, e:
 # Download the dependancies...
 u = ui.ui()
 for dep in deps:
+	os.chdir(cwd)
 	try:
 		print dep[1], '...'
 		hg.clone( u, dep[0], dep[1] );
@@ -43,6 +50,15 @@ for dep in deps:
 	except urllib2.URLError, e:
 		print 'Download failed - ', e
 
+	# and heres some more hackyness to get hg to switch branches
+    # I couldn't find any functionality to do this in the python bindings.
+    # JS - 12/11/2008
+    os.chdir(dep[1])
+    try:
+            os.system("hg up "+branch)
+    except:
+            print "fail"
+
 # Tell this root repository that its has forest
 c=ConfigParser.ConfigParser()
 c.read('.hg/hgrc')



More information about the CIG-COMMITS mailing list