Submitter | Sean Farley |
---|---|
Date | Aug. 12, 2013, 4:26 p.m. |
Message ID | <c19f46b904b99937a939.1376324817@laptop.local> |
Download | mbox | patch |
Permalink | /patch/2128/ |
State | Accepted |
Commit | c19f46b904b99937a9391f4f98f01f3b7aee3ba9 |
Headers | show |
Comments
On Mon, Aug 12, 2013 at 11:26:57AM -0500, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1376165426 18000 > # Sat Aug 10 15:10:26 2013 -0500 > # Node ID c19f46b904b99937a9391f4f98f01f3b7aee3ba9 > # Parent 103edf3ed79e1885fbcf7832c236eb8c8b6a0c89 > basefilectx: add an empty class that will be used as a parent of file contexts Queued the lot, thanks. Very easy to review for its size. > > 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 > > diff --git a/mercurial/context.py b/mercurial/context.py > --- a/mercurial/context.py > +++ b/mercurial/context.py > @@ -407,11 +407,21 @@ > # specified pattern is a directory > continue > if match.bad(fn, _('no such file in rev %s') % self) and match(fn): > yield fn > > -class filectx(object): > +class basefilectx(object): > + """A filecontext object represents the common logic for its children: > + 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.""" > + def __new__(cls, repo, path, *args, **kwargs): > + return super(basefilectx, cls).__new__(cls) > + > +class filectx(basefilectx): > """A filecontext object makes access to data related to a particular > filerevision convenient.""" > def __init__(self, repo, path, changeid=None, fileid=None, > filelog=None, changectx=None): > """changeid can be a changeset revision, node, or tag. > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -407,11 +407,21 @@ # specified pattern is a directory continue if match.bad(fn, _('no such file in rev %s') % self) and match(fn): yield fn -class filectx(object): +class basefilectx(object): + """A filecontext object represents the common logic for its children: + 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.""" + def __new__(cls, repo, path, *args, **kwargs): + return super(basefilectx, cls).__new__(cls) + +class filectx(basefilectx): """A filecontext object makes access to data related to a particular filerevision convenient.""" def __init__(self, repo, path, changeid=None, fileid=None, filelog=None, changectx=None): """changeid can be a changeset revision, node, or tag.