开发者

How to show list of unapplied changesets in Mercurial

开发者 https://www.devze.com 2023-03-17 03:54 出处:网络
After pushing changesets to a repository called \'A\' how can I see the list of changesets waiting to be 开发者_Go百科applied when I am in \'A\'?

After pushing changesets to a repository called 'A' how can I see the list of changesets waiting to be 开发者_Go百科applied when I am in 'A'?

Expanding on that,

  1. In repo B I push changesets to repo B
  2. I change to repo B
  3. How can I list the changesets pushed in step 1?


Not sure what you mean by "unapplied" changesets, however here's a couple thoughts.

You can easily see what changesets will be pushed to a repository by doing hg outgoing prior to doing the hg push. This will list all of the changesets that will be pushed using default options.

Similarly you can use hg incoming in the destination repository to show what changesets would be pulled from another repo.

As for "unapplied" changesets, if I assume you mean changesets that are newer than the working directory, you could use hg log -r .:tip, which should (I've not had a chance to test it) show all newer revisions, but not actually all recently-pushed ones.

Edit: I've updated the revision set in the -r option to something that should work. Have a look at revsets on the Mercurial manpage for more possibilities.


$ hg summary
parent: 0:9f47fcf4811f 
 .
branch: default
commit: (clean)
update: 2 new changesets (update) <<<<<

The update bit tells you what (I think) you want.


I had written a different answer, but I ended up with a better way of doing what is needed here (an even better and definitive –for me– solution is at the end of this post, in the [EDIT] section).

Use hg log.

Specifically, issue an hg sum command first. This will give me:

parent: 189:77e9fd7e4554
 <some commit message>
branch: default
commit: (clean)
update: 2 new changesets (update) 

To see what those 2 new changesets are made of, I use

hg log -r tip -r 2 -v

Obviously, 2 is to be replaced with the number of changesets that hg sum reports.

This works because tip will refer to the most recent (or "unapplied") changeset. By limiting the output to the 2 latest changes (-l 2), the information is shown only for those changesets that I'm interested in. With -v, the list of files affected by the changeset is also shown.

To make things simpler, I have defined a user command in my .bashrc file:

alias hglog="hg log -r tip -l $1"

This allows me to type hg sum (to get the number of pending/unapplied changesets) and then to type hglog x where x is the number of changesets revealed by hg sum.

There is probably a more complete way of doing this, for instance using custom templates, but I guess it's pushing things too far in terms of sophistication.

[EDIT] (Third iteration) I have reached the most satisfying answer to this question by expanding on the alias idea so that I no longer have to type hg sum. My .bashrc file now contains this:

show_pending_changesets() {
  nb=$(hg sum | grep "update:" | sed 's/update: \([0-9]*\) .*/\1/');
  if [ `expr $nb + 1 2> /dev/null` ] ; then
    hg log -r tip -v -l $nb
  else 
    echo "Nothing new to report"
  fi ;
}
...
alias hgwhatsnew=show_pending_changesets

Explanation: I'm using sed to extract the number of changesets from the last line (which is the one that starts with update:) of the output of hg sum. That number is then fed to hg log. All I have to do then is to type hgw and tab-complete it. HTH

0

精彩评论

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