In the repository, there is a directory named like "hand-0.0.1.1" and there is a source file named like "hand_soldier.erl".
I want to ignore hand-0.0.1.1 directory and keep "hand_soldier.erl".
In the sourcetree's repository ignore file, I have tried to write:
hand\-*
and
hand-*
but both not work.
You need add just hand- in ignore file.
For me it works good:
hg init
touch hand_soldier.erl
mkdir hand-0.1
touch hand-0.1/file.txt
echo 'hand-' > .hgignore
hg status
? .hgignore
? hand_soldier.erl
Related
I have a pretty large folder (with many sub folders) on a mercurial repository. I was a bit too fast with my first commit so I added a lot of files that i now realize shouldn't be on version control. I've updated my .hgignore file accordingly but all the old files are still version controlled. Is there a command that I can write in the root directory that forgets all files that are in a folder of a specific name. These folder names exist in a lot of places and i want them all forgotten with one command since it would take a long time to go through them all manually and forget the folders/files
I guess it would maybe look something like this:
hg ignore ../folderName/
Yes... use a pattern to match them like
hg forget FOLDERNAME**
hg commit -m "Forget FOLDERNAME"
hg help forget
hg forget [OPTION]... FILE...
(...)
options ([+] can be repeated):
-I --include PATTERN [+] include names matching the given patterns
or use a one-line script:
for i in $(hg ma | grep FOLDERNAME); do hg forget $i; done
You can read hg help filesets and use one of it's samples
Forget files that are in .hgignore but are already tracked:
hg forget "set:hgignore() and not ignored()"
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
i am using Mercurial for version controlling. I am trying to ignore zip files in the repository, my hgignore file is in the root directory of project
i got the codes below from http://www.selenic.com/mercurial/hg.1.html#patterns.
syntax: glob
**.zip
syntax: regexp
re:.*\.zip$
But these doesnt work for me.
i also tried
hg addremove
and
hg forget -I '*'
but it didnt help. Can you tell me how can properly ignore zip files from the repository?
Thanks for help.
EDIT
My problem was the zip files were already added to repository. I first forgot them and committed. Now it ignores
Simply writing *.zip inside .hgignore will do this. The patterns inside .hgignore are not rooted, so *.zip would match a zip archive no matter where it appears.
I have been thinking that it sure would be nice to have a command like "hg ignore" that would automatically add all untracked files to the .hgignore file.
Manually editing the .hgignore file is powerful, but when I am frequently creating new repositories it would be nice to be able to add only the files I want and then do an hg ignore to automatically have Mercurial ignore any others.
Does anyone know of any extensions that do this?
Try this once you've added all the files you need:
hg stat --unknown --no-status >> .hgignore
You can create a command to automatically generate your .hgignore using an alias. On a Unix-like system, add the following lines to your .hg/hgrc (or one of Mercurial's other configuration files):
[alias]
ignore = !echo 'syntax: glob' >> $(hg root)/.hgignore && \
$HG status --unknown --no-status >> $(hg root)/.hgignore
This will give you a hg ignore command that will populate the .hgignore file with all currently unknown files, thus turning them into ignored.
On Windows, the syntax for the alias is:
[alias]
ignore = !echo syntax: glob > .hgignore && "%HG%" status --unknown --no-status -X .hgignore >> .hgignore
On Windows, you must run it in the root directory of the repository, otherwise the .hgignore file will be created in the current directory, which is probably not what you want.
The ! syntax in aliases is new in Mercurial 1.7. In earlier versions you can add
[alias]
ignore = status --unknown --no-status
and then redirect the output of this command to the .hgignore file yourself:
hg ignore >> .hgignore
You will then also need to take care of adding a syntax: glob line, if necessary (the default syntax is regular expressions).
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.