[PATCH] Use the pager given by the environment to display long output

Bryan O'Sullivan bos at serpentine.com
Sun Mar 16 23:34:47 CDT 2008

David Soria Parra wrote:
> I tried to follow all advices from the people who replied to the last thread about paging.

Good stuff, thanks.  Still one last comment:

> +            if self.getpager() and not self.pager:
> +                self.pager = os.popen(self.getpager(), "w")
>              for a in args:
> -                sys.stdout.write(str(a))
> +                if self.pager:
> +                    self.pager.write(a)
> +                else:
> +                    sys.stdout.write(str(a))

I think that it would make more sense to set sys.stdout (and probably
sys.stderr) to the popened value, because this will avoid the need for
self.pager and will keep the code changes more local.

The reason you'd want sys.stderr paged, too, is that without that, it
will be very difficult for users of a pager to capture error output.


More information about the Mercurial-devel mailing list