OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Thomas Lotterer
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   06-Mar-2003 22:15:55
  Branch: HEAD                             Handle: 2003030621155500

  Modified files:
    openpkg-re              openpkg-dev

  Log:
    partial but useful branch command implementation

  Summary:
    Revision    Changes     Path
    1.57        +61 -0      openpkg-re/openpkg-dev
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-re/openpkg-dev
  ============================================================================
  $ cvs diff -u -r1.56 -r1.57 openpkg-dev
  --- openpkg-re/openpkg-dev    3 Mar 2003 10:46:29 -0000       1.56
  +++ openpkg-re/openpkg-dev    6 Mar 2003 21:15:55 -0000       1.57
  @@ -226,6 +226,7 @@
           \$ openpkg-dev setup ..... already been done ;)
           \$ openpkg-dev bash ...... enter development environment
           \$ openpkg-dev update .... update development environment from master server
  +        \$ openpkg-dev branch .... switch to a different branch
           \$ openpkg-dev install ... install a package
           \$ openpkg-dev list ...... list source and binary packages
           \$ openpkg-dev diff ...... dry run "release"
  @@ -245,6 +246,65 @@
       )
   }
   
  +branch () {
  +    anybin2branch $1
  +    echo "++ branching to ${BRANCH}"
  +    ( HOME=${OPENPKG_WORK}
  +      export HOME
  +      cvs update -r ${BRANCH}
  +    )
  +    echo "FIXME: please run \"cd .\" to update prompt"
  +    echo "FIXME: still using ${OPENPKG_INST}, automatic instance selection not 
implemented, yet"
  +}
  +
  +#   convert any (branch|instance|name) into branch and set ${BRANCH}
  +#
  +#   Branch              Instance   Name
  +#   ------------------- ---------- --------
  +#   HEAD                /cw        CURRENT
  +#   OPENPKG_1_STABLE    /cw1       1-STABLE
  +#   OPENPKG_1_2_SOLID   /cw12      1.2
  +#   OPENPKG_1_1_SOLID   /cw11      1.1
  +#   OPENPKG_1_0_SOLID   /cw10      1.0
  +#
  +anybin2branch () {
  +    #   remove surrounding whitespaces, take first arg only, toupper
  +    BRANCH=`echo $1 | cut -f 1 -d" " | tr '[a-z]' '[A-Z]'`
  +
  +    #   strip off any abbreviated form of a leading OPENPKG_
  +    BRANCH=`echo "${BRANCH}" | sed -e 
's;^O\{0,1\}P\{0,1\}E\{0,1\}N\{0,1\}P\{0,1\}K\{0,1\}G\{0,1\}_\{0,1\};;'`
  +
  +    #   transform instance into branch
  +    BRANCH=`echo "${BRANCH}" | sed -e 's;^/[A-Z]\{1,\}$;HEAD;' -e 
's;^/[A-Z]\{1,\}\([1-9]\);\1_;'`
  +
  +    #   replace dots from (SOLID name) and dashes (STABLE name) with underscore for 
convenience
  +    BRANCH=`echo "${BRANCH}" | sed -e 's;[\.-];_;g'`
  +
  +    #   check for HEAD (branch) aka CURRENT (name)
  +    echo "CURRENT" | egrep -q "^${BRANCH}" && BRANCH="HEAD"
  +    echo "HEAD"    | egrep -q "^${BRANCH}" && BRANCH="HEAD"
  +
  +    if [ .${BRANCH} != ".HEAD" ]; then
  +
  +        #   extract branchpoint (1, 1_1 ...) and optional direction
  +        BRANBP=`echo "${BRANCH}" | sed -e 
's;^\([1-9][0-9]*\(_\{0,1\}[0-9]*\)\)\(.*\)$;\1;' -e 's;_*$;;'`
  +        BRANDR=`echo "${BRANCH}" | sed -e 
's;^\([1-9][0-9]*\(_\{0,1\}[0-9]*\)\)\(.*\)$;\3;' -e 's;^_*;;'`
  +
  +        #   select direction, check optional direction
  +        echo ${BRANBP} | grep -q '_'
  +        if [ $? = 0 ]; then
  +            BRANCH="OPENPKG_${BRANBP}_SOLID"
  +            echo "SOLID"  | egrep -q "^${BRANDR}" || die "automatic (SOLID) vs. 
manual (${BRANDR}) direction mismatch"
  +        else
  +            BRANCH="OPENPKG_${BRANBP}_STABLE"
  +            echo "STABLE" | egrep -q "^${BRANDR}" || die "automatic (STABLE) vs. 
manual (${BRANDR}) direction mismatch"
  +        fi
  +
  +        unset BRANBP
  +        unset BRANDR
  +    fi
  +}
  +
   bash () {
       cd ${OPENPKG_WORK} || die "cannot cd to ${OPENPKG_WORK}"
   
  @@ -724,6 +784,7 @@
   case ${cmd} in
       setup   | s* ) cmd="setup"   ;;
       update  | u* ) cmd="update"  ;;
  +    branch  | br* ) cmd="branch"  ;;
       bash    | b* ) cmd="bash"    ;;
       list    | l* ) cmd="list"    ;;
       diff    | d* ) cmd="diff"    ;;
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to