How to delete a remote branch in Mercurial? - mercurial

Apparently strip only works on local branch but I want to delete a remote branch.
Anything equivalent to these git command for mercurial?
git push origin —delete [branch_name]
git branch -d [branch_name]

You cannot delete a remote branch ever.
Stripping and hist-editing is a strictly local operation. Thus you need access to the server and strip there (maybe that's possible via web-interface, e.g. on BitBucket).
The only exception is - to some degree - if the changesets are of phase draft AND the remote server is configured a non-publishing server. Then you can obsolete the changesets on the remote server (but not delete them either).

Related

Updating a local mercurial copy with a specific commit from another remote site

(I'm using real examples, so it is clearer.)
I cloned an official Mercurial repository locally
hg clone https://bitbucket.org/Coin3D/soqt -r default
from this repo: https://bitbucket.org/Coin3D/soqt/branch/default
Now I want to update my local copy with a commit taken from a remote fork of the main project:
https://bitbucket.org/roboticslibrary/soqt/branch/patch-hidpi
How can I integrate a specific commit from a remote fork (#214c74a in this example) into my local clone?
With git I would add the remote fork, then I would use "fetch" on that and then I would use "cherry-pick" to get the specific commit.
Is that possible at all in Mercurial?
Thanks a lot!

How to delete remote branch on phpstorm after I delete on gitlab?

How to delete remote branch on phpstorm after I delete on gitlab
After deleting that branch on GitLab, I cannot select the same branch in my PhpStorm-managed local repo without seeing the error message:
Failed to delete remote branch origin/branch1
unable to delete 'branch1': remote ref does not exist failed to push
some refs to 'http://user#gitlab.company.com/owner/projectname.git'
How can I avoid that error message?
This is seen when a remote repo has no longer a specific branch, but an IntelliJ GUI like PhpStorm still reference it as a remote tracking branch.
See IDEA-96402 (Dec. 2012, not yet closed):
Remote branches on a project hosted on bitbucket.org don't exist anymore, but are still listed on my phpstorm installation.
Bitbucket does not list the branch anymore
When I select the branch to delete from within PHPSTORM, i receive the message
Failed to delete remote branch origin/hotfix/bug-121: null: NON_EXISTING
The workaround is for now a manual one:
You can call git remote prune origin in the command line.
If you call Update Project to pull from the remote, it will automatically prune all obsolete references.
The ticket adds:
Note that if you delete a remote branch from the IDE or from the command line, the reference is deleted as well.
This request is about deleting remote reference on the branch which was removed from the remote via some other way, not from this repository.

Mercurial: create local copy of a remote repository at the remote respository

I use Mercurial on desktops, and then push local repositories to a centralized server. I noticed that this remote server does not hold local copies of files in its repositories (the directory is empty, except obviously for the .hg one).
What is the preferred way to populate these directories with local copies? (which in turn are used by various unrelated services on that server).
What I came up so far is to use a hook and hg archive to create a local copy. This would be a satisfactory solution but I need to configure a per-repository hgrc file (which is tedious but I did not find a way to centralize this in /etc/mercurial/hgrc). Maybe a global script (in /etc/mercurial/hgrc, run for each changegroup event)? (in that case how can I get the repository name to use in a if...then scenario?)
If you can get access to the remote repository, you could install a hook for when changegroups come in, and perform an hg update when that happens.
A quick check shows this in the FAQ (question 4.21), but to summarize/duplicate: edit the .hg/hgrc file on the remote repository, and add the following lines:
[hooks]
changegroup = hg update
Whenever the remote repository gets pushed to (or when it performs a pull), it will update to the latest changeset.
Some caveats - this may fail if any changes have been made to the files on the remote side (you could use hg update -C instead). Also, if you have pushed any anonymous branches (which you would have to consciously force), you may not update to what you want to update to.

How to do a quick push with Mercurial

After a change in my local repo, I commit with hg commit -m <message>, then I push to my server with hg push, then in my server I update working dir with hg update.
Is there a better way to do this?
The first two steps you have described:
hg commit -m <message>
hg push
are required as per the fact that commits are kept completely separate from the server in Mercurial (and most other DVCS as well). You could write a post-commit hook to perform the push after each commit, but this is not advised because it prevents you from correcting simple mistakes during the commit and before the push.
Because you're trying to perform an update on 'the server' I'm assuming you are executing a version of the code in your repository on the server. I'm assuming this because typically the server would simply act as a master repository for you and your developers to access (and also to be subject to backups, etc..), and would not need the explicit hg update.
Assuming you are executing code on the server, you can try and replace the push and the update with this command:
hg pull <path to development repo> -u
which will perform a pull from your local repo and then an automatic update. Depending on your server configuration, it might be difficult to get the path to your local repo.
For the first part of the question (ie. automatically push when you do a commit), you can use the trick described in this answer : mercurial automatic push on every commit .
If you want to automatically update the working directory, you can do this with a hook. Add this in the hgrc of your repository (.hg/hgrc on your server directory) :
[hooks]
changegroup = hg update >&2
This will automatically update the working directory every time a push is made to this server. This hook is described in the Mercurial FAQ.
If you use these 2 solutions, the next time you do hg commit -m "message", the commit will be automatically pushed to the remote server and the working directory on the server will be updated.
There is an extension called autosync you might find useful:
This extension provides the autosync command which automatically and continuously commits working copy changes, fetches (pull, merge, commit) changes from another repository and pushes local changes back to the other repository. Think of configuration files or to-do lists as examples for things to synchronize. On a higher level the autosync command not only synchronizes repositories but working copies. A central repository (usually without a working copy) must be used as synchronization hub:

Correct command to retrieve remote mercurial updates pushed from my second machine

I'm new to Mercurial.
I initialized a Mercurial project on Machine A, committed my changes and uploaded them to a remote repository.
Then I cloned that repository on Machine B, committed some additional changes and uploaded them to the same remote repository.
In both cases, I uploaded the changes with the same command:
hg push https://username:password#domain/user/repository/
Now I'm back on Machine A and I'm not sure how to update my local repository with the last changes I uploaded to the remote repository from Machine B.
The commands hg clone or hg pull look like they might work but I'm not sure.
Would appreciate any guidance. Thanks.
hg pull will transfer any remote changesets not present in your local repo. Afterwards, you'll need to either hg update or hg merge depending on the presence of local changes.
Use hg pull; pull transfers only changesets which are missing in the existing destination repository.
hg clone creates local copy of a remote repository.
See also this so question.