Mercurial > hg
annotate contrib/darcs2hg.py @ 5350:bd706eb8bc25
darcs2hg: Added support for darcs tags.
author | Terry Smith <terry@t11e.com> |
---|---|
date | Tue, 11 Sep 2007 13:30:37 -0400 |
parents | ad8783fe20f7 |
children | 6b6104430964 |
rev | line source |
---|---|
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
2 # Encoding: iso-8859-1 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
3 # vim: tw=80 ts=4 sw=4 noet |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
4 # ----------------------------------------------------------------------------- |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
5 # Project : Basic Darcs to Mercurial conversion script |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
6 # ----------------------------------------------------------------------------- |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
7 # Authors : Sebastien Pierre <sebastien@xprima.com> |
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
8 # TK Soh <teekaysoh@gmail.com> |
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
9 # ----------------------------------------------------------------------------- |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
10 # Creation : 24-May-2006 |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
11 # Last mod : 05-Jun-2006 |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
12 # ----------------------------------------------------------------------------- |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
13 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
14 import os, sys |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
15 import tempfile |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
16 import xml.dom.minidom as xml_dom |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
17 from time import strptime, mktime |
5349
ad8783fe20f7
darcs2hg: Now detects and recovers from simple darcs conflicts.
Terry Smith <terry@t11e.com>
parents:
5348
diff
changeset
|
18 import re |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
19 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
20 DARCS_REPO = None |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
21 HG_REPO = None |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
22 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
23 USAGE = """\ |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
24 %s DARCSREPO HGREPO [SKIP] |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
25 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
26 Converts the given Darcs repository to a new Mercurial repository. The given |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
27 HGREPO must not exist, as it will be created and filled up (this will avoid |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
28 overwriting valuable data. |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
29 |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
30 In case an error occurs within the process, you can resume the process by |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
31 giving the last successfuly applied change number. |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
32 """ % (os.path.basename(sys.argv[0])) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
33 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
34 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
35 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
36 # Utilities |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
37 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
38 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
39 |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
40 def cmd(text, path=None, silent=False): |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
41 """Executes a command, in the given directory (if any), and returns the |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
42 command result as a string.""" |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
43 cwd = None |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
44 if path: |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
45 path = os.path.abspath(path) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
46 cwd = os.getcwd() |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
47 os.chdir(path) |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
48 if not silent: print "> ", text |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
49 res = os.popen(text).read() |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
50 if path: |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
51 os.chdir(cwd) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
52 return res |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
53 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
54 def writefile(path, data): |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
55 """Writes the given data into the given file.""" |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
56 f = file(path, "w") ; f.write(data) ; f.close() |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
57 |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
58 def error( *args ): |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
59 sys.stderr.write("ERROR: ") |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
60 for a in args: sys.stderr.write(str(a)) |
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
61 sys.stderr.write("\n") |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
62 sys.stderr.write("You can make manual fixes if necessary and then resume by" |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
63 " giving the last changeset number") |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
64 sys.exit(-1) |
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
65 |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
66 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
67 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
68 # Darcs interface |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
69 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
70 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
71 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
72 def darcs_changes(darcsRepo): |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
73 """Gets the changes list from the given darcs repository. This returns the |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
74 chronological list of changes as (change name, change summary).""" |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
75 changes = cmd("darcs changes --reverse --xml-output", darcsRepo) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
76 doc = xml_dom.parseString(changes) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
77 for patch_node in doc.childNodes[0].childNodes: |
3673
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2749
diff
changeset
|
78 name = filter(lambda n: n.nodeName == "name", patch_node.childNodes) |
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2749
diff
changeset
|
79 comm = filter(lambda n: n.nodeName == "comment", patch_node.childNodes) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
80 if not name:continue |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
81 else: name = name[0].childNodes[0].data |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
82 if not comm: comm = "" |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
83 else: comm = comm[0].childNodes[0].data |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
84 author = patch_node.getAttribute("author") |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
85 date = patch_node.getAttribute("date") |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
86 chash = os.path.splitext(patch_node.getAttribute("hash"))[0] |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
87 yield author, date, name, chash, comm |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
88 |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
89 def darcs_tip(darcs_repo): |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
90 changes = cmd("darcs changes",darcs_repo,silent=True) |
3673
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2749
diff
changeset
|
91 changes = filter(lambda l: l.strip().startswith("* "), changes.split("\n")) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
92 return len(changes) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
93 |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
94 def darcs_pull(hg_repo, darcs_repo, chash): |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
95 old_tip = darcs_tip(darcs_repo) |
2749
d13e4ffaa79d
[darcs2hg] Windows compatibilty patct
Sébastien Pierre <sebastien@xprima.com>
parents:
2588
diff
changeset
|
96 res = cmd("darcs pull \"%s\" --all --match=\"hash %s\"" % (darcs_repo, chash), hg_repo) |
5349
ad8783fe20f7
darcs2hg: Now detects and recovers from simple darcs conflicts.
Terry Smith <terry@t11e.com>
parents:
5348
diff
changeset
|
97 if re.search('^We have conflicts in the following files:$', res, re.MULTILINE): |
ad8783fe20f7
darcs2hg: Now detects and recovers from simple darcs conflicts.
Terry Smith <terry@t11e.com>
parents:
5348
diff
changeset
|
98 print "Trying to revert files to work around conflict..." |
ad8783fe20f7
darcs2hg: Now detects and recovers from simple darcs conflicts.
Terry Smith <terry@t11e.com>
parents:
5348
diff
changeset
|
99 rev_res = cmd ("darcs revert --all", hg_repo) |
ad8783fe20f7
darcs2hg: Now detects and recovers from simple darcs conflicts.
Terry Smith <terry@t11e.com>
parents:
5348
diff
changeset
|
100 print rev_res |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
101 print res |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
102 new_tip = darcs_tip(darcs_repo) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
103 if not new_tip != old_tip + 1: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
104 error("Darcs pull did not work as expected: " + res) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
105 |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
106 def darcs_changes_summary(darcs_repo, chash): |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
107 """Gets the changes from the darcs summary. This returns the chronological |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
108 list of changes as (change_type, args). Eg. ('add_file', 'foo.txt') or |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
109 ('move', ['foo.txt','bar.txt']).""" |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
110 change = cmd("darcs changes --summary --xml-output --match=\"hash %s\"" % (chash), darcs_repo) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
111 doc = xml_dom.parseString(change) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
112 for patch_node in doc.childNodes[0].childNodes: |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
113 summary_nodes = filter(lambda n: n.nodeName == "summary" and n.nodeType == n.ELEMENT_NODE, patch_node.childNodes) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
114 for summary_node in summary_nodes: |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
115 change_nodes = filter(lambda n: n.nodeType == n.ELEMENT_NODE, summary_node.childNodes) |
5350
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
116 if len(change_nodes) == 0: |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
117 name = filter(lambda n: n.nodeName == "name", patch_node.childNodes) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
118 if not name: |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
119 error("Darcs patch has an empty summary node and no name: " + patch_node.toxml()) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
120 name = name[0].childNodes[0].data.strip() |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
121 (tag, sub_count) = re.subn('^TAG ', '', name, 1) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
122 if sub_count != 1: |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
123 error("Darcs patch has an empty summary node but doesn't look like a tag: " + patch_node.toxml()); |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
124 for change_node in change_nodes: |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
125 change = change_node.nodeName |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
126 if change == 'modify_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
127 yield change, change_node.childNodes[0].data.strip() |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
128 elif change == 'add_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
129 yield change, change_node.childNodes[0].data.strip() |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
130 elif change == 'remove_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
131 yield change, change_node.childNodes[0].data.strip() |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
132 elif change == 'add_directory': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
133 yield change, change_node.childNodes[0].data.strip() |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
134 elif change == 'remove_directory': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
135 yield change, change_node.childNodes[0].data.strip() |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
136 elif change == 'move': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
137 yield change, (change_node.getAttribute('from'), change_node.getAttribute('to')) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
138 else: |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
139 error('Problem parsing summary xml: Unexpected element: ' + change_node.toxml()) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
140 |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
141 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
142 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
143 # Mercurial interface |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
144 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
145 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
146 |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
147 def hg_commit( hg_repo, text, author, date ): |
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
148 fd, tmpfile = tempfile.mkstemp(prefix="darcs2hg_") |
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
149 writefile(tmpfile, text) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
150 old_tip = hg_tip(hg_repo) |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
151 cmd("hg add -X _darcs", hg_repo) |
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
152 cmd("hg remove -X _darcs --after", hg_repo) |
2749
d13e4ffaa79d
[darcs2hg] Windows compatibilty patct
Sébastien Pierre <sebastien@xprima.com>
parents:
2588
diff
changeset
|
153 res = cmd("hg commit -l %s -u \"%s\" -d \"%s 0\"" % (tmpfile, author, date), hg_repo) |
d13e4ffaa79d
[darcs2hg] Windows compatibilty patct
Sébastien Pierre <sebastien@xprima.com>
parents:
2588
diff
changeset
|
154 os.close(fd) |
2352
61909dfb316d
various fixes to darcs conversion script
TK Soh <teekaysoh@yahoo.com>
parents:
2349
diff
changeset
|
155 os.unlink(tmpfile) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
156 new_tip = hg_tip(hg_repo) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
157 if not new_tip == old_tip + 1: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
158 # Sometimes we may have empty commits, we simply skip them |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
159 if res.strip().lower().find("nothing changed") != -1: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
160 pass |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
161 else: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
162 error("Mercurial commit did not work as expected: " + res) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
163 |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
164 def hg_tip( hg_repo ): |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
165 """Returns the latest local revision number in the given repository.""" |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
166 tip = cmd("hg tip", hg_repo, silent=True) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
167 tip = tip.split("\n")[0].split(":")[1].strip() |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
168 return int(tip) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
169 |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
170 def hg_rename( hg_repo, from_file, to_file ): |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
171 cmd("hg rename --after \"%s\" \"%s\"" % (from_file, to_file), hg_repo); |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
172 |
5350
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
173 def hg_tag ( hg_repo, text, author, date ): |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
174 old_tip = hg_tip(hg_repo) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
175 res = cmd("hg tag -u \"%s\" -d \"%s 0\" \"%s\"" % (author, date, text), hg_repo) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
176 new_tip = hg_tip(hg_repo) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
177 if not new_tip == old_tip + 1: |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
178 error("Mercurial tag did not work as expected: " + res) |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
179 |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
180 def hg_handle_change( hg_repo, author, date, change, arg ): |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
181 """Processes a change event as output by darcs_changes_summary. These |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
182 consist of file move/rename/add/delete commands.""" |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
183 if change == 'modify_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
184 pass |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
185 elif change == 'add_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
186 pass |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
187 elif change =='remove_file': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
188 pass |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
189 elif change == 'add_directory': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
190 pass |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
191 elif change == 'remove_directory': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
192 pass |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
193 elif change == 'move': |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
194 hg_rename(hg_repo, arg[0], arg[1]) |
5350
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
195 elif change == 'tag': |
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
196 hg_tag(hg_repo, arg, author, date) |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
197 else: |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
198 error('Unknown change type ' + change + ': ' + arg) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
199 |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
200 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
201 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
202 # Main |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
203 # |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
204 # ------------------------------------------------------------------------------ |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
205 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
206 if __name__ == "__main__": |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
207 args = sys.argv[1:] |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
208 # We parse the arguments |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
209 if len(args) == 2: |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
210 darcs_repo = os.path.abspath(args[0]) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
211 hg_repo = os.path.abspath(args[1]) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
212 skip = None |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
213 elif len(args) == 3: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
214 darcs_repo = os.path.abspath(args[0]) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
215 hg_repo = os.path.abspath(args[1]) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
216 skip = int(args[2]) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
217 else: |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
218 print USAGE |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
219 sys.exit(-1) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
220 # Initializes the target repo |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
221 if not os.path.isdir(darcs_repo + "/_darcs"): |
2586
bb63d29ce03d
darcs2hg: improved logging
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
222 print "No darcs directory found at: " + darcs_repo |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
223 sys.exit(-1) |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
224 if not os.path.isdir(hg_repo): |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
225 os.mkdir(hg_repo) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
226 elif skip == None: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
227 print "Given HG repository must not exist when no SKIP is specified." |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
228 sys.exit(-1) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
229 if skip == None: |
2749
d13e4ffaa79d
[darcs2hg] Windows compatibilty patct
Sébastien Pierre <sebastien@xprima.com>
parents:
2588
diff
changeset
|
230 cmd("hg init \"%s\"" % (hg_repo)) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
231 cmd("darcs initialize", hg_repo) |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
232 # Get the changes from the Darcs repository |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
233 change_number = 0 |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
234 for author, date, summary, chash, description in darcs_changes(darcs_repo): |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
235 print "== changeset", change_number, |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
236 if skip != None and change_number <= skip: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
237 print "(skipping)" |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
238 else: |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
239 text = summary + "\n" + description |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
240 # The commit hash has a date like 20021020201112 |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
241 # --------------------------------YYYYMMDDHHMMSS |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
242 date = chash.split("-")[0] |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
243 epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S'))) |
5348
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
244 darcs_pull(hg_repo, darcs_repo, chash) |
b62a59fa9d26
darcs2hg: Now understands files that were explicitly renamed in darcs.
Terry Smith <terry@t11e.com>
parents:
3673
diff
changeset
|
245 for change, arg in darcs_changes_summary(darcs_repo, chash): |
5350
bd706eb8bc25
darcs2hg: Added support for darcs tags.
Terry Smith <terry@t11e.com>
parents:
5349
diff
changeset
|
246 hg_handle_change(hg_repo, author, epoch, change, arg) |
2587
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
247 hg_commit(hg_repo, text, author, epoch) |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
248 change_number += 1 |
fe3e87358b47
darcs2hg: pause and resume support, date extraction from commit hash, does not break on empty commits
Sébastien Pierre <sebastien@xprima.com>
parents:
2585
diff
changeset
|
249 print "Darcs repository (_darcs) was not deleted. You can keep or remove it." |
2349
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
250 |
88c881bda888
darcs2hg.py: import darcs project into mercurial
Sébastien Pierre <sebastien@xprima.com>
parents:
diff
changeset
|
251 # EOF |