comparison mercurial/context.py @ 19572:c19f46b904b9

basefilectx: add an empty class that will be used as a parent of file contexts Similar to the refactoring of context, we split common logic from filectx to a parent class called basefilectx that will be inherited by filectx, workingfilectx, and memfilectx. This will allow a clear disinction of all the file contexts: - filectx: read-only access to a filerevision that is already present in the repo, - workingfilectx: a filecontext that represents files from the working directory, - memfilectx: a filecontext that represents files in-memory
author Sean Farley <sean.michael.farley@gmail.com>
date Sat, 10 Aug 2013 15:10:26 -0500
parents 103edf3ed79e
children dffad92ab709
comparison
equal deleted inserted replaced
19571:103edf3ed79e 19572:c19f46b904b9
407 # specified pattern is a directory 407 # specified pattern is a directory
408 continue 408 continue
409 if match.bad(fn, _('no such file in rev %s') % self) and match(fn): 409 if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
410 yield fn 410 yield fn
411 411
412 class filectx(object): 412 class basefilectx(object):
413 """A filecontext object represents the common logic for its children:
414 filectx: read-only access to a filerevision that is already present
415 in the repo,
416 workingfilectx: a filecontext that represents files from the working
417 directory,
418 memfilectx: a filecontext that represents files in-memory."""
419 def __new__(cls, repo, path, *args, **kwargs):
420 return super(basefilectx, cls).__new__(cls)
421
422 class filectx(basefilectx):
413 """A filecontext object makes access to data related to a particular 423 """A filecontext object makes access to data related to a particular
414 filerevision convenient.""" 424 filerevision convenient."""
415 def __init__(self, repo, path, changeid=None, fileid=None, 425 def __init__(self, repo, path, changeid=None, fileid=None,
416 filelog=None, changectx=None): 426 filelog=None, changectx=None):
417 """changeid can be a changeset revision, node, or tag. 427 """changeid can be a changeset revision, node, or tag.