Show More
@@ -113,6 +113,14 b' def darcs_changes_summary(darcs_repo, ch' | |||||
113 | summary_nodes = filter(lambda n: n.nodeName == "summary" and n.nodeType == n.ELEMENT_NODE, patch_node.childNodes) |
|
113 | summary_nodes = filter(lambda n: n.nodeName == "summary" and n.nodeType == n.ELEMENT_NODE, patch_node.childNodes) | |
114 | for summary_node in summary_nodes: |
|
114 | for summary_node in summary_nodes: | |
115 | change_nodes = filter(lambda n: n.nodeType == n.ELEMENT_NODE, summary_node.childNodes) |
|
115 | change_nodes = filter(lambda n: n.nodeType == n.ELEMENT_NODE, summary_node.childNodes) | |
|
116 | if len(change_nodes) == 0: | |||
|
117 | name = filter(lambda n: n.nodeName == "name", patch_node.childNodes) | |||
|
118 | if not name: | |||
|
119 | error("Darcs patch has an empty summary node and no name: " + patch_node.toxml()) | |||
|
120 | name = name[0].childNodes[0].data.strip() | |||
|
121 | (tag, sub_count) = re.subn('^TAG ', '', name, 1) | |||
|
122 | if sub_count != 1: | |||
|
123 | error("Darcs patch has an empty summary node but doesn't look like a tag: " + patch_node.toxml()); | |||
116 | for change_node in change_nodes: |
|
124 | for change_node in change_nodes: | |
117 | change = change_node.nodeName |
|
125 | change = change_node.nodeName | |
118 | if change == 'modify_file': |
|
126 | if change == 'modify_file': | |
@@ -162,7 +170,14 b' def hg_tip( hg_repo ):' | |||||
162 | def hg_rename( hg_repo, from_file, to_file ): |
|
170 | def hg_rename( hg_repo, from_file, to_file ): | |
163 | cmd("hg rename --after \"%s\" \"%s\"" % (from_file, to_file), hg_repo); |
|
171 | cmd("hg rename --after \"%s\" \"%s\"" % (from_file, to_file), hg_repo); | |
164 |
|
172 | |||
165 |
def hg_ |
|
173 | def hg_tag ( hg_repo, text, author, date ): | |
|
174 | old_tip = hg_tip(hg_repo) | |||
|
175 | res = cmd("hg tag -u \"%s\" -d \"%s 0\" \"%s\"" % (author, date, text), hg_repo) | |||
|
176 | new_tip = hg_tip(hg_repo) | |||
|
177 | if not new_tip == old_tip + 1: | |||
|
178 | error("Mercurial tag did not work as expected: " + res) | |||
|
179 | ||||
|
180 | def hg_handle_change( hg_repo, author, date, change, arg ): | |||
166 | """Processes a change event as output by darcs_changes_summary. These |
|
181 | """Processes a change event as output by darcs_changes_summary. These | |
167 | consist of file move/rename/add/delete commands.""" |
|
182 | consist of file move/rename/add/delete commands.""" | |
168 | if change == 'modify_file': |
|
183 | if change == 'modify_file': | |
@@ -177,6 +192,8 b' def hg_handle_change( hg_repo, change, a' | |||||
177 | pass |
|
192 | pass | |
178 | elif change == 'move': |
|
193 | elif change == 'move': | |
179 | hg_rename(hg_repo, arg[0], arg[1]) |
|
194 | hg_rename(hg_repo, arg[0], arg[1]) | |
|
195 | elif change == 'tag': | |||
|
196 | hg_tag(hg_repo, arg, author, date) | |||
180 | else: |
|
197 | else: | |
181 | error('Unknown change type ' + change + ': ' + arg) |
|
198 | error('Unknown change type ' + change + ': ' + arg) | |
182 |
|
199 | |||
@@ -226,7 +243,7 b' if __name__ == "__main__":' | |||||
226 | epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S'))) |
|
243 | epoch = int(mktime(strptime(date, '%Y%m%d%H%M%S'))) | |
227 | darcs_pull(hg_repo, darcs_repo, chash) |
|
244 | darcs_pull(hg_repo, darcs_repo, chash) | |
228 | for change, arg in darcs_changes_summary(darcs_repo, chash): |
|
245 | for change, arg in darcs_changes_summary(darcs_repo, chash): | |
229 | hg_handle_change(hg_repo, change, arg) |
|
246 | hg_handle_change(hg_repo, author, epoch, change, arg) | |
230 | hg_commit(hg_repo, text, author, epoch) |
|
247 | hg_commit(hg_repo, text, author, epoch) | |
231 | change_number += 1 |
|
248 | change_number += 1 | |
232 | print "Darcs repository (_darcs) was not deleted. You can keep or remove it." |
|
249 | print "Darcs repository (_darcs) was not deleted. You can keep or remove it." |
General Comments 0
You need to be logged in to leave comments.
Login now