===================================================================
@@ -235,6 +235,7 @@ def action_get(rpc, patch_id):
sys.exit(1)
try:
+ f.write("Message-ID: %s\n" % patch['msgid']);
f.write(s)
f.close()
print "Saved patch to %s" % fname
------------------
pwclient: lookup patch_id given Message-id
Add a pwclient search option '-m' to look up a patch id given a Message-id.
This is useful for automation and mailer hooks.
Signed-off-by: Ben Myers <bpm@sgi.com>
===================================================================
@@ -119,7 +119,8 @@ def usage():
-p <project> : Filter by project name (see 'projects' for list)
-w <who> : Filter by submitter (name, e-mail substring search)
-d <who> : Filter by delegate (name, e-mail substring search)
- -n <max #> : Restrict number of results\n""")
+ -n <max #> : Restrict number of results
+ -m <messageid>: Filter by Message-id\n""")
sys.stderr.write("""\nActions that take an ID argument can also be \
invoked with:
-h <hash> : Lookup by patch hash\n""")
@@ -294,11 +295,19 @@ def patch_id_from_hash(rpc, hash):
return patch['id']
+def patch_id_from_msgid(rpc, msgid_str):
+ f = Filter();
+ f.add("msgid", msgid_str)
+ patches = rpc.patch_list(f.d)
+ for patch in patches:
+ sys.stdout.write("%s\n" % patch['id'])
+ return patches
+
auth_actions = ['update']
def main():
try:
- opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:')
+ opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:m:')
except getopt.GetoptError, err:
print str(err)
usage()
@@ -316,6 +325,7 @@ def main():
commit_str = ""
state_str = ""
hash_str = ""
+ msgid_str = ""
url = DEFAULT_URL
config = ConfigParser.ConfigParser()
@@ -341,6 +351,8 @@ def main():
commit_str = value
elif name == '-h':
hash_str = value
+ elif name == '-m':
+ msgid_str = value
elif name == '-n':
try:
filt.add("max_count", int(value))
@@ -389,6 +401,11 @@ def main():
sys.stderr.write("No patch has the hash provided")
sys.exit(1)
+ if msgid_str:
+ patches = patch_id_from_msgid(rpc, msgid_str)
+ if not patches:
+ sys.exit(1)
+ return
if action == 'list' or action == 'search':
if len(args) > 0: