diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index 0b175c250..c22f578e6 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -87,24 +87,24 @@ class HostRSync(py.execnet.RSync): else: return True - def add_target_host(self, host, reporter=lambda x: None, - destrelpath="", finishedcallback=None): - remotepath = host.relpath - key = host.hostname, remotepath - if host.hostname == "localhost" and not remotepath: - p = py.path.local(host.gw_remotepath) - assert p.join(destrelpath) == self._sourcedir - self._synced[key] = True - if key in self._synced: - if finishedcallback: - finishedcallback() - return False - self._synced[key] = True - # the follow attributes are set from host.initgateway() + def add_target_host(self, host, destrelpath="", reporter=lambda x: None): + remotepath = host.gw_remotepath + key = host.hostname, host.relpath if destrelpath: remotepath = os.path.join(remotepath, destrelpath) + if host.hostname == "localhost" and remotepath == self._sourcedir: + self._synced[key] = True + synced = key in self._synced + reporter(repevent.HostRSyncing(host, self._sourcedir, + remotepath, synced)) + def hostrsynced(host=host): + reporter(repevent.HostRSyncRootReady(host, self._sourcedir)) + if key in self._synced: + hostrsynced() + return + self._synced[key] = True super(HostRSync, self).add_target(host.gw, remotepath, - finishedcallback, + finishedcallback=hostrsynced, delete=True, ) return remotepath @@ -129,20 +129,15 @@ class HostManager(object): host.gw.host = host def init_rsync(self, reporter): - # send each rsync root ignores = self.config.getvalue_pathlist("dist_rsync_ignore") self.prepare_gateways(reporter) + # send each rsync root for root in self.roots: rsync = HostRSync(root, ignores=ignores, verbose=self.config.option.verbose) destrelpath = root.relto(self.config.topdir) for host in self.hosts: - def donecallback(host, root): - reporter(repevent.HostRSyncRootReady(host, root)) - remotepath = rsync.add_target_host( - host, reporter, destrelpath, finishedcallback= - lambda host=host, root=root: donecallback(host, root)) - reporter(repevent.HostRSyncing(host, root, remotepath)) + rsync.add_target_host(host, destrelpath, reporter) rsync.send(raises=False) def setup_hosts(self, reporter): diff --git a/py/test/rsession/repevent.py b/py/test/rsession/repevent.py index 7992dadd6..b14e50404 100644 --- a/py/test/rsession/repevent.py +++ b/py/test/rsession/repevent.py @@ -74,10 +74,11 @@ class CallFinish(CallEvent): pass class HostRSyncing(ReportEvent): - def __init__(self, host, root, remotepath): + def __init__(self, host, root, remotepath, synced): self.host = host self.root = root self.remotepath = remotepath + self.synced = synced class HostGatewayReady(ReportEvent): def __init__(self, host, roots): diff --git a/py/test/rsession/reporter.py b/py/test/rsession/reporter.py index f9726af14..8022be339 100644 --- a/py/test/rsession/reporter.py +++ b/py/test/rsession/reporter.py @@ -58,11 +58,16 @@ class AbstractReporter(object): def report_HostRSyncing(self, item): hostrepr = self._hostrepr(item.host) - if not item.remotepath: - print "%15s: skip duplicate rsync of %r" % ( - hostrepr, item.root.basename) + if item.synced: + if (item.host.hostname == "localhost" and + item.root == item.remotepath): + print "%15s: skipping inplace rsync of %r" %( + hostrepr, item.remotepath) + else: + print "%15s: skip duplicate rsync to %r" % ( + hostrepr, str(item.root)) else: - print "%15s: rsync %r to remote %s" % (hostrepr, + print "%15s: rsync %r to remote %r" % (hostrepr, item.root.basename, item.remotepath) diff --git a/py/test/rsession/testing/test_hostmanage.py b/py/test/rsession/testing/test_hostmanage.py index 4dcdcef67..862c642d9 100644 --- a/py/test/rsession/testing/test_hostmanage.py +++ b/py/test/rsession/testing/test_hostmanage.py @@ -132,6 +132,7 @@ class TestSyncing(DirSetup): rsync = HostRSync(self.source) l = [] h1.initgateway() + h2.initgateway() res1 = rsync.add_target_host(h1) assert res1 res2 = rsync.add_target_host(h2) diff --git a/py/test/rsession/testing/test_rest.py b/py/test/rsession/testing/test_rest.py index 96d734ff9..6e607eed9 100644 --- a/py/test/rsession/testing/test_rest.py +++ b/py/test/rsession/testing/test_rest.py @@ -53,7 +53,7 @@ class TestRestUnits(object): def test_report_HostRSyncing(self): event = repevent.HostRSyncing(HostInfo('localhost:/foo/bar'), "a", - "b") + "b", False) reporter.report(event) assert stdout.getvalue() == ('::\n\n localhost: RSYNC ==> ' '/foo/bar\n\n')