Commits

Ronny Pfannschmidt committed ee587f2

initial scm support

Comments (0)

Files changed (3)

     from glas_process.model import Task
     task = Task(_id=nodeid, testcase=nodeid)
     db.save_doc(task)
-    return ProcDir(db, tmpdir/'proc', task)
+    procdir = ProcDir(db, tmpdir/'proc', task)
+    if 'no_create' not in request._pyfuncitem.keywords:
+        procdir.create()
+    return procdir

glas_process/dispatch.py

 from collections import Counter
 
 class ProcDir(object):
+    scminfo = None
+
     def __init__(self, db, path, job):
         self.db = db
         self.path = path
         self.belongs_to = job
         self._idcounter = Counter()
-        self.create()
+
+    def create(self):
+        #XXX: tasks?
+        if self.scminfo is None:
+            self.path.ensure(dir=1)
+        else:
+            #XXX: patch repos
+            import anyvc
+            anyvc.workdir.clone(self.scminfo.repo, self.path)
+
+    def update(self):
+        if not self.scminfo:
+            return
+        import anyvc
+        wd = anyvc.workdir.open(self.path)
+        if wd.repository:
+            wd.repository.pull()
+
+        if 0 and wd.patches:
+            wd.patches.pop_all()
+        wd.update(self.scminfo.branch)
+        if 0 and self.scminfo.patch:
+            wd.patches.push(upto=self.scminfo.patch)
 
     def get_id(self, stepper, given=None):
         if given is not None:
         suffix = '_%s'%current if current else ""
         return '%s:%s%s' % (self.belongs_to._id, stepper, suffix)
 
-    def create(self):
-        #XXX: vcs integration
-        self.path.ensure(dir=1)
-
     def save_with_batch(self, doc):
         return self.db.save_doc(doc, batch='ok')
 

testing/test_scmprocdir.py

+import pytest
+
+
+class scminfo(object):
+    def __init__(self, **kw):
+        self.__dict__.update(kw)
+
+
+@pytest.mark.no_create
+def test_simple_clone(procdir):
+    assert not procdir.path.check()
+    procdir.scminfo = scminfo(
+        repo='http://bitbucket.org/RonnyPfannschmidt/hgdistver',
+    )
+    procdir.create()
+    assert procdir.path.check()