10
10
11
11
12
12
class VCSVersion (object ):
13
+
13
14
"""
14
15
Represents a Version (tag or branch) in a VCS.
15
16
@@ -18,6 +19,7 @@ class VCSVersion(object):
18
19
It can act as a context manager to temporarily switch to this tag (eg to
19
20
build docs for this tag).
20
21
"""
22
+
21
23
def __init__ (self , repository , identifier , verbose_name ):
22
24
self .repository = repository
23
25
self .identifier = identifier
@@ -30,23 +32,23 @@ def __repr__(self):
30
32
31
33
class VCSProject (namedtuple ("VCSProject" ,
32
34
"name default_branch working_dir repo_url" )):
35
+
33
36
"""Transient object to encapsulate a projects stuff"""
37
+
34
38
pass
35
39
36
40
37
41
class BaseCLI (object ):
38
- """
39
- Helper class for CLI-heavy classes.
40
- """
42
+
43
+ """ Helper class for CLI-heavy classes."""
44
+
41
45
log_tmpl = u'VCS[{name}:{ident}]: {args}'
42
46
43
47
def __call__ (self , * args ):
44
48
return self .run (args )
45
49
46
50
def run (self , * args ):
47
- """
48
- :param bits: list of command and args. See `subprocess` docs
49
- """
51
+ """:param bits: list of command and args. See `subprocess` docs"""
50
52
process = subprocess .Popen (args , stdout = subprocess .PIPE ,
51
53
stderr = subprocess .PIPE ,
52
54
cwd = self .working_dir , shell = False ,
@@ -74,10 +76,13 @@ def env(self):
74
76
75
77
76
78
class BaseVCS (BaseCLI ):
79
+
77
80
"""
78
81
Base for VCS Classes.
82
+
79
83
Built on top of the BaseCLI.
80
84
"""
85
+
81
86
supports_tags = False # Whether this VCS supports tags or not.
82
87
supports_branches = False # Whether this VCS supports branches or not.
83
88
@@ -96,12 +101,14 @@ def check_working_dir(self):
96
101
os .makedirs (self .working_dir )
97
102
98
103
def make_clean_working_dir (self ):
99
- "Ensures that the working dir exists and is empty"
104
+ """ Ensures that the working dir exists and is empty"" "
100
105
shutil .rmtree (self .working_dir , ignore_errors = True )
101
106
self .check_working_dir ()
102
107
103
108
def update (self ):
104
109
"""
110
+ Update a local copy of the repository in self.working_dir.
111
+
105
112
If self.working_dir is already a valid local copy of the repository,
106
113
update the repository, else create a new local copy of the repository.
107
114
"""
@@ -116,24 +123,24 @@ def update(self):
116
123
@property
117
124
def tags (self ):
118
125
"""
119
- Returns a list of VCSVersion objects. See VCSVersion for more
120
- information.
126
+ Returns a list of VCSVersion objects.
127
+
128
+ See VCSVersion for more information.
121
129
"""
122
130
raise NotImplementedError
123
131
124
132
@property
125
133
def branches (self ):
126
134
"""
127
- Returns a list of VCSVersion objects. See VCSVersion for more
128
- information.
135
+ Returns a list of VCSVersion objects.
136
+
137
+ See VCSVersion for more information.
129
138
"""
130
139
raise NotImplementedError
131
140
132
141
@property
133
142
def commit (self ):
134
- """
135
- Returns a string representing the current commit.
136
- """
143
+ """Returns a string representing the current commit."""
137
144
raise NotImplementedError
138
145
139
146
def checkout (self , identifier = None ):
0 commit comments