Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
Excerpts from Yuya Nishihara's message of 2016-12-02 23:19:56 +0900: > On Fri, 2 Dec 2016 08:38:53 +0100, Denis Laxalde wrote: > > Yuya Nishihara a écrit : > > > On Mon, 28 Nov 2016 11:12:35 +0100, Denis Laxalde wrote: > > >> Denis Laxalde a écrit : > > >>> # HG changeset patch > > >>> # User Denis Laxalde > > >>> # Date 1480086890 -3600 > > >>> # Fri Nov 25 16:14:50 2016 +0100 > > >>> # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 > > >>> # Parent 6dd93ae7b35002531308444c87dcf47beb773648 > > >>> # EXP-Topic linerange-log/revset > > >>> revset: add a changes(file, fromline, toline[, rev]) revset > > >> > > >> This is the first step of my work (in progress) about adding a "line > > >> range" filtering for log discussed in > > >> https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html > > >> . > > >> > > >> I would have liked to add tests for this revset but it seems to me that > > >> the current test repositories are not complex enough for this: I'd need > > >> files with significant content and changes in this content. Any idea how > > >> I could do this? > > > > > > Maybe we can share some bits with test-annotate.t ? > > > > Repositories in these are indeed more complex. So should I append tests > > in this file or reproduce similar repositories in test-revset.t? > > I *think* adding tests to test-annotate.t is okay since the behavior of > changes() revset is somewhat similar to annotate. > > Jun might have more data sets for his fastannotate extension? fastannotate basically reuses the original annotate test cases for the core algorithm, and with some additional tests about extra features like wireprotocol, --deleted etc. Because fastannotate works differently from the vanilla algorithm: it tracks '!' blocks instead of '=' blocks and it deals with p1 and p2 differently, the output is slightly different: bitbucket.org/facebook/hg-experimental/src/27a94a/tests/test-fastannotate-hg.t?#test-fastannotate-hg.t-229 bitbucket.org/facebook/hg-experimental/src/27a94a/tests/test-fastannotate-hg.t?#test-fastannotate-hg.t-324 With the recent bdiff change, fastannotate became more different from the vanilla annotate: https://bitbucket.org/facebook/hg-experimental/commits/11c9b13fc1ef778c5636ac04e3812a06c0e4a08f ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
Excerpts from Denis Laxalde's message of 2016-12-02 08:38:53 +0100: > Yuya Nishihara a écrit : > > On Mon, 28 Nov 2016 11:12:35 +0100, Denis Laxalde wrote: > >> Denis Laxalde a écrit : > >>> # HG changeset patch > >>> # User Denis Laxalde > >>> # Date 1480086890 -3600 > >>> # Fri Nov 25 16:14:50 2016 +0100 > >>> # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 > >>> # Parent 6dd93ae7b35002531308444c87dcf47beb773648 > >>> # EXP-Topic linerange-log/revset > >>> revset: add a changes(file, fromline, toline[, rev]) revset > >> > >> This is the first step of my work (in progress) about adding a "line > >> range" filtering for log discussed in > >> https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html > >> . > >> > >> I would have liked to add tests for this revset but it seems to me that > >> the current test repositories are not complex enough for this: I'd need > >> files with significant content and changes in this content. Any idea how > >> I could do this? > > > > Maybe we can share some bits with test-annotate.t ? > > > > > Repositories in these are indeed more complex. So should I append tests > in this file or reproduce similar repositories in test-revset.t? I think the "buildcontents" method in absorb test case could be helpful for linear history cases: bitbucket.org/facebook/hg-experimental/src/3138c2/tests/test-absorb-filefixupstate.py#test-absorb-filefixupstate.py-74 For the "non-linear" case, "drawdag.py" may be helpful. I'm thinking about using some custom comments as some kind of DSL in drawdag input to describe file contents, like: C |\ B D |/ A # Lines of file foo: (line content, exist in which changesets) # abc A # def A B # ghi A D # foo B C D I'm not sure this is a good way to go but it looks easy to use and could be helpful in this case. If you like the idea, I could change drawdag.py to support this (the final syntax is to be discussed). drawdag.py would probably want to have the ability to control file contents sooner or later. The current test-annotate.t is somehow "unpredictable" because the bdiff algorithm change: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/090999.html I'd expect the diff algorithm to change in the future so I won't reuse confusing (unpredictable) test cases in test-annotate.t. I'd start a new test case with no duplicated lines and enhance it after the diff algorithm being more predictable. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
On Fri, 2 Dec 2016 08:38:53 +0100, Denis Laxalde wrote: > Yuya Nishihara a écrit : > > On Mon, 28 Nov 2016 11:12:35 +0100, Denis Laxalde wrote: > >> Denis Laxalde a écrit : > >>> # HG changeset patch > >>> # User Denis Laxalde > >>> # Date 1480086890 -3600 > >>> # Fri Nov 25 16:14:50 2016 +0100 > >>> # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 > >>> # Parent 6dd93ae7b35002531308444c87dcf47beb773648 > >>> # EXP-Topic linerange-log/revset > >>> revset: add a changes(file, fromline, toline[, rev]) revset > >> > >> This is the first step of my work (in progress) about adding a "line > >> range" filtering for log discussed in > >> https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html. > >> > >> I would have liked to add tests for this revset but it seems to me that > >> the current test repositories are not complex enough for this: I'd need > >> files with significant content and changes in this content. Any idea how > >> I could do this? > > > > Maybe we can share some bits with test-annotate.t ? > > Repositories in these are indeed more complex. So should I append tests > in this file or reproduce similar repositories in test-revset.t? I *think* adding tests to test-annotate.t is okay since the behavior of changes() revset is somewhat similar to annotate. Jun might have more data sets for his fastannotate extension? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
Yuya Nishihara a écrit : On Mon, 28 Nov 2016 11:12:35 +0100, Denis Laxalde wrote: Denis Laxalde a écrit : # HG changeset patch # User Denis Laxalde # Date 1480086890 -3600 # Fri Nov 25 16:14:50 2016 +0100 # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 # Parent 6dd93ae7b35002531308444c87dcf47beb773648 # EXP-Topic linerange-log/revset revset: add a changes(file, fromline, toline[, rev]) revset This is the first step of my work (in progress) about adding a "line range" filtering for log discussed in https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html. I would have liked to add tests for this revset but it seems to me that the current test repositories are not complex enough for this: I'd need files with significant content and changes in this content. Any idea how I could do this? Maybe we can share some bits with test-annotate.t ? Repositories in these are indeed more complex. So should I append tests in this file or reproduce similar repositories in test-revset.t? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
On Mon, 28 Nov 2016 10:54:16 +0100, Denis Laxalde wrote: > # HG changeset patch > # User Denis Laxalde > # Date 1480086890 -3600 > # Fri Nov 25 16:14:50 2016 +0100 > # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 > # Parent 6dd93ae7b35002531308444c87dcf47beb773648 > # EXP-Topic linerange-log/revset > revset: add a changes(file, fromline, toline[, rev]) revset > > This relies on `filectx.blocksancetors(fromline, toline)`. > > diff --git a/mercurial/revset.py b/mercurial/revset.py > --- a/mercurial/revset.py > +++ b/mercurial/revset.py > @@ -18,6 +18,7 @@ from . import ( > error, > hbisect, > match as matchmod, > +mdiff, unused. > +@predicate('changes(file, fromline, toline, rev)', safe=True) > +def changes(repo, subset, x): > +"""Changesets modifying 'file' in line range ('fromline', 'toline'). > + > +Line range corresponds to 'file' content at 'rev'. If rev is not > +specified, working directory's parent is used. > +""" > +args = map(getsymbol, > + getargs(x, 3, 4, _('changes takes at least three arguments'))) file can be a string, and rev should be a revset expression. > +fname = args[0] > + > +try: > +fromline, toline = map(int, args[1:3]) > +except ValueError: > +raise error.ParseError(_('line range bounds must be integers')) > +if toline - fromline < 0: > +raise error.Abort("line range must be positive") > +if fromline < 1: > +raise error.Abort("fromline must be > 0") > +fromline -= 1 > + > +rev = '.' > +if len(args) == 4: > +rev = args[3] > +fctx = repo[rev].filectx(fname) file path is relative to the current directory in general. > +revs = (c.rev() for c in fctx.blockancestors(fromline, toline)) > +return subset & generatorset(revs, iterasc=False) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
On Mon, 28 Nov 2016 11:12:35 +0100, Denis Laxalde wrote: > Denis Laxalde a écrit : > > # HG changeset patch > > # User Denis Laxalde > > # Date 1480086890 -3600 > > # Fri Nov 25 16:14:50 2016 +0100 > > # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 > > # Parent 6dd93ae7b35002531308444c87dcf47beb773648 > > # EXP-Topic linerange-log/revset > > revset: add a changes(file, fromline, toline[, rev]) revset > > This is the first step of my work (in progress) about adding a "line > range" filtering for log discussed in > https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html. > > I would have liked to add tests for this revset but it seems to me that > the current test repositories are not complex enough for this: I'd need > files with significant content and changes in this content. Any idea how > I could do this? Maybe we can share some bits with test-annotate.t ? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
Denis Laxalde a écrit : # HG changeset patch # User Denis Laxalde # Date 1480086890 -3600 # Fri Nov 25 16:14:50 2016 +0100 # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 # Parent 6dd93ae7b35002531308444c87dcf47beb773648 # EXP-Topic linerange-log/revset revset: add a changes(file, fromline, toline[, rev]) revset This is the first step of my work (in progress) about adding a "line range" filtering for log discussed in https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088687.html. I would have liked to add tests for this revset but it seems to me that the current test repositories are not complex enough for this: I'd need files with significant content and changes in this content. Any idea how I could do this? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 3] revset: add a changes(file, fromline, toline[, rev]) revset
# HG changeset patch # User Denis Laxalde # Date 1480086890 -3600 # Fri Nov 25 16:14:50 2016 +0100 # Node ID e88a112076294d9b1639a486e7ef0ec9c1ffa660 # Parent 6dd93ae7b35002531308444c87dcf47beb773648 # EXP-Topic linerange-log/revset revset: add a changes(file, fromline, toline[, rev]) revset This relies on `filectx.blocksancetors(fromline, toline)`. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -18,6 +18,7 @@ from . import ( error, hbisect, match as matchmod, +mdiff, node, obsolete as obsmod, parser, @@ -1350,6 +1351,34 @@ def modifies(repo, subset, x): pat = getstring(x, _("modifies requires a pattern")) return checkstatus(repo, subset, pat, 0) +@predicate('changes(file, fromline, toline, rev)', safe=True) +def changes(repo, subset, x): +"""Changesets modifying 'file' in line range ('fromline', 'toline'). + +Line range corresponds to 'file' content at 'rev'. If rev is not +specified, working directory's parent is used. +""" +args = map(getsymbol, + getargs(x, 3, 4, _('changes takes at least three arguments'))) +fname = args[0] + +try: +fromline, toline = map(int, args[1:3]) +except ValueError: +raise error.ParseError(_('line range bounds must be integers')) +if toline - fromline < 0: +raise error.Abort("line range must be positive") +if fromline < 1: +raise error.Abort("fromline must be > 0") +fromline -= 1 + +rev = '.' +if len(args) == 4: +rev = args[3] +fctx = repo[rev].filectx(fname) +revs = (c.rev() for c in fctx.blockancestors(fromline, toline)) +return subset & generatorset(revs, iterasc=False) + @predicate('named(namespace)') def named(repo, subset, x): """The changesets in a given namespace. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel