commit:     b1fddaac107100a6722008e7ae646531b223d794
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 10:59:32 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 22 10:59:32 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b1fddaac

RsyncSync: support file:// sync-uri

This will be useful for unit tests that will sync from a local
file:// sync-uri.

---
 pym/portage/sync/modules/rsync/rsync.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/pym/portage/sync/modules/rsync/rsync.py 
b/pym/portage/sync/modules/rsync/rsync.py
index 76d83f2..74c10e7 100644
--- a/pym/portage/sync/modules/rsync/rsync.py
+++ b/pym/portage/sync/modules/rsync/rsync.py
@@ -66,6 +66,9 @@ class RsyncSync(SyncBase):
                        rsync_opts = self._validate_rsync_opts(rsync_opts, 
syncuri)
                self.rsync_opts = self._rsync_opts_extend(opts, rsync_opts)
 
+               self.extra_rsync_opts = portage.util.shlex_split(
+                       self.settings.get("PORTAGE_RSYNC_EXTRA_OPTS",""))
+
                # Real local timestamp file.
                self.servertimestampfile = os.path.join(
                        self.repo.location, "metadata", "timestamp.chk")
@@ -93,6 +96,14 @@ class RsyncSync(SyncBase):
                except:
                        maxretries = -1 #default number of retries
 
+               if syncuri.startswith("file://"):
+                       self.proto = "file"
+                       dosyncuri = syncuri[6:]
+                       is_synced, exitcode = self._do_rsync(
+                               dosyncuri, timestamp, opts)
+                       self._process_exitcode(exitcode, dosyncuri, out, 1)
+                       return (exitcode, exitcode == os.EX_OK)
+
                retries=0
                try:
                        self.proto, user_name, hostname, port = re.split(
@@ -116,8 +127,6 @@ class RsyncSync(SyncBase):
                        getaddrinfo_host = hostname[1:-1]
                updatecache_flg=True
                all_rsync_opts = set(self.rsync_opts)
-               self.extra_rsync_opts = portage.util.shlex_split(
-                       self.settings.get("PORTAGE_RSYNC_EXTRA_OPTS",""))
                all_rsync_opts.update(self.extra_rsync_opts)
 
                family = socket.AF_UNSPEC

Reply via email to