##// END OF EJS Templates
darcs2hg: improved logging
Sébastien Pierre -
r2586:bb63d29c default
parent child Browse files
Show More
@@ -4,12 +4,11 b''
4 # -----------------------------------------------------------------------------
4 # -----------------------------------------------------------------------------
5 # Project : Basic Darcs to Mercurial conversion script
5 # Project : Basic Darcs to Mercurial conversion script
6 # -----------------------------------------------------------------------------
6 # -----------------------------------------------------------------------------
7 # Author : Sebastien Pierre <sebastien@xprima.com>
7 # Authors : Sebastien Pierre <sebastien@xprima.com>
8 # TK Soh <teekaysoh@gmail.com>
9 # -----------------------------------------------------------------------------
8 # Creation : 24-May-2006
10 # Creation : 24-May-2006
9 # Last mod : 26-May-2006
11 # Last mod : 01-Jun-2006
10 # History :
11 # 26-May-2006 - Updated
12 # 24-May-2006 - First implementation
13 # -----------------------------------------------------------------------------
12 # -----------------------------------------------------------------------------
14
13
15 import os, sys
14 import os, sys
@@ -35,7 +34,7 b' USAGE = """\\'
35 #
34 #
36 # ------------------------------------------------------------------------------
35 # ------------------------------------------------------------------------------
37
36
38 def cmd(text, path=None):
37 def cmd(text, path=None, silent=False):
39 """Executes a command, in the given directory (if any), and returns the
38 """Executes a command, in the given directory (if any), and returns the
40 command result as a string."""
39 command result as a string."""
41 cwd = None
40 cwd = None
@@ -43,7 +42,7 b' def cmd(text, path=None):'
43 path = os.path.abspath(path)
42 path = os.path.abspath(path)
44 cwd = os.getcwd()
43 cwd = os.getcwd()
45 os.chdir(path)
44 os.chdir(path)
46 print text
45 if not silent: print "> ", text
47 res = os.popen(text).read()
46 res = os.popen(text).read()
48 if path:
47 if path:
49 os.chdir(cwd)
48 os.chdir(cwd)
@@ -53,6 +52,12 b' def writefile(path, data):'
53 """Writes the given data into the given file."""
52 """Writes the given data into the given file."""
54 f = file(path, "w") ; f.write(data) ; f.close()
53 f = file(path, "w") ; f.write(data) ; f.close()
55
54
55 def error( *args ):
56 sys.stderr.write("ERROR:")
57 for a in args: sys.stderr.write(str(a))
58 sys.stderr.write("\n")
59 sys.exit(-1)
60
56 # ------------------------------------------------------------------------------
61 # ------------------------------------------------------------------------------
57 #
62 #
58 # Darcs interface
63 # Darcs interface
@@ -64,7 +69,6 b' def darcs_changes(darcsRepo):'
64 chronological list of changes as (change name, change summary)."""
69 chronological list of changes as (change name, change summary)."""
65 changes = cmd("darcs changes --reverse --xml-output", darcsRepo)
70 changes = cmd("darcs changes --reverse --xml-output", darcsRepo)
66 doc = xml_dom.parseString(changes)
71 doc = xml_dom.parseString(changes)
67 res = []
68 for patch_node in doc.childNodes[0].childNodes:
72 for patch_node in doc.childNodes[0].childNodes:
69 name = filter(lambda n:n.nodeName == "name", patch_node.childNodes)
73 name = filter(lambda n:n.nodeName == "name", patch_node.childNodes)
70 comm = filter(lambda n:n.nodeName == "comment", patch_node.childNodes)
74 comm = filter(lambda n:n.nodeName == "comment", patch_node.childNodes)
@@ -111,7 +115,7 b' if __name__ == "__main__":'
111 sys.exit(-1)
115 sys.exit(-1)
112 # Initializes the target repo
116 # Initializes the target repo
113 if not os.path.isdir(darcs_repo + "/_darcs"):
117 if not os.path.isdir(darcs_repo + "/_darcs"):
114 print "No darcs directory found at: " + darc_repo
118 print "No darcs directory found at: " + darcs_repo
115 sys.exit(-1)
119 sys.exit(-1)
116 if not os.path.isdir(hg_repo):
120 if not os.path.isdir(hg_repo):
117 os.mkdir(hg_repo)
121 os.mkdir(hg_repo)
@@ -128,4 +132,3 b' if __name__ == "__main__":'
128 hg_commit(hg_repo, text, author, epoch)
132 hg_commit(hg_repo, text, author, epoch)
129
133
130 # EOF
134 # EOF
131
General Comments 0
You need to be logged in to leave comments. Login now