source: trunk/bin/push_git2svn.py @ 3941

Last change on this file since 3941 was 3941, checked in by bradbell, 2 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: b7056a15a1028d7be587b70a3ecc44b1f42dc05e
end hash code: c8c4cc081accff3628e7e66370ec01e4c99afe8d

commit c8c4cc081accff3628e7e66370ec01e4c99afe8d
Author: Brad Bell <bradbell@…>
Date: Thu Jun 1 23:16:39 2017 -0600

Changes automatically generated by the autotools.

commit f4392bc3eee8f6d0ccd45a0bb3be51181e211680
Author: Brad Bell <bradbell@…>
Date: Thu Jun 1 23:11:56 2017 -0600

  1. Add colpack_jac.cpp example (rename colpack_jac.cpp->colpack_jacobian.cpp).
  2. Add colpack_hescpp example (rename colpack_hes.cpp->colpack_hessian.cpp).


test_one.sh.in: adapt to using test_boolofvoid for testing.
sparse_hes.hpp: fix bug in cppad.symmetric case.

commit 086b8a8709b0c9cb01ce2cf8bc7910e903105ff7
Author: Brad Bell <bradbell@…>
Date: Thu Jun 1 08:54:59 2017 -0600

  1. Fix bug in use of colpack (see kludge in comments).
  2. Fix colpack.symmetric (not general) and add colpack.general.
  3. Deprecate colpack.star.
  4. More autotools from install to deprecated.
  5. Advance to cppad-20170601.

commit 23f26c060648f5c6fc62a1598c659aeccc5ca46f
Author: Brad Bell <bradbell@…>
Date: Tue May 30 08:14:04 2017 -0700

Advance to cppad-20170530.

commit 97f8c08509865d1bfb7ec2e5cd557ddc979f8412
Author: Brad Bell <bradbell@…>
Date: Tue May 30 07:38:47 2017 -0700

debug_rel branch:
There is a problem with speed sparse_hessian debug that goes back to master.
Supresss debug in cppad speed tests until it is fixed.

commit 39ea0d7d9c041784ccd26ce80d19a7ab02752818
Author: Brad Bell <bradbell@…>
Date: Mon May 29 22:34:22 2017 -0700

debug_rel branch:
run_cmake.sh: fix debug_none case.
CMakeLists.txt: use cppad_debug_which to determine debug or release.
CMakeLists.txt: let set_compile_flags determkine build type.

commit 191553e54dca407207789cf0d7c6c27fe6188775
Author: Brad Bell <bradbell@…>
Date: Mon May 29 19:53:08 2017 -0700

debug_rel branch:
Use set_compile_flags in introduction.

commit fba276a84e58d9a0d0944168d5706b7446beb32c
Author: Brad Bell <bradbell@…>
Date: Mon May 29 19:46:30 2017 -0700

debug_rel branch:
Use set_compile_flags in eample/multi_thread subdirectories.

commit 66c8cdb266fa3af29b211b8c870a3aed7a13b021
Author: Brad Bell <bradbell@…>
Date: Mon May 29 18:56:48 2017 -0700

debug_rel branch:
Use set_compile_flags in speed directory.

commit c431b15ee7714d3106234bc527ba2f9a836750e1
Author: Brad Bell <bradbell@…>
Date: Mon May 29 18:36:51 2017 -0700

debug_rel branch:
Convert cppad_ipopt to use set_compile_flags and cppad_debug_which.


CMakeLists.txt: alwasy compile for release to reduce testing time.

commit 2c95b0019f1b665fb14b9f00b049e8b5fb11f89d
Author: Brad Bell <bradbell@…>
Date: Mon May 29 16:55:07 2017 -0700

debug_rel branch:
Add cppad_debug_which to the cmake command line.

commit fd8d1498cf6dc092deca41f764cbb2a001a4cc88
Author: Brad Bell <bradbell@…>
Date: Mon May 29 08:14:23 2017 -0700

debug_rel branch:
Change random_debug_release -> set_compile_flags.

commit 159f5a5aa09012213a52f4ed1c9f0607129a5fe7
Author: Brad Bell <bradbell@…>
Date: Mon May 29 06:50:43 2017 -0700

debug_rel branch:
Update the autotools automatically generated build files.


batch_edit.sh: Start comments about a plan for editing all the source files.
get_sacado.sh: advance to trilions-12.10.11.
makefile.am: advance to trilinos-12.10.1

commit 302153317cd296ec6f927c3202cf96bf38594bbb
Author: Brad Bell <bradbell@…>
Date: Mon May 29 05:20:00 2017 -0700

debug_rel branch:
Add error message if sacado configuration file does not exist.

commit 3f01a631ae808c3a1359e53e1cd55e9a0ea88711
Author: Brad Bell <bradbell@…>
Date: Mon May 29 04:24:00 2017 -0700

debug_rel branch:
CMakeLists.txt: automate naming of libraries Sacado needs.
checkpoint.cpp: fix warnings.

commit dd240928c0c8b6972a8197c985ccc01f08b8886b
Author: Brad Bell <bradbell@…>
Date: Sun May 28 08:25:20 2017 -0700

debug_rel branch:
sparse_sub_hes.cpp: add missing cases found by clang compiler.

commit 30a0c35f1ac50ec425be9a2b7b026284026eccd7
Author: Brad Bell <bradbell@…>
Date: Sun May 28 07:57:36 2017 -0700

debug_rel branch:
eigen_cholesky.hpp: fix compiler warning.
harmonic_time.cpp: remove include that is not used.
forward_active.cpp: fix compiler warning.

commit 4876d14e49dc235865b1574fb38a55cf5ea7a422
Author: Brad Bell <bradbell@…>
Date: Sun May 28 06:19:48 2017 -0700

debug_rel branch:
random_debug_release.cmake: fix comment, remove message replaced by random_choice_0123 in output.
multiple_solution.cpp: fix warnings with clang compiler.
eigen_cholesky.hpp: fix warnings with clang compiler.
compare_change.cpp: fix CPPAD_DEBUG_AND_RELEASE case.

commit 2c51a18f35188d04d2f94069382439580e23f4ac
Author: Brad Bell <bradbell@…>
Date: Sat May 27 21:04:37 2017 -0700

debug_rel branch:
Advance version to cppad-20170527.

commit 4500887b362537774b05e954ad2a95b65a7b8ba0
Author: Brad Bell <bradbell@…>
Date: Sat May 27 09:04:56 2017 -0700

debug_rel branch:
Ramdomly select debug or release flags in example directory.


CMakeLists.txt: always debug for multi_threed examples.

commit 140b5269a0b1a30643894e5a7a8c9a5eb1310301
Author: Brad Bell <bradbell@…>
Date: Sat May 27 08:10:51 2017 -0700

debug_rel branch:
Changing how we set all debug and release flags.

commit e6fb2639db1288fb75de4030b5906df1e41756f9
Author: Brad Bell <bradbell@…>
Date: Sat May 27 07:30:24 2017 -0700

debug_rel branch:
Replace use of cppad_extra_debug by CPPAD_DEBUG_AND_RELEASE.

commit fbbfd0f6e94862174a8a7a17308489ffddb28084
Author: Brad Bell <bradbell@…>
Date: Sat May 27 05:55:58 2017 -0700

debug_rel branch:
Improve random selection of which files are build for release or debug.


forward.cpp: use new -DCPPAD_DEBUG_AND_RELEASE flag.

commit 284be366fb5e2f685a0c71ea6a0e3f74584bf187
Author: Brad Bell <bradbell@…>
Date: Thu May 25 07:39:32 2017 -0700

debug_rel branch:
Add test that failed before change to player.


player.hpp: Fix so it has the same size in debug and release more.
checkpoint.cpp: fix warning when compiling for release.
run_cmake.sh: prepare to use random number to switch debug and release set.
CMakeLists.txt: switch to only test debug (for now).

commit f32375b77e3825628fee6cb160f691a32c48b796
Author: Brad Bell <bradbell@…>
Date: Wed May 24 12:04:27 2017 -0700

debug_rel branch:
forward.cpp: fix a warning during release build.

commit 5fcc7eb78ae8de9f1dbc6c4f0c76fe38e8aeba95
Author: Brad Bell <bradbell@…>
Date: Wed May 24 10:11:12 2017 -0700

debug_rel branch:
CMakeLists.txt: make easy to mix debug and release builds.
eigen_mat_inv.hpp: fix release version warning.

commit 696266f3d62079f5e3bfb1a0f60a7e4f8134e068
Author: Brad Bell <bradbell@…>
Date: Wed May 24 05:43:29 2017 -0700

push_git2svn.py: user ./build in place of ./build/work.
testvector.hpp: improve comments about replacing CPPAD_TESTVECTOR.

  • Property svn:executable set to *
File size: 10.1 KB
Line 
1#! /bin/python
2# $Id
3# -----------------------------------------------------------------------------
4# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
5#
6# CppAD is distributed under multiple licenses. This distribution is under
7# the terms of the
8#                     Eclipse Public License Version 1.0.
9#
10# A copy of this license is included in the COPYING file of this distribution.
11# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
12# -----------------------------------------------------------------------------
13from __future__ import print_function
14# -----------------------------------------------------------------------------
15# imports
16import sys
17import os
18import re
19import subprocess
20import pdb
21# -----------------------------------------------------------------------------
22# command line arguments
23usage = '\tbin/push_git2svn.py svn_branch_path\n'
24narg  = len(sys.argv)
25if sys.argv[0] != 'bin/push_git2svn.py' :
26        msg = 'bin/push_git2svn.py must be executed from its parent directory'
27        sys.exit(usage + msg)
28if narg != 2 :
29        msg = 'expected 1 but found ' + str(narg-1) + ' command line arguments'
30        sys.exit(usage + msg)
31svn_branch_path = sys.argv[1]
32if svn_branch_path == 'master' :
33        msg = 'trunk is the svn_branch_path for the master branch'
34        sys.exit(usage + msg)
35# -----------------------------------------------------------------------------
36# some settings
37svn_repository = 'https://projects.coin-or.org/svn/CppAD'
38git_repository = 'https://github.com/coin-or/CppAD'
39work_directory = 'build'
40# -----------------------------------------------------------------------------
41# some simple functions
42def pause(question, choice_list) :
43        response=''
44        while not response in choice_list :
45                print(question, end='')
46                response = sys.stdin.readline()
47                if response.endswith('\n') :
48                        response = response[:-1]
49        return response
50#
51def system(cmd) :
52        try :
53                output = subprocess.check_output(
54                        cmd,
55                        stderr=subprocess.STDOUT,
56                        shell=True
57                )
58        except subprocess.CalledProcessError as info :
59                msg  = info.output
60                msg += '\nbin/push_git2svn.py exiting because command above failed'
61                sys.exit(cmd + '\n\n' + msg)
62        return output
63def print_system(cmd) :
64        print(cmd)
65        try :
66                output = subprocess.check_output(
67                        cmd,
68                        stderr=subprocess.STDOUT,
69                        shell=True
70                )
71        except subprocess.CalledProcessError as info :
72                msg  = info.output
73                msg += '\nbin/push_git2svn.py exiting because command above failed'
74                sys.exit(msg)
75        return output
76def ignore_data(data) :
77        id_pattern  = re.compile(r'^.*\$Id.*$',      re.MULTILINE)
78        data        = re.sub(id_pattern,    '', data)
79        return data
80# -----------------------------------------------------------------------------
81# determine git_branch_name
82if svn_branch_path == 'trunk' :
83        git_branch_name = 'master'
84        git_branch_path = svn_branch_path
85elif svn_branch_path.startswith('branches/') :
86        git_branch_name = svn_branch_path[len('branches/'):]
87        git_branch_path = svn_branch_path
88else :
89        git_branch_name = svn_branch_path
90        git_branch_path = 'branches/' + svn_branch_path
91# -----------------------------------------------------------------------------
92# hash code for the git branch
93cmd = 'git show-ref origin/' + git_branch_name
94git_hash_code = system(cmd)
95pattern       = ' refs/remotes/origin/' + git_branch_name
96git_hash_code = git_hash_code.replace(pattern, '')
97# -----------------------------------------------------------------------------
98# make sure work directory exists
99if not os.path.isdir(work_directory) :
100        os.makedirs(work_directory)
101# -----------------------------------------------------------------------------
102# checkout svn version of directory
103svn_directory = work_directory + '/svn'
104if os.path.isdir(svn_directory) :
105        cmd         = 'rm -rf ' + svn_directory
106        print_system(cmd)
107cmd  = 'svn checkout '
108cmd +=  svn_repository + '/' + svn_branch_path + ' ' + svn_directory
109print_system(cmd)
110# ----------------------------------------------------------------------------
111# git hash code corresponding to verison in svn directory
112cmd           = 'svn info ' + svn_directory
113svn_info      = system(cmd)
114rev_pattern   = re.compile('Last Changed Rev: *([0-9]+)')
115match         = re.search(rev_pattern, svn_info)
116svn_revision  = match.group(1)
117cmd           = 'svn log -r ' + svn_revision + ' ' + svn_directory
118svn_log       = system(cmd)
119hash_pattern  = re.compile('\nend   hash code: *([0-9a-f]+)')
120match         = re.search(hash_pattern, svn_log)
121if match :
122        svn_hash_code = match.group(1)
123else :
124        svn_hash_code = None
125# -----------------------------------------------------------------------------
126# export the git verison of the directory
127git_directory = work_directory + '/git'
128if os.path.isdir(git_directory) :
129        cmd = 'rm -rf ' + git_directory
130        print_system(cmd)
131cmd  = 'svn export '
132cmd +=  git_repository + '/' + git_branch_path + ' ' + git_directory
133print_system(cmd)
134# -----------------------------------------------------------------------------
135# list of files for the svn and git directories
136svn_pattern = re.compile(svn_directory + '/')
137svn_file_list = []
138svn_dir_list  = []
139for directory, dir_list, file_list in os.walk(svn_directory) :
140        ok = ( directory.find('/.svn/') == -1 )
141        ok = ok and ( not directory.endswith('/.svn') )
142        if ok :
143                if directory != svn_directory :
144                        local_name = re.sub(svn_pattern, '', directory)
145                        svn_dir_list.append(local_name)
146                for name in file_list :
147                        local_name = directory + '/' + name
148                        local_name = re.sub(svn_pattern, '', local_name)
149                        svn_file_list.append( local_name )
150#
151git_pattern = re.compile(git_directory + '/')
152git_file_list = []
153git_dir_list  = []
154for directory, dir_list, file_list in os.walk(git_directory) :
155        index =  directory.find('/.svn/')
156        assert index == -1
157        if directory != git_directory :
158                local_name = re.sub(git_pattern, '', directory)
159                git_dir_list.append(local_name)
160        for name in file_list :
161                local_name = directory + '/' + name
162                local_name = re.sub(git_pattern, '', local_name)
163                git_file_list.append( local_name )
164# -----------------------------------------------------------------------------
165# list of files that have been created and deleted
166created_file_list=[]
167for name in git_file_list :
168        if not name in svn_file_list :
169                created_file_list.append(name)
170#
171deleted_file_list=[]
172for name in svn_file_list :
173        if not name in git_file_list :
174                deleted_file_list.append(name)
175# -----------------------------------------------------------------------------
176# list of directories that have been created and deleted
177created_dir_list=[]
178for name in git_dir_list :
179        if not name in svn_dir_list :
180                created_dir_list.append(name)
181#
182deleted_dir_list=[]
183for name in svn_dir_list :
184        if not name in git_dir_list :
185                deleted_dir_list.append(name)
186# -----------------------------------------------------------------------------
187# automated svn commands
188#
189for git_dir in created_dir_list :
190        cmd  = 'svn mkdir ' + svn_directory + '/' + git_dir
191        print_system(cmd)
192#
193for git_file in created_file_list :
194        # the original file that was copied to the git_file
195        original_file = None
196        #
197        # extract the directory that git_file is located in
198        pattern    = re.compile(r'.*/([^/]*)')
199        git_local  = re.sub(pattern, r'\1', git_file)
200        #
201        for svn_file in deleted_file_list :
202                svn_local = re.sub(pattern, r'\1', svn_file)
203                if svn_local == git_local :
204                        original_file = svn_file
205        #
206        git_f     = open(git_directory + '/' + git_file, 'rb')
207        git_data  = git_f.read()
208        git_f.close()
209        git_data  = ignore_data(git_data)
210        #
211        for svn_file in deleted_file_list :
212                svn_f    = open(svn_directory + '/' + svn_file, 'rb')
213                svn_data = svn_f.read()
214                svn_f.close()
215                svn_data = ignore_data(svn_data)
216                #
217                if svn_data == git_data :
218                        original_file = svn_file
219        if original_file == None :
220                        cmd  = 'cp ' + git_directory + '/' + git_file + ' \\\n\t'
221                        cmd += svn_directory + '/' + git_file
222                        system(cmd)
223                        cmd  = 'svn add ' + svn_directory + '/' + git_file
224                        print_system(cmd)
225        else :
226                        # remove original file from deleted file list
227                        ind  = deleted_file_list.index( original_file )
228                        del deleted_file_list[ind]
229                        # copy original file to new file name
230                        cmd  = 'svn move ' + svn_directory + '/' + original_file + ' \\\n\t'
231                        cmd += svn_directory + '/' + git_file
232                        print_system(cmd)
233                        # replace by the git version for this file
234                        cmd  = 'cp ' + git_directory + '/' + git_file + ' \\\n\t'
235                        cmd += svn_directory + '/' + git_file
236                        system(cmd)
237                        found = True
238#
239for svn_file in deleted_file_list :
240        svn_file_path = svn_directory + '/' + svn_file
241        if os.path.isfile(svn_file_path) :
242                cmd = 'svn delete --force ' + svn_file_path
243                print_system(cmd)
244#
245for git_file in git_file_list :
246        do_cp = True
247        do_cp = do_cp and git_file not in created_file_list
248        if git_file in svn_file_list :
249                git_f     = open(git_directory + '/' + git_file, 'rb')
250                git_data  = git_f.read()
251                git_f.close()
252                git_data  = ignore_data(git_data)
253                #
254                svn_f    = open(svn_directory + '/' + git_file, 'rb')
255                svn_data = svn_f.read()
256                svn_f.close()
257                svn_data = ignore_data(svn_data)
258                #
259                do_cp = do_cp and git_data != svn_data
260        if do_cp :
261                cmd  = 'cp ' + git_directory + '/' + git_file + ' \\\n\t'
262                cmd += svn_directory + '/' + git_file
263                system(cmd)
264#
265for svn_dir in deleted_dir_list :
266        cmd  = 'svn rm ' + svn_directory + '/' + svn_dir
267        print_system(cmd)
268# -----------------------------------------------------------------------------
269data  = 'merge to branch: ' + svn_branch_path + '\n'
270data += 'from repository: ' + git_repository + '\n'
271if svn_hash_code != None :
272        data += 'start hash code: ' + svn_hash_code + '\n'
273else :
274        data += 'start hash code: missing\n'
275data   += 'end   hash code: ' + git_hash_code + '\n\n'
276if svn_hash_code != None :
277        sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'"
278        cmd     = 'git log origin/' + git_branch_name + ' | ' + sed_cmd
279        output = system(cmd)
280        data  += output
281log_f  = open( svn_directory + '/push_git2svn.log' , 'wb')
282log_f.write(data)
283log_f.close()
284#
285msg  = '\nChange into svn directory with the command\n\t'
286msg += 'cd ' + svn_directory + '\n'
287msg += 'If these changes are OK, execute the command:\n\t'
288msg += 'svn commit --file push_git2svn.log\n'
289if svn_hash_code != None :
290        msg += 'You should inspect and possibly edit push_git2svn.log'
291else :
292        msg += 'The start hash code could not be automatically determined.\n'
293        msg += 'You should edit push_git2svn.log to describe the changes.'
294print(msg)
Note: See TracBrowser for help on using the repository browser.