Commits

Anonymous committed af048af Merge

merge tiem fix.

Comments (0)

Files changed (2)

 if not isdir(DIR) and not isdir(join(DIR, ".hg")): 
 	dis(["clone", URL, DIR])
 
-chdir("burner")
+chdir(DIR)
 
 # Get the burner repo for the id command
 repo = hg.repository(ui.ui(), path = ".")
+#!/usr/bin/env python
+# encoding: utf-8
+
+"""Join up to do two commits a second to a centralized repo.
+
+usage: 
+	- python burn.py [--url URL] [--target-dir DIR] [--timeout SECONDS]
+
+options: 
+	--url set the url for clone, pull and push
+	--target-dir the path to the local repo
+	--timeout the number of seconds to wait between subsequent pulls
+"""
+
+# First give help output
+
+from sys import argv
+if "--help" in argv or "-h" in argv: 
+	print __doc__
+	exit()
+
+# Now parse the rest of the command line
+
+#: Url to use for clone, pull and push
+URL = "http://edrikor.dyndns.org:6666"
+if "--url" in argv: 
+	URL = argv[argv.index("--url") + 1]
+	argv.remove("--url")
+	argv.remove(URL)
+
+#: Target dir for our local clone
+DIR = "burner"
+if "--target-dir" in argv: 
+	DIR = argv[argv.index("--target-dir") + 1]
+	argv.remove("--target-dir")
+	argv.remove(DIR)
+
+#: Wait time between pulls
+TIME = 10
+if "--timeout" in argv: 
+	TIME = argv[argv.index("--timeout") + 1]
+	argv.remove("--timeout")
+	argv.remove(TIME)
+	TIME = float(TIME)
+
+
+from mercurial import hg, ui
+from time import sleep
+from os.path import isdir, isfile, join
+from os import chdir
+from subprocess import call
+
+# First get the distributed repo
+
+if not isdir(DIR) and not isdir(join(DIR, ".hg")): 
+	call(["hg", "clone", URL, DIR])
+
+chdir(DIR)
+
+# Get the burner repo for the id command
+repo = hg.repository(ui.ui(), path = ".")
+
+# Now add the evil committer 
+def evil_committer(): 
+	"""Do a pull, then a merge and finally push.
+
+This should create no merge problems, since noone will create new remote heads, so merges should 
+always work.
+""" 
+	# First pull changes, merge and commit (first commit)
+	call(["hg", "pull", "-u"])
+	call(["hg", "merge"])
+	call(["hg", "resolve", "-m"])
+	call(["hg", "ci", "-m", "scripted merge"])
+	call(["hg", "push"])
+	
+	# Then replace the content of servername.txt by the id and commit again
+	ctx = hg.localrepo.context.changectx(repo)
+	# if we don't have a servername.txt, yet
+	NEED_TO_ADD = not isfile("servername.txt")
+	hex = ctx.hex()
+
+	# First check, if the content in servername is the hex. If yes, we just use "null". 
+	try: 
+		f = open("servername.txt", "r")
+		if f.read() == hex:
+			hex = "null"
+		f.close()
+	except: 
+		# file doesn't exist yet - don't care :) 
+		pass
+	f = open("servername.txt", "w")
+	f.write(hex)
+	f.close()
+	if NEED_TO_ADD: 
+		call(["hg", "add"])
+	call(["hg", "commit", "-m", "servername commit"])
+	
+
+# Now start the while loop for eternity :) 
+
+while True: 
+	# Do the two commits
+	evil_committer()
+	# And sleep for a second, so we do _at most_ two commits a second. 
+	sleep(TIME)
+
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 ProjectModifiedEvent.java.
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.