How am I supposed to update current branch to head in TortoiseHg 2.x?
In console I just perform hg up, but in tortoisehg I need to find current revision, look its name, switch to the current branch in the "filter toolbar" and find out manually the current branch's head. It is very odd, imho.
Right Click -> Tortoise HG -> Update -> Update to: Choose default / tip /branchname
Or in Workbench, right click on Tip and select Update. Or you can just right click, Update and select update to branchname / tip without worrying about the revision you are looking at.
Related
If I add something to a Mercurial shelf on the command line:
C:> hg shelve ...
when I then look in TortoiseHG Workbench under the Repository > Shelve > menu, there is NO new corresponding entry (in the dropdown).
Likewise, if I do the opposite and perform a shelving operation in THG, and then run hg shelve -l or just hg unshelve on the command line, it seems to ignore the new shelf.
Why is this happening? Is there a setting or something like that which is affecting this?
The shelving features in 'core' Mercurial (command line hg) and the TortoiseHG GUI are totally independent of each other, as far as I am aware.
(Historically, this strange-seeming situation resulted from, I believe, the THG feature being created first before an equivalent / similar feature with the same name was later added to HG proper).
IMO the HG shelving feature works better than the THG feature from the standpoint of efficiently using HG merge logic to apply shelved changes to the local working folder during an unshelve operation. Once I realized that, I never use the THG shelf any longer, and that is what I recommend.
It is possible to configure THG Workbench to integrate (to a certain extent) with the HG shelving feature. Instructions:
Edit your mercurial.ini settings file. (Either through File > Settings > Gobal Settings > Edit File button, OR open the file in an editor manually).
Add the following sections & items:
[tortoisehg]
...
workbench.custom-toolbar = HG_shelve HG_unshelve
and
[tortoisehg-tools]
HG_shelve.command = hg shelve
HG_shelve.enable = istrue
HG_shelve.icon = go-next
HG_shelve.label = HG_shelve
HG_shelve.showoutput = True
HG_shelve.tooltip = HG_shelve
HG_unshelve.command = hg unshelve
HG_unshelve.enable = istrue
HG_unshelve.icon = go-previous
HG_unshelve.label = HG_unshelve
HG_unshelve.showoutput = True
HG_unshelve.tooltip = HG_unshelve
(careful not to duplicate any existing [tortoisehg] or [tortoisehg-tools] sections).
This will yield new buttons on the toolbar:
One arrow will shelve the current working folder, the other will unshelve.
Obviously running shelve/unshelve this way is rather coarse-grained but I find that 99% of the time that's all I need.
Notes:
The .INI edits above can also be done through the THG Workbench File > Settings > Tools GUI section.:
You don't have to use these particular icons if you prefer something else, THG has other choices.
I cloned a Mercurial repo and did a bunch of local work, and forgot to make a feature branch for said work.
The normal flow is:
Clone
Create a branch
Switch to that branch
Do your work in that branch
Push that branch
Code review
If code review passes, merge branch w/ default (locally)
Push merged changes to default
Close the feature branch
So I need to create a new branch, port all my unstaged/uncommitted code changes (made to default) over to this branch (so that default is now clean and the new branch contains my changes), and then push my feature branch.
I created the new branch via hg branch new_feature. But after pouring over the Merucrial docs, I can't figure out the next step.
So I ask: How do I move (not just copy) all my unstaged/uncommitted changes from default to my new_feature branch)?
You shouldn't have to do anything in particular.
Your uncommitted working folder changes are fluid, and you can set the branch name before you commit, without losing your changes.
If you're on the command line, simply do this:
hg branch feature-X
hg commit -m "Added feature X"
If you're using TortoiseHg simply click the "Branch: default" button just above the commit message input field and select "Open a new named branch" and give it a name, then click OK, then commit as normal.
Setting the branch name to use during commit does not in fact change your working folder, it doesn't do an update, it doesn't do anything, except record in metadata what the branch name is supposed to be.
Also note that this will only allow you to create a new branch to commit to. If you want to continue on an existing branch you first need to update to the head of that branch and this may cause changes to your working folder. You should not need to do this, however, if you want to create a new branch.
Simple question: is there a way to revert --all from TortoiseHg workbench? I see how to revert an individual file. Ideally, I could click on a revision, and from the right mouse menu find a "revert all" item.
I'm using TortoiseHg 2.8 on a Ubuntu box.
EDIT I should have provided more details on my question to provide some context. Let me describe the particular use case:
I want to put my working directory back to the state of a past commit so I can generate output from the executable that I know was "good". Once I've generated that output, I want to go back to the tip and continue my development, keeping this history linear. From the command line, I did "hg revert --all --rev 22", generated the output, then "hg revert --all", which did what I wanted. "hg update" will create a history with a branch (if I'm understanding correctly). FWIW there is an "update" button in TortoiseHg (in the box where the list of files is shown) as well as a right-mouse menu item on a given revision.
To set the working directory to match the state of a given changeset (which could be tip), you can use Update:
Right click on the changeset you want to 'revert' to.
Select "Update"
Check the "Discard local changes" checkbox
Click Update
It would be hg update -r changeset -C in the console.
Now you can create the output from the 'state' of the working directory at that point in history (i.e. from the executable at that changeset). If you don't make any commits here there will be no changeset created and therefore nothing is added to the repo history.
Once you have the output to your satisfaction, you can update again to the tip of development via the same process and continue your work:
Right click on the tip of development.
Select "Update"
Check the "Discard local changes" checkbox
Click update
The benefit of using update over revert is that Tortoise will explicitly display the parent of the working directory as the changeset it history. Under revert it could be very easy to revert the files and lose track of which changeset you had reverted to and which part of history you occupied.
(This is assuming that you want to move to that point in the history. If you need to create a changeset that undoes a prior changeset, look into backout, though I'm not sure if that is available in Tortoise.)
You can select all modified files in the list with Ctrl+A and then select "Revert" from context menu.
The Mercurial Workbench within TortoiseHG allows a graphical use of many mercurial functions. I have a patch sitting in a mercurial queue from which I want to extract some files to another separate patch.
I found a solution here for the command line approach:
Gaol: End up with OP=P1 + P2, where OP=Original Patch, P1=Patch 1, P2=Patch 2
Solution:
hg qpush OP
hg qrefresh <paths to keep> to replace OP with P1, including only the paths you named. The other changes will remain as uncommitted changes in the working directory.
hg qnew -f P2 to pick up those changes.
I simply cannot figure out how to do this within the workbench and would be glad if someone could teach me how to accomplish this. Thanks!
When you use the refresh button in TortoiseHg it acts on the ticked items in the list so to do what you ask you follow the following steps:
Click on your patch OP in the top list
Untick the the files that you want to go into the second patch on the list of changed files on the left
Click the refresh button on the right
Click on the working directory entry on the top list to see the rest of the files
Tick all the files on the list of changes on the left
Click on the new patch button on the right (click on the little down arrow on the commit button if that it's the active button to select the new patch button)
Obviously, enter any commit messages as required.
Is there a way in mercurial to give an alternate name to the default branch while still having default work as before? I.e., Can I set things up so that either hg update main or hg update default will bring me to the default branch?
You could hand a bookmark named 'main' on the default branch like:
hg bookmark --rev default main
That bookmark will start out on the "most tipward" changeset on the default branch. And the bookmark will follow that along when you commit (including committing merges).
In general though try to keep using the name 'default' for your active development work.