[PATCH 1 of 3] Import darcs tags

John Goerzen jgoerzen at complete.org
Mon Feb 26 17:02:59 UTC 2007


I may not have looked at this carefully enough, but I believe this patch
is fundamentally broken.

It assumes that a darcs tag applies to all changesets in the darcs repo
up till that point.  That is not necessarily correct.  A darcs repo can
be the result of pulling from multiple branches, just like a hg repo.
So, for instance, I often import upstream tarballs into an upstream
branch, then pull to my local branch and hack.  So you'll see, in the
darcs history, tags that I made in the upstream branch that occur after
hacks to the local branch, but which do not apply to the code in the
local branch.

hg has a notion of this as well, but to make it all work right will take
more work than just replaying the darcs history linearally, I would
think.

-- John

On 2007-02-24, Guy Brand <gb at isis.u-strasbg.fr> wrote:
> # HG changeset patch
> # User Guy Brand <gb at isis.u-strasbg.fr>
> # Date 1171321437 -3600
> # Node ID 9028722e609686fcf7a7675b4a1dd294b092dcfe
> # Parent  97251938485365716a52aebb013d271ba5f55e68
> Import darcs tags
>
> diff -r 972519384853 -r 9028722e6096 contrib/darcs2hg.py
> --- a/contrib/darcs2hg.py	Fri Feb 23 14:16:50 2007 -0600
> +++ b/contrib/darcs2hg.py	Tue Feb 13 00:03:57 2007 +0100
> @@ -11,7 +11,7 @@
>  # Last mod  : 05-Jun-2006
>  # -----------------------------------------------------------------------------
>  
> -import os, sys
> +import os, sys, re
>  import tempfile
>  import xml.dom.minidom as xml_dom
>  from time import strptime, mktime
> @@ -117,6 +117,7 @@ def hg_commit( hg_repo, text, author, da
>  	if not new_tip == old_tip + 1:
>  		# Sometimes we may have empty commits, we simply skip them
>  		if res.strip().lower().find("nothing changed") != -1:
> +			print "Nothing to commit\n"
>  			pass
>  		else:
>  			error("Mercurial commit did not work as expected: " + res)
> @@ -126,6 +127,18 @@ def hg_tip( hg_repo ):
>  	tip = cmd("hg tip", hg_repo, silent=True)
>  	tip = tip.split("\n")[0].split(":")[1].strip()
>  	return int(tip)
> +
> +def hg_tag( hg_repo, text, author, date ):
> +	old_tip = hg_tip(hg_repo)
> +	text = text.strip()
> +	tag_file = hg_repo + "/.hgtags"
> +	res = cmd("hg tags", hg_repo, silent=True)
> +	(dead_text,hit) = re.subn(text,'',res)
> +	if hit == 0:
> +		cmd("hg tag -u \"%s\" -d \"%s 0\" \"%s\""  % (author, date, text), hg_repo)
> +		new_tip = hg_tip(hg_repo)
> +	else:
> +		print "Ignoring already seen tag %s\n" % (text)
>  
>  # ------------------------------------------------------------------------------
>  #
> @@ -172,7 +185,11 @@ if __name__ == "__main__":
>  			# --------------------------------YYYYMMDDHHMMSS
>  			date = chash.split("-")[0]
>  			epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S')))
> -			hg_commit(hg_repo, text, author, epoch)
> +			(text,hit) = re.subn('^TAG ','',text)
> +			if hit == 0:
> +				hg_commit(hg_repo, text, author, epoch)
> +			else:
> +				hg_tag(hg_repo, text, author, epoch)
>  		change_number += 1
>  	print "Darcs repository (_darcs) was not deleted. You can keep or remove it."
>  


-- 
John Goerzen
Author, Foundations of Python Network Programming
http://www.amazon.com/exec/obidos/tg/detail/-/1590593715




More information about the Mercurial mailing list