darcs2hg.py: use darcs patch hash as patch identifier
authorNils Decker <mercurial@ndecker.de>
Sun, 09 Jul 2006 21:41:00 -0700
changeset 2585 5ec2dded1bda
parent 2584 1f4703115e28
child 2586 bb63d29ce03d
child 2587 fe3e87358b47
darcs2hg.py: use darcs patch hash as patch identifier The use of the patch name is dangerous when duplicate names exist. In case of a duplicate name the second patch and all its dependancies are merged into a single mercurial patch. The patch identifier (hash) is always unique.
contrib/darcs2hg.py
--- a/contrib/darcs2hg.py	Sun Jul 09 14:42:18 2006 +0200
+++ b/contrib/darcs2hg.py	Sun Jul 09 21:41:00 2006 -0700
@@ -74,7 +74,8 @@
 		else: comm = comm[0].childNodes[0].data
 		author = patch_node.getAttribute("author")
 		date = patch_node.getAttribute("date")
-		yield author, date, name, comm
+        hash = patch_node.getAttribute("hash")
+        yield hash, author, date, name, comm
 
 def darcs_pull(hg_repo, darcs_repo, change):
 	cmd("darcs pull '%s' --all --patches='%s'" % (darcs_repo, change), hg_repo)
@@ -120,9 +121,9 @@
 	cmd("hg init '%s'" % (hg_repo))
 	cmd("darcs initialize", hg_repo)
 	# Get the changes from the Darcs repository
-	for author, date, summary, description in darcs_changes(darcs_repo):
+	for hash, author, date, summary, description in darcs_changes(darcs_repo):
 		text = summary + "\n" + description
-		darcs_pull(hg_repo, darcs_repo, summary)
+		darcs_pull(hg_repo, darcs_repo, hash)
 		epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S')))
 		hg_commit(hg_repo, text, author, epoch)