[jhbuild] Add support for the Fossil version control system (GNOME bug 606217)



commit a28b6ac2f22c5dff3f5d7af30f2a9f65e10d2b47
Author: Marc-André Lureau <marcandre lureau gmail com>
Date:   Tue Feb 2 23:24:06 2010 +0100

    Add support for the Fossil version control system (GNOME bug 606217)
    
    This is used by SQLite.

 jhbuild/versioncontrol/Makefile.am |    1 +
 jhbuild/versioncontrol/fossil.py   |  123 ++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/versioncontrol/Makefile.am b/jhbuild/versioncontrol/Makefile.am
index 40d0307..16c0272 100644
--- a/jhbuild/versioncontrol/Makefile.am
+++ b/jhbuild/versioncontrol/Makefile.am
@@ -6,6 +6,7 @@ app_PYTHON = \
 	bzr.py \
 	cvs.py \
 	darcs.py \
+	fossil.py \
 	git.py \
 	hg.py \
 	mtn.py \
diff --git a/jhbuild/versioncontrol/fossil.py b/jhbuild/versioncontrol/fossil.py
new file mode 100644
index 0000000..ffd2c08
--- /dev/null
+++ b/jhbuild/versioncontrol/fossil.py
@@ -0,0 +1,123 @@
+# jhbuild - a build script for GNOME 1.x and 2.x
+# Copyright (C) 2001-2006  James Henstridge
+# Copyright (C) 2010  Marc-Andre Lureau <marcandre lureau gmail com>
+#
+#   fossil.py: some code to handle various Fossil operations
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+__all__ = []
+__metaclass__ = type
+
+import os
+import sys
+import urlparse
+from subprocess import Popen, PIPE
+
+from jhbuild.errors import FatalError, CommandError
+from jhbuild.versioncontrol import Repository, Branch, register_repo_type
+from jhbuild.commands.sanitycheck import inpath
+
+class FossilRepository(Repository):
+    """A class representing a Fossil repository."""
+
+    init_xml_attrs = ['href']
+
+    def __init__(self, config, name, href):
+        Repository.__init__(self, config, name)
+        # allow user to adjust location of branch.
+        self.href = config.repos.get(name, href)
+
+    branch_xml_attrs = ['module', 'checkoutdir']
+
+    def branch(self, name, module=None, checkoutdir=None):
+        if name in self.config.branches:
+            module = self.config.branches[name]
+            if not module:
+                raise FatalError(_('branch for %s has wrong override, check your .jhbuildrc') % name)
+        else:
+            if module is None:
+                module = name
+            module = urlparse.urljoin(self.href, module)
+        return FossilBranch(self, module, checkoutdir)
+
+
+class FossilBranch(Branch):
+    """A class representing a Fossil branch."""
+
+    def srcdir(self):
+        if self.checkoutdir:
+            return os.path.join(self.checkoutroot, self.checkoutdir)
+        else:
+            return os.path.join(self.checkoutroot,
+                                os.path.basename(self.module))
+
+    srcdir = property(srcdir)
+
+    def repositoryfile(self):
+        return os.path.join(self.checkoutroot,
+                            os.path.basename(self.checkoutdir)  + '.fossil')
+
+    repositoryfile = property(repositoryfile)
+
+    def branchname(self):
+        return None
+
+    branchname = property(branchname)
+
+    def _checkout(self, buildscript):
+        if self.config.sticky_date:
+            raise FatalError(_('date based checkout not yet supported\n'))
+
+        if not os.path.exists(self.repositoryfile):
+            cmd = ['fossil', 'clone', self.module, self.repositoryfile]
+            buildscript.execute(cmd, 'fossil', cwd=self.checkoutroot)
+
+        os.mkdir(self.srcdir)
+
+        cmd = ['fossil', 'open', self.repositoryfile]
+        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)
+
+    def _update(self, buildscript):
+        if self.config.sticky_date:
+            raise FatalError(_('date based checkout not yet supported\n'))
+
+        cmd = ['fossil', 'pull', self.module]
+        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)
+
+        cmd = ['fossil', 'update']
+        buildscript.execute(cmd, 'fossil', cwd=self.srcdir)
+
+    def checkout(self, buildscript):
+        if not inpath('fossil', os.environ['PATH'].split(os.pathsep)):
+            raise CommandError(_('%s not found') % 'fossil')
+        Branch.checkout(self, buildscript)
+
+    def get_revision_id(self):
+        import re
+
+        try:
+            infos = Popen(['fossil', 'info'], stdout=PIPE, cwd=self.srcdir)
+        except OSError, e:
+            raise CommandError(str(e))
+        infos = infos.stdout.read().strip()
+        return re.search(r"checkout: +(\w+)", infos).group(1)
+
+    def tree_id(self):
+        if not os.path.exists(self.srcdir):
+            return None
+        return self.get_revision_id()
+
+register_repo_type('fossil', FossilRepository)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]