[PATCH 1 of 2] Import darcs tags
Guy Brand
gb at isis.u-strasbg.fr
Sun Feb 25 19:35:02 UTC 2007
# HG changeset patch
# User Guy Brand <gb at isis.u-strasbg.fr>
# Date 1172431742 -3600
# Node ID c482eec9a4b2c7a56d38a7f2b0356ad219ab6efb
# Parent 97251938485365716a52aebb013d271ba5f55e68
Import darcs tags
diff -r 972519384853 -r c482eec9a4b2 contrib/darcs2hg.py
--- a/contrib/darcs2hg.py Fri Feb 23 14:16:50 2007 -0600
+++ b/contrib/darcs2hg.py Sun Feb 25 20:29:02 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
@@ -127,6 +127,14 @@ def hg_tip( hg_repo ):
tip = tip.split("\n")[0].split(":")[1].strip()
return int(tip)
+def hg_tag( hg_repo, text, author, date ):
+ text = text.strip()
+ 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)
+
# ------------------------------------------------------------------------------
#
# Main
@@ -172,7 +180,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)
+ if text.startswith('TAG '):
+ (label, tag) = text.split(' ', 1)
+ hg_tag(hg_repo, tag, author, epoch)
+ else:
+ hg_commit(hg_repo, text, author, epoch)
change_number += 1
print "Darcs repository (_darcs) was not deleted. You can keep or remove it."
More information about the Mercurial-devel
mailing list