Issue28

Title Command to diff a repository against another repository
Priority wish Status chatting
Superseder Nosy List ThomasAH, brendan, byteshack, djc, jglick, junkblocker, movement, muli, pmezard, vadim
Assigned To Topics

Created on 2005-10-24.17:34:36 by byteshack, last changed 2008-03-18.22:21:15 by djc.

Messages
msg5227 (view) Author: jglick Date: 2008-02-12.20:42:27
I have played with the rdiff extension but it doesn't quite do what I want. In
particular, say I have a repo in which I have already fetched some remote
changes, and also have some locally made commits, and I am ready to push. hg out
-p shows:

$ hg out -p
comparing with /tmp/hgtest-synch/server/dev
searching for changes
changeset:   26:35678ff13c83
user:        Jesse Glick <jesse.glick@sun.com>
date:        Tue Feb 12 14:59:29 2008 -0500
summary:     m

diff -r 299b796ec2a9 -r 35678ff13c83 m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m	Tue Feb 12 14:59:29 2008 -0500
@@ -0,0 +1,1 @@
+m

changeset:   31:e4d334f03d11
tag:         tip
parent:      26:35678ff13c83
parent:      30:02ba71c3c120
user:        Jesse Glick <jesse.glick@sun.com>
date:        Tue Feb 12 15:01:08 2008 -0500
summary:     Automated merge with file:/tmp/hgtest-synch/server/dev

diff -r 35678ff13c83 -r e4d334f03d11 i
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i	Tue Feb 12 15:01:08 2008 -0500
@@ -0,0 +1,1 @@
+i
diff -r 35678ff13c83 -r e4d334f03d11 l
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/l	Tue Feb 12 15:01:08 2008 -0500
@@ -0,0 +1,1 @@
+l


OK, obviously (1) this shows multiple diffs whereas I wanted just one, (2) the
merge diff is meaningless. hg out -pM partially solves the second problem, but
there is no way to verify that the diff did what I expected, so if I messed up
the merge somehow -M will hide that error from me, which is not comforting.

rdiff almost gives me what I want:

$ hg di ../../server/dev
comparing with ../../server/dev
searching for changes
diff -r e4d334f03d11 -r 02ba71c3c120 m
--- a/m	Tue Feb 12 15:01:08 2008 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-m

Here it is showing me the change I will actually cause in the server, between
the current head and the proposed new head. Unfortunately it shows the diff in
reverse, which is hard to read! And I cannot figure out any way to get rdiff to
give me the patch in correct order, other than adding '| interdiff /dev/stdin
/dev/null'.

If you are willing to spend the time to look at hg tip after the fetch

$ hg tip
changeset:   31:e4d334f03d11
tag:         tip
parent:      26:35678ff13c83
parent:      30:02ba71c3c120
user:        Jesse Glick <jesse.glick@sun.com>
date:        Tue Feb 12 15:01:08 2008 -0500
summary:     Automated merge with file:/tmp/hgtest-synch/server/dev

and you have had some coffee recently, then you may be able to guess to run

$ hg di -r30:31
diff -r 02ba71c3c120 -r e4d334f03d11 m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m	Tue Feb 12 15:01:08 2008 -0500
@@ -0,0 +1,1 @@
+m

which is I wanted to see. But this is subtle enough that I should not have to
figure it out.

'hg --config extensions.parentrevspec= di -rtip^2:tip' works if you have just
run 'hg fetch' and it did a merge. But if you then make another commit in your
local repo before pushing, you will have to use different version numbers.

Since generally I will have already pulled and merged (or fetched) from the
destination repository to make sure I am able to push without creating a new
remote head, what I usually want is a command that looks back from tip for the
last merge changeset, then diffs from the second merge parent to tip. Assuming I
have only one head in my local repo and will not be passing -f to push, this
should give me a summary of what changes I am about to make to the remote repo,
including the final result of any merges I had to perform in the process.

Unfortunately this trick only works if you have merged from the remote repo and
this was your most recent merge. So in general the command would need to examine
the remote repo for its heads, aborting if more than one is found; examine the
local repo for its heads, again aborting if more than one is found; ensure that
the local head is a descendant of the remote head, aborting if not with the
suggestion that you first fetch; and then run a regular local diff from the
remote head's revision to tip.

I might suggest 'hg out --summary' for this purpose.
msg3924 (view) Author: brendan Date: 2007-08-27.01:11:03
I've just written the rdiff extension to address #1:
http://www.selenic.com/mercurial/wiki/index.cgi/RdiffExtension
#2 is outgoing -p -M
#3 I will look into adding to rdiff.
msg1499 (view) Author: movement Date: 2006-06-09.14:34:40
This is essential for properly reviewing what you're about to push. hg outgoing
includes stuff like merges (i.e. changes that /already/ exist in the parent).

Ideally, it would have three forms:

1) a big single diff (see issue 219)
2) an hg log -p style format
3) something including local uncommitted changes
msg1032 (view) Author: junkblocker Date: 2006-04-15.02:40:55
+1
msg38 (view) Author: muli Date: 2005-10-24.20:02:49
+1 on this, I'd love to see it.
msg37 (view) Author: vadim Date: 2005-10-24.17:45:44
On 10/24/05, Daniel Santa Cruz <mercurial-bugs@selenic.com> wrote:

way to do this is to have an command that prints most recent common
ancestor revision of this repository and another one. this is
something that i think pull command must already be calculating, so is
should be easy to pull out and make stand alone.

with such an command, you could just clone repository, pull remote
repository, find common ancestor like i said, and then run diff
yourself. easy to wrap that up so only one step, of course.
msg36 (view) Author: byteshack Date: 2005-10-24.17:34:35
Would be nice to have a diff command that could compare repositories.  Would
allow easy creation of patches against remote trees.
History
Date User Action Args
2008-03-18 22:21:15djcsetnosy: + djc
2008-02-13 06:49:15pmezardsetnosy: + pmezard
2008-02-12 20:42:29jglicksetnosy: vadim, ThomasAH, byteshack, muli, brendan, movement, junkblocker, jglick
messages: + msg5227
2007-11-19 18:52:22jglicksetnosy: + jglick
2007-08-27 01:11:04brendansetnosy: + brendan
messages: + msg3924
2006-06-09 14:34:50movementsetnosy: + movement
messages: + msg1499
2006-05-11 17:05:30ThomasAHsetnosy: + ThomasAH
2006-04-15 02:40:55junkblockersetnosy: + junkblocker
messages: + msg1032
2005-10-24 20:02:50mulisetnosy: + muli
messages: + msg38
2005-10-24 17:48:18vadimsetnosy: + vadim
2005-10-24 17:45:44vadimsetstatus: unread -> chatting
messages: + msg37
2005-10-24 17:34:36byteshackcreate