In Mercurial (hg), how do you see a list of files that will be pushed if an "hg push" is issued?
Solution 1
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
Solution 2
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):
Solution 3
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 thefiles:
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.
Solution 4
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.
nonopolarity
I started with Apple Basic and 6502 machine code and Assembly, then went onto Fortran, Pascal, C, Lisp (Scheme), microcode, Perl, Java, JavaScript, Python, Ruby, PHP, and Objective-C. Originally, I was going to go with an Atari... but it was a big expense for my family... and after months of me nagging, my dad agreed to buy an Apple ][. At that time, the Pineapple was also available. The few months in childhood seem to last forever. A few months nowadays seem to pass like days. Those days, a computer had 16kb or 48kb of RAM. Today, the computer has 16GB. So it is in fact a million times. If you know what D5 AA 96 means, we belong to the same era.
Updated on June 07, 2022Comments
-
nonopolarity about 2 years
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? -
nonopolarity about 14 yearsgreat 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.
-
JWWalker about 14 yearsI 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 about 14 yearsThat 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.
-
Ar5hv1r about 14 yearsAgreed 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.
-
nonopolarity about 14 yearsthe 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.
-
Mizipzor about 14 yearsMy preferred way as well, when Im not stuck in a console.
-
nonopolarity about 14 yearsI 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!
-
Martin Geisler about 14 yearsJian Lin: see MacHg for a graphical Mercurial client: jasonfharris.com/machg I don't know if it can show you a list of outgoing files, though.
-
nonopolarity about 14 yearsi thought "hg status" is between working directory and local repository, while "hg outgoing" is between 2 repositories?
-
Martin Geisler about 14 yearsYes -- 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 usehg outgoing
to learn about the first outgoing changeset and then askhg status
to show changes from that changeset. -
nonopolarity almost 14 yearsby 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?
-
Willem Van Onsem over 6 yearsI am not sure this actually answers the question: since the question deals with the files that changed.