How to checkout a specific file in repository using sharpsvn API? - sharpsvn

How to checkout a specific or a single file in repository using SharpSvn API????

Subversion doesn't allow checking out files by itself as the smallest working copy consists of a directory.
What you could do is the equivalent of
svn co http://my.example/repository/subdir --depth empty F:\scratch-dir
svn up F:\scratch-dir\file</code></pre>
This will give you a checkout of http://my.example/repository/subdir as F:\scratch-dir\file. This allows changing the file and committing changes to it.
(This can be accomplished in SharpSvn by SvnClient.CheckOut() followed by SvnClient.Update() with the right arguments)
Another option is
svn cat http://my.example/repository/subdir/file > temp-file
Which will give you a read only copy of the file.
(The SharpSvn equivalent of this is SvnClient.Write().)

Related

What is GIT Staging and Difference between Add To Index and Add To GIT Index?

I am using GibHub private repository. I don't have enough knowledge about it.
What is Git Staging ? what is the purpose of Git Staging ?
When to use Git Staging ?
I found two different options to add file in Git Staging.
Project Explorer --> Team --> Add to index
Team Synchronize --> Add to Git Index
Both of them send files to Git Staging. Then What is the difference between these two ?
Which is better to user ? Both of them send files to Git Staging.
Thanks.
They do the same thing. It's just an inconsistency in the labeling.
I pushed a change for EGit to make this consistent, it will be in the next release (3.5).
"Staging" is the process that one performs when selecting which modified files (or portion of files) will be part of the next commit.
The "Index" is the file into which Git stores the files that have been staged. It's also called the "Staging area".
Adding a file to the index is merely saying "Git, this version of this file in my working directory should be part of the next commit I'm about to create".
References:
Egit - User guide
ProGit - Recording changes to the repository

Perforce - create patch file of differences against have revision

In Perforce, how can I create a patch file which has the changes that are in the file as currently saved, compared to the have revision? Instructions for either the GUI client or the CLI client would be great.
I can see how to get the diffs between two changelists, but not how to just get the difference between the last changelist and the current state of the files. Additionally, I can see that in the GUI client, I can right-click on a file and select "Diff Against Have Revision" from the contextual menu, which shows me what I'm looking for, but I can't figure out how to get that into a file.
I'm basically looking for the equivalent of what git diff <file> > patch.diff does in Git-land.
I think that p4 diff -du FILE > patch.diff should do what you want.
Single file
p4 diff -du file > file.patch.diff
Every file
p4 diff -du > patch.diff
The problem with p4 diff is that it doesn't take into account of new files. Also you can't get files that are only in a certain pending change list.
If there is a pending changelist, you can actually use an open source perforce patcher tool, which I have created for my project needs. You can directly download from this link of github.
In case you want to checkout the source, go to the github repo.
Documentation for the tool can be found here.

Creating a new repo from a directory of old repo

I am very new to bazaar and I am exploring the features of it (and of version control system)
I have a bazaar repo, lets call it 'foo'. Under foo repo I have a directory, lets call it 'projects'.
so, I want to create a separate bazaar repo with only projects directory & I want to retain the log too. I mean to say, everything that is related to project folder present in log file, should be available with this new repo.
I tried export command, but I just got the directory without any log.
Any pointers where I should look ?
You can do this using the fastimport plugin:
bzr fast-export /path/to/orig/project | \
bzr fast-import-filter -i project1/ | \
bzr fast-import - /path/to/new/project1
(I broke the line for readability)
The first command dumps the revisions of the branch at the specified path to standard output
The second command filters the revisions, selecting only the ones that affect the project1/ directory. The trailing / is important.
The third command imports the revisions from the standard input to the specified branch. If the branch does not exist, bzr will create a shared repository with a branch named trunk in it.
For more details, see the help pages:
bzr help fast-export
bzr help fast-import-filter
bzr help fast-import
The fastimport plugin is included in the default installation on Windows and Mac OS X. If you have a more exotic setup, I recommend installing it with pip. I don't remember 100% the package name, maybe bzr-fastimport. You will also need the fastimport python library.

Subclipse SVN first commit ignore certain directories

Decided to take the jump from CVS to SVN.
I setup a new repository in subclipse for my project. When I go to 'Finish' the setup it wants to do an initial commit and presents me with a flat list of files to select the files for version controlling.
The problem is I have thousands of generated binary files I dont want to commit.
So I click on cancel because it would take me all day to go through and unselect all the unwanted files. Annoyingly when I click on a parent category for the files I want to ignore it is not recursive!
So I click cancel then go to the eclipse directory structure for the project and manually set svn:ignore on all directories I want to ignore. Then I try and do a commit again and all the files are once again presented - ignore seems to have done nothing.
Can anybody point out what I might be doing wrong?
For the first commit, I recommend writing a small script to delete (of course you'll have a backup) all the files that are not meant to be committed.
Afterwards, if you find you accidentally committed a file, you can
svn delete file
Upon the first checkout, copy back (or better yet, regenerate) all the binary files. This will trigger svn to notice that your local repository is out-of-sync with the remote repository.
cd <Root of local repository>
svn status
You will see lots of "to be added" items. Go to the parent directory and add in svn:ignore properties for each of the generated items.
cd build
svn propedit svn:ignore .
which will open an editor (if it doesn't, you need to set the environmental variable SVN_EDITOR to a suitable editor). Then you can add in entries that svn will know are not tracked.
(in the ignore property editor)
target
build
image*
*.o
(and so on)
Save the file, and it will be staged for the next commit. Subsequent runs of svn status will no longer show these files as "needing to be added", but they will show the directory as "needing to be committed (it's a revision on the directory)"
Quick Aside
So I'm not entirely certain exactly which functionality of Subclipse you were using in order to create a repo and share a project to it, I'm assuming you created like a file based repo through the eclipse SVN repo view and tried to share and then commit to it. It looks like your problem got solved but I did want to add an answer on here because I ran across this post looking for the answer to this same problem of handling initial commits even just in general with SVN and wanted to offer help to anyone else looking for the help.
Intro
To start off I would recommend not working through an IDE extension like this just for the initial commit as they can miss a lot of the options for handling opening a repo in SVN. I personally really like the command line form of SVN to work with but TortoiseSVN is a good option for a GUI.
Whether you create a local file-based repo or are connecting to an SVN server and you want better control over your first commit in an previously unversioned project here is what I've found as the best general workflow for doing so.
Create the remote folder to save to.
On command line this will be:
$> svn mkdir your-url-scheme://your-site-address.domain/path/to/repo/example-directory
Or on TortoiseSVN open your repo for browsing, right click, and select "create new folder"
This will give you a location in the SVN repo to checkout from for our next step.
Checkout in to the already started project
Make sure to use the empty, newly created folder in your repo to checkout with. SVN does not actually require a folder being checked out to to be empty, which is an important part of what makes it actually very flexible and able to subsume parts of your directory into it fairly easily if used correctly.
Now you will checkout this empty folder into the root folder of your already started project. This will add your project to the working copy of this folder without any commit being made yet. The command is:
$> svn co your-url-scheme://your-site-address.domain/path/to/repo/example-directory /your/projects/root/
"co" standing for checkout. In Tortoise svn you can right click on or in the empty repo folder and select "checkout..." and then select the project root.
Set ignores and commit
Finally, you can easily set your ignores on certain files before adding any other files to the tree using the command:
$> svn propset svn:ignore file-or-directory-to-ignore
And to add all non-ignored directories and files:
$> svn add * --force
The force is technically unnecessary in this case but ensures full recursion. You can also now do all of this in your file explorer if using TortoiseSVN or you can even use your IDE extensions to do this at this point(make sure to ignore all files you need to before mass-adding files for commit), all that's left is to make sure to commit the newly added files to the repo and you're up and running with source control :)
Added this method here simply because this method allows you to avoid any unnecessary copying of those stinky binaries that no one wants to lug around with them.

How to pull changes for multiple projects at once

I'm using Eclipse with the MercurialEclipse extension to use the Mercurial SCM.
I have lots of projects and every morning I want to pull all latest changes before starting to work. With SVN or CVS I could simply select all projects and click Team/Update. But the Team/Pull command of MercurialEclipse is disabled when multiple projects are selected.
So currently I have to call Team/Pull on each project separately. That's really annoying. How can I pull changes for multiple projects in one go?
I would rather use an external script than trying to do it directly from Eclipse.
See for instance:
Mercurial Repository Nightly Pull from a subdirectory on a server (for the idea)
Updated Mercurial Batch Pull/Update Python Script (for an actual complete script)
Then a simple refresh in your Eclipse environment would be enough.
You could highlight them all, right click, and choose synchronize. You could then pull from this view if desired (plus it will show you changes).
One not-quite-what-was-intended solution would be to make each a subrepo of of parent repository. Something with a .hgsub file of:
project1 = project1
project2 = project2
...
would be enough for 'hg pull' in the top level to do a pull in all of them.
You're probably better off just scripting it though. I don't know what eclipse offers for scripting but from the unix command line that would be:
for therepo in $(find /my/project/root -type -d -name .hg) ; do
hg --repository ${therepo%.hg} pull
done