Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion: prevent local modifications to one file from being committed?

Tags:

svn

I have a Subversion working copy where I made some local modifications to one file. The modifications are only relevant to me, I do not want to commit them. (The version in the repository contains some default values which are suitable for the other users, just not for me, which is why I want to override them locally.)

Note that although I do not want to commit my changes, I do want to receive any updates made in the repository when I do svn update. Also, it is only in my working copy that I do not want to commit the changes to that file, the other users should not be affected. So svn:ignore or commit hooks do not fit my purpose.

Currently, I simply do:

svn commit file1 file2... 

where I specify explicitly the files that have changes excluding the particular file that I do not want to commit.

However, while I'm working, I have the habit of simply writing:

svn commit -m "Log of what I just did" 

and I fear that I will inadvertently commit the "forbidden" file by using the above command at a moment when I'm not attentive.

In short, what I'm looking for is simply a way of "marking" a file in a working copy which prevents Subversion from committing the changes in that file (it doesn't have to be automatic exclusion, even if I just get an error when I try to commit all files, it is fine). Sort of like marking files in a "conflict" state...

Does such a thing exist?

Update: akent, thanks for pointing out this very similar question.

like image 206
Bruno De Fraine Avatar asked May 14 '09 12:05

Bruno De Fraine


People also ask

How stop a commit in SVN?

To undo a specific revision you can use the following command: $ svn merge -c -r3745 . In case you have other edited files in working directory, you can commit only the relevant files. Please note that undoing actually will mean you create a new revision with the negatives changes of last commit.

How do I commit local changes in SVN?

Select any file and/or folders you want to commit, then TortoiseSVN → Commit.... The commit dialog will show you every changed file, including added, deleted and unversioned files. If you don't want a changed file to be committed, just uncheck that file.

What are .SVN files?

SVN stands for Subversion. So, SVN and Subversion are the same. SVN is used to manage and track changes to code and assets across projects.


1 Answers

There have been a few answers that can work:

  1. Create a pre-commit hook script that reject the commit when a specific property is being added. You can then add this property to files in the working copy to prevent commits.
  2. TortoiseSVN will exclude files in the special changelist "ignore-on-commit". However, this is not honored by the SVN command-line client.

CoverosGene suggested that the default commands such as svn commit operate on a default changelist, such that you can exclude a file if you assign it to another changelist, but I can't find any reference of that in the documentation, and in my testing this does not work.

Since there is no good solution for the SVN command-line client, I've opened an enhancement request here. The request suggests that the command-line client could also honor the "ignore-on-commit" changelist.

Update: This is now issue 2858 and there is a feature outline to handle it with an svn:hold property.

like image 93
Bruno De Fraine Avatar answered Oct 08 '22 18:10

Bruno De Fraine