[PATCH] commands: possibly start a web browser during `hg serve` (BC)
engored at ya.ru
Sat Jul 16 02:04:46 EDT 2016
16.07.2016, 12:58, "Gregory Szorc" <gregory.szorc at gmail.com>:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1468645039 25200
> # Fri Jul 15 21:57:19 2016 -0700
> # Node ID d9f80be11783508272240020c29ffd36529de53e
> # Parent 1c22400db72de4bbeb992fde534c0abbe1367b03
> commands: possibly start a web browser during `hg serve` (BC)
> When D. Richard Hipp visited the Mozilla office several months ago
> and was showing me all the awesomeness in his Fossil VCS, one of the
> features that stood out to me was `fossil ui` starting a fully-featured
> HTTP/HTML server including the web browser. It was so... elegant
> to just type a command and get a web browser pointed to a local
> HTTP server where you could interact with your VCS.
> From my own experience, when I run `hg serve` from an interactive
> terminal I open a web browser 95% of the time. The other 5% of the
> time I start the server so I can point another Mercurial client at it.
> `hg serve` isn't currently optimized for my use case because I have
> to run `hg serve` then copy or type a URL into my browser. What a waste
> of time!
> This patch changes the behavior of `hg serve` to automatically start
> a web browser if a) the terminal is interactive and we're not running
> a background daemon or server for specialized clients b) the --browser
> argument explicitly requests we start a browser.
> While this change is backwards incompatible, I think it strikes the
> right balance of behavior: we only open browsers if it appears a user
> is typing `hg serve`. And, the escape hatch is simple for people
> wanting the previous behavior: `hg serve --browser=` or set
> "web.browser" to an empty string or "none."
> If nothing else, this change will help users discover the built-in
> HTML interface when running `hg serve` for the first time. I still
> encounter Mercurial users who don't realize that `hg serve` starts
> a browseable server (as opposed to a headless HTTP/protocol server).
> Launching the browser automatically will show them that the local
> server is more than a "listening at <URL>" message in their terminal.
I've been running 3 different browsers with different arguments and extensions on 3 different workspaces (Xfce) for a long time and found that to be great. Now, if Xfce could pick up my custom menu items or shortcuts (it can't) and make one of them the default browser, maaybe I could pick just one for every possible case of me running `hg serve` . I assume it would still open the browser on the workspace where the terminal with `hg serve` is, and not on the workspace I want to keep that browser on. All of that would be fairly annoying. Thank you for reading my rant.
So I think that opening a browser on `hg serve` without arguments should be opt-in (require e.g. web.browser=default, or an argument to the command). How about alias.ui = serve --browser?
I also think that for hgweb to become more discoverable, we could just fix https://bz.mercurial-scm.org/show_bug.cgi?id=3976 and then write "WebUI available at http://127.0.0.1:8000/" or something more... inviting. Luckily, many terminals actually allow double-clicking or right-clicking the link and picking "Open in browser" in the context menu.
 My actual default browser is w3m (the text based), that opens in a 80x24 terminal, because that's what I think an application that opens a URL without a warning deserves. (To be fair, w3m is actually nice for browsing pastebins)
More information about the Mercurial-devel