Gestion du cas où il n'y a pas encore de hash.

darcs-hash:20071216090737-af139-aa48191918f02bae8f36699f514bdcdf3b020462.gz
This commit is contained in:
Jeremie Dimino 2007-12-16 10:07:37 +01:00
parent 0a46dc2758
commit a901082b9b

View file

@ -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. """
@ -209,7 +213,7 @@ if __name__ == "__main__":
from_hash = f.read().strip()
f.close()
else:
from_hash = ""
from_hash = None
patches = get_patches_properties(from_hash)
if len(patches) == 0: