Commit Graph

21 Commits

Author SHA1 Message Date
CodemodService Bot
b4afda3890 Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D28216338

fbshipit-source-id: 2384a332505881bbc8cd621694496cf9f37c3bea
2021-05-05 04:03:47 -07:00
Jun Wu
b499dd8133 io: do not redirect stderr to pager if it is not a tty
Summary:
In case the stderr is redirected but stdout is not:

  EDENSCM_LOG=edenscm::mercurial=trace lhg log archival.py 2>/tmp/1
  cat /tmp/1

The expected behavior is to still use the pager for stdout output, and the
stderr should be redirected to the specified file.

Reviewed By: andll

Differential Revision: D27867884

fbshipit-source-id: c369bc6be40fc200c4c0e2c9bb38b5faeb1208f2
2021-04-21 09:41:31 -07:00
Jun Wu
1dd14a9cf4 io: add ways to test if a stream is a std stream
Summary: This will be used later.

Reviewed By: skotchvail

Differential Revision: D27744058

fbshipit-source-id: 411ab66ccc38b306c6bffb190e936ba1e455f07a
2021-04-13 13:43:39 -07:00
Jun Wu
5c3d6d152f io: add config for pager wrapping mode
Summary:
This allows setting the wrapping mode. For example:

   lhg log -pv
   # copy paste long lines works.

   lhg log -pv --config pager.wrapping-mode=unwrapped
   # lines are not wrapped, ">" is shown for long lines.

   lhg log -pv --config pager.wrapping-mode=word
   # long lines wrapped at word level.

The default value matches "less" behavior.

Reviewed By: DurhamG

Differential Revision: D27720767

fbshipit-source-id: e29d6b13656407c0a1e63287fb96e2f8d914cfc8
2021-04-13 12:15:16 -07:00
Jun Wu
cb58689d67 io: configparser::ConfigSet -> configmodel::Config
Summary: The latter is more lightweight.

Reviewed By: DurhamG

Differential Revision: D27641667

fbshipit-source-id: adce5a39fcb5d8e8d5d989fed46991e20ab3710d
2021-04-12 14:29:45 -07:00
Mark Juggurnauth-Thomas
973b785c3b pysptui: a tui using streampager
Summary:
Add bindings for `pysptui`.  This allows using `streampager` as a TUI, using
streampager's controlled file mode to manage the display.

Reviewed By: quark-zju

Differential Revision: D27268252

fbshipit-source-id: d191a09c44ca4ed013647feb81e6f031d553b2f2
2021-03-31 07:59:26 -07:00
Jun Wu
e78f7fbd89 progress: flush progress clear sequence
Summary:
Before this change, progress clear wasn't flushed clearly:

  % hg rebase -s ad1bb0e8d -d master --config progress.delay=0
  rebasing ad1bb0e8d7bd "1"
  merging setup3.py             ]  1/10 commits  ad1bb0e8d7bd
  rebasing 1da78a375aee "2"     ]  1/10 commits  ad1bb0e8d7bd
  merging setup3.py=>           ]  2/10 commits  1da78a375aee
  rebasing 57cd9d2ebd1a "3"     ]  2/10 commits  1da78a375aee
  merging setup3.py==>          ]  3/10 commits  57cd9d2ebd1a
  rebasing 25974e253f14 "4"     ]  3/10 commits  57cd9d2ebd1a
  merging setup3.py==>          ]  3/10 commits  57cd9d2ebd1a
  rebasing d5719551c6de "5"     ]  4/10 commits  25974e253f14
  merging setup3.py=====>       ]  5/10 commits  d5719551c6de
  rebasing 7fed88ae552b "6"     ]  5/10 commits  d5719551c6de
  merging setup3.py=======>     ]  6/10 commits  7fed88ae552b
  rebasing f47f8801a3df "7"     ]  6/10 commits  7fed88ae552b
  merging setup3.py========>    ]  7/10 commits  f47f8801a3df
  rebasing cc973be54ce2 "8">    ]  7/10 commits  f47f8801a3df
  merging setup3.py==========>  ]  8/10 commits  cc973be54ce2
  rebasing ad4cf8cfe06c "9"==>  ]  8/10 commits  cc973be54ce2
  merging setup3.py===========> ]  9/10 commits  ad4cf8cfe06c
  rebasing 00695de80a4c "10"==> ]  9/10 commits  ad4cf8cfe06c
  merging setup3.py===========> ]  9/10 commits  ad4cf8cfe06c
  00695de80a4c -> f92addadf761 "10"10/10 commits  00695de80a4c

After this change, it now clears properly:

  % lhg rebase -s bea5186e1 -d tip --config progress.delay=0
  rebasing bea5186e121c "1"
  merging setup3.py
  rebasing cfeade2a7f61 "2"
  merging setup3.py
  rebasing b74d67120010 "3"
  merging setup3.py
  rebasing 764575565711 "4"
  merging setup3.py
  rebasing d46becf867b2 "5"
  merging setup3.py
  rebasing c2256b8e9342 "6"
  merging setup3.py
  rebasing 5e3b42f07e57 "7"
  merging setup3.py
  rebasing f1a897e8aa6b "8"
  merging setup3.py
  rebasing 085d4a259de8 "9"
  merging setup3.py
  rebasing fa32e54c475a "10"
  merging setup3.py

Reviewed By: singhsrb

Differential Revision: D27408066

fbshipit-source-id: 2cc0bf456b6b9fcfb4f353538efe561cf53d2d61
2021-03-29 13:10:27 -07:00
Jun Wu
c6ed3839cd io: support nested progress disabling
Summary:
With the mix of external pager and progress suspension, the progress might
be enabled by accident:

    # pager: disable forever
    disable_progress(True)
    # suspension
    with progress.suspend()
        ...
        # on __exit__, re-enables pager

Update the pager disabling logic be nested to avoid the potential issue.

Reviewed By: andll

Differential Revision: D27275016

fbshipit-source-id: 35ca7aef1890a981e6a1f0e5313b6a482ed43368
2021-03-25 16:54:49 -07:00
Jun Wu
adb24ca54d do not show Rust progress in curses interface
Summary: Rust progress bar renderer wasn't aware of the curses interface.

Reviewed By: kulshrax

Differential Revision: D27266773

fbshipit-source-id: 66294c8fef50d01f327642beeec03fc414173d5e
2021-03-23 10:52:56 -07:00
Arun Kulshreshtha
b06906d542 io: regenerate Cargo.toml
Summary: Ran autocargo on `eden/scm/lib`.

Reviewed By: quark-zju

Differential Revision: D27241613

fbshipit-source-id: 5dafc97fc104643d67368a05ced36f91ca582241
2021-03-22 14:09:45 -07:00
Jun Wu
5e412629ee io: provide a way to disable progress rendering
Summary:
In some cases (ex. using an external pager). The IO states are changed outside
the IO struct's control. Ideally we should implement the external pager logic
on IO too but for now let's just add an API so the Python external pager logic
can disable progress output after starting an external pager.

Reviewed By: kulshrax

Differential Revision: D27149242

fbshipit-source-id: ff51fc153d3cc211cfa8ef697923d36f7c0f0d9b
2021-03-18 13:00:23 -07:00
Jun Wu
667c6a1274 io: improve mixed stdout + stderr progress output behavior
Summary:
Rework the progress. Always move the cursor to the top-left corner of the
progress output. So the clear progress instruction is just to erase till
the end of the screen. There is no need to track the height of the progress.

Update flush logic so we only do flush when crossing the progress/non-progress
boundary: When we write progress (to stderr), flush stdout, write progress,
then flush stderr.

Also, disable progress unconditionally if the current output line is incomplete.

Reviewed By: sfilipco

Differential Revision: D27109228

fbshipit-source-id: 717345e9c7eaeebeb378ce090f7b2f60957fd150
2021-03-17 09:27:51 -07:00
Jun Wu
985939bc25 io: do not write to output for write_err
Summary: This makes write_err() consistent with error().write().

Reviewed By: sfilipco

Differential Revision: D27109227

fbshipit-source-id: 4e7ea1fe464c17548c34e5f9bf78085868a20256
2021-03-17 09:27:51 -07:00
Jun Wu
3525a5b1e3 io: do not clear progress if stdout is redirected
Summary:
For example, `hg log > a.txt`, writing to `a.txt` does not need to clear the
progress bars.

Reviewed By: andll

Differential Revision: D26886281

fbshipit-source-id: 392c50e62a854e03ea0c400a1dac8bfb900815a2
2021-03-12 11:39:10 -08:00
Jun Wu
f8e2d8fd84 io: provide a way to set progress without IO reference
Summary:
Similar to `output()`, and `error()`, provide a `progress()` to support setting
progress without needing `&IO`.

Reviewed By: andll

Differential Revision: D26886278

fbshipit-source-id: a54563a9cf1d9d1cdb9dabe945aeb5ed1d84e8fb
2021-03-10 19:37:00 -08:00
Jun Wu
123789ea85 io: move set_progress implementation to inner
Summary: The method will be reused.

Reviewed By: andll

Differential Revision: D26886279

fbshipit-source-id: 5e82c53bf37aedaab4d6b14ee68be3420c613063
2021-03-10 19:37:00 -08:00
Jun Wu
f629c0097d io: flush progress output
Summary: Make sure the progress is not hidden because of buffering.

Reviewed By: singhsrb

Differential Revision: D26886277

fbshipit-source-id: d44e48e67b4529a181dd36c30e92608654d8fea6
2021-03-10 19:36:59 -08:00
Lukas Piatkowski
ad106958f2 eden/scm/lib: autogenerate all Cargo.toml files with autocargo
Summary: This diff removes the split between manually managed and autocargo managed Cargo.toml files in `eden/scm/lib`, now all files are autogenerated.

Reviewed By: quark-zju

Differential Revision: D26830884

fbshipit-source-id: 3a5d8409a61347c7650cc7d8192fa426c03733dc
2021-03-05 04:29:49 -08:00
Mark Juggurnauth-Thomas
d23885a667 upgrade streampager to 0.9.3
Summary: Upgrade the builtin streampager version to 0.9.3.

Reviewed By: singhsrb

Differential Revision: D26711549

fbshipit-source-id: ad95c4b2310bf1f007a544445d9c42f5bd9ba945
2021-03-01 06:12:00 -08:00
Jun Wu
f3a5686a15 io: add IsTty API
Summary:
Add a new API to test if a stream is a tty. This is needed to replace the
Python `fin`, `fout` etc. to Rust objects, because the Python land requires the
`istty` API. It is also useful for properly implement color detection in the
pure Rust land.

Reviewed By: sfilipco

Differential Revision: D26612480

fbshipit-source-id: 5cf79447b1d74e0031a954788db342afd48dc288
2021-02-23 22:33:47 -08:00
Jun Wu
deb50bdef8 io: move clidispatch::IO to a separate crate
Summary:
Move IO to a separate crate so it is easier to be used in other libraries.
Practically, I'm going to add `is_tty()` API, and make some types from
`cpython-ext` implement it. If `cpython-ext` depends on `clidispatch`,
that would be too heavyweight.

Reviewed By: sfilipco

Differential Revision: D26612488

fbshipit-source-id: 00b18dadce3157a357d189aaa7d985efa6b4c80a
2021-02-23 22:33:47 -08:00