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

login
register
mail settings
Submitter phabricator
Date Dec. 11, 2017, 5:47 p.m.
Message ID <differential-rev-PHID-DREV-5bnw4swqvlzvd56utesf-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26218/
State Superseded
Headers show

Comments

phabricator - Dec. 11, 2017, 5:47 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I would like to pass the memctx to the memfilectx constructor, but
  it's not available where we currently create the memfilectx. It is
  available in the 'filectxfn' callback, so let's create the memfilectx
  there instead. A later patch will start actually passing the memctx.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/synthrepo.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 12, 2017, 1:35 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> synthrepo.py:453
>                      if path not in changes:
>                          changes[path] = None
>                          break

Perhaps filectxfn() should return None in this case.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, durin42, yuja
Cc: yuja, mercurial-devel
phabricator - Dec. 12, 2017, 7:34 p.m.
martinvonz marked an inline comment as done.
martinvonz added inline comments.

INLINE COMMENTS

> yuja wrote in synthrepo.py:453
> Perhaps filectxfn() should return None in this case.

Oops, good catch.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, durin42, yuja
Cc: yuja, mercurial-devel
phabricator - Dec. 12, 2017, 10:16 p.m.
durin42 added a comment.


  Crud. I had an old version of this queued, and failed to drop it. Fixing now...

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, durin42, yuja
Cc: yuja, 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),)