{"thread":{"id":"6226","subject":"[PATCH 0/5] My set of stgit companion scripts.","startedAt":"2007-01-04T23:39:34Z","lastAt":"2007-01-09T22:26:02Z","messageCount":8,"participants":["Yann Dirson","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"30842","messageId":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":null,"subject":"[PATCH 0/5] My set of stgit companion scripts.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:39:34Z","receivedAt":"2007-01-04T23:39:34Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"The following series adds to contrib/ a set of bash scripts I find useful\nfor my daily use of stgit.  They are probably closely tied to my workflow,\nbut others may find them useful as well.  Some of them may be useful to\npythonize and integrate in some form or another.\n\n\nstg-show-old is a trivial thing, but since I often need that functionnality,\nit is much less comfortable than forging the same command-line over and over\nagain.  It is also used by some of the other scripts.\n\nstg-fold-files-from and stg-swallow are invaluable when shuffing changes\nbetween patches.\n\nstg-what-changed is invaluable when shuffling patches in the stack.\n\nstg-cvs is a very young script, and probably very fragile.  It allows a\nlightweight way of preparing changes with stgit before committing them into\na CVS tree.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"30844","messageId":"20070104234642.13580.5841.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/5] Add contrib/stg-show-old: show old version of a patch.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:46:42Z","receivedAt":"2007-01-04T23:46:42Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-show-old |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-show-old b/contrib/stg-show-old\nnew file mode 100755\nindex 0000000..82692a7\n--- /dev/null\n+++ b/contrib/stg-show-old\n@@ -0,0 +1,13 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-show-old - mini helper to look at the previous version of a\n+# patch (current one by default)\n+\n+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+[ \"$#\" -le 1 ] || { echo >&2 \"Usage: $(basename $0) [<patch>]\"; exit 1; }\n+patch=\"$1\"\n+\n+stg diff -r\"${patch}//bottom.old\"..\"${patch}//top.old\"\n"},{"id":"30845","messageId":"20070104234647.13580.50428.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/5] Add contrib/stg-whatchanged: look at what would be changed by refreshing.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:46:47Z","receivedAt":"2007-01-04T23:46:47Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis script outputs a \"metadiff\" (diff of diffs, ie. diff between 2\nversions of a single patch).  This is somewhat a proof of concept, and some\nwork is indeed needed in the way to present the results.  Consider\nfiltering the output at least through colordiff.\n\nI have 2 uses for this script:\n- when simply editing a patch, provides a 3rd way to check what I've done\n  before refreshing (in addition to \"stg diff\" and \"stg diff -r //bottom\")\n- most usefully, when resolving conflicts caused by a push, to ease\n  checking of the merge result.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-whatchanged |   37 +++++++++++++++++++++++++++++++++++++\n 1 files changed, 37 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-whatchanged b/contrib/stg-whatchanged\nnew file mode 100755\nindex 0000000..978749c\n--- /dev/null\n+++ b/contrib/stg-whatchanged\n@@ -0,0 +1,37 @@\n+#!/bin/bash\n+set -e\n+\n+# stg-whatchanged - show a metadiff for the patch being modified,\n+# especially when resolving a merge.\n+\n+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+# FIXME:\n+# - should only exclude hunk headers differing only in line offsets\n+# - diff coloring should show changes in context lines differently than\n+#   changes in contents\n+# - filter on ^index lines is a bit wide\n+# - we should be able to ask diff to force a new hunk on \"^@@ \" to better\n+#   handle them\n+# - we should always show the hunk header for any changes within a hunk\n+\n+# default to unified diff\n+if [ \"$#\" = 0 ]; then\n+    set -- -u\n+fi\n+\n+# Merges via \"push\" leave top=bottom so we must look at old patch\n+# in this case (unlike, eg., \"pick --fold\")\n+patchdir=\"$(git-rev-parse --git-dir)/patches/$(stg branch)/$(stg top)\"\n+if [ $(cat \"$patchdir/bottom\") = $(cat \"$patchdir/top\") ];\n+then\n+    current_cmd=\"stg-show-old\"\n+else\n+    current_cmd=\"stg show\"\n+fi\n+\n+colordiff \"$@\" \\\n+    -I '^index [0-9a-b]*..[0-9a-b]*' \\\n+    -I '^@@ .* @@' \\\n+    <($current_cmd) <(stg diff -r//bottom) | less -RFX\n"},{"id":"30847","messageId":"20070104234653.13580.65088.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"[PATCH 3/5] Add contrib/stg-fold-files-from: pick selected changes from a patch above current one","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:46:53Z","receivedAt":"2007-01-04T23:46:53Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-fold-files-from |   31 +++++++++++++++++++++++++++++++\n 1 files changed, 31 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-fold-files-from b/contrib/stg-fold-files-from\nnew file mode 100755\nindex 0000000..bfb4a1f\n--- /dev/null\n+++ b/contrib/stg-fold-files-from\n@@ -0,0 +1,31 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-fold-files-from - picks changes to one file from another patch.\n+# Only supports picking from one file, but allows to select any range\n+# of hunks from the file, using the -# flag to filterdiff.\n+# Use together with \"filterdiff --annotate\" in your diff pager, to\n+# identify hunk numbers easily.\n+\n+# usage: stg-fold-files-from <patch> [-#<n>[-<n>][,<n>]...] <file>\n+\n+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+PATCH=\"$1\"\n+shift\n+\n+filtercmd=cat\n+hunks=\n+foldflags=\n+while [ \"$#\" -gt 0 ]; do\n+    case \"$1\" in\n+\t-\\#*) hunks=\"$1\"; shift ;;\n+\t-t) foldflags=\"-t\"; shift ;;\n+\t-*) { echo >&2 \"unknown flag '$1'\"; exit 1; } ;;\n+\t*) break ;;\n+    esac\n+done\n+[ \"$#\" = 1 ] || { echo >&2 \"supports one file only\"; exit 1; }\n+\n+stg show \"$PATCH\" | filterdiff -p1 $hunks -i \"$1\" | stg fold $foldflags\n"},{"id":"30843","messageId":"20070104234658.13580.98141.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"[PATCH 4/5] Add contrib/stg-swallow: completely merge an unapplied patch into current one","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:46:58Z","receivedAt":"2007-01-04T23:46:58Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-swallow |   19 +++++++++++++++++++\n 1 files changed, 19 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-swallow b/contrib/stg-swallow\nnew file mode 100755\nindex 0000000..5014f39\n--- /dev/null\n+++ b/contrib/stg-swallow\n@@ -0,0 +1,19 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-swallow - completely merge an unapplied patch into current one\n+\n+# Copyright (c) 2006-2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+# FIXME:\n+# - should provide support for conflict solving ?\n+\n+[ \"$#\" = 1 ] || { echo >&2 \"Usage: $(basename $0) <patch>\"; exit 1; }\n+patch=\"$1\"\n+\n+stg pick --fold \"$patch\"\n+stg refresh\n+stg push \"$patch\"\n+#stg clean \"$patch\"\n+stg pop; stg clean -u\n"},{"id":"30846","messageId":"20070104234703.13580.3781.stgit@gandelf.nowhere.earth","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"[PATCH 5/5] Add contrib/stg-cvs: helper script to manage a mixed cvs/stgit working copy","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-04T23:47:03Z","receivedAt":"2007-01-04T23:47:03Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis is an early prototype only, use with care, and be sure to read the\nLIMITATIONS section in the script comments.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-cvs |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 126 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-cvs b/contrib/stg-cvs\nnew file mode 100755\nindex 0000000..ee3e7fa\n--- /dev/null\n+++ b/contrib/stg-cvs\n@@ -0,0 +1,126 @@\n+#!/bin/bash\n+set -e\n+\n+# stg-cvs - helper script to manage a mixed cvs/stgit working copy.\n+\n+# Allows quick synchronization of a cvs mirror branch (does not try to\n+# reconstruct patchsets, creates \"jumbo\" commits), and commits stgit\n+# patches to CVS.\n+\n+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+# LIMITATIONS\n+# - this is only a proof-of-concept prototype\n+# - lacks an \"init\" command\n+# - \"commit\" does not \"cvs add/remove\" any file or dir\n+# - \"commit\" does not ensure the base is uptodate before trying to\n+#   commit (but hey, it's CVS ;)\n+# - \"commit\" can only commit a single patch\n+# - not much robustness here\n+# - this only deals with CVS but could surely be extended to any other\n+#   VCS\n+# - stg push/pop operations confuse cvsutils because of timestamp\n+#   changes\n+# - lacks synchronisation of .cvsignore <-> .gitignore\n+\n+usage()\n+{\n+    [ \"$#\" = 0 ] || echo \"ERROR: $*\"\n+    echo \"Usage: $(basename $0) <command>\"\n+    echo \" commands: $(do_commands)\"\n+    exit 1\n+}\n+\n+do_commands()\n+{\n+    echo $(grep '^[a-z-]*)' $0 | cut -d')' -f1)\n+}\n+\n+do_fetch()\n+{\n+    local return=0\n+    local path\n+\n+    local parent=\"$1\"\n+    local branch=\"$2\"\n+\n+    # record changes from cvs into index\n+    stg branch \"$parent\"\n+    cvs -fq update -dP | grep -v '^\\? ' | tee /dev/tty | while read status path; do\n+\tif [ -e \"$path\" ]; then\n+\t    git update-index \"$path\"\n+\telse\n+\t    git rm \"$path\"\n+\tfi\n+    done\n+\n+    # create commit\n+    if git commit -m \"stg-cvs sync\"; then\n+\t:\n+    else\n+\treturn=$?\n+    fi\n+\n+    # back to branch\n+    stg branch \"$branch\"\n+\n+    return $return\n+}\n+\n+# get context\n+branch=$(stg branch)\n+parent=$(git-repo-config \"stgit.yd.${branch}.parent\") || \n+    usage \"no declared parent for '$branch' - set stgit.yd.${branch}.parent\"\n+\n+# extract command\n+\n+[ \"$#\" -ge 1 ] || usage\n+command=\"$1\"\n+shift\n+\n+case \"$command\" in\n+fetch)\n+    do_fetch \"$parent\" \"$branch\"\n+    ;;\n+\n+pull)\n+    if do_fetch \"$parent\" \"$branch\"; then\n+\t# update\n+\tstg pull --merged . \"$parent\"\n+\tstg clean --applied\n+    fi\n+    ;;\n+\n+commit)\n+    # sanity asserts\n+    [ $(stg applied | wc -l) = 1 ] ||\n+\tusage \"you don't have exactly one patch applied\"\n+\n+    # context\n+    patch=$(stg top)\n+    \n+    # commit\n+    cvs -fq commit \\\n+\t-F \".git/patches/$branch/patches/$patch/description\" \\\n+\t$(stg files --bare)\n+\n+    # sync the parent branch\n+    stg branch \"$parent\"\n+    git-cherry-pick \"patches/${branch}/${patch}\"\n+    stg branch \"${branch}\"\n+\n+    # update\n+    stg pull --merged . \"$parent\"\n+    stg clean --applied\n+    ;;\n+\n+_commands)\n+    # hint for bash-completion people :)\n+    do_commands\n+    ;;\n+\n+*)\n+    usage \"unknown command '$command'\"\n+    ;;\n+esac\n"},{"id":"31220","messageId":"b0943d9e0701090221o6437fc0ana17bb190eb1eae0b@mail.gmail.com","threadId":"6226","inReplyTo":"20070104233934.13580.17744.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH 0/5] My set of stgit companion scripts.","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2007-01-09T10:21:30Z","receivedAt":"2007-01-09T10:21:30Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 04/01/07, Yann Dirson <ydirson@altern.org> wrote:\n> The following series adds to contrib/ a set of bash scripts I find useful\n> for my daily use of stgit.  They are probably closely tied to my workflow,\n> but others may find them useful as well.  Some of them may be useful to\n> pythonize and integrate in some form or another.\n\nYes, indeed. I'll try this week (now that the holidays are finished)\nto add TODO and wishlist pages on the wiki so that people can extend\nthem.\n\n> stg-show-old is a trivial thing, but since I often need that functionnality,\n> it is much less comfortable than forging the same command-line over and over\n> again.  It is also used by some of the other scripts.\n\nSince we have some kind of patch history support, I'd rather extend\nthe git_id() function to parse patch names appended with ^ or ~x as in\nGIT. This way you can access the full history and not only the\nprevious version of the patch.\n\nYou can currently do 'stg show [<patch>]//top.old'\n\n> stg-fold-files-from and stg-swallow are invaluable when shuffing changes\n> between patches.\n\nThe first one is indeed useful and might not be easy to implement in a\npython-only script. The latter is useful as a shortcut but I would\nrather have a python command (or --swallow option to 'pick' in\naddition to --fold) to automate this.\n\n> stg-what-changed is invaluable when shuffling patches in the stack.\n\nIt's interesting to see the diff of diffs but it takes some time to\nget used to it :-). There is 'stg log (--patch|--graphical)' which\nshows the diff of every refresh you did on the patch. What it doesn't\nshow is the diff of a push since this creates a new patch version\nevery time. Maybe this could be extended so that for push with\nconflicts, it first stores a version with conflict markers and another\nversion after fixing them and refreshing.\n\n> stg-cvs is a very young script, and probably very fragile.  It allows a\n> lightweight way of preparing changes with stgit before committing them into\n> a CVS tree.\n\nI'm OK with this (but I won't use it much).\n\nThanks.\n\n-- \nCatalin\n"},{"id":"31296","messageId":"20070109222602.GE17093@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"6226","inReplyTo":"b0943d9e0701090221o6437fc0ana17bb190eb1eae0b@mail.gmail.com","subject":"Re: [PATCH 0/5] My set of stgit companion scripts.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-09T22:26:02Z","receivedAt":"2007-01-09T22:26:02Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Tue, Jan 09, 2007 at 10:21:30AM +0000, Catalin Marinas wrote:\n> >stg-what-changed is invaluable when shuffling patches in the stack.\n> \n> It's interesting to see the diff of diffs but it takes some time to\n> get used to it :-).\n\nSure :)\n\nI think there is a lot of room for improvement here, which is possibly\na bit outside the scope of StGIT itself - eg. detecting that a change\nwas indeed done but in a different place, detecting changes impacting\nonly the context, etc.\n\n\n> There is 'stg log (--patch|--graphical)' which\n> shows the diff of every refresh you did on the patch. What it doesn't\n> show is the diff of a push since this creates a new patch version\n> every time.\n\nI'm not sure what you mean here, I do get diffs for pushes, they just\nreflect the changes done in patches below (which indeed confused me\nvery must when I first saw them - I even thought at first that patch\nlogging was confused by something in my repos).\n\nOTOH, there are other places where the log shows nothing but should\nrecord something, eg. on \"refresh -e\" when only editing the message.\n\n\n> Maybe this could be extended so that for push with\n> conflicts, it first stores a version with conflict markers and another\n> version after fixing them and refreshing.\n\nWell, that could possibly help when browsing with existing tools, but\nI'm not sure it would be the right way to do things.\n\nTo be fair, I have mixed feelings towards the current patch logs\nalready.  Specifically, a patch log conceptually records how a patch\nchanges, but the current implementation (just like the one in \"pg\")\nmakes it so changes to below patches are reflected in the log.\n\nI'd rather thing patchlog entries should link 2 commits (ie. maybe we\nshould add the ability for commit object to point to a commit in its\n\"tree\" field, or maybe we should add a new \"metacommit\" type of\nobject), and that we should develop a set of tools to deal with\nchanges in changes, just like we already have tools to deal with\nchanges.  Not a trivial thing, but that should be fun :)\n\nBest regards,\n-- \nYann.\n"}]}