Show More
@@ -13,7 +13,9 b'' | |||
|
13 | 13 | # ----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | import os, sys |
|
16 | import tempfile | |
|
16 | 17 | import xml.dom.minidom as xml_dom |
|
18 | from time import strptime, mktime | |
|
17 | 19 | |
|
18 | 20 | DARCS_REPO = None |
|
19 | 21 | HG_REPO = None |
@@ -25,7 +27,7 b' USAGE = """\\' | |||
|
25 | 27 | HGREPO must not exist, as it will be created and filled up (this will avoid |
|
26 | 28 | overwriting valuable data. |
|
27 | 29 | |
|
28 |
""" % (os.path.basename( |
|
|
30 | """ % (os.path.basename(sys.argv[0])) | |
|
29 | 31 | |
|
30 | 32 | # ------------------------------------------------------------------------------ |
|
31 | 33 | # |
@@ -70,8 +72,9 b' def darcs_changes(darcsRepo):' | |||
|
70 | 72 | else: name = name[0].childNodes[0].data |
|
71 | 73 | if not comm: comm = "" |
|
72 | 74 | else: comm = comm[0].childNodes[0].data |
|
73 | res.append([name, comm]) | |
|
74 | return res | |
|
75 | author = patch_node.getAttribute("author") | |
|
76 | date = patch_node.getAttribute("date") | |
|
77 | yield author, date, name, comm | |
|
75 | 78 | |
|
76 | 79 | def darcs_pull(hg_repo, darcs_repo, change): |
|
77 | 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 ): | |
|
86 | writefile("/tmp/msg", text) | |
|
87 | cmd("hg add -X _darcs *", hg_repo) | |
|
88 |
cmd("hg |
|
|
89 | os.unlink("/tmp/msg") | |
|
88 | def hg_commit( hg_repo, text, author, date ): | |
|
89 | fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_") | |
|
90 | writefile(tmpfile, text) | |
|
91 | cmd("hg add -X _darcs", hg_repo) | |
|
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 | 120 | cmd("hg init '%s'" % (hg_repo)) |
|
116 | 121 | cmd("darcs initialize", hg_repo) |
|
117 | 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 | 124 | text = summary + "\n" + description |
|
120 | 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 | 129 | # EOF |
|
124 | 130 |
General Comments 0
You need to be logged in to leave comments.
Login now