From a901082b9b195534c2244d36ff26d77c944dac76 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Sun, 16 Dec 2007 10:07:37 +0100 Subject: [PATCH] =?UTF-8?q?Gestion=20du=20cas=20o=C3=B9=20il=20n'y=20a=20p?= =?UTF-8?q?as=20encore=20de=20hash.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20071216090737-af139-aa48191918f02bae8f36699f514bdcdf3b020462.gz --- gestion/darcs_send_changes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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: