Exclude files added/changed by a merge from hg status - mercurial

I have a repository default and a branch mybranch. Now I want to use hg status to show files which were added/changed in my branch but exclude files which were added/changed by a merge from default.
I tried
hg status --rev "branch('mybranch') and not merge()"
but this still contains files added by a merge. For testing I also tried
hg log --rev "branch('mybranch') and not merge()"
which works as expected. What am I doing wrong?

This may only be a partial answer, but it might help.
Option --rev does different things for status and log commands.
For status:
--rev REV [+] show difference from revision
For log:
-r --rev REV [+] show the specified revision or revset
Note also that status does have an -r option but it is not a synonym for --rev.
So this at least explains why the two commands don't give you the results you expected.
Oddly, though the help page for status does not mention revsets, they do seem to be supported.

Related

Mercurial list files from changegroup

I want a simple command to get the list of files which differ after pushing to a mercurial repository on a server,
that is the differences between the previous push and the current push.
On the server, I have a hook on the changegroup event which calls a bash script.
$HG_NODE is the revision for the first commit in the changegroup.
My attempts:
hg status --rev $HG_NODE::
Exclude changes made in the first commit
hg status --rev $HG_NODE^1::
Includes changes that affected the parent revision through others pushes.
hg log -v --rev $HG_NODE:: | grep ^files
Include committed then reverted changes, still has 'files:' and files are not one per line
hg status --rev $HG_NODE:: && hg status change --rev $HG_NODE
Does not give exactly what I want, rather the change between the parent to the first commit in the changegroup + the change between this one (instead of the two changesets merged)
hg status --rev some_tag ; hg tag --remove some_tag ; hg tag --local some_tag
(Have not tried, is it a good idea?) Uses a local tag to keep track of the head for the last push, updates it each time.
Also I want to only monitor the default branch, so I assume I will use something like --rev "revision and branch(default)" or the branch option for hg log.
As to why, I need to go through the changes to determine parameters for an automated build.
hg stat -r is to list the removed files. To get the list of files which differ, you should use hg st --rev as follows.
hg st -m --rev tip^:tip

Mercurial revision checkout is working, but according to the log, the revision is not exist

I have some issue with Mercurial. The checkout of a revision is working (via hg clone -r X command, which clones the X. revision), but when i tried to get log for the X. revision, it returns with revision not exist. How can i solve this problem?
Commands i use:
hg clone -r RevisionNumber /path/to/local/repo my_folder
Then:
hg log -r RevisionNumber --template 'my_template'
hg diff -c RevisionNumber
I get:
abort: unknown revision 'RevisionNumber '!
I tried revisioning with number, and with number:hash, neither worked.
My guess here is that you are referencing the changeset by the revision id (your RevisionNumber) that is local to the original repo. Only the changeset identifying hash is globally unique. I'm basing this guess on your statement
I tried revisioning with number, and with number:hash, neither worked.
You should try using only the hash and see if that works.
hg log -r [hash]
(If you do number:hash, hg thinks your are looking for the range of changes between number and hash.)
Explanation: When you clone to a specific revison, Mercurial only includes changesets that direct ancestors of that revision and leaves out all others. The numbering is locally sequential (meaning new numbers are assigned as the changeset arrives at the repo).

Diff after committing locally

I just cloned a repo from their remote.
I built the software, changed about 4 files, committed them locally and now want to create a patch that I can show them.
When I run :
hg diff -U8p abc efg pqr > patch_file
I don't see the changes I made. Does hg diff only compare the current files with the last committed files?
How do I get this to work?
To diff the working directory against a particular revision REV, use
hg diff -r REV
To compare two revisions against each other, use
hg diff -r REV1 -r REV2
To figure out which revisions to compare, examine the output of hg log. If you'll be doing this a lot and the base revision is fixed, give it a name (e.g., whatipulled) with
hg tag -r REV whatipulled
You can then specify whatipulled as the revision, instead of a numeric rev id (or a hash).
To export your diffs in a richer format, including commit comments etc., you can also use the following which is designed for this purpose:
hg export -r REV
There's also hg bundle -r REV, which produces a binary file with similar information.
But if you're sending changes back to the parent repo, the best method is to use hg push. It communicates your changesets directly to the parent; you don't even need to know which changesets need pushing. Of course, you must have the right to push to the parent repo.
hg push [ parent_repo_url ]
(If you pulled from it, mercurial should already know the path and you can leave it out).
If the parent repo is on bitbucket and you don't have pu, you can set up your own account on bitbucket, pull/push to that from your local repo, and then issue a "pull request" to the project repo, asking them to pull from you.
All of the above have options to control their behavior, which see.
From hg help diff
If only one revision is specified then that revision is compared to the working directory
In your diff for -r you must to use old tip (latest "not your" changeset) and update to tip (your latest changeset) before diffing.
If some binary data was modified in your changesets, don't forget to use -g option
hg up & hg diff -r <CSET> -g > some.patch
Improved diff for any active changeset and without hand-work for detecting base changeset (for linear history == in single branch)
hg diff -r "parent(min(outgoing()))" -r tip
By default, hg diff compares the currently checked out file with the last commit. You can change this by adding options:
-r REV compares the currently checked out files with a specific revision REV.
-c REV shows the changes made by revision REV
So in your case hg diff -c 123 ... would give you the diff for commit 123.
My guess is that hg outgoing is exactly what you want -- it compares what you've committed locally with what is at the default remote server and shows you a list of those changesets or with -p the commits.
That does, however, shows each changeset separately. If you want to see all the changes combined, you'd have to do hg diff -r HERE -r THERE or since -r HERE is a default, hg diff -r THERE
I see you've asked in a comment "How do I know what THERE is", where THERE is the last changeset remote has, and you can get that answer by doing hg outgoing. If hg outgoing shows it would send changesets 66, 67, and 68, then you want to do hg diff -r 65 to compare what's already there (65) with what's local (68).

Mercurial: Command for status similar to qdiff?

You can use qdiff to see the differences between the repository and the changes you've made in your patch queue thus far (even with qrefreshed changes). Is there a similar command for status, so that you can see all the files that are modified, even once you have qrefreshed the changes to those files?
This will show you changes in the currently applied patch:
$ hg status --change .
And this one will include changes also in your working dir:
$ hg status --rev .^

How to compare two revisions in Mercurial?

I need to know what files have been added/modified/removed between two revisions. What I do:
hg status --rev 10:11
It looks okay. But when I have only one revision (initial = 0) it doesn't work.
# not work
hg status --rev 0:0
# also not work as I want
hg status --rev 0
There is no revision -1.
The special revision null is used to indicate the parent of revision 0. You can use
hg status --rev null:0
to see the changes in the first revision.
hg status --change [rev]
ie,
hg status --change 0
and
hg log -v
You might want to look at the output of hg log -v. For each changeset, it should list the files modified in that changeset. If you had a particular changeset in mind, add the -r switch to specify it.