]> git.ozlabs.org Git - patchwork/commitdiff
pwclient,xmlrpc: Specify project for patch hash lookups
authorJeremy Kerr <jk@ozlabs.org>
Thu, 22 Oct 2009 21:46:46 +0000 (17:46 -0400)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 22 Oct 2009 21:46:46 +0000 (17:46 -0400)
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>
apps/patchwork/bin/pwclient
apps/patchwork/views/xmlrpc.py

index 863c1aeb00626b4396513a34002ba869fc363106..75fc6ff9d54cf9af62841a2dcb6dbf9b23f4a151 100755 (executable)
@@ -285,8 +285,8 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
     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
 
@@ -382,7 +382,7 @@ def main():
 
     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)
index f322e5383182fb7fa32cf04978b8610a74187036..23e58bf279bd141f076a49f6cedc17a4bc3ac8f2 100644 (file)
@@ -354,6 +354,16 @@ def patch_get_by_hash(hash):
     except:
         return {}
 
+@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."""