Submitter | Augie Fackler |
---|---|
Date | March 1, 2016, 7:35 p.m. |
Message ID | <30732f02af820e885116.1456860958@augie-macbookair2.roam.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/13508/ |
State | Superseded |
Headers | show |
Comments
> On Mar 1, 2016, at 11:35, Augie Fackler <raf@durin42.com> wrote: > > # HG changeset patch > # User Augie Fackler <augie@google.com> > # Date 1456860899 18000 > # Tue Mar 01 14:34:59 2016 -0500 > # Branch stable > # Node ID 30732f02af820e8851163e5ec177e3c3d038eb08 > # Parent 5f95d6a70e9b37bf11487580a5c750d861baa8f5 > # EXP-Topic progress-cmd > progress: disable progress when the terminal resembles cmd.exe (issue4801) I fail at patches, discard this and a v2 will follow soon. > > It appears that cmd.exe is hopelessly unreliable when it comes to > handling carriage returns, based on my own web searching. The blessed > mechanism for performing cursor positioning appears to be > SetConsoleCursorPosition(), but I don't have easy access to a Windows > machine, and we need a simple fix for stable anyway. > > Ideally, someone on Windows can write a fix for this and contribute it. > > diff --git a/mercurial/progress.py b/mercurial/progress.py > --- a/mercurial/progress.py > +++ b/mercurial/progress.py > @@ -18,8 +18,17 @@ def spacejoin(*args): > return ' '.join(s for s in args if s) > > def shouldprint(ui): > - return not (ui.quiet or ui.plain()) and ( > - ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty')) > + if ui.configbool('progress', 'assume-tty'): > + return True > + if os.name == 'nt' and 'TERM' not in os.environ: > + # We think this is cmd.exe, which means we're going to skip > + # progress. It appears that carriage returns are unreliable > + # for cursor positioning in cmd.exe, and that we should > + # instead be using SetConsoleCursorPosition() to move the > + # cursor for progress writes. See issue4801 for the report > + # that revealed this problem. > + return False > + return not (ui.quiet or ui.plain()) and ui._isatty(sys.stderr) > > def fmtremaining(seconds): > """format a number of remaining seconds in human readable way > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/progress.py b/mercurial/progress.py --- a/mercurial/progress.py +++ b/mercurial/progress.py @@ -18,8 +18,17 @@ def spacejoin(*args): return ' '.join(s for s in args if s) def shouldprint(ui): - return not (ui.quiet or ui.plain()) and ( - ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty')) + if ui.configbool('progress', 'assume-tty'): + return True + if os.name == 'nt' and 'TERM' not in os.environ: + # We think this is cmd.exe, which means we're going to skip + # progress. It appears that carriage returns are unreliable + # for cursor positioning in cmd.exe, and that we should + # instead be using SetConsoleCursorPosition() to move the + # cursor for progress writes. See issue4801 for the report + # that revealed this problem. + return False + return not (ui.quiet or ui.plain()) and ui._isatty(sys.stderr) def fmtremaining(seconds): """format a number of remaining seconds in human readable way