1
2
3
4 """
5 CVS functionality.
6 """
7
8 import os
9 import re
10 import commands
11
12 import vcs
13
14 from moap.util import util
15
17 """
18 Detect which version control system is being used in the source tree.
19
20 @return: True if the given path looks like a CVS tree.
21 """
22 if not os.path.exists(os.path.join(path, 'CVS')):
23 return False
24
25 for n in ['Entries', 'Repository', 'Root']:
26 if not os.path.exists(os.path.join(path, 'CVS', n)):
27 return False
28
29 return True
30
32 name = 'CVS'
33
35 ret = []
36 oldPath = os.getcwd()
37
38
39
40 os.chdir(self.path)
41 cmd = "cvs update"
42
43 output = commands.getoutput(cmd)
44 lines = output.split("\n")
45 matcher = re.compile('^\?\s+(.*)')
46 for l in lines:
47 m = matcher.search(l)
48 if m:
49 path = m.expand("\\1")
50 ret.append(path)
51
52
53 os.chdir(oldPath)
54 return ret
55
56 - def ignore(self, paths, commit=True):
57
58 oldPath = os.getcwd()
59 os.chdir(self.path)
60
61 tree = self.createTree(paths)
62 toCommit = []
63 for path in tree.keys():
64
65 cvsignore = os.path.join(path, '.cvsignore')
66 toCommit.append(cvsignore)
67
68 new = False
69 if not os.path.exists(cvsignore):
70 new = True
71
72 handle = open(cvsignore, "a")
73
74 for child in tree[path]:
75 handle.write('%s\n' % child)
76
77 handle.close()
78
79 if new:
80 cmd = "cvs add %s" % cvsignore
81 os.system(cmd)
82
83
84
85 if commit and toCommit:
86 cmd = "cvs commit -m 'moap ignore' %s" % " ".join(toCommit)
87 os.system(cmd)
88
89 os.chdir(oldPath)
90
91 - def commit(self, paths, message):
92 oldPath = os.getcwd()
93 os.chdir(self.path)
94 temp = util.writeTemp([message, ])
95 cmd = "cvs commit -F %s %s" % (temp, " ".join(paths))
96 os.system(cmd)
97 os.unlink(temp)
98 os.chdir(oldPath)
99
100 - def diff(self, path):
101 oldPath = os.getcwd()
102 os.chdir(self.path)
103
104 if path.startswith(self.path):
105 path = path[len(self.path) + 1:]
106
107 cmd = "cvs -q diff -u3 -N %s" % path
108 self.debug('Running command %s' % cmd)
109 output = commands.getoutput(cmd)
110 os.chdir(oldPath)
111 return output
112
114 cmd = "cvs update %s" % path
115 status, output = commands.getstatusoutput(cmd)
116 return output
117
118 VCSClass = CVS
119