1
2 """General interface to VCS implementations"""
3
4 from PyFoam.Error import notImplemented,error
5
7 """This is an abstract class that implements an interface to general VCS operations"""
8
9 - def __init__(self,
10 path,
11 init=False):
12 """@param path: path which is supposed to be under version control
13 @param init: initialize the version control system here"""
14
15 self.path=path
16
19 """Commit the current state
20 @param msg: Commit message"""
21
22 notImplemented(self,"commit")
23
24 - def addPath(self,
25 path,
26 rules=[]):
27 """Add the path to the repository (no commit)
28 @param path: the path (directory or file) to commit
29 @param rules: a list of tuples: first is whether to include or exclude
30 the regular expression that is the second member of the tuple"""
31
32 notImplemented(self,"addPath")
33
34 - def clone(self,
35 dest):
36 """Clone the repository
37 @param dest: the path that should be clones to"""
38
39 notImplemented(self,"clone")
40
43 """Add to the ignore-facility of the current VCS
44 @param expr: a regular expression"""
45
46 notImplemented(self,"addRegexpToIgnore")
47
50 """Add to the ignore-facility of the current VCS
51 @param expr: a glob expression"""
52
53 notImplemented(self,"addGlobToIgnore")
54
61
62 -def getVCS(vcs,
63 path,
64 init=False):
65 """Factory to create a proper VCS-interface
66 @param vcs: name of the VCS-implementation
67 @param path: path which is under version control
68 @param init: whether the Version-control should be initialized here"""
69
70 table = { "hg" : "HgInterface" }
71
72 if vcs not in table:
73 error("Unknown VCS",vcs,". Known are",table.keys())
74
75 modName=table[vcs]
76
77 exec "from "+modName+" import "+modName
78
79 return eval(modName+"(path,init)")
80