[PATCH 1 of 3 V2 STABLE] changelog: introduce count argument to revs() function
Brodie Rao
brodie at sf.io
Mon Jul 22 18:47:53 CDT 2013
On Mon, Jul 22, 2013 at 2:54 AM, Alexander Plavin <me at aplavin.ru> wrote:
> # HG changeset patch
> # User Alexander Plavin <me at aplavin.ru>
> # Date 1374321959 -14400
> # Sat Jul 20 16:05:59 2013 +0400
> # Node ID 82096c966790ec607efb16ebff2cfa53c643b700
> # Parent b97ce93726dbcbfc439458e244a266953c22940e
> changelog: introduce count argument to revs() function
>
> This allows specifying count of revisions to yield, which is convenient when
> some revs are filtered.
>
> diff -r b97ce93726db -r 82096c966790 mercurial/changelog.py
> --- a/mercurial/changelog.py Fri Jul 19 21:26:08 2013 +0400
> +++ b/mercurial/changelog.py Sat Jul 20 16:05:59 2013 +0400
> @@ -147,11 +147,23 @@
>
> return filterediter()
>
> - def revs(self, start=0, stop=None):
> + def revs(self, start=0, stop=None, count=None):
> """filtered version of revlog.revs"""
> + if count is not None:
> + if count < 0:
> + stop = 0
> + elif count > 0:
> + stop = len(self)
> + else:
> + stop = start
> +
> + curcount = 0
> for i in super(changelog, self).revs(start, stop):
> if i not in self.filteredrevs:
> yield i
> + curcount += 1
> + if count is not None and curcount >= abs(count):
> + break
Instead of making this change inside changelog.revs(), couldn't you
use itertools.islice() where you need to limit the number of
revisions?
> @util.propertycache
> def nodemap(self):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list