[darcs_send_changes] Rollback
darcs-hash:20100119004527-ffbb2-e78f684a375dd1639dea481681017f6db2e75f67.gz
This commit is contained in:
parent
255742e3d6
commit
e0a82bad0f
1 changed files with 13 additions and 55 deletions
|
@ -5,7 +5,7 @@
|
||||||
# ---------------------
|
# ---------------------
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Jeremie Dimino <jeremie@dimino.org>
|
# Copyright (C) 2007 Jeremie Dimino <jeremie@dimino.org>
|
||||||
# Copyright (C) 2007,2008,2010 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
|
# Copyright (C) 2007,2008 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
|
||||||
#
|
#
|
||||||
# This file is free software; you can redistribute it and/or modify
|
# This file is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,12 +26,7 @@
|
||||||
Envoie un mail détaillant le dernier patch appliqué à un dépot.
|
Envoie un mail détaillant le dernier patch appliqué à un dépot.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import commands
|
import commands, os, sys, email
|
||||||
import email
|
|
||||||
import gzip
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
@ -55,7 +50,6 @@ from email import Encoders
|
||||||
CONF_PATH = "_darcs/third-party/darcs-send-changes"
|
CONF_PATH = "_darcs/third-party/darcs-send-changes"
|
||||||
DATE_FILE = CONF_PATH + "/date-last-send"
|
DATE_FILE = CONF_PATH + "/date-last-send"
|
||||||
ID_FILE = CONF_PATH + "/id"
|
ID_FILE = CONF_PATH + "/id"
|
||||||
DARCS2 = False
|
|
||||||
|
|
||||||
def to_utf8(input):
|
def to_utf8(input):
|
||||||
""" Decode un str ou un unicode vers un str en UTF-8. """
|
""" Decode un str ou un unicode vers un str en UTF-8. """
|
||||||
|
@ -76,32 +70,16 @@ def to_utf8(input):
|
||||||
except (UnicodeDecodeError, UnicodeEncodeError):
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||||
return input.decode("ascii", "replace").encode("UTF-8")
|
return input.decode("ascii", "replace").encode("UTF-8")
|
||||||
|
|
||||||
def getdate(patch):
|
|
||||||
"""Récupère la date correspondant à un patch..."""
|
|
||||||
if not DARCS2:
|
|
||||||
return patch.split("-", 1)[0]
|
|
||||||
else:
|
|
||||||
f = os.path.join("_darcs/patches", patch)
|
|
||||||
gzf = gzip.open(f)
|
|
||||||
try:
|
|
||||||
g = gzf.readlines()
|
|
||||||
except IOError:
|
|
||||||
gzf.close()
|
|
||||||
return '19700101000000'
|
|
||||||
gzf.close()
|
|
||||||
return g[1].split("**")[1][:-1]
|
|
||||||
|
|
||||||
def darcs(args):
|
def darcs(args):
|
||||||
""" Invoque darcs et renvoie sa sortie. """
|
""" Invoque darcs et renvoie sa sortie. """
|
||||||
(s, o) = commands.getstatusoutput("env DARCS_DONT_ESCAPE_8BIT=1 darcs " + args)
|
(s, o) = commands.getstatusoutput("env DARCS_DONT_ESCAPE_8BIT=1 darcs " + args)
|
||||||
o = to_utf8(o)
|
o = to_utf8(o)
|
||||||
return (s, o)
|
return (s, o)
|
||||||
|
|
||||||
def get_patch_properties(patch):
|
def get_patch_properties(hash):
|
||||||
""" Récupère les informations a propos d'un certain patch. """
|
""" Récupère les informations a propos d'un certain patch. """
|
||||||
if patch:
|
if hash:
|
||||||
date = getdate(patch)
|
match_cmd = "--match='hash %s'" % hash
|
||||||
match_cmd = "--match='date %s'" % date
|
|
||||||
else:
|
else:
|
||||||
match_cmd = "--last 1"
|
match_cmd = "--last 1"
|
||||||
(status, changelog) = darcs("changes %s --xml-output" % match_cmd)
|
(status, changelog) = darcs("changes %s --xml-output" % match_cmd)
|
||||||
|
@ -224,35 +202,19 @@ def getnew(lastdate=None):
|
||||||
lastdate='19700101000000'
|
lastdate='19700101000000'
|
||||||
files = os.listdir("_darcs/patches")
|
files = os.listdir("_darcs/patches")
|
||||||
patches = []
|
patches = []
|
||||||
if not DARCS2:
|
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith(".gz"):
|
if f.endswith(".gz"):
|
||||||
date = getdate(f)
|
date = f.split("-", 1)[0]
|
||||||
if date > lastdate:
|
if date > lastdate:
|
||||||
patches.append(f)
|
patches.append(f)
|
||||||
patches.sort()
|
patches.sort()
|
||||||
else:
|
|
||||||
for f in files:
|
|
||||||
date = getdate(f)
|
|
||||||
if date > lastdate:
|
|
||||||
gz = gzip.open(os.path.join('_darcs/patches',f))
|
|
||||||
try:
|
|
||||||
gz.read(1)
|
|
||||||
except IOError:
|
|
||||||
gz.close()
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
patches.append((getdate(f), f))
|
|
||||||
patches.sort()
|
|
||||||
patches = [patch for _, patch in patches]
|
|
||||||
|
|
||||||
return patches
|
return patches
|
||||||
|
|
||||||
def select(patches):
|
def select(patches):
|
||||||
'''Sélection interactive de patches'''
|
'''Sélection interactive de patches'''
|
||||||
decided = []
|
decided = []
|
||||||
while patches:
|
while patches:
|
||||||
(status, changelog) = darcs("changes --match='date %s'" % getdate(patches[0]))
|
(status, changelog) = darcs("changes --match='hash %s'" % patches[0])
|
||||||
if status == 0:
|
if status == 0:
|
||||||
print
|
print
|
||||||
print changelog
|
print changelog
|
||||||
|
@ -336,10 +298,6 @@ if __name__ == "__main__":
|
||||||
cprint("Pas de dépôt darcs trouvé")
|
cprint("Pas de dépôt darcs trouvé")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
|
||||||
DARCS2 = "darcs-2" in open('_darcs/format').read()
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not os.path.exists(CONF_PATH):
|
if not os.path.exists(CONF_PATH):
|
||||||
partial_path = ''
|
partial_path = ''
|
||||||
|
@ -364,7 +322,7 @@ if __name__ == "__main__":
|
||||||
patches = getnew(lastdate)
|
patches = getnew(lastdate)
|
||||||
if c == "none":
|
if c == "none":
|
||||||
if patches:
|
if patches:
|
||||||
open(DATE_FILE, "w").write(getdate(patches[-1]))
|
open(DATE_FILE, "w").write(patches[-1].split("-", 1)[0])
|
||||||
patches = []
|
patches = []
|
||||||
else:
|
else:
|
||||||
open(DATE_FILE, "w").write("19700101000000")
|
open(DATE_FILE, "w").write("19700101000000")
|
||||||
|
@ -394,4 +352,4 @@ if __name__ == "__main__":
|
||||||
if props:
|
if props:
|
||||||
cprint("Envoi du patch %s a %s." % (props['hash'], ", ".join(recipient)))
|
cprint("Envoi du patch %s a %s." % (props['hash'], ", ".join(recipient)))
|
||||||
send_changes(smtplib.SMTP(smtp), recipient, props)
|
send_changes(smtplib.SMTP(smtp), recipient, props)
|
||||||
open(DATE_FILE, "w").write(getdate(patch))
|
open(DATE_FILE, "w").write(patch.split("-", 1)[0])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue