jbardin/scp.py — pull request #15 by jtriley (2013-11-22 22:31:40+00:00)
Title: match every pushd with a popd in _send_recursive

Fixes a bug where files/directories may end up improperly nested on the
remote machine. For example on the client machine you run the following:
```
$ mkdir srcdir
$ mkdir srcdir/another
$ touch srcfile

scpclient.put(['srcdir', 'srcfile'], recursive=True)
```
Then on the remote machine the files end up like:
```
$ find $HOME
srcdir
srcdir/another
srcdir/another/srcfile
```
This patch fixes the issue by calling popd for each path component of
the last directory in the loop which changes the remote path back to
where we started before the last directory transfer.

See also jtriley/StarCluster#331