Fix some issues at fetch.svn

parent c19cf6b1
...@@ -19,58 +19,56 @@ ...@@ -19,58 +19,56 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>. # along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
"""Module providing the stuff for handling SVN repositories"""
import os import os
import logging import logging
import platform
from tempfile import TemporaryFile from tempfile import TemporaryFile
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from hdlmake.util import path from hdlmake.util import path as path_utils
from .fetcher import Fetcher from .fetcher import Fetcher
class Svn(Fetcher): class Svn(Fetcher):
"""This class provides the SVN fetcher instances, that are
used to fetch and handle SVN repositories"""
def __init__(self): def __init__(self):
pass pass
def fetch(self, module): def fetch(self, module):
"""Get the code from the remote SVN repository"""
fetchto = module.fetchto() fetchto = module.fetchto()
if not os.path.exists(fetchto): if not os.path.exists(fetchto):
os.mkdir(fetchto) os.mkdir(fetchto)
cur_dir = module.pool.top_module.path cur_dir = module.pool.top_module.path
os.chdir(fetchto) os.chdir(fetchto)
basename = path_utils.svn_basename(module.url)
basename = path.svn_basename(module.url)
mod_path = os.path.join(fetchto, basename) mod_path = os.path.join(fetchto, basename)
cmd = "svn checkout {0} " + module.basename cmd = "svn checkout {0} " + module.basename
if module.revision: if module.revision:
cmd = cmd.format(module.url + '@' + module.revision) cmd = cmd.format(module.url + '@' + module.revision)
else: else:
cmd = cmd.format(module.url) cmd = cmd.format(module.url)
success = True success = True
logging.info("Checking out module %s", mod_path)
logging.info("Checking out module %s" % mod_path)
logging.debug(cmd) logging.debug(cmd)
if os.system(cmd) != 0: if os.system(cmd) != 0:
success = False success = False
os.chdir(cur_dir) os.chdir(cur_dir)
module.isfetched = True module.isfetched = True
module.path = os.path.join(fetchto, module.basename) module.path = os.path.join(fetchto, module.basename)
return success return success
@staticmethod @staticmethod
def check_revision_number(path): def check_id(path):
"""Get the revision number for the SVN repository at path"""
cur_dir = os.getcwd() cur_dir = os.getcwd()
revision = None revision = None
stderr = TemporaryFile() stderr = TemporaryFile()
try: try:
is_windows = path.check_windows() is_windows = path_utils.check_windows()
os.chdir(path) os.chdir(path)
svn_cmd = "svn info 2>/dev/null | awk '{if(NR == 5) {print $2}}'" svn_cmd = "svn info 2>/dev/null | awk '{if(NR == 5) {print $2}}'"
svn_out = Popen( svn_out = Popen(
...@@ -83,9 +81,8 @@ class Svn(Fetcher): ...@@ -83,9 +81,8 @@ class Svn(Fetcher):
errmsg = stderr.readlines() errmsg = stderr.readlines()
if errmsg: if errmsg:
logging.debug( logging.debug(
"svn error message (in %s): %s" % "svn error message (in %s): %s",
(path, '\n'.join(errmsg))) path, '\n'.join(errmsg))
try: try:
revision = svn_out.stdout.readlines()[0].strip() revision = svn_out.stdout.readlines()[0].strip()
except IndexError: except IndexError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment