File: git2svn.py

package info (click to toggle)
cmor 3.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,976 kB
  • sloc: ansic: 28,053; f90: 13,893; python: 12,699; sh: 3,739; makefile: 111
file content (32 lines) | stat: -rw-r--r-- 727 bytes parent folder | download
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
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()