We may see the same hash for two patches if one is sent to two lists
tracked by patchwork.
This change adds a new xmlrpc method, patch_get_by_project_hash, which
adds the linkname parameter to the lookup. We need to add a new method
instead of replacing patch_get_by_hash, to avoid breaking existing
pwclient apps.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
if not success:
sys.stderr.write("Patch not updated\n")
if not success:
sys.stderr.write("Patch not updated\n")
-def patch_id_from_hash(rpc, hash):
- patch = rpc.patch_get_by_hash(hash)
+def patch_id_from_hash(rpc, project, hash):
+ patch = rpc.patch_get_by_project_hash(project, hash)
if patch == {}:
return None
if patch == {}:
return None
patch_id = None
if hash_str:
patch_id = None
if hash_str:
- patch_id = patch_id_from_hash(rpc, hash_str)
+ patch_id = patch_id_from_hash(rpc, project_str, hash_str)
if patch_id is None:
sys.stderr.write("No patch has the hash provided\n")
sys.exit(1)
if patch_id is None:
sys.stderr.write("No patch has the hash provided\n")
sys.exit(1)
+@xmlrpc_method(False)
+def patch_get_by_project_hash(project, hash):
+ """Return structure for the given patch hash."""
+ try:
+ patch = Patch.objects.filter(project__linkname = project,
+ hash = hash)[0]
+ return patch_to_dict(patch)
+ except:
+ return {}
+
@xmlrpc_method(False)
def patch_get_mbox(patch_id):
"""Return mbox string for the given patch ID."""
@xmlrpc_method(False)
def patch_get_mbox(patch_id):
"""Return mbox string for the given patch ID."""