Patchwork D1669: synthrepo: create filectx instance in 'filectxfn' callback

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2017, 1:05 p.m.
Message ID <a2e8d280bba15cd73ac045a9bb11b62d@localhost.localdomain>
Download mbox | patch
Permalink /patch/26264/
State Not Applicable
Headers show

Comments

phabricator - Dec. 13, 2017, 1:05 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG26064f261bbe: synthrepo: create filectx instance in &#039;filectxfn&#039; callback (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1669?vs=4394&id=4416

REVISION DETAIL
  https://phab.mercurial-scm.org/D1669

AFFECTED FILES
  contrib/synthrepo.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, yuja
Cc: mercurial-devel

Patch

diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py
--- a/contrib/synthrepo.py
+++ b/contrib/synthrepo.py
@@ -369,14 +369,14 @@ 
             while not validpath(path):
                 path = pickpath()
             data = '%s contents\n' % path
-            files[path] = context.memfilectx(repo, path, data)
+            files[path] = data
             dir = os.path.dirname(path)
             while dir and dir not in dirs:
                 dirs.add(dir)
                 dir = os.path.dirname(dir)
 
         def filectxfn(repo, memctx, path):
-            return files[path]
+            return context.memfilectx(repo, path, files[path])
 
         ui.progress(_synthesizing, None)
         message = 'synthesized wide repo with %d files' % (len(files),)
@@ -444,14 +444,12 @@ 
                 for __ in xrange(add):
                     lines.insert(random.randint(0, len(lines)), makeline())
                 path = fctx.path()
-                changes[path] = context.memfilectx(repo, path,
-                                                   '\n'.join(lines) + '\n')
+                changes[path] = '\n'.join(lines) + '\n'
             for __ in xrange(pick(filesremoved)):
                 path = random.choice(mfk)
                 for __ in xrange(10):
                     path = random.choice(mfk)
                     if path not in changes:
-                        changes[path] = None
                         break
         if filesadded:
             dirs = list(pctx.dirs())
@@ -466,9 +464,11 @@ 
                 pathstr = '/'.join(filter(None, path))
             data = '\n'.join(makeline()
                              for __ in xrange(pick(linesinfilesadded))) + '\n'
-            changes[pathstr] = context.memfilectx(repo, pathstr, data)
+            changes[pathstr] = data
         def filectxfn(repo, memctx, path):
-            return changes[path]
+            if path not in changes:
+                return None
+            return context.memfilectx(repo, path, changes[path])
         if not changes:
             continue
         if revs: