Changeset 3588


Ignore:
Timestamp:
Jan 11, 2015 7:16:20 AM (5 years ago)
Author:
bradbell
Message:

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

commit f60d3341fa0a97fca9c7bd57e48b2aa8a8efc27a
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 05:12:39 2015 -0700

push_git2svn.py:

  1. Give use choice to use or overwrite the current svn directory.
  2. Always overwrite the git directory (to get the new values).

commit d427f7d77f50347a57ef03a5980ff7e21b3fe9de
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 04:34:04 2015 -0700

push_git2svn.py: minor spelling error in documentaiton.

commit 546e1664eb739cff025012fc2de1b1cd4efa336b
Author: Brad Bell <bradbell@…>
Date: Sat Jan 10 18:05:34 2015 -0700

push_git2svn.py:

  1. Use svn update to bring log up to date.
  2. Change pattern that has ending hash code in it.
  3. Minor edit of white space in log.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/push_git2svn.py

    r3587 r3588  
    3838# -----------------------------------------------------------------------------
    3939# some simple functions
    40 def pause() :
     40def pause(question, choice_list) :
    4141        response=''
    42         while response != 'y\n' and  response != 'n\n' :
    43                 print('Continue [y/n] ')
     42        while not response in choice_list :
     43                print(question, end='')
    4444                response = sys.stdin.readline()
    45         if response == 'n\n' :
    46                 sys.exit('user abort')
     45                if response.endswith('\n') :
     46                        response = response[:-1]
     47        return response
    4748#
    4849def system(cmd) :
     
    9394svn_directory = work_directory + '/svn'
    9495if os.path.isdir(svn_directory) :
    95         print('Use existing svn directory: ' + svn_directory)
    96         pause()
     96        question    = 'Use existing svn directory:\n\t'
     97        question   +=  svn_directory + '\n'
     98        question   += 'or remove it and check out a new copy ? [use/new] '
     99        choice_list = [ 'use' , 'new' ]
     100        choice      = pause(question, choice_list)
     101        if choice == 'new' :
     102                cmd         = 'rm -r ' + svn_directory
     103                print_system(cmd)
     104else :
     105        choice      = 'new'
     106if choice == 'use' :
    97107        cmd = 'svn revert --recursive ' + svn_directory
     108        print_system(cmd)
     109        cmd = 'svn update ' + svn_directory
    98110        print_system(cmd)
    99111        cmd        = 'svn status ' + svn_directory
     
    110122        print_system(cmd)
    111123# ----------------------------------------------------------------------------
    112 # git hash code corresponding to verison isn svn directory
     124# git hash code corresponding to verison in svn directory
    113125cmd           = 'svn info ' + svn_directory
    114126svn_info      = system(cmd)
    115 rev_pattern   = re.compile('Last Changed Rev: ([0-9]+)')
     127rev_pattern   = re.compile('Last Changed Rev: *([0-9]+)')
    116128match         = re.search(rev_pattern, svn_info)
    117129svn_revision  = match.group(1)
    118130cmd           = 'svn log -r ' + svn_revision + ' ' + svn_directory
    119131svn_log       = system(cmd)
    120 hash_pattern  = re.compile('https://github.com/bradbell/cppad ([0-9a-f]+)')
     132hash_pattern  = re.compile('\nend   hash code: *([0-9a-f]+)')
    121133match         = re.search(hash_pattern, svn_log)
    122134svn_hash_code = match.group(1)
     
    125137git_directory = work_directory + '/git'
    126138if os.path.isdir(git_directory) :
    127         print('Use existing git directory: ' + git_directory)
    128         pause()
    129 else :
    130         cmd  = 'svn export '
    131         cmd +=  git_repository + '/' + git_branch_path + ' ' + git_directory
    132         print_system(cmd)
     139        cmd = 'rm -r ' + git_directory
     140        print_system(cmd)
     141cmd  = 'svn export '
     142cmd +=  git_repository + '/' + git_branch_path + ' ' + git_directory
     143print_system(cmd)
    133144# -----------------------------------------------------------------------------
    134145# list of files for the svn and git directories
     
    223234data  = 'merge to branch: ' + svn_branch_path + '\n'
    224235data += 'from repository: ' + git_repository + '\n'
    225 data += 'start hash code:  ' + svn_hash_code + '\n'
    226 data += 'end   hash code:  ' + git_hash_code + '\n\n'
     236data += 'start hash code: ' + svn_hash_code + '\n'
     237data += 'end   hash code: ' + git_hash_code + '\n\n'
    227238sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'"
    228239if svn_branch_path == 'trunk' :
     
    230241else :
    231242        cmd    = 'git log origin/' + git_branch_path + ' | ' + sed_cmd
    232 output = print_system(cmd)
    233 data += output
    234 log_f = open( svn_directory + '/push_git2svn.log' , 'wb')
     243output = system(cmd)
     244data  += output
     245log_f  = open( svn_directory + '/push_git2svn.log' , 'wb')
    235246log_f.write(data)
    236247log_f.close()
Note: See TracChangeset for help on using the changeset viewer.