-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo.py
69 lines (55 loc) · 1.94 KB
/
repo.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python2.6
import time
import os
import pysvn
class Repo:
svn_repo_url = ''
def __init__ (self, svn_repo_path):
svn_cli = pysvn.Client ()
if not os.path.isdir (svn_repo_path):
print "SVN repositories not found at the given location!"
quit ()
if svn_repo_path [-1:] != '/':
svn_repo_path = svn_repo_path + '/'
self.svn_repo_url = 'file://' + svn_repo_path
def init (self, dir_name, repo_name):
svn_cli = pysvn.Client ()
if not os.path.isdir (dir_name):
print "Directory doesn't exist! Can't init repository."
quit ()
try:
svn_cli.import_ (dir_name, self.svn_repo_url + repo_name, 'Initial import')
except:
print 'SVN Error! Failed to import...'
quit ()
print 'Repo created at ' + self.svn_repo_url + dir_name
print 'Working copy at ' + dir_name
def update (self, dir_name, repo_name):
svn_cli = pysvn.Client ()
if not os.path.isdir (dir_name):
print "Directory doesn't exist! Can't update repository."
quit ()
timestamp = time.asctime (time.localtime(time.time()))
try:
svn_cli.checkin (dir_name, timestamp)
except:
print "Can't update " + dir_name + '! SVN Error!'
quit ()
print 'Updated Repo!'
def checkout (self, dir_name, repo_name):
svn_cli = pysvn.Client ()
if not os.path.isdir (dir_name):
try:
os.makedirs (dir_name)
except:
print 'Failed to create directory.'
quit()
svn_cli.checkout (self.svn_repo_url + repo_name, dir_name)
def diff (self, dir_name):
svn_cli = pysvn.Client ()
try:
svn_diff_text = svn_cli.diff('', dir_name)
except:
print 'SVN Error!'
quit ()
return svn_diff_text