Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

View the history of line ranges on hg.mozilla.org

71 views
Skip to first unread message

Gregory Szorc

unread,
May 24, 2017, 4:12:32 PM5/24/17
to dev-version-control, dev-platform, Erik Rose, Bill McCloskey
Mercurial 4.2 (just deployed to https://hg.mozilla.org/) contains a new
feature for visualizing the history of a subset of a file. Those of you who
perform a lot of code archeology may find it more useful than the classical
annotate/blame UI (which is based on whole files and single revisions and
can therefore become unwieldy for large files and files with long history).

To use the feature, load a view of a whole file (URL paths with
<repo>/file/<rev>/<path>). e.g.
https://hg.mozilla.org/mozilla-central/file/37d777d87200/dom/base/nsContentList.cpp.
Then as you hover over lines, click once to set a start line and click
again to set an end line. A hover box should appear presenting links to
follow line history for changes that are "older" and/or "newer" than the
revision you are currently on. That will load a URL like
https://hg.mozilla.org/mozilla-central/log/37d777d87200/dom/base/nsContentList.cpp?patch=&linerange=507:536
(in this case showing the history of the arbitrarily chosen function
nsContentList::NamedItem).

Having used the feature for a few months, I find it to be one of those
things that you didn't realize you wanted. But after you start using it,
you can't live without it because it allows you to efficiently answer a lot
of archeology questions.

Some quick notes:

* If you load an old file revision, you can use this feature to find newer
changes to a range in that file.
* The feature actually follows diff blocks, not lines. (Because tracing
lines/content is a non-exact science, especially from the perspective of
version control where files are just bytes, not rich, structured
documents.) So, if "extra" changes sneak into a block, it could widen the
data being reported. That's why the last/earliest revision is often the
full file content.
* Run `hg serve` to start a local HTTP server and get a similar interface
without going over the Internet.
* The UI could use some polish. If you want to hack on it yourself,
instructions are at [1].
* There is no command-line equivalent yet for the "log of line range" view.
The feature is being considered for Mercurial 4.3.
* This feature was brought to you by a MOSS grant.
* Prefix the "action" component of Mercurial URL with "json-" to get JSON
output. e.g.
https://hg.mozilla.org/mozilla-central/json-log/37d777d87200/dom/base/nsContentList.cpp?patch=&linerange=507:536
.
* I think it would be rad if DXR and/or Searchfox hyperlinked to the
Mercurial view for history of a function, class, etc :)

Your suggestions on how to improve the feature will be used to prioritize
future work upstream. Some changes can even be rolled out to hg.mozilla.org
within minutes. So please get in touch (reply, ping me on IRC, file a
hg.mozilla.org bug, etc) with ideas for improvements.

[1]
https://mozilla-version-control-tools.readthedocs.io/en/latest/hgmo/contributing.html#hacking-the-theming
0 new messages