diff --git a/gestion/darcs_send_changes.py b/gestion/darcs_send_changes.py index 18784e9d..6c0464bc 100755 --- a/gestion/darcs_send_changes.py +++ b/gestion/darcs_send_changes.py @@ -65,8 +65,12 @@ def darcs(args): def get_patch_properties(hash): """ Récupère les informations a propos d'un certain patch. """ - prop = etree.XML(darcs("changes --match='hash %s' --xml-output" % hash))[0] - diff = darcs("diff --match='hash %s' --unified" % hash) + if hash: + match_cmd = "--match='hash %s'" % hash + else: + match_cmd = "--last 1" + prop = etree.XML(darcs("changes %s --xml-output" % match_cmd))[0] + diff = darcs("diff %s --unified" % match_cmd) diff = diff[diff.find('\ndiff ')+1:] cwd = os.getcwd() return { 'author': prop.attrib['author'], @@ -77,7 +81,7 @@ def get_patch_properties(hash): 'name': prop.findtext('name'), 'comment': prop.findtext('comment'), 'diff': diff, - 'changes': darcs("changes --match='hash %s' --summary" % hash) } + 'changes': darcs("changes %s --summary" % match_cmd) } def get_patches_properties(from_hash): """ Construit la liste des informations sur les patches à partir du patch from_hash. """ @@ -134,7 +138,7 @@ contenir les variables suivantes: texte = MIMEText(message_template % patch_props, "UTF-8") texte.set_charset("UTF-8") mail.attach(texte) - + patch = MIMEText(diff_template % patch_props, "UTF-8") patch.set_type('text/x-patch') patch.set_charset("UTF-8") @@ -202,14 +206,14 @@ if __name__ == "__main__": if not os.path.exists('_darcs') and os.getcwd() == '/': cprint("Pas de dépôt darcs trouvé") sys.exit(1) - + if not from_hash: if os.path.exists(LAST_SEEN_FILE): f = open(LAST_SEEN_FILE) from_hash = f.read().strip() f.close() else: - from_hash = "" + from_hash = None patches = get_patches_properties(from_hash) if len(patches) == 0: