21

We can see all the changesets and the files involved using

hg outgoing -v

but the filenames are all scattered in the list of changesets.

Is there a way to just see a list of all the files that will go out if hg push is issued?

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
nonopolarity
  • 146,324
  • 131
  • 460
  • 740

5 Answers5

10

First, create a file with this content:

changeset = "{files}"
file = "{file}\n"

Let's say you call it out-style.txt and put it in your home directory. Then you can give this command:

hg -q outgoing --style ~/out-style.txt | sort -u
JWWalker
  • 22,385
  • 6
  • 55
  • 76
  • great thanks! wow... this is not often needed that there is no standard way to list all files that will be pushed? I mean, isn't it useful to see something like that before we do a push? For example, right now, when I do "hg out -v", I see a list of 20 changesets and individual file and file lists... and I have to mentally combine the names... and this is a Ruby on Rails project where there are tons of files. – nonopolarity Jun 15 '10 at 00:12
  • I guess it all depends on how you work. At the end of each day, I just push when anything is outgoing. I don't need to know which changesets or files will be pushed. – JWWalker Jun 15 '10 at 00:24
  • Agreed with JWWalker, it's really not something you're normally concerned about. However it seems like it would be a trivial extension to write if you really wanted the functionality more easily. – dimo414 Jun 15 '10 at 00:37
  • 1
    the reason was that, back in the SVN days, before I commit to the central repository, I will diff every file, re-read the changes I made, line by line and character by character, before I really commit and do a push to all the production servers. Some of my coworkers just go play video games with the CTO instead, and they actually get a better performance reviews even if they break the whole system sometimes, as they are "good buddies" of the CTO. – nonopolarity Jun 15 '10 at 00:43
  • by the way, you can push every day? Is that push to the live server each day? Or do you push to a server first and every few days or 1 or 2 weeks, push to the production servers? – nonopolarity Aug 03 '10 at 21:07
7

A somewhat under-appreciated feature: hg status can show information about changes in file status between arbitrary changesets. This can be used to get a list of files changed between revisions X and Y:

hg status --rev X:Y

In this case, we can use hg outgoing, to find the first outgoing changeset X and then do

hg status --rev X:

to see the files changes since revision X. You can combine this into a single line in your shell:

hg status --rev $(hg outgoing -q --template '{node}' -l 1):
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
  • i thought "hg status" is between working directory and local repository, while "hg outgoing" is between 2 repositories? – nonopolarity Jun 15 '10 at 09:24
  • Yes -- 99% of the time, you use `hg status` to show the differences between the parent revision of the working copy and the working copy itself. But you can ask for the file status between any two revisions. So above I simply use `hg outgoing` to learn about the first outgoing changeset and then ask `hg status` to show changes from that changeset. – Martin Geisler Jun 15 '10 at 09:45
6

I usually use

hg outgoing -v | grep files

It makes the listing shorter, but doesnt sort. But thus far I havent been in a situation where I want to push so much (and at the same time check the files) that its been a problem.

[Edit] To do what you want:

  • Use cut to remove the files: part
  • For changesets with more than one touched file, use tr to put them on separate lines
  • Finally sort the resulting output with sort

Like so:

hg outgoing -v |grep files: |cut -c 14- |tr ' ' '\n' |sort -u

You can put this in ~/outgoingfiles.sh or something to have it nice and ready.

Mizipzor
  • 51,151
  • 22
  • 97
  • 138
  • That method has the disadvantage that file names within a changeset are separated by spaces. If you have any file names that contain spaces, then there is no way to automatically separate the file names before sorting. – JWWalker Jun 15 '10 at 00:28
3

I use Torgoise Hg, which is a shell extension that has a "synchronize" view allowing you to see outgoing files before you push them. It's convenient for commits as well, and other things.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Robusto
  • 31,447
  • 8
  • 56
  • 77
  • My preferred way as well, when Im not stuck in a console. – Mizipzor Jun 15 '10 at 00:47
  • I use a Macbook Pro with Snow Leopard on it... seems like the Windows guys have TortouseHg but the Mac guys are stuck with the command line! – nonopolarity Jun 15 '10 at 00:59
  • Jian Lin: see MacHg for a graphical Mercurial client: http://jasonfharris.com/machg/ I don't know if it can show you a list of outgoing files, though. – Martin Geisler Jun 15 '10 at 09:14
-1

A simple hg out will also solve this. It will list all committed but yet to push checkins.

karthipan raj
  • 657
  • 1
  • 8
  • 15