[PATCH] patch: Add a way to access a patch by its Message-ID

Damien Lespiau damien.lespiau at intel.com
Fri Oct 2 06:56:05 AEST 2015


Similar to:
http://mid.gmane.org/1443511466-8017-1-git-send-email-jani.nikula@intel.com

It's really handy to be able to find a patchwork patch from the original
mail. For instance, a key stroke in mutt will open the patch page in the
browser.

Suggested-by: Jani Nikula <jani.nikula <at> intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 patchwork/urls.py        | 1 +
 patchwork/views/patch.py | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/patchwork/urls.py b/patchwork/urls.py
index b28eb90..bc792d0 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -35,6 +35,7 @@ urlpatterns = patterns('',
     (r'^patch/(?P<patch_id>\d+)/$', 'patchwork.views.patch.patch'),
     (r'^patch/(?P<patch_id>\d+)/raw/$', 'patchwork.views.patch.content'),
     (r'^patch/(?P<patch_id>\d+)/mbox/$', 'patchwork.views.patch.mbox'),
+    (r'^patch/msgid/(?P<msgid>[^/]+)/$', 'patchwork.views.patch.msgid'),
 
     # logged-in user stuff
     (r'^user/$', 'patchwork.views.user.profile'),
diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py
index 62ff853..f350ec0 100644
--- a/patchwork/views/patch.py
+++ b/patchwork/views/patch.py
@@ -21,7 +21,7 @@
 from patchwork.models import Patch, Project, Bundle
 from patchwork.forms import PatchForm, CreateBundleForm
 from patchwork.requestcontext import PatchworkRequestContext
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render_to_response, get_object_or_404, redirect
 from django.http import HttpResponse, HttpResponseForbidden
 from patchwork.views import generic_list, patch_to_mbox
 
@@ -105,3 +105,7 @@ def list(request, project_id):
     context = generic_list(request, project, 'patchwork.views.patch.list',
             view_args = {'project_id': project.linkname})
     return render_to_response('patchwork/list.html', context)
+
+def msgid(request, msgid):
+    patch = get_object_or_404(Patch, msgid='<' + msgid + '>')
+    return redirect(patch)
-- 
2.1.0



More information about the Patchwork mailing list