OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Performs all git-svn setup steps necessary for 'git svn dcommit' to work. | 6 """Performs all git-svn setup steps necessary for 'git svn dcommit' to work. |
7 | 7 |
8 Assumes that trunk of the svn remote maps to master of the git remote. | 8 Assumes that trunk of the svn remote maps to master of the git remote. |
9 | 9 |
10 Example: | 10 Example: |
11 git clone https://chromium.googlesource.com/chromium/tools/depot_tools | 11 git clone https://chromium.googlesource.com/chromium/tools/depot_tools |
12 cd depot_tools | 12 cd depot_tools |
13 git auto-svn | 13 git auto-svn |
14 """ | 14 """ |
15 | 15 |
16 import argparse | 16 import argparse |
17 import os | 17 import os |
18 import sys | 18 import sys |
19 import urlparse | 19 import urlparse |
20 | 20 |
21 import subprocess2 | 21 import subprocess2 |
22 | 22 |
23 from git_common import run as run_git | 23 from git_common import run as run_git |
24 from git_common import run_stream as run_git_stream | 24 from git_common import run_stream_with_retcode as run_git_stream_with_retcode |
25 from git_common import set_config, root, ROOT | 25 from git_common import set_config, root, ROOT |
26 from git_footers import parse_footers, get_unique, GIT_SVN_ID_PATTERN | 26 from git_footers import parse_footers, get_unique, GIT_SVN_ID_PATTERN |
27 | 27 |
28 | 28 |
29 SVN_EXE = ROOT+'\\svn.bat' if sys.platform.startswith('win') else 'svn' | 29 SVN_EXE = ROOT+'\\svn.bat' if sys.platform.startswith('win') else 'svn' |
30 | 30 |
31 | 31 |
32 def run_svn(*cmd, **kwargs): | 32 def run_svn(*cmd, **kwargs): |
33 """Runs an svn command. | 33 """Runs an svn command. |
34 | 34 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 ' from https://chromium-access.appspot.com' % maybe_repo) | 86 ' from https://chromium-access.appspot.com' % maybe_repo) |
87 print | 87 print |
88 continue | 88 continue |
89 assert svn_repo is not None, 'Unable to find svn repo for %s' % match.group(1) | 89 assert svn_repo is not None, 'Unable to find svn repo for %s' % match.group(1) |
90 print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path) | 90 print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path) |
91 | 91 |
92 set_config('svn-remote.svn.url', svn_repo) | 92 set_config('svn-remote.svn.url', svn_repo) |
93 set_config('svn-remote.svn.fetch', | 93 set_config('svn-remote.svn.fetch', |
94 '%s:refs/remotes/%s' % (svn_path, upstream)) | 94 '%s:refs/remotes/%s' % (svn_path, upstream)) |
95 print 'Configured metadata, running "git svn fetch". This may take some time.' | 95 print 'Configured metadata, running "git svn fetch". This may take some time.' |
96 for line in run_git_stream('svn', 'fetch').xreadlines(): | 96 with run_git_stream_with_retcode('svn', 'fetch') as stdout: |
97 print line.strip() | 97 for line in stdout.xreadlines(): |
| 98 print line.strip() |
98 return 0 | 99 return 0 |
99 | 100 |
100 | 101 |
101 if __name__ == '__main__': | 102 if __name__ == '__main__': |
102 try: | 103 try: |
103 sys.exit(main(sys.argv[1:])) | 104 sys.exit(main(sys.argv[1:])) |
104 except KeyboardInterrupt: | 105 except KeyboardInterrupt: |
105 sys.stderr.write('interrupted\n') | 106 sys.stderr.write('interrupted\n') |
106 sys.exit(1) | 107 sys.exit(1) |
OLD | NEW |