dim: function based subcommand handling
cover dim: function based subcommand handling
I propose to change the dim tool to handle subcommands via functions matching the subcommand. Each 'dim sub-command' would be handled by a function named dim_sub_command. Only functions handling subcommands would have the dim_ prefix.
Patches 1-11 are mostly renames to follow the proposed naming scheme.
Patch 12 separates handling of aliases to an independent piece of code.
Patch 13 actually starts handling subcommands via the defined functions. Some of the benefits of the approach are covered in the commit message.
Patches 14-17 starts abstracting subcommand cases to functions. This is mostly mechanical work, and I didn't bother with it until I get an ack on the approach.
I've only tested this lightly, thus RFC.
BR,
Jani.
Jani Nikula (17):
dim: rename dim_push to dim_push_branch
dim: rename dim_apply to dim_apply_branch
dim: rename dim_co to dim_checkout
dim: rename dim_shell_checkpatch to shell_checkpatch
dim: rename dim_checkpatch to checkpatch_commit
dim: rename dim_checkrange to dim_checkpatch
dim: rename setup_dim to dim_setup
dim: rename create_workdir to dim_create_workdir
dim: rename update_nightly to dim_rebuild_nightly
dim: rename magic_patch to dim_magic_patch
dim: move dim_pull_request parameter check to the function
dim: separate handling of aliases
dim: handle subcommands through functions
dim: abstract dim_nightly_forget
dim: abstract dim_update_branches
dim: abstract dim_for_each_workdirs
dim: abstract dim_push_*
dim | 239 ++++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 128 insertions(+), 111 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 1/17 dim: rename dim_push to dim_push_branch
Rename to match the subcommand name. Move error checking to the function too.
--- dim | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
dim +10 -9
@@ -346,8 +346,13 @@ function update_nightly # push branch $1, rebuild nightly. the rest of the arguments are passed to git # push. -function dim_push +function dim_push_branch { + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch" + exit 1 + fi + branch=$1 shift
@@ -763,20 +768,16 @@ case "$subcommand" in cat > `cat .fixup_file_path` ;; push-branch) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch" - exit 1 - fi - dim_push "$@" + dim_push_branch "$@" ;; push-queued|pq) - dim_push drm-intel-next-queued "$@" + dim_push_branch drm-intel-next-queued "$@" ;; push-next-fixes|pnf) - dim_push drm-intel-next-fixes "$@" + dim_push_branch drm-intel-next-fixes "$@" ;; push-fixes|pf) - dim_push drm-intel-fixes "$@" + dim_push_branch drm-intel-fixes "$@" ;; checkout|co) if [[ "x$1" = "x" ]]; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 2/17 dim: rename dim_apply to dim_apply_branch
In reply to Jani NikulaRename to match the subcommand name.
--- dim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
dim +5 -5
@@ -366,7 +366,7 @@ function dim_push_branch # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. -function dim_apply +function dim_apply_branch { local branch=$1 shift
@@ -796,16 +796,16 @@ case "$subcommand" in dim_co drm-intel-next-fixes ;; apply-branch|ab|sob) - dim_apply "$@" + dim_apply_branch "$@" ;; apply-queued|aq) - dim_apply drm-intel-next-queued "$@" + dim_apply_branch drm-intel-next-queued "$@" ;; apply-fixes|af) - dim_apply drm-intel-fixes "$@" + dim_apply_branch drm-intel-fixes "$@" ;; apply-next-fixes|anf) - dim_apply drm-intel-next-fixes "$@" + dim_apply_branch drm-intel-next-fixes "$@" ;; apply-resolved|ar) make -j 20 && git add -u && git am --resolved
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 3/17 dim: rename dim_co to dim_checkout
In reply to Jani NikulaRename to match the (long) subcommand name. Move error checking to the function too.
--- dim | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
dim +12 -11
@@ -430,8 +430,13 @@ function dim_cd cd $path } -function dim_co +function dim_checkout { + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch" + exit 1 + fi + dim_cd $1 if ! git branch | grep $1 > /dev/null ; then git checkout -t $DIM_DRM_INTEL_REMOTE/$1
@@ -734,14 +739,14 @@ case "$subcommand" in check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel for branch in $dim_branches ; do - dim_co $branch + dim_checkout $branch if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then $DRY git rebase else $DRY git rebase -i fi done - dim_co drm-intel-next + dim_checkout drm-intel-next $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next # TODO: Restore -nightly merge state from the rerere-cache # branch
@@ -780,20 +785,16 @@ case "$subcommand" in dim_push_branch drm-intel-fixes "$@" ;; checkout|co) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch" - exit 1 - fi - dim_co "$@" + dim_checkout "$@" ;; conq) - dim_co drm-intel-next-queued + dim_checkout drm-intel-next-queued ;; cof) - dim_co drm-intel-fixes + dim_checkout drm-intel-fixes ;; conf) - dim_co drm-intel-next-fixes + dim_checkout drm-intel-next-fixes ;; apply-branch|ab|sob) dim_apply_branch "$@"
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 4/17 dim: rename dim_shell_checkpatch to shell_checkpatch
In reply to Jani NikulaDrop the dim_ prefix as there's no corresponding subcommand.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -383,7 +383,7 @@ function dim_apply_branch local message_id=$(message_get_id $file) - dim_shell_checkpatch "cat $file" + shell_checkpatch "cat $file" cat $file | git am -3 "$@"
@@ -456,7 +456,7 @@ function check_repo_clean } # $1 is the shell command to display the patch/commit -function dim_shell_checkpatch +function shell_checkpatch { local cmd=$1
@@ -473,7 +473,7 @@ function dim_checkpatch local commit=$1 git --no-pager log --oneline -1 $commit - dim_shell_checkpatch "git show $commit --pretty=email" + shell_checkpatch "git show $commit --pretty=email" } function dim_checkrange
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 5/17 dim: rename dim_checkpatch to checkpatch_commit
In reply to Jani NikulaRename as there's no corresponding subcommand (the check-patch subcommand does a slightly different thing).
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -468,7 +468,7 @@ function shell_checkpatch } # $1 is the git sha1 to check -function dim_checkpatch +function checkpatch_commit { local commit=$1
@@ -489,7 +489,7 @@ function dim_checkrange fi for commit in $(git rev-list --reverse $range); do - dim_checkpatch $commit || true + checkpatch_commit $commit || true done }
@@ -810,7 +810,7 @@ case "$subcommand" in ;; apply-resolved|ar) make -j 20 && git add -u && git am --resolved - dim_checkpatch HEAD + checkpatch_commit HEAD git commit --amend & ;; apply-igt|ai)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 6/17 dim: rename dim_checkrange to dim_checkpatch
In reply to Jani NikulaRename to match the subcommand. Also add checkpatch subcommand (without the hyphen) to match the spelling of the tool.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -476,7 +476,7 @@ function checkpatch_commit shell_checkpatch "git show $commit --pretty=email" } -function dim_checkrange +function dim_checkpatch { local range
@@ -846,8 +846,8 @@ case "$subcommand" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - check-patch|cp) - dim_checkrange $@ + checkpatch|check-patch|cp) + dim_checkpatch $@ ;; cherry-pick) if [[ "x$1" = "x" ]]; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 7/17 dim: rename setup_dim to dim_setup
In reply to Jani NikulaRename to match the subcommand.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -615,7 +615,7 @@ function dim_pull_request "$addr_drm_maintainer" } -function setup_dim +function dim_setup { if [ ! -d $DIM_PREFIX ]; then echo "please set up your repository directory with:"
@@ -724,7 +724,7 @@ function assert_branch case "$subcommand" in setup) - setup_dim + dim_setup ;; nightly-forget) cd $DIM_PREFIX/drm-intel-nightly
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 8/17 dim: rename create_workdir to dim_create_workdir
In reply to Jani NikulaAdd dim_ prefix to functions corresponding to subcommands.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -545,7 +545,7 @@ function prep_pull_mail prep_pull_mail_signature >> ~/tmp/dim-pull-request } -function create_workdir +function dim_create_workdir { cd $DIM_PREFIX local branches
@@ -753,7 +753,7 @@ case "$subcommand" in update_rerere_cache ;; create-workdir) - create_workdir $1 + dim_create_workdir $1 ;; for-each-workdirs|fw) cd $DIM_PREFIX/$DIM_DRM_INTEL
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 9/17 dim: rename update_nightly to dim_rebuild_nightly
In reply to Jani NikulaRename to match the subcommand name.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -231,7 +231,7 @@ function update_rerere_cache cd - } -function update_nightly +function dim_rebuild_nightly { local integration_branch=drm-intel-nightly local specfile=`mktemp`
@@ -360,7 +360,7 @@ function dim_push_branch git push $DRY_RUN $DIM_DRM_INTEL_REMOTE $branch "$@" - update_nightly + dim_rebuild_nightly update_linux_next }
@@ -766,7 +766,7 @@ case "$subcommand" in done ;; rebuild-nightly) - update_nightly + dim_rebuild_nightly ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 10/17 dim: rename magic_patch to dim_magic_patch
In reply to Jani NikulaAdd dim_ prefix to functions corresponding to subcommands.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -396,7 +396,7 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } -function magic_patch +function dim_magic_patch { if [[ "$1" = "-a" ]]; then cd `cat ~/.dim-last-path`
@@ -818,7 +818,7 @@ case "$subcommand" in git am --whitespace=fix -3 -s ;; magic-patch|mp) - magic_patch "$@" + dim_magic_patch "$@" ;; magic-rebase-resolve|mrr) git diff HEAD | patch -p1 -R
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 11/17 dim: move dim_pull_request parameter check to the function
In reply to Jani NikulaMore abstraction is better, also guards against invalid internal use.
--- dim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
dim +5 -4
@@ -581,6 +581,11 @@ function dim_create_workdir # dim_pull_request branch upstream function dim_pull_request { + if [[ "x$1" = "x" || "x$2" = "x" ]]; then + echo "usage: $0 $subcommand branch upstream" + exit 1 + fi + branch=$1 upstream=$2
@@ -864,10 +869,6 @@ case "$subcommand" in $DRY git cherry-pick $1 ;; pull-request) - if [[ "x$1" = "x" || "x$2" = "x" ]]; then - echo "usage: $0 $subcommand branch upstream" - exit 1 - fi dim_pull_request $* ;; pull-request-next)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 12/17 dim: separate handling of aliases
In reply to Jani Nikula--- dim | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-)
dim +35 -15
@@ -727,7 +727,27 @@ function assert_branch fi } +# handle aliases case "$subcommand" in + ab|sob) subcmd=apply-branch;; + af) subcmd=apply-fixes;; + ai) subcmd=apply-igt;; + anf) subcmd=apply-next-fixes;; + aq) subcmd=apply-queued;; + ar) subcmd=apply-resolved;; + check-patch|cp) subcmd=checkpatch;; + co) subcmd=checkout;; + fw) subcmd=for-each-workdirs;; + mp) subcmd=magic-patch;; + mrr) subcmd=magic-rebase-resolve;; + pf) subcmd=push-fixes;; + pnf) subcmd=push-next-fixes;; + pq) subcmd=push-queued;; + ub) subcmd=update-branches;; + *) subcmd="$subcommand";; +esac + +case "$subcmd" in setup) dim_setup ;;
@@ -738,7 +758,7 @@ case "$subcommand" in git merge origin/drm-intel-fixes git rerere forget ;; - update-branches|ub) + update-branches) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel
@@ -760,7 +780,7 @@ case "$subcommand" in create-workdir) dim_create_workdir $1 ;; - for-each-workdirs|fw) + for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@ for branch in $dim_branches ; do
@@ -780,16 +800,16 @@ case "$subcommand" in push-branch) dim_push_branch "$@" ;; - push-queued|pq) + push-queued) dim_push_branch drm-intel-next-queued "$@" ;; - push-next-fixes|pnf) + push-next-fixes) dim_push_branch drm-intel-next-fixes "$@" ;; - push-fixes|pf) + push-fixes) dim_push_branch drm-intel-fixes "$@" ;; - checkout|co) + checkout) dim_checkout "$@" ;; conq)
@@ -801,31 +821,31 @@ case "$subcommand" in conf) dim_checkout drm-intel-next-fixes ;; - apply-branch|ab|sob) + apply-branch) dim_apply_branch "$@" ;; - apply-queued|aq) + apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;; - apply-fixes|af) + apply-fixes) dim_apply_branch drm-intel-fixes "$@" ;; - apply-next-fixes|anf) + apply-next-fixes) dim_apply_branch drm-intel-next-fixes "$@" ;; - apply-resolved|ar) + apply-resolved) make -j 20 && git add -u && git am --resolved checkpatch_commit HEAD git commit --amend & ;; - apply-igt|ai) + apply-igt) cd ~/xorg/intel-gpu-tools/ git am --whitespace=fix -3 -s ;; - magic-patch|mp) + magic-patch) dim_magic_patch "$@" ;; - magic-rebase-resolve|mrr) + magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp make -j 20
@@ -851,7 +871,7 @@ case "$subcommand" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - checkpatch|check-patch|cp) + checkpatch) dim_checkpatch $@ ;; cherry-pick)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [maintainer-tools RFC PATCH 12/17] dim: separate handling of aliases
Quoted 21 lines · Jani Nikula
--- dim | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-)dim +8
-0@@ -727,7 +727,27 @@ function assert_branch fi } +# handle aliases case "$subcommand" in + ab|sob) subcmd=apply-branch;; + af) subcmd=apply-fixes;; + ai) subcmd=apply-igt;; + anf) subcmd=apply-next-fixes;; + aq) subcmd=apply-queued;; + ar) subcmd=apply-resolved;; + check-patch|cp) subcmd=checkpatch;;
dim function assert_branch · line 748
Quoted 10 lines
dim +10
-0+ co) subcmd=checkout;; + fw) subcmd=for-each-workdirs;; + mp) subcmd=magic-patch;; + mrr) subcmd=magic-rebase-resolve;; + pf) subcmd=push-fixes;; + pnf) subcmd=push-next-fixes;; + pq) subcmd=push-queued;; + ub) subcmd=update-branches;; + *) subcmd="$subcommand";; +esac
This is a bit unfortunate imo since it separates the aliases from the functions. Could we do something like:
local af=apply-fixes
right next to the dim_apply_fixes function to group them together again? Just and idea, haven't tried to make the bash-foo for this work.
Otherwise I really like this, ACK on the entire series/concept. -Daniel
Quoted 96 lines
dim +17
-15+ +case "$subcmd" in setup) dim_setup ;;@@ -738,7 +758,7 @@ case "$subcommand" in git merge origin/drm-intel-fixes git rerere forget ;; - update-branches|ub) + update-branches) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel@@ -760,7 +780,7 @@ case "$subcommand" in create-workdir) dim_create_workdir $1 ;; - for-each-workdirs|fw) + for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@ for branch in $dim_branches ; do@@ -780,16 +800,16 @@ case "$subcommand" in push-branch) dim_push_branch "$@" ;; - push-queued|pq) + push-queued) dim_push_branch drm-intel-next-queued "$@" ;; - push-next-fixes|pnf) + push-next-fixes) dim_push_branch drm-intel-next-fixes "$@" ;; - push-fixes|pf) + push-fixes) dim_push_branch drm-intel-fixes "$@" ;; - checkout|co) + checkout) dim_checkout "$@" ;; conq)@@ -801,31 +821,31 @@ case "$subcommand" in conf) dim_checkout drm-intel-next-fixes ;; - apply-branch|ab|sob) + apply-branch) dim_apply_branch "$@" ;; - apply-queued|aq) + apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;; - apply-fixes|af) + apply-fixes) dim_apply_branch drm-intel-fixes "$@" ;; - apply-next-fixes|anf) + apply-next-fixes) dim_apply_branch drm-intel-next-fixes "$@" ;; - apply-resolved|ar) + apply-resolved) make -j 20 && git add -u && git am --resolved checkpatch_commit HEAD git commit --amend & ;; - apply-igt|ai) + apply-igt) cd ~/xorg/intel-gpu-tools/ git am --whitespace=fix -3 -s ;; - magic-patch|mp) + magic-patch) dim_magic_patch "$@" ;; - magic-rebase-resolve|mrr) + magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp make -j 20@@ -851,7 +871,7 @@ case "$subcommand" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - checkpatch|check-patch|cp) + checkpatch) dim_checkpatch $@ ;; cherry-pick)Signature · 1 line
2.1.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 13/17 dim: handle subcommands through functions
In reply to Jani NikulaIf there's a dim_ prefixed function matching the subcommand, call it to handle the subcommand without going through the big switch case.
Drop the cases which already match the convention. Once all the cases are converted to functions, the handling of subcommands becomes much cleaner.
This also allows extending of dim by the user via functions declared outside of dim. The current aliases could also be made the user's responsibility to define as the user wishes (the user could define dim_ prefixed functions in the dimrc).
--- dim | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-)
dim +9 -27
@@ -747,10 +747,16 @@ case "$subcommand" in *) subcmd="$subcommand";; esac +# if there's a function by the subcommand name, call it +subcmd_func=dim_${subcmd//-/_} +if declare -f $subcmd_func >/dev/null; then + $subcmd_func "$@" + exit 0 +fi + +# XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case +# into an else branch in the above check for functions. case "$subcmd" in - setup) - dim_setup - ;; nightly-forget) cd $DIM_PREFIX/drm-intel-nightly git fetch origin >& /dev/null
@@ -777,9 +783,6 @@ case "$subcmd" in # branch update_rerere_cache ;; - create-workdir) - dim_create_workdir $1 - ;; for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@
@@ -790,16 +793,10 @@ case "$subcmd" in fi done ;; - rebuild-nightly) - dim_rebuild_nightly - ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - push-branch) - dim_push_branch "$@" - ;; push-queued) dim_push_branch drm-intel-next-queued "$@" ;;
@@ -809,9 +806,6 @@ case "$subcmd" in push-fixes) dim_push_branch drm-intel-fixes "$@" ;; - checkout) - dim_checkout "$@" - ;; conq) dim_checkout drm-intel-next-queued ;;
@@ -821,9 +815,6 @@ case "$subcmd" in conf) dim_checkout drm-intel-next-fixes ;; - apply-branch) - dim_apply_branch "$@" - ;; apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;;
@@ -842,9 +833,6 @@ case "$subcmd" in cd ~/xorg/intel-gpu-tools/ git am --whitespace=fix -3 -s ;; - magic-patch) - dim_magic_patch "$@" - ;; magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp
@@ -871,9 +859,6 @@ case "$subcmd" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - checkpatch) - dim_checkpatch $@ - ;; cherry-pick) if [[ "x$1" = "x" ]]; then echo "usage: $0 $subcommand commit-ish"
@@ -888,9 +873,6 @@ case "$subcmd" in git log --grep=$sha_short --pretty=oneline $sha..$DIM_DRM_INTEL_REMOTE/drm-intel-nightly $DRY git cherry-pick $1 ;; - pull-request) - dim_pull_request $* - ;; pull-request-next) upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} dim_pull_request drm-intel-next $upstream
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 14/17 dim: abstract dim_nightly_forget
In reply to Jani Nikula--- dim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
dim +9 -7
@@ -344,6 +344,15 @@ function dim_rebuild_nightly } +function dim_nightly_forget +{ + cd $DIM_PREFIX/drm-intel-nightly + git fetch origin >& /dev/null + git reset --hard origin/drm-intel-next-queued >& /dev/null + git merge origin/drm-intel-fixes + git rerere forget +} + # push branch $1, rebuild nightly. the rest of the arguments are passed to git # push. function dim_push_branch
@@ -757,13 +766,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - nightly-forget) - cd $DIM_PREFIX/drm-intel-nightly - git fetch origin >& /dev/null - git reset --hard origin/drm-intel-next-queued >& /dev/null - git merge origin/drm-intel-fixes - git rerere forget - ;; update-branches) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 15/17 dim: abstract dim_update_branches
In reply to Jani Nikula--- dim | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
dim +21 -19
@@ -629,6 +629,27 @@ function dim_pull_request "$addr_drm_maintainer" } +function dim_update_branches +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + git fetch $DIM_DRM_INTEL_REMOTE + check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel + + for branch in $dim_branches ; do + dim_checkout $branch + if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then + $DRY git rebase + else + $DRY git rebase -i + fi + done + dim_checkout drm-intel-next + $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next + # TODO: Restore -nightly merge state from the rerere-cache + # branch + update_rerere_cache +} + function dim_setup { if [ ! -d $DIM_PREFIX ]; then
@@ -766,25 +787,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - update-branches) - cd $DIM_PREFIX/$DIM_DRM_INTEL - git fetch $DIM_DRM_INTEL_REMOTE - check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel - - for branch in $dim_branches ; do - dim_checkout $branch - if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then - $DRY git rebase - else - $DRY git rebase -i - fi - done - dim_checkout drm-intel-next - $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next - # TODO: Restore -nightly merge state from the rerere-cache - # branch - update_rerere_cache - ;; for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 16/17 dim: abstract dim_for_each_workdirs
In reply to Jani Nikula--- dim | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
dim +12 -10
@@ -587,6 +587,18 @@ function dim_create_workdir done } +function dim_for_each_workdirs +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + $@ + for branch in $dim_branches ; do + if [[ -d $DIM_PREFIX/$branch ]] ; then + cd $DIM_PREFIX/$branch + $@ + fi + done +} + # dim_pull_request branch upstream function dim_pull_request {
@@ -787,16 +799,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - for-each-workdirs) - cd $DIM_PREFIX/$DIM_DRM_INTEL - $@ - for branch in $dim_branches ; do - if [[ -d $DIM_PREFIX/$branch ]] ; then - cd $DIM_PREFIX/$branch - $@ - fi - done - ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path`
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC PATCH 17/17 dim: abstract dim_push_*
In reply to Jani Nikula--- dim | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
dim +15 -9
@@ -373,6 +373,21 @@ function dim_push_branch update_linux_next } +function dim_push_queued +{ + dim_push_branch drm-intel-next-queued "$@" +} + +function dim_push_next_fixes +{ + dim_push_branch drm-intel-next-fixes "$@" +} + +function dim_push_fixes +{ + dim_push_branch drm-intel-fixes "$@" +} + # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. function dim_apply_branch
@@ -803,15 +818,6 @@ case "$subcmd" in cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - push-queued) - dim_push_branch drm-intel-next-queued "$@" - ;; - push-next-fixes) - dim_push_branch drm-intel-next-fixes "$@" - ;; - push-fixes) - dim_push_branch drm-intel-fixes "$@" - ;; conq) dim_checkout drm-intel-next-queued ;;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 3 lines · Jani Nikula
Patches 14-17 starts abstracting subcommand cases to functions. This is mostly mechanical work, and I didn't bother with it until I get an ack on the approach.
I mean, I didn't bother with convering *all* of the functions yet.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx