##// END OF EJS Templates
various fixes to darcs conversion script...
TK Soh -
r2352:61909dfb default
parent child Browse files
Show More
@@ -13,7 +13,9 b''
13 # -----------------------------------------------------------------------------
13 # -----------------------------------------------------------------------------
14
14
15 import os, sys
15 import os, sys
16 import tempfile
16 import xml.dom.minidom as xml_dom
17 import xml.dom.minidom as xml_dom
18 from time import strptime, mktime
17
19
18 DARCS_REPO = None
20 DARCS_REPO = None
19 HG_REPO = None
21 HG_REPO = None
@@ -25,7 +27,7 b' USAGE = """\\'
25 HGREPO must not exist, as it will be created and filled up (this will avoid
27 HGREPO must not exist, as it will be created and filled up (this will avoid
26 overwriting valuable data.
28 overwriting valuable data.
27
29
28 """ % (os.path.basename(__file__))
30 """ % (os.path.basename(sys.argv[0]))
29
31
30 # ------------------------------------------------------------------------------
32 # ------------------------------------------------------------------------------
31 #
33 #
@@ -70,8 +72,9 b' def darcs_changes(darcsRepo):'
70 else: name = name[0].childNodes[0].data
72 else: name = name[0].childNodes[0].data
71 if not comm: comm = ""
73 if not comm: comm = ""
72 else: comm = comm[0].childNodes[0].data
74 else: comm = comm[0].childNodes[0].data
73 res.append([name, comm])
75 author = patch_node.getAttribute("author")
74 return res
76 date = patch_node.getAttribute("date")
77 yield author, date, name, comm
75
78
76 def darcs_pull(hg_repo, darcs_repo, change):
79 def darcs_pull(hg_repo, darcs_repo, change):
77 cmd("darcs pull '%s' --all --patches='%s'" % (darcs_repo, change), hg_repo)
80 cmd("darcs pull '%s' --all --patches='%s'" % (darcs_repo, change), hg_repo)
@@ -82,11 +85,13 b' def darcs_pull(hg_repo, darcs_repo, chan'
82 #
85 #
83 # ------------------------------------------------------------------------------
86 # ------------------------------------------------------------------------------
84
87
85 def hg_commit( hg_repo, text ):
88 def hg_commit( hg_repo, text, author, date ):
86 writefile("/tmp/msg", text)
89 fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_")
87 cmd("hg add -X _darcs *", hg_repo)
90 writefile(tmpfile, text)
88 cmd("hg commit -l /tmp/msg", hg_repo)
91 cmd("hg add -X _darcs", hg_repo)
89 os.unlink("/tmp/msg")
92 cmd("hg remove -X _darcs --after", hg_repo)
93 cmd("hg commit -l %s -u '%s' -d '%s 0'" % (tmpfile, author, date), hg_repo)
94 os.unlink(tmpfile)
90
95
91 # ------------------------------------------------------------------------------
96 # ------------------------------------------------------------------------------
92 #
97 #
@@ -115,10 +120,11 b' if __name__ == "__main__":'
115 cmd("hg init '%s'" % (hg_repo))
120 cmd("hg init '%s'" % (hg_repo))
116 cmd("darcs initialize", hg_repo)
121 cmd("darcs initialize", hg_repo)
117 # Get the changes from the Darcs repository
122 # Get the changes from the Darcs repository
118 for summary, description in darcs_changes(darcs_repo):
123 for author, date, summary, description in darcs_changes(darcs_repo):
119 text = summary + "\n" + description
124 text = summary + "\n" + description
120 darcs_pull(hg_repo, darcs_repo, summary)
125 darcs_pull(hg_repo, darcs_repo, summary)
121 hg_commit(hg_repo, text)
126 epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S')))
127 hg_commit(hg_repo, text, author, epoch)
122
128
123 # EOF
129 # EOF
124
130
General Comments 0
You need to be logged in to leave comments. Login now