changeset 23235:4cdc3e2810b9

synthrepo: when adding files, ensure new path is not a directory
author Mike Edgar <adgar@google.com>
date Mon, 20 Oct 2014 14:20:43 -0400
parents 944d6cfbe166
children 7ea2ef4479f2
files contrib/synthrepo.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/synthrepo.py	Mon Oct 20 13:59:13 2014 -0400
+++ b/contrib/synthrepo.py	Mon Oct 20 14:20:43 2014 -0400
@@ -410,16 +410,18 @@
                         break
         if filesadded:
             dirs = list(pctx.dirs())
-            dirs.append('')
+            dirs.insert(0, '')
         for __ in xrange(pick(filesadded)):
-            path = [random.choice(dirs)]
-            if pick(dirsadded):
+            pathstr = ''
+            while pathstr in dirs:
+                path = [random.choice(dirs)]
+                if pick(dirsadded):
+                    path.append(random.choice(words))
                 path.append(random.choice(words))
-            path.append(random.choice(words))
-            path = '/'.join(filter(None, path))
+                pathstr = '/'.join(filter(None, path))
             data = '\n'.join(makeline()
                              for __ in xrange(pick(linesinfilesadded))) + '\n'
-            changes[path] = context.memfilectx(repo, path, data)
+            changes[pathstr] = context.memfilectx(repo, pathstr, data)
         def filectxfn(repo, memctx, path):
             return changes[path]
         if not changes: