Submitter | Siddharth Agarwal |
---|---|
Date | May 25, 2017, 2:39 a.m. |
Message ID | <6e5c992e40f311e7aa5f0002c991e86a-964d56b0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c> |
Download | mbox | patch |
Permalink | /patch/20890/ |
State | Accepted |
Headers | show |
Comments
On 5/24/17 7:39 PM, Siddharth Agarwal wrote: > # HG changeset patch > # User Siddharth Agarwal <sid0@fb.com> > # Date 1495672708 25200 > # Wed May 24 17:38:28 2017 -0700 > # Node ID de6d23b18ea0e4e6eb46b509639c63b2318ac979 > # Parent e8c043375b53b30c4b468687f08323cbeeb452ef > annotate: move pair function to top level Sorry about the threading being broken here -- it's related to some Facebook MTA changes that I'm following up on :/ > > We'll want to make this more complicated and have unit tests for it in upcoming > patches. > > diff --git a/mercurial/context.py b/mercurial/context.py > --- a/mercurial/context.py > +++ b/mercurial/context.py > @@ -969,15 +969,6 @@ class basefilectx(object): > def decorate(text, rev): > return ([(rev, False)] * lines(text), text) > > - def pair(parent, child): > - blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) > - for (a1, a2, b1, b2), t in blocks: > - # Changed blocks ('!') or blocks made only of blank lines ('~') > - # belong to the child. > - if t == '=': > - child[0][b1:b2] = parent[0][a1:a2] > - return child > - > getlog = util.lrucachefunc(lambda x: self._repo.file(x)) > > def parents(f): > @@ -1054,7 +1045,7 @@ class basefilectx(object): > visit.pop() > curr = decorate(f.data(), f) > for p in pl: > - curr = pair(hist[p], curr) > + curr = _annotatepair(hist[p], curr, diffopts) > if needed[p] == 1: > del hist[p] > del needed[p] > @@ -1082,6 +1073,15 @@ class basefilectx(object): > c = visit.pop(max(visit)) > yield c > > +def _annotatepair(parent, child, diffopts): > + blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) > + for (a1, a2, b1, b2), t in blocks: > + # Changed blocks ('!') or blocks made only of blank lines ('~') > + # belong to the child. > + if t == '=': > + child[0][b1:b2] = parent[0][a1:a2] > + return child > + > class filectx(basefilectx): > """A filecontext object makes access to data related to a particular > filerevision convenient.""" > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -969,15 +969,6 @@ class basefilectx(object): def decorate(text, rev): return ([(rev, False)] * lines(text), text) - def pair(parent, child): - blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) - for (a1, a2, b1, b2), t in blocks: - # Changed blocks ('!') or blocks made only of blank lines ('~') - # belong to the child. - if t == '=': - child[0][b1:b2] = parent[0][a1:a2] - return child - getlog = util.lrucachefunc(lambda x: self._repo.file(x)) def parents(f): @@ -1054,7 +1045,7 @@ class basefilectx(object): visit.pop() curr = decorate(f.data(), f) for p in pl: - curr = pair(hist[p], curr) + curr = _annotatepair(hist[p], curr, diffopts) if needed[p] == 1: del hist[p] del needed[p] @@ -1082,6 +1073,15 @@ class basefilectx(object): c = visit.pop(max(visit)) yield c +def _annotatepair(parent, child, diffopts): + blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) + for (a1, a2, b1, b2), t in blocks: + # Changed blocks ('!') or blocks made only of blank lines ('~') + # belong to the child. + if t == '=': + child[0][b1:b2] = parent[0][a1:a2] + return child + class filectx(basefilectx): """A filecontext object makes access to data related to a particular filerevision convenient."""