Utilisation d'un id personalisé par repo.

darcs-hash:20071216094313-af139-2001a3642846e9d468adf4843dba7ee7c38c086a.gz
This commit is contained in:
Jeremie Dimino 2007-12-16 10:43:13 +01:00
parent a901082b9b
commit 744e4bf745

View file

@ -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"