aws/aws-cli — pull request #444 by jamesls (2013-10-28 00:43:50+00:00)
Title: list_files() should yield in alphabetical order

Fixes #440.

The issue was that we were not yielding files in the same order that
S3 was yielding files. This occurred whenever a directory was
a prefix of a file, for example, S3 would list objects in this order:

```
test-123.txt
test/test-0.txt
test123.txt
```

Whereas we were listing local directory contents depth first:

```
test/test-0.txt
test-123.txt
test123.txt
```

Because the syncing algorithm relies on the fact that both local
and S3 ordering is the same, this would result in unnecessary
syncing of files. Conceptually, we'd see an S3 -> local sync
do this:

```

S3 : 5 1 2 3 4 6 7
local: 1 2 3 4 5 6 7
```

So when we compare S3-5 to local-1, we decide to delete local-1,
then local-2, up to local-5. However, when we get to S3-1 and
local-6, we decide we need to add local-1 to local-5.
Once we get to s3-6, local-6 we'd be back on track. The end
result is that we have a set of tasks to delete files, followed
by a set of tasks to readd the files back.

The fix here was to ensure that we are listing local files by
including an `os.path.sep` for any sub directory before sorting
the contents. Then we just recurse whenever we hit a sub directory.