* [PATCH dim 1/2] dim: Add extract-tags command
@ 2017-03-14 18:50 ville.syrjala
2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: ville.syrjala @ 2017-03-14 18:50 UTC (permalink / raw)
To: intel-gfx
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Add a command for extracting various tags (eg. Reviwed-by:) from
emails. You can give the comamnd a rangeish to add the tags from
the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People
tend to typo these things, or add extra whitespace etc. However the
broad regexp does mean this occasionally picks up stuff that isn't
a tag. So manually amending the commit is probably a wise idea,
and so I simply decided to also leave a '--- extracted tags ---'
separator in the commit message just before the extracted tags,
which can be cleaned up manually when verifying that the tags look
correct.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/dim b/dim
index 6d3b9734b348..4110642b2f4a 100755
--- a/dim
+++ b/dim
@@ -333,6 +333,28 @@ if message_id is not None:
EOF
}
+message_print_body ()
+{
+ python2 <<EOF
+import email
+
+def print_part(part):
+ mtype = part.get_content_maintype()
+ if mtype == 'text':
+ print(part.get_payload(decode=True))
+
+def print_msg(file):
+ msg = email.message_from_file(file)
+ if msg.is_multipart():
+ for part in msg.get_payload():
+ print_part(part)
+ else:
+ print_part(msg)
+
+print_msg(open('$1', 'r'))
+EOF
+}
+
# append all arguments as tags at the end of the commit message of HEAD
function dim_commit_add_tag
{
@@ -973,6 +995,44 @@ function rangeish()
fi
}
+dim_alias_xt=extract-tags
+function dim_extract_tags
+{
+ local branch=$1
+ shift
+ local range=$(rangeish "$1")
+ local file=`mktemp`
+
+ assert_branch $branch
+ assert_repo_clean
+
+ cat > $file
+
+ echo "message_print_body \"$file\""
+ local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
+ test -n "$tags" || return 0
+ local tags=$(printf -- "--- extracted tags ---\n%s" "$tags")
+ git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
+}
+
+dim_alias_xq=extract-queued
+function dim_extract_queued
+{
+ dim_extract_tags drm-intel-next-queued "$@"
+}
+
+dim_alias_xf=extract-fixes
+function dim_extract_fixes
+{
+ dim_extract_tags drm-intel-fixes "$@"
+}
+
+dim_alias_xnf=extract-next-fixes
+function dim_extract_next_fixes
+{
+ dim_extract_tags drm-intel-next-fixes "$@"
+}
+
dim_alias_check_patch=checkpatch
dim_alias_cp=checkpatch
function dim_checkpatch
--
2.10.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH dim 2/2] dim: Add add-link command 2017-03-14 18:50 [PATCH dim 1/2] dim: Add extract-tags command ville.syrjala @ 2017-03-14 18:50 ` ville.syrjala 2017-03-15 9:17 ` Jani Nikula 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 2017-03-15 9:11 ` [PATCH dim 1/2] dim: Add extract-tags command Jani Nikula 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 2 siblings, 2 replies; 15+ messages in thread From: ville.syrjala @ 2017-03-14 18:50 UTC (permalink / raw) To: intel-gfx From: Ville Syrjälä <ville.syrjala@linux.intel.com> Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> --- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/dim b/dim index 4110642b2f4a..b44d087b19ac 100755 --- a/dim +++ b/dim @@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_ll=add-link +function dim_add_link +{ + local branch=$1 + shift + local file=`mktemp` + + assert_branch $branch + assert_repo_clean + + cat > $file + + local message_id=$(message_get_id $file) + + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echo "No message-id found in the patch file." + fi +} + +dim_alias_lq=add-link-queued +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +dim_alias_lf=add-link-fixes +function dim_add_link_fixes +{ + dim_add_link drm-intel-fixes "$@" +} + +dim_alias_lnf=add-link-next-fixes +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} + dim_alias_aq=apply-queued function dim_apply_queued { -- 2.10.2 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH dim 2/2] dim: Add add-link command 2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala @ 2017-03-15 9:17 ` Jani Nikula 2017-03-15 9:18 ` Jani Nikula 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 1 sibling, 1 reply; 15+ messages in thread From: Jani Nikula @ 2017-03-15 9:17 UTC (permalink / raw) To: ville.syrjala, intel-gfx On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: > From: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Add the "add-link" command so that you can add the Link: tag to > patches that failed to apply directly. > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> > --- > dim | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/dim b/dim > index 4110642b2f4a..b44d087b19ac 100755 > --- a/dim > +++ b/dim > @@ -664,6 +664,45 @@ function dim_apply_branch > eval $DRY $DIM_POST_APPLY_ACTION > } > > +dim_alias_ll=add-link > +function dim_add_link > +{ > + local branch=$1 > + shift > + local file=`mktemp` Same complaints about locals as in previous patch. > + > + assert_branch $branch > + assert_repo_clean > + > + cat > $file > + > + local message_id=$(message_get_id $file) > + > + if [ -n $message_id ]; then > + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" > + else > + echo "No message-id found in the patch file." Please use echoerr to print to stderr. > + fi > +} > + > +dim_alias_lq=add-link-queued > +function dim_add_link_queued > +{ > + dim_add_link drm-intel-next-queued "$@" > +} > + > +dim_alias_lf=add-link-fixes > +function dim_add_link_fixes > +{ > + dim_add_link drm-intel-fixes "$@" > +} > + > +dim_alias_lnf=add-link-next-fixes > +function dim_add_link_next_fixes > +{ > + dim_add_link drm-intel-next-fixes "$@" > +} > + I'm thinking this one's so rarely used that the aliases are not needed. Short aliases will make dim bash completion less useful, as the completion automatically completes all dim commands and aliases. > dim_alias_aq=apply-queued > function dim_apply_queued > { -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim 2/2] dim: Add add-link command 2017-03-15 9:17 ` Jani Nikula @ 2017-03-15 9:18 ` Jani Nikula 2017-03-15 10:53 ` Ville Syrjälä 0 siblings, 1 reply; 15+ messages in thread From: Jani Nikula @ 2017-03-15 9:18 UTC (permalink / raw) To: ville.syrjala, intel-gfx On Wed, 15 Mar 2017, Jani Nikula <jani.nikula@linux.intel.com> wrote: > On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: >> From: Ville Syrjälä <ville.syrjala@linux.intel.com> >> >> Add the "add-link" command so that you can add the Link: tag to >> patches that failed to apply directly. >> >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> >> --- >> dim | 39 +++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 39 insertions(+) >> >> diff --git a/dim b/dim >> index 4110642b2f4a..b44d087b19ac 100755 >> --- a/dim >> +++ b/dim >> @@ -664,6 +664,45 @@ function dim_apply_branch >> eval $DRY $DIM_POST_APPLY_ACTION >> } >> >> +dim_alias_ll=add-link >> +function dim_add_link >> +{ >> + local branch=$1 >> + shift >> + local file=`mktemp` > > Same complaints about locals as in previous patch. > >> + >> + assert_branch $branch >> + assert_repo_clean >> + >> + cat > $file >> + >> + local message_id=$(message_get_id $file) rm -f $file >> + >> + if [ -n $message_id ]; then >> + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" >> + else >> + echo "No message-id found in the patch file." > > Please use echoerr to print to stderr. > >> + fi >> +} >> + >> +dim_alias_lq=add-link-queued >> +function dim_add_link_queued >> +{ >> + dim_add_link drm-intel-next-queued "$@" >> +} >> + >> +dim_alias_lf=add-link-fixes >> +function dim_add_link_fixes >> +{ >> + dim_add_link drm-intel-fixes "$@" >> +} >> + >> +dim_alias_lnf=add-link-next-fixes >> +function dim_add_link_next_fixes >> +{ >> + dim_add_link drm-intel-next-fixes "$@" >> +} >> + > > I'm thinking this one's so rarely used that the aliases are not > needed. Short aliases will make dim bash completion less useful, as the > completion automatically completes all dim commands and aliases. > >> dim_alias_aq=apply-queued >> function dim_apply_queued >> { -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim 2/2] dim: Add add-link command 2017-03-15 9:18 ` Jani Nikula @ 2017-03-15 10:53 ` Ville Syrjälä 2017-03-15 11:08 ` Jani Nikula 0 siblings, 1 reply; 15+ messages in thread From: Ville Syrjälä @ 2017-03-15 10:53 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx On Wed, Mar 15, 2017 at 11:18:00AM +0200, Jani Nikula wrote: > On Wed, 15 Mar 2017, Jani Nikula <jani.nikula@linux.intel.com> wrote: > > On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: > >> From: Ville Syrjälä <ville.syrjala@linux.intel.com> > >> > >> Add the "add-link" command so that you can add the Link: tag to > >> patches that failed to apply directly. > >> > >> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> > >> --- > >> dim | 39 +++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 39 insertions(+) > >> > >> diff --git a/dim b/dim > >> index 4110642b2f4a..b44d087b19ac 100755 > >> --- a/dim > >> +++ b/dim > >> @@ -664,6 +664,45 @@ function dim_apply_branch > >> eval $DRY $DIM_POST_APPLY_ACTION > >> } > >> > >> +dim_alias_ll=add-link > >> +function dim_add_link > >> +{ > >> + local branch=$1 > >> + shift > >> + local file=`mktemp` > > > > Same complaints about locals as in previous patch. > > > >> + > >> + assert_branch $branch > >> + assert_repo_clean > >> + > >> + cat > $file > >> + > >> + local message_id=$(message_get_id $file) > > rm -f $file Indeed. And looks like it's missing from extract-tags as well. > > >> + > >> + if [ -n $message_id ]; then > >> + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" > >> + else > >> + echo "No message-id found in the patch file." > > > > Please use echoerr to print to stderr. > > > >> + fi > >> +} > >> + > >> +dim_alias_lq=add-link-queued > >> +function dim_add_link_queued > >> +{ > >> + dim_add_link drm-intel-next-queued "$@" > >> +} > >> + > >> +dim_alias_lf=add-link-fixes > >> +function dim_add_link_fixes > >> +{ > >> + dim_add_link drm-intel-fixes "$@" > >> +} > >> + > >> +dim_alias_lnf=add-link-next-fixes > >> +function dim_add_link_next_fixes > >> +{ > >> + dim_add_link drm-intel-next-fixes "$@" > >> +} > >> + > > > > I'm thinking this one's so rarely used that the aliases are not > > needed. Short aliases will make dim bash completion less useful, as the > > completion automatically completes all dim commands and aliases. I've not used bash completion for this stuff so far, so the short commands have been handy. But I can always move it all into my .dimrc. > > > >> dim_alias_aq=apply-queued > >> function dim_apply_queued > >> { > > -- > Jani Nikula, Intel Open Source Technology Center -- Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim 2/2] dim: Add add-link command 2017-03-15 10:53 ` Ville Syrjälä @ 2017-03-15 11:08 ` Jani Nikula 0 siblings, 0 replies; 15+ messages in thread From: Jani Nikula @ 2017-03-15 11:08 UTC (permalink / raw) To: Ville Syrjälä; +Cc: intel-gfx On Wed, 15 Mar 2017, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote: > I've not used bash completion for this stuff so far, so the short > commands have been handy. But I can always move it all into my .dimrc. Oh, you should give the bash completions a try! It completes more than just the subcommands, e.g. 'dim co TAB' completes the branches. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH dim v2 2/2] dim: Add add-link command 2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala 2017-03-15 9:17 ` Jani Nikula @ 2017-03-15 15:09 ` ville.syrjala 1 sibling, 0 replies; 15+ messages in thread From: ville.syrjala @ 2017-03-15 15:09 UTC (permalink / raw) To: intel-gfx From: Ville Syrjälä <ville.syrjala@linux.intel.com> Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly. v2: Drop the aliases Remove the temp file Clean up locals Use echoerr for error prints Cc: Jani Nikula <jani.nikula@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> --- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/dim b/dim index 8d76953d1746..f737b2878a42 100755 --- a/dim +++ b/dim @@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +function dim_add_link +{ + local branch file message_id + + branch=$1 + shift + file=$(mktemp) + + assert_branch $branch + assert_repo_clean + + cat > $file + + message_id=$(message_get_id $file) + + rm -f $file + + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echoerr "No message-id found in the patch file." + fi +} + +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +function dim_add_link_fixes +{ + dim_add_link drm-intel-fixes "$@" +} + +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} + dim_alias_aq=apply-queued function dim_apply_queued { -- 2.10.2 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH dim 1/2] dim: Add extract-tags command 2017-03-14 18:50 [PATCH dim 1/2] dim: Add extract-tags command ville.syrjala 2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala @ 2017-03-15 9:11 ` Jani Nikula 2017-03-15 10:51 ` Ville Syrjälä 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 2 siblings, 1 reply; 15+ messages in thread From: Jani Nikula @ 2017-03-15 9:11 UTC (permalink / raw) To: ville.syrjala, intel-gfx On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: > From: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Add a command for extracting various tags (eg. Reviwed-by:) from > emails. You can give the comamnd a rangeish to add the tags from > the same email to multiple already applied patches. > > The regexp used to pick up tags is purposefully quite broad. People > tend to typo these things, or add extra whitespace etc. However the > broad regexp does mean this occasionally picks up stuff that isn't > a tag. So manually amending the commit is probably a wise idea, > and so I simply decided to also leave a '--- extracted tags ---' > separator in the commit message just before the extracted tags, > which can be cleaned up manually when verifying that the tags look > correct. > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> > --- > dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/dim b/dim > index 6d3b9734b348..4110642b2f4a 100755 > --- a/dim > +++ b/dim > @@ -333,6 +333,28 @@ if message_id is not None: > EOF > } > > +message_print_body () > +{ > + python2 <<EOF > +import email > + > +def print_part(part): > + mtype = part.get_content_maintype() > + if mtype == 'text': > + print(part.get_payload(decode=True)) > + > +def print_msg(file): > + msg = email.message_from_file(file) > + if msg.is_multipart(): > + for part in msg.get_payload(): > + print_part(part) > + else: > + print_part(msg) > + > +print_msg(open('$1', 'r')) > +EOF > +} > + > # append all arguments as tags at the end of the commit message of HEAD > function dim_commit_add_tag > { > @@ -973,6 +995,44 @@ function rangeish() > fi > } > > +dim_alias_xt=extract-tags > +function dim_extract_tags > +{ > + local branch=$1 > + shift > + local range=$(rangeish "$1") > + local file=`mktemp` So shell has an annoying feature that the 'set -e' has no effect on commands failing when used in an initialization within the local variable declaration. Simple assignments would be okay, but for clarity I've opted to put all local variable declarations in a single line, folled by a blank line and then assignments. See elsewhere in dim. I also prefer $(...) over `...`. > + > + assert_branch $branch > + assert_repo_clean > + > + cat > $file > + > + echo "message_print_body \"$file\"" Leftover debug message? > + local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]') That's indeed quite liberal in accepting stuff. But perhaps it's okay for starters, and we can restrict it more if it gets to be annoying. > + test -n "$tags" || return 0 Maybe it's just me trying to maintain a 1.5k line shell script, but I'd like to be more verbose with the if statements. I'd write this as if [[ -n "$tags" ]]; then ... > + local tags=$(printf -- "--- extracted tags ---\n%s" "$tags") Lose the local here. Nitpick, AFAICT most git commands (like format-patch) wrap placeholders in *** rather than ---. An interesting observation, if you put # in front of the line, you can actually have that as part of the commit message. But after you do 'git commit --amend' on it, the line gets dropped as a comment automatically. In short, that would save a couple of keystrokes perhaps, even if you'd have to move the other tags around. > + git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range I wonder what I screwed up when I was trying to use that for dim_commit_add_tag and failed; the current implementation of it is hidous. :/ > +} > + > +dim_alias_xq=extract-queued > +function dim_extract_queued > +{ > + dim_extract_tags drm-intel-next-queued "$@" > +} > + > +dim_alias_xf=extract-fixes > +function dim_extract_fixes > +{ > + dim_extract_tags drm-intel-fixes "$@" > +} > + > +dim_alias_xnf=extract-next-fixes > +function dim_extract_next_fixes > +{ > + dim_extract_tags drm-intel-next-fixes "$@" > +} These are all in line with what we have all around, but makes me wonder if we should consider just working on the current branch in the future. Thanks for doing this, regardless of the nitpicks above. ;) BR, Jani. > + > dim_alias_check_patch=checkpatch > dim_alias_cp=checkpatch > function dim_checkpatch -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim 1/2] dim: Add extract-tags command 2017-03-15 9:11 ` [PATCH dim 1/2] dim: Add extract-tags command Jani Nikula @ 2017-03-15 10:51 ` Ville Syrjälä 2017-03-15 11:04 ` Jani Nikula 0 siblings, 1 reply; 15+ messages in thread From: Ville Syrjälä @ 2017-03-15 10:51 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx On Wed, Mar 15, 2017 at 11:11:29AM +0200, Jani Nikula wrote: > On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: > > From: Ville Syrjälä <ville.syrjala@linux.intel.com> > > > > Add a command for extracting various tags (eg. Reviwed-by:) from > > emails. You can give the comamnd a rangeish to add the tags from > > the same email to multiple already applied patches. > > > > The regexp used to pick up tags is purposefully quite broad. People > > tend to typo these things, or add extra whitespace etc. However the > > broad regexp does mean this occasionally picks up stuff that isn't > > a tag. So manually amending the commit is probably a wise idea, > > and so I simply decided to also leave a '--- extracted tags ---' > > separator in the commit message just before the extracted tags, > > which can be cleaned up manually when verifying that the tags look > > correct. > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> > > --- > > dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 60 insertions(+) > > > > diff --git a/dim b/dim > > index 6d3b9734b348..4110642b2f4a 100755 > > --- a/dim > > +++ b/dim > > @@ -333,6 +333,28 @@ if message_id is not None: > > EOF > > } > > > > +message_print_body () > > +{ > > + python2 <<EOF > > +import email > > + > > +def print_part(part): > > + mtype = part.get_content_maintype() > > + if mtype == 'text': > > + print(part.get_payload(decode=True)) > > + > > +def print_msg(file): > > + msg = email.message_from_file(file) > > + if msg.is_multipart(): > > + for part in msg.get_payload(): > > + print_part(part) > > + else: > > + print_part(msg) > > + > > +print_msg(open('$1', 'r')) > > +EOF > > +} > > + > > # append all arguments as tags at the end of the commit message of HEAD > > function dim_commit_add_tag > > { > > @@ -973,6 +995,44 @@ function rangeish() > > fi > > } > > > > +dim_alias_xt=extract-tags > > +function dim_extract_tags > > +{ > > + local branch=$1 > > + shift > > + local range=$(rangeish "$1") > > + local file=`mktemp` > > So shell has an annoying feature that the 'set -e' has no effect on > commands failing when used in an initialization within the local > variable declaration. Simple assignments would be okay, but for clarity > I've opted to put all local variable declarations in a single line, > folled by a blank line and then assignments. See elsewhere in dim. > > I also prefer $(...) over `...`. dim is a bit of a hodge podge of varying styles. Which is why my copy-paste coding technique gave me all kinds of things ;) > > > + > > + assert_branch $branch > > + assert_repo_clean > > + > > + cat > $file > > + > > + echo "message_print_body \"$file\"" > > Leftover debug message? Most likely. Dropped. > > > + local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]') > > That's indeed quite liberal in accepting stuff. But perhaps it's okay > for starters, and we can restrict it more if it gets to be annoying. I've had surprisingly few false positives with this myself. But yeah, it can always be refined. Or if needed we could even make it user configurable. > > > + test -n "$tags" || return 0 > > Maybe it's just me trying to maintain a 1.5k line shell script, but I'd > like to be more verbose with the if statements. I'd write this as > > if [[ -n "$tags" ]]; then > ... Done > > > + local tags=$(printf -- "--- extracted tags ---\n%s" "$tags") > > Lose the local here. Nitpick, AFAICT most git commands (like > format-patch) wrap placeholders in *** rather than ---. Dunno. I can live with either, so changed to *** > > An interesting observation, if you put # in front of the line, you can > actually have that as part of the commit message. But after you do 'git > commit --amend' on it, the line gets dropped as a comment > automatically. In short, that would save a couple of keystrokes perhaps, > even if you'd have to move the other tags around. That's a nice idea. I'll give it a go. > > > + git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range > > I wonder what I screwed up when I was trying to use that for > dim_commit_add_tag and failed; the current implementation of it is > hidous. :/ > > > +} > > + > > +dim_alias_xq=extract-queued > > +function dim_extract_queued > > +{ > > + dim_extract_tags drm-intel-next-queued "$@" > > +} > > + > > +dim_alias_xf=extract-fixes > > +function dim_extract_fixes > > +{ > > + dim_extract_tags drm-intel-fixes "$@" > > +} > > + > > +dim_alias_xnf=extract-next-fixes > > +function dim_extract_next_fixes > > +{ > > + dim_extract_tags drm-intel-next-fixes "$@" > > +} > > These are all in line with what we have all around, but makes me wonder I can drop the aliases here as well if people prefer. My .dimrc already has a boatload of these for all the other branches so having to move a few more there isn't a big deal. > if we should consider just working on the current branch in the future. Not sure there is any "current branch" as such when you have worktrees for everything. > > Thanks for doing this, regardless of the nitpicks above. ;) > > BR, > Jani. > > > + > > dim_alias_check_patch=checkpatch > > dim_alias_cp=checkpatch > > function dim_checkpatch > > -- > Jani Nikula, Intel Open Source Technology Center -- Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim 1/2] dim: Add extract-tags command 2017-03-15 10:51 ` Ville Syrjälä @ 2017-03-15 11:04 ` Jani Nikula 0 siblings, 0 replies; 15+ messages in thread From: Jani Nikula @ 2017-03-15 11:04 UTC (permalink / raw) To: Ville Syrjälä; +Cc: intel-gfx On Wed, 15 Mar 2017, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote: > On Wed, Mar 15, 2017 at 11:11:29AM +0200, Jani Nikula wrote: >> On Tue, 14 Mar 2017, ville.syrjala@linux.intel.com wrote: >> > From: Ville Syrjälä <ville.syrjala@linux.intel.com> >> > >> > Add a command for extracting various tags (eg. Reviwed-by:) from >> > emails. You can give the comamnd a rangeish to add the tags from >> > the same email to multiple already applied patches. >> > >> > The regexp used to pick up tags is purposefully quite broad. People >> > tend to typo these things, or add extra whitespace etc. However the >> > broad regexp does mean this occasionally picks up stuff that isn't >> > a tag. So manually amending the commit is probably a wise idea, >> > and so I simply decided to also leave a '--- extracted tags ---' >> > separator in the commit message just before the extracted tags, >> > which can be cleaned up manually when verifying that the tags look >> > correct. >> > >> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> >> > --- >> > dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> > 1 file changed, 60 insertions(+) >> > >> > diff --git a/dim b/dim >> > index 6d3b9734b348..4110642b2f4a 100755 >> > --- a/dim >> > +++ b/dim >> > @@ -333,6 +333,28 @@ if message_id is not None: >> > EOF >> > } >> > >> > +message_print_body () >> > +{ >> > + python2 <<EOF >> > +import email >> > + >> > +def print_part(part): >> > + mtype = part.get_content_maintype() >> > + if mtype == 'text': >> > + print(part.get_payload(decode=True)) >> > + >> > +def print_msg(file): >> > + msg = email.message_from_file(file) >> > + if msg.is_multipart(): >> > + for part in msg.get_payload(): >> > + print_part(part) >> > + else: >> > + print_part(msg) >> > + >> > +print_msg(open('$1', 'r')) >> > +EOF >> > +} >> > + >> > # append all arguments as tags at the end of the commit message of HEAD >> > function dim_commit_add_tag >> > { >> > @@ -973,6 +995,44 @@ function rangeish() >> > fi >> > } >> > >> > +dim_alias_xt=extract-tags >> > +function dim_extract_tags >> > +{ >> > + local branch=$1 >> > + shift >> > + local range=$(rangeish "$1") >> > + local file=`mktemp` >> >> So shell has an annoying feature that the 'set -e' has no effect on >> commands failing when used in an initialization within the local >> variable declaration. Simple assignments would be okay, but for clarity >> I've opted to put all local variable declarations in a single line, >> folled by a blank line and then assignments. See elsewhere in dim. >> >> I also prefer $(...) over `...`. > > dim is a bit of a hodge podge of varying styles. Which is why my > copy-paste coding technique gave me all kinds of things ;) I know... I've been trying to gradually clean it up, and I think I have a branch fixing a bunch of shellcheck issues too. I'm sure some might feel that enforcing a style or shellcheck cleanliness in a shell script is overkill, but I'm thinking overgrown shell scripts like this will become completely unmaintainable otherwise. >> These are all in line with what we have all around, but makes me wonder > > I can drop the aliases here as well if people prefer. My .dimrc already > has a boatload of these for all the other branches so having to move a > few more there isn't a big deal. Yeah, let's drop the aliases, at least for now. Having an alias mechanism (that also bash autocompletes for user defined aliases) should be good enough. Again, can be added later if there's demand. > >> if we should consider just working on the current branch in the future. > > Not sure there is any "current branch" as such when you have worktrees > for everything. Right. BR, Jani. > >> >> Thanks for doing this, regardless of the nitpicks above. ;) >> >> BR, >> Jani. >> >> > + >> > dim_alias_check_patch=checkpatch >> > dim_alias_cp=checkpatch >> > function dim_checkpatch >> >> -- >> Jani Nikula, Intel Open Source Technology Center -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH dim v2 1/2] dim: Add extract-tags command 2017-03-14 18:50 [PATCH dim 1/2] dim: Add extract-tags command ville.syrjala 2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala 2017-03-15 9:11 ` [PATCH dim 1/2] dim: Add extract-tags command Jani Nikula @ 2017-03-15 15:09 ` ville.syrjala 2017-03-15 15:15 ` Chris Wilson 2 siblings, 1 reply; 15+ messages in thread From: ville.syrjala @ 2017-03-15 15:09 UTC (permalink / raw) To: intel-gfx From: Ville Syrjälä <ville.syrjala@linux.intel.com> Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches. The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct. v2: Drop the aliases Remove the temp file Clean up locals Other codingstyle cleanups Use '# *** ... ***' for the separator Cc: Jani Nikula <jani.nikula@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> --- dim | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/dim b/dim index 6d3b9734b348..8d76953d1746 100755 --- a/dim +++ b/dim @@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag { @@ -973,6 +995,48 @@ function rangeish() fi } +function dim_extract_tags +{ + local branch range file tags + + branch=$1 + shift + range=$(rangeish "$1") + file=$(mktemp) + + assert_branch $branch + assert_repo_clean + + cat > $file + + tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]') + + rm -f $file + + if [[ -z "$tags" ]]; then + return 0 + fi + + tags=$(printf -- "# *** extracted tags ***\n%s" "$tags") + + git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range +} + +function dim_extract_queued +{ + dim_extract_tags drm-intel-next-queued "$@" +} + +function dim_extract_fixes +{ + dim_extract_tags drm-intel-fixes "$@" +} + +function dim_extract_next_fixes +{ + dim_extract_tags drm-intel-next-fixes "$@" +} + dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatch -- 2.10.2 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH dim v2 1/2] dim: Add extract-tags command 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala @ 2017-03-15 15:15 ` Chris Wilson 2017-03-16 7:40 ` Jani Nikula 0 siblings, 1 reply; 15+ messages in thread From: Chris Wilson @ 2017-03-15 15:15 UTC (permalink / raw) To: ville.syrjala; +Cc: intel-gfx On Wed, Mar 15, 2017 at 05:09:04PM +0200, ville.syrjala@linux.intel.com wrote: > From: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Add a command for extracting various tags (eg. Reviwed-by:) from > emails. You can give the comamnd a rangeish to add the tags from > the same email to multiple already applied patches. > > The regexp used to pick up tags is purposefully quite broad. People > tend to typo these things, or add extra whitespace etc. However the > broad regexp does mean this occasionally picks up stuff that isn't > a tag. So manually amending the commit is probably a wise idea, > and so I simply decided to also leave a '--- extracted tags ---' > separator in the commit message just before the extracted tags, > which can be cleaned up manually when verifying that the tags look > correct. An example of typical use would be nice. -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim v2 1/2] dim: Add extract-tags command 2017-03-15 15:15 ` Chris Wilson @ 2017-03-16 7:40 ` Jani Nikula 2017-03-16 9:49 ` Ville Syrjälä 0 siblings, 1 reply; 15+ messages in thread From: Jani Nikula @ 2017-03-16 7:40 UTC (permalink / raw) To: Chris Wilson, ville.syrjala; +Cc: intel-gfx On Wed, 15 Mar 2017, Chris Wilson <chris@chris-wilson.co.uk> wrote: > On Wed, Mar 15, 2017 at 05:09:04PM +0200, ville.syrjala@linux.intel.com wrote: >> From: Ville Syrjälä <ville.syrjala@linux.intel.com> >> >> Add a command for extracting various tags (eg. Reviwed-by:) from >> emails. You can give the comamnd a rangeish to add the tags from >> the same email to multiple already applied patches. >> >> The regexp used to pick up tags is purposefully quite broad. People >> tend to typo these things, or add extra whitespace etc. However the >> broad regexp does mean this occasionally picks up stuff that isn't >> a tag. So manually amending the commit is probably a wise idea, >> and so I simply decided to also leave a '--- extracted tags ---' >> separator in the commit message just before the extracted tags, >> which can be cleaned up manually when verifying that the tags look >> correct. > > An example of typical use would be nice. I believe you can pipe an email to 'dim extract-tags' or one of its variants, and have the tags in the email applied to the commits in the branch in question. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim v2 1/2] dim: Add extract-tags command 2017-03-16 7:40 ` Jani Nikula @ 2017-03-16 9:49 ` Ville Syrjälä 2017-03-16 13:33 ` Jani Nikula 0 siblings, 1 reply; 15+ messages in thread From: Ville Syrjälä @ 2017-03-16 9:49 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx On Thu, Mar 16, 2017 at 09:40:05AM +0200, Jani Nikula wrote: > On Wed, 15 Mar 2017, Chris Wilson <chris@chris-wilson.co.uk> wrote: > > On Wed, Mar 15, 2017 at 05:09:04PM +0200, ville.syrjala@linux.intel.com wrote: > >> From: Ville Syrjälä <ville.syrjala@linux.intel.com> > >> > >> Add a command for extracting various tags (eg. Reviwed-by:) from > >> emails. You can give the comamnd a rangeish to add the tags from > >> the same email to multiple already applied patches. > >> > >> The regexp used to pick up tags is purposefully quite broad. People > >> tend to typo these things, or add extra whitespace etc. However the > >> broad regexp does mean this occasionally picks up stuff that isn't > >> a tag. So manually amending the commit is probably a wise idea, > >> and so I simply decided to also leave a '--- extracted tags ---' > >> separator in the commit message just before the extracted tags, > >> which can be cleaned up manually when verifying that the tags look > >> correct. > > > > An example of typical use would be nice. > > I believe you can pipe an email to 'dim extract-tags' or one of its > variants, and have the tags in the email applied to the commits in the > branch in question. Yes. My typical work flow with mutt is something like 'open patch mail ; | dim apply... ; open reply mail with tag(s) ; | dim extract...'. Or if someone has r-b'd an entire series I apply everything first, and then do 'dim extract... <remote>/drm-intel-next-queued..HEAD' to slap the tag(s) onto all the commits. -- Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH dim v2 1/2] dim: Add extract-tags command 2017-03-16 9:49 ` Ville Syrjälä @ 2017-03-16 13:33 ` Jani Nikula 0 siblings, 0 replies; 15+ messages in thread From: Jani Nikula @ 2017-03-16 13:33 UTC (permalink / raw) To: Ville Syrjälä; +Cc: intel-gfx On Thu, 16 Mar 2017, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote: > On Thu, Mar 16, 2017 at 09:40:05AM +0200, Jani Nikula wrote: >> On Wed, 15 Mar 2017, Chris Wilson <chris@chris-wilson.co.uk> wrote: >> > On Wed, Mar 15, 2017 at 05:09:04PM +0200, ville.syrjala@linux.intel.com wrote: >> >> From: Ville Syrjälä <ville.syrjala@linux.intel.com> >> >> >> >> Add a command for extracting various tags (eg. Reviwed-by:) from >> >> emails. You can give the comamnd a rangeish to add the tags from >> >> the same email to multiple already applied patches. >> >> >> >> The regexp used to pick up tags is purposefully quite broad. People >> >> tend to typo these things, or add extra whitespace etc. However the >> >> broad regexp does mean this occasionally picks up stuff that isn't >> >> a tag. So manually amending the commit is probably a wise idea, >> >> and so I simply decided to also leave a '--- extracted tags ---' >> >> separator in the commit message just before the extracted tags, >> >> which can be cleaned up manually when verifying that the tags look >> >> correct. >> > >> > An example of typical use would be nice. >> >> I believe you can pipe an email to 'dim extract-tags' or one of its >> variants, and have the tags in the email applied to the commits in the >> branch in question. > > Yes. My typical work flow with mutt is something like 'open patch mail ; > | dim apply... ; open reply mail with tag(s) ; | dim extract...'. > Or if someone has r-b'd an entire series I apply everything first, > and then do 'dim extract... <remote>/drm-intel-next-queued..HEAD' to > slap the tag(s) onto all the commits. Pushed both patches (though I guess you could have yourself too). Please update the dim.rst man page too. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-03-16 13:33 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-03-14 18:50 [PATCH dim 1/2] dim: Add extract-tags command ville.syrjala 2017-03-14 18:50 ` [PATCH dim 2/2] dim: Add add-link command ville.syrjala 2017-03-15 9:17 ` Jani Nikula 2017-03-15 9:18 ` Jani Nikula 2017-03-15 10:53 ` Ville Syrjälä 2017-03-15 11:08 ` Jani Nikula 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 2017-03-15 9:11 ` [PATCH dim 1/2] dim: Add extract-tags command Jani Nikula 2017-03-15 10:51 ` Ville Syrjälä 2017-03-15 11:04 ` Jani Nikula 2017-03-15 15:09 ` [PATCH dim v2 " ville.syrjala 2017-03-15 15:15 ` Chris Wilson 2017-03-16 7:40 ` Jani Nikula 2017-03-16 9:49 ` Ville Syrjälä 2017-03-16 13:33 ` Jani Nikula
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox