Commits

Ronny Pfannschmidt committed 41f71cf

propper pull and update support

Comments (0)

Files changed (5)

glas_process/baseproc.py

         self.greenlets.append(res)
         return res
 
+
+    def emit(self, event=None, **kw):
+        self.queue.put(event or kw)
+
     def _store(self):
         for i, doc in enumerate(self.queue):
             if isinstance(doc, dict):

glas_process/scm.py

 
 class ScmProc(Proc):
     def __init__(self, procdir, scminfo, _id=None):
-        self.procdir = procdir
+        Proc.__init__(self, procdir)
         self.scminfo = scminfo
         self.makestep(_id, steper='scm', **scminfo)
 
         repo = self.step.repo
 
         if not target.check(dir=1):
+            self.emit(start='clone')
             self.wd = anyvc.workdir.clone(repo, target)
+            self.emit(end='clone')
         else:
-            pass  # XXX
+            self.emit(start='pull')
+            self.wd = anyvc.workdir.open(target)
+            self.wd.repository.pull(repo)
+            self.emit(start='pull')
 
     def reset_state(self):
         "undo patches, purge workdir if exists"

glas_process/subprocess.py

         wait_read(fp.fileno())
 
 
-def _stream_reader(step, proc, stream, queue):
+def _stream_reader(proc, stream, queue):
     fp = getattr(proc, stream)
     for lineno, line in enumerate(stream_line_iter(fp)):
         queue.put({
             'line': line,
         })
 
-def _exit_poller(step, proc, q):
+def _exit_poller(proc, q):
     while True:
         gevent.sleep(.1)
         code = proc.poll()
             q.put({'returncode': code})
             return
 
+
+
+
 def _joinall(queue, *greenlets):
     gevent.joinall(greenlets)
     queue.put(StopIteration)
         stderr=subprocess.PIPE,
     )
     q = proc.queue
-    out = gevent.spawn(_stream_reader, step, popen, 'stdout', q)
-    err = gevent.spawn(_stream_reader, step, popen, 'stderr', q)
-    ret = gevent.spawn(_exit_poller, step, popen, q)
+    out = gevent.spawn(_stream_reader, popen, 'stdout', q)
+    err = gevent.spawn(_stream_reader, popen, 'stderr', q)
+    ret = gevent.spawn(_exit_poller, popen, q)
     gevent.spawn(_joinall, q, out, err, ret)
 
     stdin = getattr(step, 'stdin', None)
 setup(
     name='glas_process',
     setup_requires=['hgdistver'],
+    install_requires=[
+        'couchdbkit',
+        'anyvc',
+    ],
     get_version_from_hg=True,
 )

testing/test_scmprocdir.py

     p.create_or_pull()
     gevent.sleep(0)
     assert procdir.path.check()
-    p.update_wd()
+    p.create_or_pull()
+