1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
23 from netrender
.utils
import *
30 def update(self
, info
):
32 Update a working copy to the specified revision.
33 If working copy doesn't exist, do a full get from server to create it.
34 [info] model.VersioningInfo instance, specifies the working path, remote path and version number."""
37 def revision(self
, path
):
39 return the current revision of the specified working copy path"""
44 return the remote path of the specified working copy path"""
47 class Subversion(AbstractVCS
):
49 description
= "Use the Subversion version control system"
52 self
.version_exp
= re
.compile("([0-9]*)")
53 self
.path_exp
= re
.compile("URL: (.*)")
55 def update(self
, info
):
56 if not os
.path
.exists(info
.wpath
):
57 base
, folder
= os
.path
.split(info
.wpath
)
59 with
DirectoryContext(base
):
60 subprocess
.call(["svn", "co", "%s@%s" % (info
.rpath
, str(info
.revision
)), folder
])
62 with
DirectoryContext(info
.wpath
):
63 subprocess
.call(["svn", "up", "--accept", "theirs-full", "-r", str(info
.revision
)])
65 def revision(self
, path
):
66 if not os
.path
.exists(path
):
69 with
DirectoryContext(path
):
70 stdout
= subprocess
.check_output(["svnversion"])
72 match
= self
.version_exp
.match(str(stdout
, encoding
="utf-8"))
78 if not os
.path
.exists(path
):
81 with
DirectoryContext(path
):
82 stdout
= subprocess
.check_output(["svn", "info"])
84 match
= self
.path_exp
.search(str(stdout
, encoding
="utf-8"))
89 class Git(AbstractVCS
):
91 description
= "Use the Git distributed version control system"
94 self
.version_exp
= re
.compile("^commit (.*)")
96 def update(self
, info
):
97 if not os
.path
.exists(info
.wpath
):
98 base
, folder
= os
.path
.split(info
.wpath
)
100 with
DirectoryContext(base
):
101 subprocess
.call(["git", "clone", "%s" % (info
.rpath
), folder
])
103 with
DirectoryContext(info
.wpath
):
104 subprocess
.call(["git", "checkout", str(info
.revision
)])
106 def revision(self
, path
):
107 if not os
.path
.exists(path
):
110 with
DirectoryContext(path
):
111 stdout
= subprocess
.check_output(["git", "show"])
113 match
= self
.version_exp
.search(str(stdout
, encoding
="utf-8"))
116 return match
.group(1)
118 def path(self
, path
):
119 if not os
.path
.exists(path
):
122 # find something that could somehow work for git (fun times)
126 Subversion
.name
: Subversion(),
131 (Subversion
.name
, Subversion
.name
, Subversion
.description
),
132 (Git
.name
, Git
.name
, Git
.description
),