开发者

How can I limit the size of a Mercurial log?

When I run Mercurial's "hg log" command from a terminal window, the results often fal开发者_JAVA技巧l off the screen, forcing me to scroll up to the top. As a result, I created a template to reduce the verboseness and format of the log:

[alias]
slog = log --template '{rev}:{node|short} {desc|firstline} ({author})\n'

However, I'd like to improve this even further by either a) limiting the size of the "slog" to just the last 10 commits or b) using a command like "hg slog ##", where "##" would be the number of logs shown in the results.

Any thoughts on how to achieve either A or B?


You could define your alias to do only a fixed limit in this way:

slog = log --limit 10 --template "{rev}:{node|short} {desc|firstline} ({author})\n"

Or, you could put --limit on the end so that you can pass a number to it, as arguments to an alias will be appended to the end:

slog = log --template "{rev}:{node|short} {desc|firstline} ({author})\n" --limit

The above could be called like this for the last 10 changesets:

hg slog 10

You should also be able to define the parameterized version in this way, but it doesn't seem to be property expanding the $1:

slog = log --limit $1 --template "{rev}:{node|short} {desc|firstline} ({author})\n"

#I had to use shell execute to make it expand:
#slog = !hg log --limit $1 --template "{rev}:{node|short} {desc|firstline} ({author})\n"


To get last 10 changeset:
hg log -l10

Alternative solution:
Configure autopager plugin in the .hgrc file.
The end result is similar to already mentioned solution

hg log | less


If you're using a *nix environment, this allows you to scroll back through log history at your leisure:

hg log | less

or according to your preference:

hg log | more
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜