[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,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
|
||||
# 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.
|
||||
"""
|
||||
|
||||
import commands
|
||||
import email
|
||||
import gzip
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import commands, os, sys, email
|
||||
|
||||
try:
|
||||
from lxml import etree
|
||||
|
@ -55,7 +50,6 @@ from email import Encoders
|
|||
CONF_PATH = "_darcs/third-party/darcs-send-changes"
|
||||
DATE_FILE = CONF_PATH + "/date-last-send"
|
||||
ID_FILE = CONF_PATH + "/id"
|
||||
DARCS2 = False
|
||||
|
||||
def to_utf8(input):
|
||||
""" Decode un str ou un unicode vers un str en UTF-8. """
|
||||
|
@ -76,32 +70,16 @@ def to_utf8(input):
|
|||
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||
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):
|
||||
""" Invoque darcs et renvoie sa sortie. """
|
||||
(s, o) = commands.getstatusoutput("env DARCS_DONT_ESCAPE_8BIT=1 darcs " + args)
|
||||
o = to_utf8(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. """
|
||||
if patch:
|
||||
date = getdate(patch)
|
||||
match_cmd = "--match='date %s'" % date
|
||||
if hash:
|
||||
match_cmd = "--match='hash %s'" % hash
|
||||
else:
|
||||
match_cmd = "--last 1"
|
||||
(status, changelog) = darcs("changes %s --xml-output" % match_cmd)
|
||||
|
@ -224,35 +202,19 @@ def getnew(lastdate=None):
|
|||
lastdate='19700101000000'
|
||||
files = os.listdir("_darcs/patches")
|
||||
patches = []
|
||||
if not DARCS2:
|
||||
for f in files:
|
||||
if f.endswith(".gz"):
|
||||
date = getdate(f)
|
||||
if date > lastdate:
|
||||
patches.append(f)
|
||||
patches.sort()
|
||||
else:
|
||||
for f in files:
|
||||
date = getdate(f)
|
||||
for f in files:
|
||||
if f.endswith(".gz"):
|
||||
date = f.split("-", 1)[0]
|
||||
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]
|
||||
|
||||
patches.append(f)
|
||||
patches.sort()
|
||||
return patches
|
||||
|
||||
def select(patches):
|
||||
'''Sélection interactive de patches'''
|
||||
decided = []
|
||||
while patches:
|
||||
(status, changelog) = darcs("changes --match='date %s'" % getdate(patches[0]))
|
||||
(status, changelog) = darcs("changes --match='hash %s'" % patches[0])
|
||||
if status == 0:
|
||||
print
|
||||
print changelog
|
||||
|
@ -336,10 +298,6 @@ if __name__ == "__main__":
|
|||
cprint("Pas de dépôt darcs trouvé")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
DARCS2 = "darcs-2" in open('_darcs/format').read()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
if not os.path.exists(CONF_PATH):
|
||||
partial_path = ''
|
||||
|
@ -364,7 +322,7 @@ if __name__ == "__main__":
|
|||
patches = getnew(lastdate)
|
||||
if c == "none":
|
||||
if patches:
|
||||
open(DATE_FILE, "w").write(getdate(patches[-1]))
|
||||
open(DATE_FILE, "w").write(patches[-1].split("-", 1)[0])
|
||||
patches = []
|
||||
else:
|
||||
open(DATE_FILE, "w").write("19700101000000")
|
||||
|
@ -394,4 +352,4 @@ if __name__ == "__main__":
|
|||
if props:
|
||||
cprint("Envoi du patch %s a %s." % (props['hash'], ", ".join(recipient)))
|
||||
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