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
Related
I'm having difficulties creating an hg-subrepo to a local hg repository.
I've created a "core" repository that I would like to be a subrepository inside another repo. I'm able to clone the "core" repo inside the target but when I go to create/checkin the .hgsub file, I get a parse error that prohibits me from committing the file.
PS C:\Temp\subrepo_experiments\target01> hg status
PS C:\Temp\subrepo_experiments\target01> hg clone C:\Temp\subrepo_experiments\core
destination directory: core
updating to branch default
resolving manifests
getting core_001.txt
getting core_002.txt
getting core_003.txt
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
PS C:\Temp\subrepo_experiments\target01> echo core = C:\Temp\subrepo_experiments\core > .hgsub
PS C:\Temp\subrepo_experiments\target01> hg status
? .hgsub
PS C:\Temp\subrepo_experiments\target01> hg add .hgsub
adding .hgsub
PS C:\Temp\subrepo_experiments\target01> hg commit
hg: parse error at .hgsub:1: ■c o r e
PS C:\Temp\subrepo_experiments\target01>
Whatever editor you used to create your .hgsub file has created an abomination. It appears to be using 16-bit UTF-16 encoding and has a BOM (byte order mark) at the front. Use something that creates UTF-8 or ASCII text without a BOM, and you'll be in good shape. You can see this problem in the output:
hg: parse error at .hgsub:1: ■c o r e
It's telling you "Hey, there's a piece of nonsense at the front and then a non-printable character (NUL / 0x00 in this case) in between every character!
You have re-read Subrepositories manuals, better - Subrepositories from "Mercurial Kick Start Exercises", at least first chapter of Introduction
Your mistake is bad definition of right side of subrepository. It have to be relative path (to the root of contaner-repository) or URL (for external subrepo).
If core is subdir of subrepo_experiments (which is root of main repo), then .hgsub will have the easieast form
core = core
It will be fully functional repository with subrepository in it
Repeated sample from Kick Start
z:\mainrepo>dir /B
.hg
subrepo
.hgsub
.hgsubstate
z:\mainrepo>dir subrepo /B
.hg
z:\mainrepo>type .hgsub
subrepo = subrepo
and just for testing
z:\>hg clone mainrepo main-clone -v
updating to branch default
resolving manifests
getting .hgsub
getting .hgsubstate
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
Note: Ry4an catched first main problem, which I miss going deeper
I got all the fonts from the Google font project on my computer via Terminal by using:
hg clone someURL;
I would like to delete it all from my computer. I've seen the following code suggested in another thread:
rm -r .hg
I'm uncertain what the .hg refers to though. There are less than 20 fonts in the 'googlefontdirectory' folder, even though I can use many more Google fonts in various apps. I'm concerned that simply deleting the 'googlefontdirectory' folder won't get rid of everything, since most of the fonts don't seem to be there. What is the best way to delete/remove all fonts that came with the 'hg clone'?
ALL files in repo, cloned by hg clone command placed inside one directory, which is Working Copy and local repository in .hg subdir. rm -r .hg doesn't remove all cloned data, only repository without working copy
hg help clone
...
Create a copy of an existing repository in a new directory.
If no destination directory name is specified, it defaults to the
basename of the source.
Added results of repo-clone
There are less than 20 fonts in the 'googlefontdirectory' folder
Really?!
hg clone https://code.google.com/p/googlefontdirectory/
...
added 3056 changesets with 60182 changes to 46816 files (+1 heads)
updating to branch default
27215 files updated, 0 files merged, 0 files removed, 0 files unresolved
dir /S *.ttf
...
Total Files Listed:
1295 File(s) 201 270 824 bytes
Over time a number of the developers have committed files that were then added to the .hgignore. From what I hear there is no way to remove items from the history of mercurial, which is ok. But I also heard that there is a way to do a clone, I think using the convert plugin, to clone/export a repo while specifying which files to not include in the conversion.
I can't help but think that someone out there has a script that does this export/filter/convert using the patterns from the .hgignore file.
Has anyone created such a beast?
You could create a filemap from .hgignore doing something like this:
hg clone -U yourrepo temprepo # create a temp repo with no files in working dir
cd tmprepo
hg revert --all # put files in working dir
hg forget ** # un-add the files
hg status --ignored --no-status | sed 's/^/exclude /' > ../filemap
that will get you a filemap you can pass into hg convert that removes all the added files that would be ignored given your .hgignore.
Do understand though, that running convert creates a whole new repo that is unrelated to your previous repo. All existing clones will be unusable with the new one. It's not normally worth it.
hg convert is indeed the thing you want to use.
You will want to create a file map (just a text file) which will list all of the things you either want to include, exclude, or rename:
include subfolder
exclude subfolder/supersub
etc...
Read the following for a more concrete example:
https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap
Once you have created this file you will just use the following command:
$ hg convert --filemap my_file_map /path/to/source/repo /path/to/dest/repo
The source repo will not be modified and a dest repo will be created. I don't want to just copy verbatim what the documentation already says so here is the link:
How to keep just a subdirectory (or run on the mercurial repo):
https://www.mercurial-scm.org/wiki/ConvertExtension#Converting_from_Mercurial
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.
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.