Changeset 3593


Ignore:
Timestamp:
Jan 11, 2015 6:29:49 PM (5 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/bradbell/cppad
start hash code: f60d3341fa0a97fca9c7bd57e48b2aa8a8efc27a
end hash code: f4baab0ea7c2679ba9351b0439b6efebfa77ba04

commit f4baab0ea7c2679ba9351b0439b6efebfa77ba04
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 16:27:27 2015 -0700

new_branch.sh: convert from git-svn; i.e. make similar to push_git2svn.sh.
push_git2svn.py: use build/work for work directory.

commit 93faca1533e1113e157027423e510fcaf588587b
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 08:07:52 2015 -0700

new_release.sh: fix message about conf directory.

commit 3e83230bd86c25b70f623b8cdca0a842204df2d2
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 07:02:49 2015 -0700

new_release.sh: Changes copied from stable/20150000.
new_stable.sh: Put abort at beginning and fix new year (when use it).
push_git2svn.py: Fixes for working with stable branches.

Location:
trunk/bin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/new_branch.sh

    r3577 r3593  
    1616        exit 1
    1717fi
    18 if [ ! -e '.git/svn' ]
     18if [ "$1" == '' ] || [ "$2" == 'trunk' ]
    1919then
    20         echo 'bin/new_branch.sh: must be executed in the git_svn repository'
     20        echo 'usage:  bin/new_branch.sh svn_branch_path'
     21        echo 'copies the current trunk to svn_branch_path'
    2122        exit 1
    2223fi
    23 if [ "$2" == '' ]
    24 then
    25         echo 'usage:  bin/new_branch.sh branch_path svn_revision'
    26         exit 1
    27 fi
    28 branch_path="$1"
    29 svn_revision="$2"
    30 repository='https://projects.coin-or.org/svn/CppAD'
     24svn_branch_path="$1"
    3125# -----------------------------------------------------------------------------
    3226# bash function that echos and executes a command
     
    3630}
    3731# -----------------------------------------------------------------------------
    38 # make sure repsitories are in sync
    39 echo_eval git svn rebase
    40 echo_eval git fetch github
     32# some settings
     33svn_repository='https://projects.coin-or.org/svn/CppAD'
     34git_repository='https://github.com/bradbell/cppad'
     35work_directory='build/work'
    4136# -----------------------------------------------------------------------------
    42 msg="Creating $branch_path from trunk at revision $svn_revision."
    43 cmd="svn copy -r $svn_revision $repository/trunk $repository/$branch_path"
    44 echo "$cmd -m \"$msg\""
    45 $cmd -m "$msg"
     37# check that remote master is in sync
     38hash_origin=`git show-ref origin/master | sed -e 's|^\([0-9a-f]*\).*|\1|'`
     39hash_list=`git show-ref master | sed -e 's|^\([0-9a-f]*\).*|\1|'`
     40for hash in $hash_list
     41do
     42        if [ "$hash" != "$hash_origin" ]
     43        then
     44                echo_eval git show-ref master
     45                echo 'exiting because hash codes are different'
     46                exit 1
     47        fi
     48done
     49# -----------------------------------------------------------------------------
     50# make sure work directory exists
     51if [ ! -d "$work_directory" ]
     52then
     53        echo_eval mkdir -p "$work_directory"
     54fi
     55# -----------------------------------------------------------------------------
     56# checkout svn version of directory
     57svn_directory="$work_directory/svn"
     58if [ -e "$svn_directory" ]
     59then
     60        echo 'Use existing svn direcory'
     61        echo "  $svn_directory"
     62        read -p '? [y/n] ' response
     63        if [ "$response" != 'y' ]
     64        then
     65                echo_eval rm -r $svn_directory
     66        else
     67                echo_eval svn revert --recursive $svn_directory
     68                svn_status=`svn status $svn_directory | \
     69                        sed -n -e '/^\?/p' | sed -e 's|^\? *||'`
     70                for file_name in $svn_status
     71                do
     72                        echo_eval rm $file_name
     73                done
     74        fi
     75fi
     76if [ ! -e "$svn_directory" ]
     77then
     78        echo_eval svn checkout $svn_repository/trunk $svn_directory
     79fi
    4680# ----------------------------------------------------------------------------
    47 echo 'Use git-svn to fetch the new stable version'
    48 fetch="$branch_path:refs/remotes/svn/$branch_path"
    49 if ! grep "fetch *= *$fetch" .git/config > /dev/null
     81# git hash code corresponding to current version of trunk
     82svn_revision=`svn info $svn_directory | \
     83        sed -n -e '/^Last Changed Rev:/p' | sed -e 's|^Last Changed Rev: *||'`
     84hash_svn=`svn log -r $svn_revision $svn_directory | \
     85        sed -n -e '/^end *hash *code:/p' | sed -e 's|^end *hash *code: *||'`
     86if [ "$hash_origin" != "$hash_svn" ]
    5087then
    51         # backup current version of .git/config
    52         index='1'
    53         while [ -e .git/config.$index ]
    54         do
    55                 index=`expr $index + 1`
    56         done
    57         echo_eval cp .git/config .git/config.$index
    58         #
    59         sed -e "s|^\turl *= *$repository|&\n\tfetch = $fetch|" -i .git/config
    60 fi
    61 # fetch the branch
    62 echo_eval git svn fetch
     88        echo "$hash_origin hash code for master"
     89        echo "$hash_svn hash code for trunk"
     90        echo 'Exiting because hash codes are different.'
     91        echo 'Use the following command to fix this'
     92        echo '  bin/push_git2svn.py trunk'
     93        exit 1
     94fi 
    6395# -----------------------------------------------------------------------------
    64 # checkout the new stable version
    65 branch_name=`echo $branch_path | sed -e 's|branches/||'`
    66 echo_eval git checkout -b $branch_name svn/$branch_path
     96cat << EOF > $svn_directory/new_branch.log
     97copy trunk to:   $svn_branch_path
     98start hash code: $hash_origin
     99EOF
     100echo_eval svn copy --file new_branch.log \
     101        $repository/trunk $repository/$branch_path
    67102# -----------------------------------------------------------------------------
    68 # push it to github
    69 git push github $branch_name
    70 # -----------------------------------------------------------------------------
     103echo_eval git checkout master
     104git_branch_name=`echo $svn_branch_path | sed -e 's|^branches/||'`
     105echo_eval git branch $git_branch_name
  • trunk/bin/new_release.sh

    r3550 r3593  
    2424repository="https://projects.coin-or.org/svn/CppAD"
    2525stable_version="20150000"
    26 release='0'
     26release='2'
    2727release_version="$stable_version.$release"
    2828# -----------------------------------------------------------------------------
     
    5050        echo "  bin/version.sh set $release_version"
    5151        echo '  bin/version.sh copy'
    52         echo 'then test and then commit the changes.'
     52        echo 'Then test and then commit the changes.'
     53        echo 'Then push changes to github.'
     54        echo 'Then execute the following command:'
     55        echo "  bin/push_git2svn.sh  stable/$stable_version"
    5356        exit 1
    5457fi
     
    6265        -m "corresponds $repository/releases/$release_version" \
    6366        $release_version
    64 #
    65 # copy committed changes to coin repository
    66 echo_eval git svn dcommit
    67 #
    68 # copy commited changes to github repository
    69 echo_eval git push github stable/$stable_version
    70 echo_eval git push --tabs github
    7167# -----------------------------------------------------------------------------
    7268msg="Creating releases/$release_version"
     
    8581#
    8682msg="Update stable and release numbers in projDesc.xml"
    87 echo 'Settting stable and advance release in ../../conf/projDesc.xml.'
     83echo 'Settting stable and advance release in build/conf/projDesc.xml.'
    8884sed -i projDesc.xml \
    8985        -e "/^ *<stable/,/^ *<\/stable/s/[0-9]\{8\}/$stable_version/" \
  • trunk/bin/new_stable.sh

    r3517 r3593  
    1111# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1212# -----------------------------------------------------------------------------
     13echo 'Need to change this from using git-svn to using push_git2svn.sh'
     14echo 'See bin/new_release.sh.'
     15exit 1
    1316if [ "$0" != "bin/new_stable.sh" ]
    1417then
  • trunk/bin/push_git2svn.py

    r3588 r3593  
    3535svn_repository = 'https://projects.coin-or.org/svn/CppAD'
    3636git_repository = 'https://github.com/bradbell/cppad'
    37 work_directory = 'build/push_git2svn'
     37work_directory = 'build/work'
    3838# -----------------------------------------------------------------------------
    3939# some simple functions
     
    5454                        shell=True
    5555                )
    56         except subprocess.CalledProcessError :
    57                 msg  = subprocess.CalledProcessError.output
     56        except subprocess.CalledProcessError as info :
     57                msg  = info.output
    5858                msg += '\nbin/push_git2svn.py exiting because command above failed'
    5959                sys.exit(cmd + '\n\n' + msg)
     
    7373        return output
    7474# -----------------------------------------------------------------------------
    75 # determine git_branch_path
    76 if svn_branch_path == 'trunk' or svn_branch_path.startswith('branches/') :
     75# determine git_branch_name
     76if svn_branch_path == 'trunk' :
     77        git_branch_name = 'master'
    7778        git_branch_path = svn_branch_path
    78 else :
     79elif svn_branch_path.startswith('branches/') :
     80        git_branch_name = svn_branch_path[len('branches/'):]
     81        git_branch_path = svn_branch_path
     82else :
     83        git_branch_name = svn_branch_path
    7984        git_branch_path = 'branches/' + svn_branch_path
    8085# -----------------------------------------------------------------------------
    8186# hash code for the git branch
    82 if svn_branch_path == 'trunk' :
    83         cmd = 'git show-ref origin/master'
    84 else :
    85         cmd = 'git show-ref origin/' + git_branch_path
     87cmd = 'git show-ref origin/' + git_branch_name
    8688git_hash_code = system(cmd)
    87 git_hash_code = git_hash_code.replace(' refs/remotes/origin/master\n', '')
     89pattern       = ' refs/remotes/origin/' + git_branch_name
     90git_hash_code = git_hash_code.replace(pattern, '')
    8891# -----------------------------------------------------------------------------
    8992# make sure work directory exists
     
    132135hash_pattern  = re.compile('\nend   hash code: *([0-9a-f]+)')
    133136match         = re.search(hash_pattern, svn_log)
    134 svn_hash_code = match.group(1)
     137if match :
     138        svn_hash_code = match.group(1)
     139else :
     140        svn_hash_code = None
    135141# -----------------------------------------------------------------------------
    136142# export the git verison of the directory
     
    178184# -----------------------------------------------------------------------------
    179185# automated svn commands
    180 id_pattern = re.compile(r'^.*\$Id.*')
     186id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE)
    181187#
    182188for git_file in created_list :
     
    234240data  = 'merge to branch: ' + svn_branch_path + '\n'
    235241data += 'from repository: ' + git_repository + '\n'
    236 data += 'start hash code: ' + svn_hash_code + '\n'
    237 data += 'end   hash code: ' + git_hash_code + '\n\n'
    238 sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'"
    239 if svn_branch_path == 'trunk' :
    240         cmd    = 'git log origin/master | ' + sed_cmd
    241 else :
    242         cmd    = 'git log origin/' + git_branch_path + ' | ' + sed_cmd
    243 output = system(cmd)
    244 data  += output
     242if svn_hash_code != None :
     243        data += 'start hash code: ' + svn_hash_code + '\n'
     244else :
     245        data += 'start hash code: missing\n'
     246data   += 'end   hash code: ' + git_hash_code + '\n\n'
     247if svn_hash_code != None :
     248        sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'"
     249        cmd     = 'git log origin/' + git_branch_name + ' | ' + sed_cmd
     250        output = system(cmd)
     251        data  += output
    245252log_f  = open( svn_directory + '/push_git2svn.log' , 'wb')
    246253log_f.write(data)
    247254log_f.close()
     255#
    248256msg  = '\nChange into svn directory with the command\n\t'
    249257msg += 'cd ' + svn_directory + '\n'
    250258msg += 'If these changes are OK, execute the command:\n\t'
    251259msg += 'svn commit --file push_git2svn.log\n'
    252 msg += 'You may want to edit the log push_git2svn.log'
     260if svn_hash_code != None :
     261        msg += 'You should inspect and possibly edit push_git2svn.log'
     262else :
     263        msg += 'The start hash code could not be automatically determined.\n'
     264        msg += 'You should edit push_git2svn.log to describe the changes.'
    253265print(msg)
Note: See TracChangeset for help on using the changeset viewer.