How to not overwrite and delete moved file - mercurial

I'm moving file A from directory C to directory B by hg move C B. In the directory B there's already file called A.
How can I tell to mercurial not overwrite the already existing in B file and mark the file as moved (delete the ile in C)?

Delete file A from directory C.
Tell Mercurial that you already moved the file using hg rename from the command line:
hg rename --after C/A B/A

Related

Extra directory can be created in hg rename-ing directory

I try to rename directory which includes largefile-normal mixed via hg rename <orig-dir> <dest-dir>, and results as this:
orig/foo.png(largefile) → dest/orig/foo.png
orig/bar.txt(normal) → dest/bar.txt
...
I'm annoyed by this behavior, I'd like to know how to resolve this problem.
I guess what you are seeing is because the folder has a file which isn't tracked by mercurial.
Workaround might be to rename the folder then run hg rename --after
For example (windows):
ren orig dest
hg rename --after orig dest

Move a file inside a mercurial forest from one repo to another?

Is there an hg command to move a file within a forest from one repo to another?
That is, a command, similar to what hg mv does for a single repository?
Or do I have to delete the file in one repo and create a copy in the another repo?
There are no commands to move files between repositories, so yes, copy and commit the file in the other repo and delete from the original.

How to allow a deleted file to remain untracked in Mercurial?

I've got a configuration file ("config") that we originally committed to our repository. (first mistake)
We then deleted that file using hg rm, and left a sample configuration file in the repository.
When developing, we just copy the "config.sample" file to "config". However, whenever I update to a different branch and back to the branch with the delete, the untracked config file is deleted.
I've already added the config file to .hgignore.
Is there a way to make mercurial allow the existence of this untracked file going forward?
It looks like the branch you go to before coming back contains a config file too. When updating back, the file was deleted, so mercurial removes it.
Try deleting the config file in your other branch, too, and adding the file in the .hgignore of that same branch.

abort: untracked file in working directory differs from file in requested revision: '.hgignore'

I am trying to pull some files and directories and I am having the following messages:
When I look in my repository I can see that the files have been downloaded but all contains _ as prefix, and even the names of files and folders contain _
requesting all changes
adding changesets
adding manifests
adding file changes
added 1094 changesets with 4304 changes to 1071 files abort:
untracked file in working directory differs from file in requested revision: '.hgignore' [command interrupted]
What is wrong?
I think you have created a .hgignore in your working directory without adding it to the repository (hg add). This file is "untracked".
Someone else, from another clone, has added this file too, committed and pushed it. Now, when you try to update your working directory, Mercurial try to add this file but sees a file with the same name in your working directory which is untracked and different.
There's two solution to your problem :
Backup your .hgignore file, do the update and add the differences from the backup if necessary
Add your own file to the repository with hg add, then re-run the update. It will maybe be necessary to commit the file prior to the update.
I'll advise using the first solution.
When you say the files in the repository have _ as a prefix, you're looking down inside the .hg directory aren't you? That's the data store for Mercurial itself and the files in there are revlogs, not your files. Outside of .hg you'll have a working directory where the files are the actual files you expect. You're not getting one of those now because hg update is refusing to update the working directory because doing so would overwrite your uncomitted .hgignore file.
What exact command are you running? It looks like it's doing a hg pull followed by an hg update so I'd guess hg clone but if you already have a .hgignore lying around that's not the right command to use. If instead you're using hg pull -u or hg fetch you should just use hg pull instead to get the changesets. Then you can:
hg add .hgignore # add the hg ignore file you already have that's untracked
hg commit -m .hgignore # commit the .hgignore file you just added
hg merge # merge your new commit (.hgignore) with the changesets you just pulled down.

Mercurial: copying ONE file and its history to another repository

I'm wondering if I can copy one file and its history from one repository to another, without having to import the whole other repository.
You can use the ConvertExtension to export just that one file from the first repository into a new temporary repository, then use hg pull -f to import the new repository into the target repository.
Create a filemap for the ConvertExtension with the single line:
include path/to/file
Then use:
hg convert path/to/original path/to/temporary --filemap filemap
to create the temporary repository. Next, in the target repository, do:
hg pull -f path/to/temporary
to pull in that file with its history. This will create a new head, so use hg merge to merge it with the head in your target repository.
Just to add to Niall C.'s answer, you can rename the files you are importing to place them at the correct place too.
You must first rename the file, then include it. Your filemap would look like that:
rename "original/path" "wished/path"
include "original/path"