I'd like to get an hg status list for a range of revisions, and also filter the list for a given branch name.
e.g. The issue with this command is that it includes changes from multiple branches, and I'm only interested in a particular branch:
hg status --rev 150:175
Is there a way to add an additional filter by branch for this list with hg or a mainstream hg tool?
You can do this using revsets:
hg status --rev "150:175 and branch(<BRANCH_NAME>)"
I believe that you can use revsets (hg help revsets) to do this. There are a large number of options for selecting revisions, but I think that what you want would be something along these lines:
hg status --rev "150:175 and branch(mybranch)"
Revsets can be tricky at times, but they are very powerful, and so well worth reading about them in hg help.
Related
Not much to add to the title. hg branches --help --verbose doesn't show anything useful, although I'm not sure if the user can be shown via the --template option (in this case tools like grep could help). Or may be I'm looking in the wrong direction?
Automating this search would be really useful because there are a lot of unclosed branches in the current project and that would help for both checking if I left some opened branch and suggesting collegues to take a look at certain branches.
Bashism of #Jello is rather good, but... it's bashism.
Some steps (not ready to use solution) to almost pure hg-style
Re-read hg help revsets+ hg help templates
All starting points of branches (named and anonymous) are child of branchpoints. All changesets have authors. Because every branch may have any amounts branchpoints in it (and every branchpoint means 2 branches of child), branchnames can be duplicated in output of suggested command (and I'm too lazy to clean-up it)
Task 1 - find all starting revisions of branches
-r "children(branchpoint())"
Task 2 - output only branch and author of changeset
--template "{branch} - {author}"
full command (T1+T2, all branches of all users), somrthing like this
hg log -r "children(branchpoint())" --template "{branch} - {author}\n"
as starting point.
You can:
add ifeq logic into template (don't print "old" branchname for changesets with
branch(r)=branch(p1))
add ANDed condition "USER" into revset, define full command as parametrised alias and have ready to use shareable solution
Try a bash loop like this:
for branch in $(hg branches -q); do hg log -r "branch($branch)and 0:" -u "username" -l 1; done
I have tried the
hg log --rev "branch([changeset])"
but what I got is a collection of all the changesets in this branch.
What I do want to get is the name of the target branch (e.g. default) instead of the whole collection.
Is there a way to achieve this goal?
That's... not what revsets are for. You want to do something rather different:
hg log --rev [changeset] --template "{branch}\n"
See hg help templates.
I stopped using hg fetch to pull and merge in another head for a Mercurial repository because I like to make the commit message say what is merging with what. Furthermore, I am moving from "merge repo1 -> repo2" to a more specific "merge head1guid -> head2guid" format.
How can I automate this so I don't have to list the heads with hg heads then copy and paste the guids for the two changesets into my commit message?
As others have pointed out in comments the one or two parents of a changeset are already stored in a changeset and shown in hg log and other command line views -- You're probably better off not re-storing them.
If you really wanted to you could do something like:
hg commit -m "merging $(hg log -r . --template '{parents}')"
but I always try to put something actually useful in the message like "Merging Jim's work on foo into Alice's work on bar"; there's no new information in re-storing the nodeids of the parents.
Note that command only works when you're committing a merge -- it'll be empty otherise.
After I pull a new head into my repository, I want to see what files are touched by the new head. Like an hg status but without changing over to it. I don't want the whole diff, just an overview.
Which I expect is a specific version of the more general question: how do i see a summary of the changes in a specific revision?
This is on the commandline, I don't want to fire up TortoiseHG or some other GUI.
The status command shows you which files are changed. Use
hg status --rev .:tip
to compare the working copy parent revision (the currently checked out revision) with the tip revision.
If you've pulled more than one changeset, then this is different from
hg status --change tip
That command only shows the files touched by the tip changeset — not the combined changes between the currently checked out changeset (.) and tip.
Use the --change option to hg status, passing it the revision you're curious about. For instance,
hg status --change tip
lists the files changed in tip. I believe this flag was added in hg 1.7.
Lol. Amazing how forcing myself to ask the question makes me realise where best to look.
hg diff -r11 --stat
The --stat seems to get me what I'm after.
I want to remove a changeset from history but hg export does not work for merge changesets (see https://www.mercurial-scm.org/wiki/Export). Is there a way to use hg pull for a range of revisions? For example, say I want to remove revision 999 I want to be able to say:
hg init NewRepo
hg pull ../OldRepo -r 0:1000
hg pull ../OldRepo -r 1000:tip
Any ideas?
Pull can't pull a range of revisions because every mercurial revision that exists in a repository must have all of its ancestor changesets in that revision too. So if you do:
hg pull ../oldRepo -r 1000
you get all of revision 1000's ancestor revisions too.
In general, mercurial is about building an immutable history -- if you regret a changeset you don't remove it you create a new one that undoes the work of the changeset you no longer like. If you can't abide having full history in your repo you need to use something like the strip or convert extension. Both work as advertised, but provide plenty of opportunities to shoot yourself in the foot. If you can stand it, just undo the onerous changeset in a subsequent changeset and move on.