We automate pulling from a remote repository and do the customary Post-Pull Update. In a couple of cases, we'd like the repository to update not to the tip, but to a node with a specific label (tag).
Did I miss an obvious option? Any thoughts?
It seems that hg update --rev <tag name> should do the trick for you.
Related
I've recently started to work on an open source project which uses Mercurial.
I'm a new user to Mercurial, so I read the HG book and started working.
My goal was to write code and always pull and merge changes from the upstream
so I can stay up-to-date. The area that I am working on is also under heavy
development by others so I do want to merge my changes after a long period of
time. I cloned a repo. So, my workflow is like this:
I created a bookmark mybook
hg up mybook
Write code
3.1 hg commit -m 'new functions'
hg up default
hg pull
hg update
hg up mybook
hg merge default
Go to step 3.
In my mind this is the simplest workflow that allows me to stay up-to-date. I
also have only one HEAD because I always merge.
Since I am not a contributor yet, I am not allowed to push changes to remote
repo.
Recently I wanted to show my work to a project lead and he said send me a patch.
And this is where I am stuck. hg out shows 10 changesets. First of which
appeard already a month ago. They're numbers are 3341, 3342, 3345, 3346, 3349, 3356, 3360, 3365, 3366, 3368. The changeset numer 3368 is the tip.
I've recently read the chapter about the MQ extension. And this extensions seems to be what I need. But the problem is that I wrote code without using the MQ
extension.
So, how can I make use of the MQ extension on already created changesets so that
I can make a patch to send to the project lead so that he can apply it and see
my changes?
I've just issued hg qinit. What's next?
Issueing hg qimport -r 3341 gives
abort: revision 3341 has unmanaged children
Reading the book and googling further does not help me. I need an advice.
PS I've tried not using hg and MQ at all: simple diff -urN old/ new/ but I
want understand how to do it with the MQ.
Thank you.
Yeah, don't use MQ. It's a parallel system, meant for keeping things out of the history, and more important you don't need it.
You were asked for "a patch", not a complete history of your work, so I would recommend sending it in the form of a single before-after diff. hg export will give you a series of diffs, for all the work you've done, including the merges. I find it's far easier to read and review a single diff (before applying it). But instead of plain diff, use hg diff which knows to only look at tracked files, and has a number of other nice features (including the --git option, which provides richer metadata). This should do it:
hg up mybook
hg diff --git -r default > mywork.patch
Before sending it off, do an hg up default and apply the patch to check that it works without conflicts. And mention to the recipient which version of default you are patching against.
Edit: As you can read in the comments, #LazyBadger is a fan of the step-by-step patch generated by export. I prefer the single-step patch
since my history is usually TMI: Nobody cares about all the times I added a forgotten file, or noticed a bug too late and fixed in in the next commit, etc.
Take your pick.
When mercurial reports that it has merged files, how do I get the list of those automatically merged files? Is there a way to see this?
Sure, there are plenty. Mercurial doesn't commit that merge for you, so you can see what was modified using just:
hg status
If you want more detail you can use
hg resolve --list
I am using the patch queue to achieve something like what this person asked here:
Why can't I rebase on to an ancestor of source changesets if on a different branch?
However, what I would like to do, is that when I have all the patches in the queue, rather than apply them one by one, I would like to collapse them into one changeset. Is this possible, by either a switch I didn't find, or by when pushing the patch from the queue, not committing, just having a local change.
Thanks
It sounds like you want to try hg qfold <PATCH>.... See the EditingHistory wiki or hg help qfold for further info.
There is no --all option for the qfold command, so you must specify each patch file manually or write a script / one-liner if you want to make this a batch process. See this related SO question:
Mercurial qfold ALL patches?
How do I check out a particular named branch of a Mercurial repo?
Ah. I was asking the wrong question.
I needed to know how to switch to a particular branch in Mercurial.
The terminology you've used here is check out.
If you're coming from git, then this means you probably want to set the state of your working directory to whatever is in the particular named branch.
In SVN, you might call this switching. While the answer to this question may be the same, if you ask the same question using git terminology (as you did here), you might not find that answer, so this question is still useful in itself.
In Mercurial, it's called updating: You update the contents of your working tree, like so:
hg update -c <your-named-branch>
The -c isn't necessary, but if you're used to git warning you before anything is permanently overwritten, you'll find it more comfortable. Use -C instead to wipe all local changes, or -m to merge changes.
If you're trying to check out a branch that only exists on a remote repository, you might want to use this instead:
hg pull -u <your-named-branch>
Or else just pull (without -u) first so that the remote branch is brought into your local repository before you use update.
If you prefer git parlance, you'll be pleased to know that checkout and co are both aliases for update. You can also use -r to specify a revision. See the update help page for more detail.
I want to know what changes I made, without looking at the 30 other files that other team members modified.
So when I hg out, it said the first changeset to push was 4821, so since then I have pulled, merged, and pushed a couple times. Now I want to make sure all the debugging code is removed. Is there a way to diff the current revision (4873) against revision 4821 but only for my changes?
If your changes are in different files than those of your coworkers, which is how it sounds, you can use something like this:
hg diff -r 4821 -r 4863 -I path/to/file1 -I path/to/file2
If they're mixed in the same files as other people's changes then you would have needed to keep your changes in a separate branch (which doesn't require the branch command, anonymous branching is commonly used for this sort of thing).
The following command should do the trick:
hg diff -r "4821:4873 and user(your_username)"
I don't know if you can upgrade to the recently release Mercurial 1.6 or not, but this functional query language feature they just put in is what you might be looking for.
Try this approach:
First clone your local repo to another folder
In the new clone, rebase your last changeset so that it immediately follows your the other changeset (this should create a new head from it)
Do the diff