14

So in Subversion when I do an svn up I get a list of files that were added, modified, deleted, and conflicted.

When I do an hg pull then hg up -v it just displays a list of: getting file.ext but I have no way of know if that file is new or already existed. Is there a way to have Mercurial display the same sort of meta about if the file was added, modified, or deleted?

Does Mercurial offer any ability to do what I am asking?

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
James
  • 281
  • 3
  • 8

4 Answers4

18

Omni has your answer, and I voted for it, but just to show all the options:

Before pulling

  • hg incoming # shows the changesets you'll get
  • hg incoming --verbose # shows the changesets you'll get including a file list for each
  • hg incoming --patch # shows the full diffs of all the changesets you'll be getting

After pulling (but not updating):

  • hg log -r .:tip # shows the changesets you got
  • hg log --verbose -r .:tip # shows the changesets you got including a file list for each
  • hg log --patch -r .:trip # shows the full diffs of all the changesets you got
Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
17

Use the status command to list changes in file status between the working copy and its parent revision or between any two revisions. It gives you output like this:

$ hg status --rev .:tip
M hgext/keyword.py
M mercurial/cmdutil.py
M mercurial/commands.py
M mercurial/context.py
M mercurial/patch.py
A tests/test-encoding-align
A tests/test-encoding-align.out

which corresponds to this update:

$ hg update -v
resolving manifests
getting hgext/keyword.py
getting mercurial/cmdutil.py
getting mercurial/commands.py
getting mercurial/context.py
getting mercurial/patch.py
getting tests/test-encoding-align
getting tests/test-encoding-align.out
7 files updated, 0 files merged, 0 files removed, 0 files unresolved

Edit: You can create a preupdate hook to always get this information as part of your updates. I happen to be on Windows right now, and here this hook works:

[hooks]
preupdate = hg status --rev .:%HG_PARENT1%

Replace %HG_PARENT1% with $HG_PARENT1 on Unix-like systems. This should make the Mercurial experience even more Subversion-like :-)

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
6

The hg incoming --stat command does something like what you're asking. Also, if you're updating to a new revision, you can do hg diff --git -r <rev> and it will give you a diff that shows which files are new.

Omnifarious
  • 54,333
  • 19
  • 131
  • 194
  • hg incoming --stat still doesn't tell me if a file is new or not and I would have to run hg diff on each file to see. The worst case I can recurse the directory before I update and see what is new after I update but that seems so terrible. It just surprises me that this information is more easily available – James Jul 19 '10 at 00:07
  • @James - I wonder if a specialized template for 'log' wouldn't handle this. I will investigate a bit and see. – Omnifarious Jul 19 '10 at 05:04
1

You can use hg incoming with bundles, to apply Martin's answer to changes you haven't actually pulled yet.

> cd myrepo
# Get the latest revision in my copy
> hg tip
changeset:   17:5005ce2dc418
.
.
.
# Get a bundle file of changes, but don't put them in myrepo yet
> hg incoming --bundle changes.bundle
# Overlay the bundle on myrepo and do hg status as if I've already pulled
> hg -R changes.bundle status --rev 17:tip
A addedfile
M modifiedfile
.
.
.
# Changes are good! Pull from bundle
hg pull changes.bundle
anton.burger
  • 5,637
  • 32
  • 48