Extra directory can be created in hg rename-ing directory - mercurial

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

Related

hg convert with filemap giving empty repository

I have got a new repository converted from SVN. I want to minimize this repository further by removing unintended files.
For that I am again converting the mercurial repository to a new one by using hg convert and the filemap parameter.
So my filemap looks like this:
include a
rename a .
The command I am using is:
hg convert --filemap fm.txt . ../new_repo
This ends after full conversion as I can see in the console output.
But if I now check the content of the directory new repo, I can see only .hg files in there.
I ran hg update -C within the directory whic gives me one more file .hgtags
Can anyone please suggest what has gone wrong?
This answer was spot on: you don't actually create an empty directory, but a directory with a hidden .hg directory. If you run
hg update
in your target directory, you will have your target directory with all its contents as expected.
In common, you done all correct (if directory a exist in source repo)
In my test for repository with directory lang, which I want to move into the root of new repo, I used filemap
include lang
rename lang .
identical to your filemap and got bare repository after converting (no files in Working Dir, only repository on .hg). Testing repository
hg log
changeset: 19:41e96453fa67
tag: tip
...
changeset: 0:ba52ea5c5c1f
showed me all related hisory
hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(without -C) brings all files into the Working Directory
SR>dir /B
.hg
UTF-8

Reorganize directory structure with Mercurial

I have a project with directory structure
Foo/
.hg
Bar1/
...
Bar2/
...
Zope/
...
I want to change this to
Foo/
.hg
Source/
Bar1/
...
Bar2/
...
Zope/
...
What is the easiest way? (There are too many files to move them one-by-one. And there are several files with identical content, so if I just move the files and ask Mercurial to figure things out afterwards, then things get a little messy.)
Mercurial has a special command to move stuff: hg mv
When you move your folders like this, it knows in the history that Foo/Source/Bar/SomeFile was previously Foo/Bar/SomeFile.
So when you look at the history of Foo/Source/Bar/SomeFile now, you also see the changes that were made when the file was still Foo/Bar/SomeFile.
Here's an example how to move the Bar1 folder into the Source folder and commit:
hg mv Bar1 Source
hg commit -m "moved to Source folder"
Drag the 2 Bar folders into the new Source folder and commit.

How to add files to a mercurial repository after they were deleted

I have a mercurial repository. I removed a folder that contained a lot of subfolders and files from it and made a commit.
Now, when I try to to add a folder that has the same name that also contains huge amount of files and subfolders, mercurial doesn't see these new files.
I tried hg add folder_name, hg add folder_name/ and even hg add folder_name/* but hg status displays nothing after that.
What is wrong?
UPD: I tried to add a new folder with a different name withoud deleting the old one: hg add service/resources/skels/0.92/* but that didn't add files that are in subfolders of 0.92 folder.
The following session with Mercurial 1.7.1 demonstrates that removing and re-adding a folder is normally not a problem:
D:\hg>hg init test
D:\hg>cd test
D:\hg\test>mkdir folder
D:\hg\test>echo foo > folder/foo
D:\hg\test>hg add folder
adding folder\foo
D:\hg\test>hg ci -m "added folder"
D:\hg\test>hg rm folder
removing folder\foo
D:\hg\test>hg ci -m "removed folder"
D:\hg\test>mkdir folder
D:\hg\test>echo foo > folder/foo
D:\hg\test>hg add folder
adding folder\foo
D:\hg\test>hg status
A folder\foo
D:\hg\test>hg ci -m "added folder again"
Can you show such a sequence of commands which reproduces the problem?
I'm guessing you made an error during your original deletion/commit.
Try removing folder_name entirely, then doing a commit and verify it's completely removed from the latest changeset. Then move folder_name back into the repo. You should then be able to hg add folder_name.

hg rename doesn't delete the original folder in the working copy

I've a directory in Mercurial repository called httpdocs/css/ui-lightness. I want to move this directory and all its contents to httpdocs/css/jquery/themes/ui-lightness. So, I think this is the command to launch:
hg rename httpdocs/css/ui-lightness httpdocs/css/jquery/themes/ui-lightness
In fact, I've already tried and it seems to work, except that in the working copy the "source" directory (that is, httpdocs/css/ui-lightness) is NOT deleted (while in the repository it is).
Can someone explain why?
A Krtek found, what you're doing should work. Here's me running it locally:
~$ mkdir -p httpdocs/css/ui-lightness
~$ cd httpdocs/
~/httpdocs$ hg init
~/httpdocs$ echo test > css/ui-lightness/file
~/httpdocs$ hg commit -A -m "initial commit, old location"
adding css/ui-lightness/file
~/httpdocs$ hg rename css/ui-lightness css/jquery/themes/ui-lightness
moving css/ui-lightness/file to css/jquery/themes/ui-lightness/file
~/httpdocs$ ;s
bash: syntax error near unexpected token `;'
~/httpdocs$ ls
css
~/httpdocs$ tree
.
`-- css
`-- jquery
`-- themes
`-- ui-lightness
`-- file
4 directories, 1 file
~/httpdocs$ hg stat
A css/jquery/themes/ui-lightness/file
R css/ui-lightness/file
If you have any untracked (possibly ignored) files in httpdocs/css/ui-lightness they won't be renamed and thus the directory won't be empty and thus not removed, but the tracked contents in that directory should be moved.
Notice I've not yet committed that rename (and that it shows up as an Add and a Remove even though Mercurial knows it's a rename), but for it to be reflected in other clones, I'd need to hg commit, hg push and they'd have to hg pull and then either hg update or hg merge.
What are you calling the "repository" and the "working copy" and where do you do your hg rename command ?
I think you just forgot to push your changes on one side and then do a pull on the other side. Changes won't magically appear in all the clones of your repository, you must retrieve the changes.
I just tested, hg rename removes the files just fine.
It does not delete the source, it just marks it for removal in the repository. You should remove files by hands afterwards.

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.