From 4f34599c63b844daa7aea251002b213ed9016043 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Wed, 3 Dec 2008 16:26:45 -0500 Subject: [PATCH] svn: only allow one process to fetch at a time --- plugins/svn.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugins/svn.py b/plugins/svn.py index ed0fdaf..1a8c960 100644 --- a/plugins/svn.py +++ b/plugins/svn.py @@ -210,9 +210,36 @@ class SvnPlugin(YapCore): master = get_output("git rev-parse --verify refs/heads/master 2>/dev/null") if master: run_safely("git update-ref -d refs/heads/master %s" % master[0]) + + def _lock_svn(self): + repo = get_output('git rev-parse --git-dir')[0] + dir = os.path.join(repo, 'yap') + fd, tmplock = tempfile.mkstemp("yap", dir=dir) + try: + os.close(fd) + + lockfile = os.path.join(dir, 'svn-lock') + try: + os.link(tmplock, lockfile) + except OSError: + raise YapError("A subversion operation is already in progress") + finally: + os.unlink(tmplock) + + def _unlock_svn(self): + repo = get_output('git rev-parse --git-dir')[0] + dir = os.path.join(repo, 'yap') + lockfile = os.path.join(dir, 'svn-lock') + + try: + os.unlink(lockfile) + except OSError: + pass def _fetch_svn(self): + self._lock_svn() os.system("git svn fetch svn") + self._unlock_svn() self._create_tagged_blob() self._cleanup_branches() -- 2.11.4.GIT