Received: from spf1.us4.outblaze.com (spf1.us4.outblaze.com [205.158.62.23]) by sdf.lonestar.org (8.12.10/8.12.10) with ESMTP id j0JCKbxO014870 for ; Wed, 19 Jan 2005 12:20:37 GMT Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by spf1.us4.outblaze.com (Postfix) with ESMTP id 4DA74298493 for ; Wed, 19 Jan 2005 12:21:02 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CrF1X-0005Xg-B2 for migo@homemail.com; Wed, 19 Jan 2005 07:33:23 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CrEZD-000377-4U for gnu-arch-users@gnu.org; Wed, 19 Jan 2005 07:04:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CrESF-0001tK-9w for gnu-arch-users@gnu.org; Wed, 19 Jan 2005 06:56:57 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CrESE-0001cI-CA for gnu-arch-users@gnu.org; Wed, 19 Jan 2005 06:56:54 -0500 Received: from [202.72.174.244] (helo=euclid.patrick.wattle.id.au) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CrE9L-0006Uh-Iz for gnu-arch-users@gnu.org; Wed, 19 Jan 2005 06:37:26 -0500 Received: from kant.home (kant.vpn.patrick.wattle.id.au [IPv6:2002:ca48:aef4:4::1]) by euclid.patrick.wattle.id.au (Postfix) with ESMTP id 15F3053ECC for ; Wed, 19 Jan 2005 19:36:21 +0800 (WST) Received: by kant.home (Postfix, from userid 1000) id 79B1E3C9CE; Wed, 19 Jan 2005 19:36:48 +0800 (WST) Date: Wed, 19 Jan 2005 19:36:47 +0800 From: Cameron Patrick To: gnu-arch-users@gnu.org Subject: Re: [Gnu-arch-users] Optimal setup for disconnected/laptop use? Message-ID: <20050119113647.GA29831@patrick.wattle.id.au> Mail-Followup-To: gnu-arch-users@gnu.org References: <891bd33905011820306214875d@mail.gmail.com> Mime-Version: 1.0 In-Reply-To: <891bd33905011820306214875d@mail.gmail.com> Organization: Parenthesis Conspiracy User-Agent: Mutt/1.5.6+20040803i X-BeenThere: gnu-arch-users@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: a discussion list for all things arch-ish List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0778720173==" Sender: gnu-arch-users-bounces+migo=homemail.com@gnu.org Errors-To: gnu-arch-users-bounces+migo=homemail.com@gnu.org Status: RO Content-Length: 12457 Lines: 424 --===============0778720173== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1UWUbFP1cBYEclgG" Content-Disposition: inline --1UWUbFP1cBYEclgG Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Yaron Minsky wrote: > And is there some way of making the commits I do on the laptop show > up cleanly and individually on the desktop once they are merged in? I recently wrote the attached script to do just that; haven't used it much yet but It Seems To Work. It's modelled on the user interface of Darcs and asks you about merging each changeset not present in the upstream version (and optionally lets you review the diffs) before doing anything, etc. The general idea is you create an archive on your laptop, tag your project across to that, hack on it, then run something like tla-pure-merge --push my.other.archive@example.net/foo--bar--1 If you create a file called {arch}/+upstream-version it will use that as the default version to merge into (or merge from if you use --pull). Cameron. --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=tla-pure-merge Content-Transfer-Encoding: quoted-printable #! /bin/sh # tla-pure-merge: apply un-merged patches on one branch to another # Copyright (C) Cameron Patrick, 2005. # # Permission is hereby granted, free of charge, to any person obtaining a = copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation t= he # rights to use, copy, modify, merge, publish, distribute, sublicense, and= /or # sell copies of the Software, and to permit persons to whom the Software = is # furnished to do so, subject to the following conditions: #=20 # The above copyright notice and this permission notice shall be included = in # all copies or substantial portions of the Software. #=20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS = OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL = THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL= INGS # IN THE SOFTWARE. # # TODO: should allow applying patches to existing project tree set -e usage() { echo "usage: tla-pure-merge [options] SOURCE DESTINATION" echo "Replays pure changesets from the SOURCE version or revision to" echo "the DESTINATION version." echo echo "Options:" echo " -h --help Display this message" echo " -a --all Merge all patches without ask= ing" echo "* -i --interactive Ask which patches to merge" echo " -p PATCH --patches PATCH Merge the listed patches" echo " -l --pull Use current tree version as D= ESTINATION" echo " -s --push Use current tree version as S= OURCE" echo " --edit-summary Add source revision to summar= y" echo "* --no-edit-summary Use the same log summaries as= the source" echo "* --skip-present Use tla missing --skip-presen= t" echo " --no-skip-present Disable the --skip-present be= haviour" echo echo "Options indicated with a * are on by default." echo echo "If --pull or --push is specified, and no revision name is given, = tla-pure-merge" echo "will use use {arch}/+upstream-version as the SOURCE or DESTINATIO= N." exit 0 } die() { echo "$@" 1>&2 echo "Try tla-pure-merge --help for command-line options." 1>&2 exit 1 } find_upstream_vers() { local tree_root=3D"$(tla tree-root)" if [ -f "${tree_root}/{arch}/+upstream-version" ]; then upstream_vers=3D"$(cat ${tree_root}/{arch}/+upstream-version)" else upstream_vers=3D"" fi } clean_up() { cd .. rm -rf $temp_dir } if [ "$PAGER" =3D "" ]; then PAGER=3Dless fi edit_summary=3Dno skip_present=3Dyes interactive=3Dyes mode=3Dnormal patches_missing=3D"" source_vers=3D"" dest_vers=3D"" # parse command line arguments while [ "$#" !=3D "0" ]; do case "$1" in -h|--help) usage ;; -a|--all) interactive=3Dno ;; -i|--interace) interactive=3Dyes ;; -p|--patches) if [ "$2" =3D "" ]; then die "--patches specified but no patch list given" fi patches_missing=3D"$2" interactive=3Dno echo "* patches to merge: $2" shift ;; -l|--pull) mode=3Dpull if ! tla tree-root >/dev/null; then die "--pull given but not in a project tree." fi dest_vers=3D"$(tla tree-version)" find_upstream_vers echo "* using tree version ${dest_vers} as destination" ;; -s|--push) mode=3Dpush if ! tla tree-root >/dev/null; then die "--push given but not in a project tree." fi find_upstream_vers source_vers=3D"$(tla tree-version)" echo "* using tree version ${source_vers} as source" ;; --edit-summary) edit_summary=3Dyes ;; --no-edit-summary) edit_summary=3Dno ;; --skip-present) skip_present=3Dyes ;; --no-skip-present) skip_present=3Dno ;; -*) die "Unknown option argument $1" ;; *) if [ "$source_vers" =3D "" ]; then source_vers=3D"$1" elif [ "$dest_vers" =3D "" ]; then dest_vers=3D"$1" else die "Don't know what to do with argument $1" fi ;; esac shift done # default to upstream versions if possible if [ "$mode" =3D "pull" ] && [ "$source_vers" =3D "" ] && [ "$upstream_vers" !=3D "" ]; then echo "* using upstream version ${upstream_vers} as source" source_vers=3D"$upstream_vers" fi if [ "$mode" =3D "push" ] && [ "$dest_vers" =3D "" ] && [ "$upstream_vers" !=3D "" ]; then echo "* using upstream version ${upstream_vers} as destination" dest_vers=3D"$upstream_vers" fi # make sure we have a source and a destination if [ "$source_vers" =3D "" ]; then die "No source version specified to merge from." fi if [ "$dest_vers" =3D "" ]; then die "No destination version specified to merge into." fi # grab a copy of the destination revision temp_dir=3D",,pure-merge-$$-$(tla parse-package-name --non-arch $dest_vers)" tla get --silent $dest_vers $temp_dir cd $temp_dir trap "clean_up; exit 1" INT EXIT # decide which patches to consider merging if [ "$patches_missing" !=3D "" ]; then : elif tla parse-package-name -l $source_vers >/dev/null 2>/dev/null; then patches_missing=3D"$(tla parse-package-name -l $source_vers)" else skip_present_flag=3D--skip-present [ $skip_present =3D no ] && skip_present_flag=3D'' patches_missing=3D"$(tla missing $skip_present_flag $source_vers | grep= -v ^base- || true)" fi source_vers=3D"$(tla parse-package-name -a $source_vers)/$(tla parse-packag= e-name --package-version $source_vers)" # maybe there are no missing patches? if [ "$patches_missing" =3D "" ]; then echo echo "No changes to merge." exit 0 fi # fetch patches and log entries for x in $patches_missing; do patch=3D"$source_vers--$x" echo "* fetching patch $patch" tla get-changeset $patch ,tmp-cset-$x tla cat-archive-log $patch >,tmp-log-$x done # decide which patches to merge if [ "$interactive" =3D "no" ]; then act=3D"a" else act=3D"?" fi patches_to_merge=3D"" for x in $patches_missing; do summary=3D"$(grep '^Summary: ' ,tmp-log-$x | sed 's/^Summary: //g')" creator=3D"$(grep '^Creator: ' ,tmp-log-$x | sed 's/^Creator: //g')" date=3D"$(grep '^Date: ' ,tmp-log-$x | sed 's/^Date: //g')" echo echo "$x" echo " $date $creator" echo " $summary" while true; do if [ "$act" =3D "a" ] || [ "$act" =3D "d" ]; then break fi echo -n "Merge this patch? [ynvxdaq?] " read act case $act in y|Y|n|N|d|D|a|A) break ;; v|V) tla show-changeset --diffs ,tmp-cset-$x | $PAGER ;; x|X) tla show-changeset ,tmp-cset-$x ;; q|Q) echo "Cancelling merge." exit 0 ;; *) echo "Your choices are:" echo " y - merge this patch" echo " n - don't merge this patch" echo " v - view this patch and ask again" echo " x - view a summary of this patch and ask again" echo " d - skip this patch and all after it" echo " a - merge this patch and all after it" echo " q - cancel, don't merge anything" echo ;; esac done if [ "$act" =3D "y" ] || [ "$act" =3D "a" ]; then patches_to_merge=3D"$patches_to_merge $x" fi done echo # merge selected patches for x in $patches_to_merge; do patch=3D"$source_vers--$x" if ! tla changes -q; then echo "PANIC: Gah, changes have been made to source tree." echo "This shouldn't happen :(" # remove trap now, we don't want to remove the temp dir trap - EXIT exit 2 fi rm -rf ,tmp-log cp ,tmp-log-$x ,tmp-log =20 echo "* pure merge: applying $patch" log_file=3D"$(tla make-log)" merge_of=3D"$patch" merge_of_pure=3Dno if grep -q '^Pure-merge-of: ' ,tmp-log; then merge_of=3D"$(sed -n -e '/^Pure-merge-of: / { s/^Pure-merge-of: \(.= *\)/\1/g; p }' ,tmp-log)" merge_of_pure=3Dyes fi cat /dev/null >$log_file if [ "$merge_of_pure" =3D "yes" ]; then cat ,tmp-log | \ sed -n -e '/^Original-/ p' -e '/^Summary: / Q' >>$log_file else cat ,tmp-log | \ sed -e 's/^\(Creator\|Date\|Standard-date\): /Original-\1: /g' \ -e t -e d -e '/^Summary: / Q' \ >>$log_file fi echo "Direct-ancestor: $patch" >>$log_file echo "Pure-merge-of: $merge_of" >>$log_file if [ "$edit_summary" =3D "yes" ]; then cat ,tmp-log | sed -n \ -e '/^Summary: / { s/ [merge of .*]$//g; s%$% [merge of '"$merg= e_of"']%g; p; q }' >>$log_file else cat ,tmp-log | sed -n \ -e '/^Summary: / { p; q }' >>$log_file fi cat ,tmp-log | sed -e '1,/^Summary: / d' >>$log_file rm -f ,tmp-log if ! tla apply-changeset ,tmp-cset-$x .; then echo "* conflicts during pure merge of $patch" echo "Please fix conflicts by hand and run \`tla commit\`" echo "in directory $temp_dir" # remove trap now, we don't want to remove the temp dir trap - EXIT exit 1 fi tla commit done exit 0 # arch-tag: a36bd7cf-88b4-4ef9-9d6f-944d18ac6600 --/04w6evG8XlLl3ft-- --1UWUbFP1cBYEclgG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFB7kZPl1rlvh2uVnMRAtJ6AKC7tBRtmwE9wjOjWueNMKkBePMRAACfYtfR 9JI8HqRcCuoqce5qfosKv8M= =OHwD -----END PGP SIGNATURE----- --1UWUbFP1cBYEclgG-- --===============0778720173== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gnu-arch-users mailing list Gnu-arch-users@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-arch-users GNU arch home page: http://savannah.gnu.org/projects/gnu-arch/ --===============0778720173==--