IT_Programming/Dev Tools

[Android Studio] Using SVN in Android Studio

JJun ™ 2015. 4. 5. 02:07



 출처: http://www.cs.dartmouth.edu/~campbell/cs65/svn/androidstudio.html



For each submission, you should create an folder for it. 
At the end of the term, your SVN repo should similar to

Lab1_submission
Lab2_submission
Lab3_submission
Lab4_submission
Lab5_submission
Lab6_submission
CodeItOne
CodeItTwo
CodeItThree
...

Make sure you submit the project source but not the zip file, and remove these following files in your project source before your final submission of each project. You will learn how to delete files in theDelete files section.

.gradle
build
local.properties
.idea/workspace.xml
.idea/libraries

The following instructions are using Myruns lab1 as an example.



Create a new project

If you create a new project that is not in your SVN repo, you need to import the project first
(select "VCS" => "Import into version control" => "Import into subversion"):


Add your repo address to it, for example, for the lab1 submission, the repo should be “https://svn.cs.dartmouth.edu/classes/cs65-W15/Your_Name/Lab1_submission/”(You don’t have to create the Lab1_submission on svn in advance, it will create it for you if it doesn’t exist).




Then choose your project folder, and click “import”.




Type your commit message, and click “OK”.




You may need to enter your SVN credentials.


About login credentials:

Your login names are the "full" dnd names, as reported on the web site http://dndlookup.dartmouth.edu with the capitalization shown there, and please use your DND passwords (which you use for Dartmouth Banner).

After that, you can open your web browser and go to the address https://svn.cs.dartmouth.edu/classes/cs65-W15/Your_Name/Lab1_submission, you can see the project is successfully uploaded.






Checkout your project

Before you start working on your project, you need to checkout your project from SVN repo.

First you need to enable version control integration
("VCS" => "Enable Version Control Integration")




choose subversion as the version control system and click “OK”




Then you would be able to see more selections under “VCS”




To checkout a project, choose “VCS" => "Checkout from Version Control => "subversion”




Choose your SVN repo of your project and click “Checkout”.
It will get the contents from your SVN repo and update them to your local project.




Choose your project location as destination directory




Select the first one as the destination then click “OK”.




It may pop up a dialog showing “Subversion Working Copy Format”, you can choose the highest version and click “OK”.




Then click “Yes” to reopen the project






Working your project

After you checkout the project from SVN, you can start writing your new codes in your
project. 
If you create a new file, Android studio will ask you to add file to subversion. 

Click “OK”.




Once you finish your coding, choose “VCS" => "Commit changes” to apply your changes to SVN repo.




You can find the files you updated will be displayed in the dialog. (Green color means new file, and blue color means modified file). Then click “Commit”.



It may pop up a dialog for code analysis. 

You can review your code first and then click “commit”.




Check code changes in Android Studio

One of the great benefits from version control system is that you can view your changes in the code and revert it if necessary. (You will notice that the file is in blue color if you did update on it). Choose "VCS" => "Show Changes View"




Some config/environment files are changed by Android Studio, you don’t need to worry about them. Right click on the file, and choose “Show diff”.




You can see the changes you made.





Delete files

We recognize that some of you may forget to delete config files before your submission.
Choose "Project" at the upper-left corner of the figure below, then you can delete above files accordingly. (No worry for the deletion because they can be re-generated when you run you code.)




Choose “Yes” if it pops up the following dialog




Then it will be deleted on your SVN repo after you commit the changes.