]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/bin/pwclient
pwclient: fallback to patch_get_by_hash
[patchwork] / apps / patchwork / bin / pwclient
index 863c1aeb00626b4396513a34002ba869fc363106..b0bd1d175b8105464b42951ad40c9a8db1abedfa 100755 (executable)
@@ -285,8 +285,14 @@ 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):
+    try:
+        patch = rpc.patch_get_by_project_hash(project, hash)
+    except xmlrpclib.Fault:
+        # the server may not have the newer patch_get_by_project_hash function,
+        # so fall back to hash-only.
+        patch = rpc.patch_get_by_hash(hash)
+
     if patch == {}:
         return None
 
@@ -382,7 +388,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)