Submitter | Sean Farley |
---|---|
Date | May 6, 2014, 11:33 p.m. |
Message ID | <dae520d39627d8fd5066.1399419201@laptop.local> |
Download | mbox | patch |
Permalink | /patch/4648/ |
State | Accepted |
Commit | f251b92d9ed98db18d40f7af0a1dac8cdb3c0b32 |
Headers | show |
Comments
On 5/6/14, 4:33 PM, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1394579400 18000 > # Tue Mar 11 18:10:00 2014 -0500 > # Node ID dae520d39627d8fd50668c590516baaae236d26b > # Parent eecae40cba0ea00b3cd5d1284f820d65fb32d6b4 > localrepo: factor out parentworking logic for comparing files > class committablefilectx(basefilectx): > """A committablefilectx provides common functionality for a file context > that wants the ability to commit, e.g. workingfilectx or memfilectx.""" > def __init__(self, repo, path, filelog=None, ctx=None): > self._repo = repo > diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py > --- a/mercurial/localrepo.py > +++ b/mercurial/localrepo.py > @@ -1552,36 +1552,16 @@ class localrepository(object): > listclean, listunknown) > cmp, modified, added, removed, deleted, unknown, ignored, clean = s > > # check for any possibly clean files > if parentworking and cmp: > - fixup = [] > - # do a full compare of any files that might have changed > - for f in sorted(cmp): > - if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) > - or ctx1[f].cmp(ctx2[f])): > - modified.append(f) > - else: > - fixup.append(f) > + modified2, fixup = ctx2._checklookup(cmp) > + modified += modified2 > Is it ok to call a underscore method from another class? I thought underscore methods were considered private to that class.
Durham Goode <durham@fb.com> writes: > On 5/6/14, 4:33 PM, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1394579400 18000 >> # Tue Mar 11 18:10:00 2014 -0500 >> # Node ID dae520d39627d8fd50668c590516baaae236d26b >> # Parent eecae40cba0ea00b3cd5d1284f820d65fb32d6b4 >> localrepo: factor out parentworking logic for comparing files > >> class committablefilectx(basefilectx): >> """A committablefilectx provides common functionality for a file context >> that wants the ability to commit, e.g. workingfilectx or memfilectx.""" >> def __init__(self, repo, path, filelog=None, ctx=None): >> self._repo = repo >> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py >> --- a/mercurial/localrepo.py >> +++ b/mercurial/localrepo.py >> @@ -1552,36 +1552,16 @@ class localrepository(object): >> listclean, listunknown) >> cmp, modified, added, removed, deleted, unknown, ignored, clean = s >> >> # check for any possibly clean files >> if parentworking and cmp: >> - fixup = [] >> - # do a full compare of any files that might have changed >> - for f in sorted(cmp): >> - if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) >> - or ctx1[f].cmp(ctx2[f])): >> - modified.append(f) >> - else: >> - fixup.append(f) >> + modified2, fixup = ctx2._checklookup(cmp) >> + modified += modified2 >> > Is it ok to call a underscore method from another class? I thought > underscore methods were considered private to that class. It is just temporary as we move code from localrepo to context while maintaining passing tests.
Patch
diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1197,10 +1197,43 @@ class workingctx(committablectx): ' "%s"\n' % f) continue sane.append(f) return sane + def _checklookup(self, files): + # check for any possibly clean files + if not files: + return [], [] + + modified = [] + fixup = [] + pctx = self._parents[0] + # do a full compare of any files that might have changed + for f in sorted(files): + if (f not in pctx or self.flags(f) != pctx.flags(f) + or pctx[f].cmp(self[f])): + modified.append(f) + else: + fixup.append(f) + + # update dirstate for files that are actually clean + if fixup: + try: + # updating the dirstate is optional + # so we don't wait on the lock + normal = self._repo.dirstate.normal + wlock = self._repo.wlock(False) + try: + for f in fixup: + normal(f) + finally: + wlock.release() + except error.LockError: + pass + return modified, fixup + + class committablefilectx(basefilectx): """A committablefilectx provides common functionality for a file context that wants the ability to commit, e.g. workingfilectx or memfilectx.""" def __init__(self, repo, path, filelog=None, ctx=None): self._repo = repo diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1552,36 +1552,16 @@ class localrepository(object): listclean, listunknown) cmp, modified, added, removed, deleted, unknown, ignored, clean = s # check for any possibly clean files if parentworking and cmp: - fixup = [] - # do a full compare of any files that might have changed - for f in sorted(cmp): - if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) - or ctx1[f].cmp(ctx2[f])): - modified.append(f) - else: - fixup.append(f) + modified2, fixup = ctx2._checklookup(cmp) + modified += modified2 # update dirstate for files that are actually clean - if fixup: - if listclean: - clean += fixup - - try: - # updating the dirstate is optional - # so we don't wait on the lock - normal = self._repo.dirstate.normal - wlock = self.wlock(False) - try: - for f in fixup: - normal(f) - finally: - wlock.release() - except error.LockError: - pass + if fixup and listclean: + clean += fixup if not parentworking: mf1 = mfmatches(ctx1) if working: # we are comparing working dir against non-parent