diff --git a/gestion/darcs_send_changes.py b/gestion/darcs_send_changes.py index 6c0464bc..09c77efc 100755 --- a/gestion/darcs_send_changes.py +++ b/gestion/darcs_send_changes.py @@ -43,6 +43,10 @@ from email.MIMEText import MIMEText from email.Utils import formatdate from email import Encoders +CONF_PATH = "_darcs/third-party/darcs-send-changes" +LAST_SEEN_FILE = CONF_PATH + "/last-seen" +ID_FILE = CONF_PATH + "/id" + def to_utf8(str): """ Decode un str ou un unicode vers un str en UTF-8. """ if isinstance(str, unicode): @@ -73,9 +77,17 @@ def get_patch_properties(hash): diff = darcs("diff %s --unified" % match_cmd) diff = diff[diff.find('\ndiff ')+1:] cwd = os.getcwd() + hostname = commands.getoutput('hostname -s') + shortrepo = os.path.basename(cwd) + if os.path.exists(ID_FILE): + id = file(ID_FILE).read() + else: + id = shortrepo return { 'author': prop.attrib['author'], - 'repo': "%s:%s" % (commands.getoutput('hostname -s'), cwd), - 'shortrepo': os.path.basename(cwd), + 'hostname': hostname, + 'id': id, + 'repo': "%s:%s" % (hostname, cwd), + 'shortrepo': shortrepo, 'date': prop.attrib['local_date'], 'hash': prop.attrib['hash'], 'name': prop.findtext('name'), @@ -93,9 +105,6 @@ def get_patches_properties(from_hash): props.append(get_patch_properties(change.attrib['hash'])) return props -CONF_PATH = "_darcs/third-party/darcs-send-changes" -LAST_SEEN_FILE = CONF_PATH + "/last-seen" - def send_changes(smtp, recipient, patch_props): """ Formate et envoie un mail avec les modifications sur le dernier patch appliqué au dépot. @@ -111,7 +120,7 @@ contenir les variables suivantes: * recipient: les destinataires du mail """ from_template = "%(author)s" - subject_template = "Darcs record (%(shortrepo)s): %(name)s" + subject_template = "Darcs record (%(id)s): %(name)s" message_template = "%(changes)s" diff_template = "%(diff)s"