Ignore changes to files that are already in repository - version-control

Adding files to .hgignore will prevent them from being tracked. But we have some files that we want to be in the repository - we just don't want users to ever commit changes. Is there a way to ignore changes to these files, so they won't get committed in an hg commit.

That cannot be done in Mercurial — a file is either tracked or untracked (and then optionally ignored). You should instead version a template file and then ignore the real file.
So add config.template to version control and add config to .hgignore. Ask your developers to copy the template to the real name and customize it as needed.

Related

Replace local file by remote file

How do I replace a local file by its latest version in the repository?
Is there also a way of replacing all local files which are conflicting with the corresponding files from the repository?
Both hg update -C and hg revert will do what you are looking for - replace a locally modified file with the clean version in the repository. Personally I prefer hg revert but hg up -C will also do the job
hg revert
Some further details from the help for hg revert
With no revision specified, revert the specified files or directories to
the contents they had in the parent of the working directory. This
restores the contents of files to an unmodified state and unschedules
adds, removes, copies, and renames. If the working directory has two
parents, you must explicitly specify a revision.
Using the -r/--rev or -d/--date options, revert the given files or
directories to their states as of a specific revision. Because revert does
not change the working directory parents, this will cause these files to
appear modified. This can be helpful to "back out" some or all of an
earlier change. See "hg backout" for a related method.
Modified files are saved with a .orig suffix before reverting. To disable
these backups, use --no-backup.
Hope that helps
Chris
svn update ?
Or delete your folder, and svn checkout...
Or try the option --force.

VCS: push only source code directory

I work on Java project. How I can push only source directory without temporary files, build files and project files? I use Mercurial.
Mercurial will only push history, which means that it is only things that you have asked it to track (with hg add) and later committed (with hg commit) that will be pushed.
So like Jim says, you should setup .hgignore file. Do this before adding files to your project and double-check that hg status only lists files you want to add. Then run hg add to add them all.
If you've already put the temporary files and build artifacts under version control, then you can either use hg forget to stop tracking them. You'll still carry them around in the history, so if we've talking about tens of megabytes, then you probably want to re-create the repository.
Create an .hgignore file.

Subclipse wants to commit an folder conaining an svn:ignore file

I have a project with a subfolder Resources. In this folder there is a file I added to SVN:ignore.
Now there aren't any other changes compared with the latest respository revision. But in eclipse's synchronzite view, this folder is still beeing displayed. No other files are displayed under it, because nothing changed.
Why is this folder beeing displayed in the synchronize view?
Is it because SVN metadata changed?
Do I have to commit the metadata into the repository?
Is there a way, to get this folder out of the synchronize view, without commiting metadata?
I don't want to commit those SVN:ignore metadata, because its user specific. I don't want to ignore the folder's contents, because there are regular files which has to be version controlled.
Thanks in advance.
Is it because SVN metadata changed?
Yes, you modified the svn:ignore property of the Resources folder.
Do I have to commit the metadata into the repository?
Yes, svn:ignore properties are stored in the repository. They are shared between all SVN users.
Is there a way, to get this folder out of the synchronize view, without commiting metadata? I don't want to commit those SVN:ignore metadata, because its user specific.
Yes. You can use global-ignores in your SVN configuration file, instead of the svn:ignore property. From the section Runtime Configuration Area in the SVN book:
global-ignores
When running the svn status command, Subversion lists unversioned files and directories along with the versioned ones, annotating them with a ? character (see the section called “See an overview of your changes”). Sometimes it can be annoying to see uninteresting, unversioned items—for example, object files that result from a program's compilation—in this display. The global-ignores option is a list of whitespace-delimited globs that describe the names of files and directories that Subversion should not display unless they are versioned. The default value is *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store.
You must commit svn:ignore when it should be work. There is no other way I think. Because all project metadata are under version control!
maybe it is trying to add the .ignore file itself? (It might have created that file to list ignored files.) Check for any other hidden files too.
if you want, you can add the whole folder to the ignore list
EDIT
Svn does not create a ignore file list, but maybe it is committing the parent folder or there is some hidden file inside that folder

What is the difference between hg forget and hg remove?

I want mercurial to remove several files from the current state of the repository. However, I want the files to exist in prior history.
How do forget and remove differ, and can they do what I want?
'hg forget' is just shorthand for 'hg remove -Af'. From the 'hg remove' help:
...and -Af can be used to remove files
from the next revision without
deleting them from the working
directory.
Bottom line: 'remove' deletes the file from your working copy on disk (unless you uses -Af) and 'forget' doesn't.
The best way to put is that hg forget is identical to hg remove except that it leaves the files behind in your working copy. The files are left behind as untracked files and can now optionally be ignored with a pattern in .hgignore.
In other words, I cannot tell if you used hg forget or hg remove when I pull from you. A file that you ran hg forget on will be deleted when I update to that changeset — just as if you had used hg remove instead.
From the documentation, you can apparently use either command to keep the file in the project history. Looks like you want remove, since it also deletes the file from the working directory.
From the Mercurial book at http://hgbook.red-bean.com/read/:
Removing a file does not affect its
history. It is important to
understand that removing a file has
only two effects. It removes the
current version of the file from the
working directory. It stops Mercurial
from tracking changes to the file,
from the time of the next commit.
Removing a file does not in any way
alter the history of the file.
The man page hg(1) says this about forget:
Mark the specified files so they will
no longer be tracked after the next
commit. This only removes files from
the current branch, not from the
entire project history, and it does
not delete them from the working
directory.
And this about remove:
Schedule the indicated files for
removal from the repository. This
only removes files from the current
branch, not from the entire project
history.
If you use "hg remove b" against a file with "A" status, which means it has been added but not commited, Mercurial will respond:
not removing b: file has been marked for add (use forget to undo)
This response is a very clear explication of the difference between remove and forget.
My understanding is that "hg forget" is for undoing an added but not committed file so that it is not tracked by version control; while "hg remove" is for taking out a committed file from version control.
This thread has a example for using hg remove against files of 7 different types of status.
A file can be tracked or not, you use hg add to track a file and
hg remove or hg forget to un-track it. Using hg remove without
flags will both delete the file and un-track it, hg forget will
simply un-track it without deleting it.

hg local ignore

I could have sworn there was a way to keep a local ignore file in an hg repo, i.e. a file similar in function to .hgignore, but not checked into the repo. This could be used to ignore changes to an IDE project file if different IDEs are being used, for example. I'm having trouble finding how it's done. Does anyone recall the details?
This is what I was looking for.
Add the following to the repo's .hg/hgrc:
[ui]
ignore = /path/to/repo/.hg/hgignore
and create a new file .hg/hgignore beside it. This new file will be
untracked, but work the same as the versioned .hgignore file for this
specific working copy. (The /path/to/repo bit is unfortunate but
necessary to make it work when invoking 'hg' from within a subdir of
the repo.)
In version 3.5, setting the ignore property under the ui section changes the global ignore file. To add additional files to be ignored, follow the advice of Jeroen Dierckx and set the ignore.local property to get the same effect as adding to .git/info/exclude in a git repository.
[ui]
ignore = .hgignore
ignore.local = .hg/hgignore
Just make an .hgignore file and add .hgignore to the .hgignore file itself.