Using SVN, how do I selectively create a patch file? - windows

I have a codebase with several changes in it that are best split up into several commits.
In git, I would use git add -p to select the changes I wanted from each file and create a commit and pull request based on those.
I'm new to SVN and I'm wondering about the best way to achieve this? It looks like I can do file-level selection, but not changes within those files?
I'm using TortoiseSVN as my local version control tool, but I'm happy to use another tool (has to run on Windows) if there's one that will do what I want.

This is something you won't get from SVN. Separating changes in your working area into multiple commit can only have a file granularity. You can't split changes from the same file into several commits.
So I'd say you should instead give a look at how git-svn works. It allows you to use Git over an SVN repository, with some limitations. You'll use git dcommit to push to the SVN repository for example. You must use a rebasing strategy over merging too. But otherwise, you get colored diffs, stash, rebasing, proper handling of multiple branches, proper formatting of patches by default, etc.
If you already know git, this will give you more, for less annoyance.

It looks like I can do file-level selection, but not changes within those files?
This is easily possible with VisualSVN plug-in for Visual Studio 2017. The feature is called QuickCommit and it helps you partially commit selected changes in a file.
Use the Commit this Block and Commit Selection context menu commands in the Visual Studio editor.
Here is an animated screenshot:

Related

How do i get an automatic merge comment in TFS

In source control systems and tools like tortoises for svn or sourcetree for git, when I am committing a merge, I can usually just left a default comment generated by the tool that is basically a summary of what changes were merged. In visual studio using TFS, there is a comment textbox right above the changes list, but I have to type it all manually. It's not super important but it is a time saver sometimes. Maybe i'm just not looking at the right place.
If you're using TFS with Git, then this becomes less of an issue. When you merge all the individual commits come along for the ride, so it's not necessary to re-describe them in the merge commit.
Try extension Auto Merge
If you need set original comment setup Settings "comment_format" like {{OriginalComment}}
I have used TFS a lot, and unfortunately I don't think that option exists. I usually copy my original checkin text and then paste it if I am doing multiple merges. I realize this is a low tech way to do it and the original comment isn't generated for me. If you want to be able to do this bad enough, you can probably write a Visual Studio plug in that would do it for you, or you could code up just about anything you want to add with the Team Foundation Server SDK.

VisualSVN - disable auto checkout

Recently switched jobs and with it switched source control from TFS to SVN, which is new to me.
In TFS there was an option to disable automatic checkout of files when you started typing in them. It's enabled by default and a lot of users like this behaviour, but I prefer to know for certain what's being changed before committing. A personal thing.
VisualSVN auto-checkouts by default. Is there an similar option to turn it off? I can't seem to find out in the settings.
"Automatic checkout" term in SVN and in TFS worlds has different meanings, as far as I see.
In Subversion, checkout relates to svn checkout operation which gets a working copy from a repository. In TFS it looks like the term somehow relates to automatic locking mechanism.
If you want a file to be locked automatically when you start modifying it in Visual Studio (with VisualSVN extension installed), see the KB article "Lock-Modify-Unlock Model with VisualSVN". I also suggest reading the SVNBook chapter "Locking".
Generally speaking, you can set svn:needs-lock property on files. The property instructs client which files must be locked before editing. After applying svn:need-lock to a file the file gets read-only attribute. Before editing the file must be explicitly locked by the user. After committing the lock is released by default.
Short answer: I don;t think you can do this without becoming very unpopular.
I think you should read up on the SVN redbook's description of how SVN works, especially the versioning models
In your environment, everyone wants to be able to modify any file locally and then send their changes to the server, merging changes with colleague's changes if necessary. This approach works well if 2 people are not changing the same files all the time, which is typical of most dev shops.
The old TFS/VSS model of checkout a file to work on it is pretty obsolete today - the more 'optimistic' approach where you assume you have exclusive access is much more productive. (as usual its easier to ask forgiveness if it goes wrong than ask permission every time)
Your main problem is that you cannot mix these models - if your colleagues are using the merge model, then you have to as well. You cannot lock a file and expect them to still be able to change any file anytime.
Now, there are tricks you can use to prevent yourself from modifying files you never meant to - I'm not sure of VisualSVN but TortoiseSVN (awesome tool) can run client hooks - ie you can write a program to run on every checkout, and that program can be as simple as setting every file's read-only flag. Whether this is god enough for you is another matter.
Personally, I would get used to the idea of change whatever you like whenever. If you accidentally edit a file, you can see the change indicator (AnkhSVN turns the file icon orange for changed files), and its easy to 'svn revert' changes you didn't want to make. Also SVN lets you see diffs really easily, especially on commit - double click the files in the commit dialog. The productivity gains from being able to work without the tools getting in your way (as I found with TFS continually pinging at me as I tried to edit a file) are huge. The SVN tools are really good to let you "ask forgiveness" so you don't need to run in the crappy old TFS way now you've upgraded to something better.
The other advantage is that this applies to files that are not in a Visual Studio project, if you've ever had a project file that was edited outside VS (eg a generated WCF client stub) then you will appreciate how SVN works - never again will you do a full commit and find that TFS has conveniently decided that your changed file wasn't changed and so didn't need to be committed!

Git: don't update certain files on Windows

We work with a git respository that has over 20,000 files.
My group maintains local versions of about 100 or so of configuration and source files from this repository. THe original acts as a sort of base that several groups modify and tweak to their own needs (some core things are not allowed to be changed, but front end and some custom DB stuff are different between groups)
So we want to update to the latest version generally, but not have the git update overwrite the files that we keep local modifications for.
The machines we use are windows based. Currently the repository gets cloned to a windows server that then gets checked out/cloned to the development machines (which are also windows). The developers make changes as necessary and recommit to our local repo. The local repo updates against the master daily. We never commit back to the master.
So we want all the files that haven't been changed by our group to update, but any that have been changed (ever) won't get updated.
Is there a way to allow this to happen automatically, so the windows server just automatically updates daily, ignoring those files we keep modifications for. And if we want to add a new file to this "don't update" list its just a right-click (or even a flat file list away). I looked at git-ignore but it seems to be for committing, not for updating.
Even better would be a way to automatically download the vanilla files but have them renamed automatically. For example settings.conf is a file we want to keep changes on generally, but if they modify the way entries in that file are handled or add extra options it would be nice it it downloaded it as settings.conf.vanilla or something so we just run a diff on .vanilla files against ours and see what we want to keep. Though this feature is not absolutely necessary and seems unlikely.
If this cannot be accomplished on a windows machine (the software for windows doesn't support such features), please list some Linux options as well if available. We do have an option to use a Linux server for hosting the local git repo if needed.
Thanks.
It sounds like you're working with a third party code base that's under active development and you have your own customisations which you need to apply.
I think the answer you're looking for is rebase. You shouldn't need to write any external logic to achieve this, except for a job which regularly pulls in the third party changes and rebases your modifications on top of them.
This should also be more correct than simply ignoring the files you've modified, as you won't then accidentally ignore changes that the third party has made to those files (you may sometimes get a conflict, which could be frustrating, but better than silently missing an important change).
Assuming that your local repo is indeed simply a fork, maintain your changes on your own branch, and every time you update the remote repository, simply rebase your local branch on top of those changes:
git pull origin master
git checkout custom_branch
git rebase master
Edit
After you've done this, you'll end up with all the changes you made on your custom_branch sitting on top of master. You can then continue to make your customisations on your own branch, and development of the third party code can continue independently.
The next time you want to pull in the extra changes, you'll repeat the process:
Make sure you're on the master branch before pulling in changes to the third party code:
git checkout master
Pull in the changes:
git pull origin master
Change to your customised branch:
git checkout custom_branch
Move your changes on top of the third party changes:
git rebase master
This will then put all your own changes on top of master again. master itself won't be changed.
Remember that the structure of your repo just comes from a whole set of "hashes" which form a tree. Your branches are just like "post it" notes which are attached to a particular hash, and can be moved to another hash as your branch grows.
The rebase is like chopping off a branch and re-attaching it somewhere else. In this case, you're saying something like "chop off our changes and re-attach them on top of the main trunk".
If you can install a visual tool like GitX, it will really help to see how the branch tags move around when you rebase. The command line is ideal for working with but I find something like GitX is invaluable for getting a handle on the structure of your repo.

Looking to Incorporate Version Control after the fact

I'm doing a single developer Visual Studio solution and reached a point where I'd like to incorporate Versioning Control. Several posts address this issue, but one problem I'm facing is a large merge. I have a production copy of the solution and a beta copy. They are NOT dramatically different, but they will require a number of interactions I suspect. I'm using TortoiseSVN and have imported the production version.
Yes, I know I should have used Version Control from the start, but that is hind sight. Would it be best practice to simply use the beta as a reference and work the interations from scratch. Or should I branch off and import the beta separately, then attempt to merge the change. Or is there another alternative I'm missing.
Thanks,
dgp
well, I have experienced SVN in the past ... and I must say, it's lovely cause it's really easy to understand the concept, but it's awful terrible when things pass from the plain commit.
I'm currently using GIT (to host small code on GitHub) and Mercurial (Hg) (I use Kiln in the company - was recommended by myself so they can start using - and in BitBucket for personal use)
I have used SVN for more than a hole year and every time I need something from "the past" or to merge something, it was a nightmare, but the server/client concept was really a break deal and extremely easy to get it... but I found my self, over and over to do merging by hand :(
When GIT started to be hot, I was afraid to move as, dang! SVN was a pain, why should be different in a DVCS?
This videos rocked my world, [ part 1 part 2 ], only then I understood DVCS vs VCS and it was with this that I moved COMPLETELY to DVCS and never go back... proudly!
For your problem, I would install git (or hg), and then create a repository on the folder you have your current source with:
git init will tell your folder, "Hey, I'm a GIT Repo"
git add . let's add all files and folders to be tracked by git
git commit -m "initial commit" let's save all the hard work :)
So, now you have a tracked code, you can simple create a branch and overwrite all your files. YES, worry not, you don't need to have copies of your code in a folder called branch ;) no more copies! all is in the GIT database
then, after creating the branch, changed the files, added all files to be tracked on that branch and committed, safely do a merge :)
ohh, and you don't need a server connection to do all this, all you need is a computer with GIT installed... no more connection dependencies! DVCS is cool or what?! :D

Disabling automatic checkout in AnkhSVN

I'm using Visual Studio 2k8 with AnkhSVN.
When I start to modify file, it's automatically checkouted. How can I disable it? I don't want to accidentally modify my files.
Your files will not be modified in your Subversion repository until you check them back in. And even when they are checked back in, you can still roll them back to any previous point.
So, no need to worry about doing something accidentally...that's the whole point of version control!
What you call "check-out" just means the file has been marked as modified locally on your machine (without the SVN server knowing anything about it). This is different than say, ClearCase, where the file is actually checked out on the server. So as Michael suggests, you don't really have to worry about it, you can always revert it locally. And if you just use Undo in VisualStudio, the file will again be marked as not modified.
What some of the other answers have hinted at: You don't "checkout" files with SVN. It sounds like you're coming from a ClearCase/SourceSafe mentality. SVN works on a different versioning model. When you "checkout" a working copy, you're pulling down the latest version of the files from the repository. You are free to modify any of them. Once you are done with your edits, you push, "commit" them back to the server.
I could ramble on and on, but instead of botching it, I'll just point you to the de-facto-standard SVN Manual - here's the first chapter which explains the versioning model that SVN uses.
Open the AnkhSVN Conviguration dialog (Tools->AnkhSVN->Configuration…) and set DisableSolutionReload to True.
There is also an option to do the opposite—to prevent it from automatically adding new files to SVN—that you can disable (setting AutoAddNewFiles to False).

Resources