File: git2svn.py

package info (click to toggle)
cmor 3.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,960 kB
  • sloc: ansic: 28,094; f90: 13,872; python: 12,423; sh: 3,738; makefile: 111
file content (33 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import print_function
import os
import sys

svn = sys.argv[1]

git = os.popen("git status").readlines()

modfiles = []
delfiles = []
newfiles = []
for l in git:
    if l.find("new file:") > -1:
        newfiles.append(l.split()[3])
    if l.find("modified:") > -1:
        modfiles.append(l.split()[2])
    if l.find("deleted:") > -1:
        delfiles.append(l.split()[2])

for f in modfiles + newfiles:
    cmd = "cp -pf %s %s/%s" % (f, svn, f)
    print('Cp:', cmd)
    os.popen(cmd).readlines()

for f in newfiles:
    cmd = "cd %s ; svn add %s" % (svn, f)
    print('svn add :', cmd)
    os.popen(cmd).readlines()

for f in delfiles:
    cmd = "cd %s ; svn delete --force %s" % (svn, f)
    print('svn del :', cmd)
    os.popen(cmd).readlines()