Mercurial > public > mercurial-scm > hg
comparison contrib/synthrepo.py @ 35400:8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
committablefilectx has three subclasses: workingfilectx, memfilectx,
and overlayfilectx. committablefilectx takes an optional (change) ctx
instance to its constructor. If it's provided, it's set on the
instance as self._changectx. If not, that property is supposed to be
defined by the class. However, only workingfilectx does that. The
other two will have the property undefined if it's not passed in the
constructor. That seems bad to me. This patch makes the changectx
argument to the memfilectx constructor mandatory because that fixes
the failure I ran into. It seems like we should also fix the
overlayfilectx case.
Differential Revision: https://phab.mercurial-scm.org/D1658
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 11 Dec 2017 09:27:40 -0800 |
parents | 2123e7629ec0 |
children | 238646784294 |
comparison
equal
deleted
inserted
replaced
35399:dffc35a5be9f | 35400:8a0cac20a1ad |
---|---|
374 while dir and dir not in dirs: | 374 while dir and dir not in dirs: |
375 dirs.add(dir) | 375 dirs.add(dir) |
376 dir = os.path.dirname(dir) | 376 dir = os.path.dirname(dir) |
377 | 377 |
378 def filectxfn(repo, memctx, path): | 378 def filectxfn(repo, memctx, path): |
379 return context.memfilectx(repo, path, files[path]) | 379 return context.memfilectx(repo, memctx, path, files[path]) |
380 | 380 |
381 ui.progress(_synthesizing, None) | 381 ui.progress(_synthesizing, None) |
382 message = 'synthesized wide repo with %d files' % (len(files),) | 382 message = 'synthesized wide repo with %d files' % (len(files),) |
383 mc = context.memctx(repo, [pctx.node(), nullid], message, | 383 mc = context.memctx(repo, [pctx.node(), nullid], message, |
384 files.iterkeys(), filectxfn, ui.username(), | 384 files.iterkeys(), filectxfn, ui.username(), |
466 for __ in xrange(pick(linesinfilesadded))) + '\n' | 466 for __ in xrange(pick(linesinfilesadded))) + '\n' |
467 changes[pathstr] = data | 467 changes[pathstr] = data |
468 def filectxfn(repo, memctx, path): | 468 def filectxfn(repo, memctx, path): |
469 if path not in changes: | 469 if path not in changes: |
470 return None | 470 return None |
471 return context.memfilectx(repo, path, changes[path]) | 471 return context.memfilectx(repo, memctx, path, changes[path]) |
472 if not changes: | 472 if not changes: |
473 continue | 473 continue |
474 if revs: | 474 if revs: |
475 date = repo['tip'].date()[0] + pick(interarrival) | 475 date = repo['tip'].date()[0] + pick(interarrival) |
476 else: | 476 else: |