Home >Common Problem >How to use svn
Usage scenario:
If a certain part of your project (here refers to the mobile client project) The version (for example, version 1.0) has been developed, tested and has been launched online. Next, new requirements are received. The development of new requirements requires modifying the code in multiple files. When the requirements have been developed for a period of time, a sudden request is received. According to feedback from users or testers, there is a major bug in the project that needs to be fixed urgently, and it is required to go online immediately after the bug is fixed. How should the bug be fixed at this time? Is the repair based on the new needs that have been developed? The answer is no, and the reason is: If the bugs are fixed on the basis of new requirements that have been developed, then the new requirements have not been developed yet, let alone tested. How can it be put online immediately (or as quickly as possible)? ! Thirdly, what should I do if the development of new features and the code for bug fixing involve conflicts with the same piece of code. Obviously, bug fixing cannot be performed based on the currently developed code. The perfect solution is to perform bug fix in the version that was completed at that time. The benefits of this are:
1: After the bug is fixed It can be launched immediately, and the launch time will not be delayed because the new requirements have not been completed or tested.
2: Bug fixes are fixed in the version that was originally launched, and the risk of causing new bugs is small. If it is in the new Fix bugs based on requirements, then new features may bring new bugs
Related recommendations: "SVN Video Tutorial"
SVN warehouse directory structure Repository:
(1) trunk
(2) tags
(3) branches
trunk (trunk|main line) branches (branch) tags (mark)
truck (trunk|main line|main branch): It is used for main direction development. The development of new functions should be placed in the main line as a module. After development is completed, if modifications are needed, use branch.
branch (branch): Branch development and mainline development can be carried out at the same time, that is, parallel development. Branches are usually used to fix bugs.
tag (tag): used for tags An available version can be marked as a version that has been released online or as a version under testing. It is usually read-only.
SVN specific operation steps: (TortoiseSVN version: 1.8.8)
1: Create a warehouse
1. Create Directory structure D:\TortoiseSVN\Repository\Repo-iOS
2. Right-click on the directory structure
---> TortoiseSVN
---> Create repository here
---> Create folder structure (Create file structure) ---> Start Repobrowser (Start repository browsing) --- > Ok
#2: Upload the project to SVN
FAQ"
3: Check Out 1. Create it anywhere on the computer A directory where the project code is stored, for example: D:\TortoiseSVN\Repository\Source2. Check out the code to this location Four: Development Cycle 1. Develop in the directory D:\TortoiseSVN\Repository\Source\trunk\MyAppProject. Note that it is on the trunk main line. Because the project has just been established, this is developing new functions. , so it needs to be developed on the main line- (void) viewDidLoad { [super viewDidLoad]; // ----------------------------------------- int y = 0; int result = 10 / y; NSLog(@"iOS APP 第一阶段开发完成了! 结果是:%ld", result); // End }
3. Create a new directory: 1.0 in the D:\TortoiseSVN\Repository\Source\tags directory, submit the directory to SVN, and then right-click the directory D:\TortoiseSVN\Repository\Source\trunk\MyAppProject ---> TortoiseSVN---->Branch/tag... -----> To Path :/tags/1.0/MyAppProject and select Head revision in repository ---> OkSource/ There is no content in the tags/1.0 directory. You need to update the directory for an update operation. After the update, you will see a complete project source code saved in this directory (the source code in this directory can be regarded as a copy of version 1.0 in the trunk directory). Check viewDidLoad and trunk/MyAppProject in /tags/1.0/HomeViewController. The viewDidLoad code in /HomeViewController is exactly the same.
4. Develop new requirements for the next stage, under development
5. Users or Testers report that the application has a major bug, which needs to be fixed immediately and put online as soon as possible. At this time, the programmer needs to create a branch for MyAppProject under tags/1.0.
The operation process is as follows: Select Source/ tags/1.0/MyAppProject Right-click TortoiseSVN---->Branch/tag... -----> To Path:/branches/MyAppProject ---> Ok
Look at D at this time: There is still no content in the \TortoiseSVN\Repository\Source\branches directory, and it needs to be updated. After the update, it is found that a complete project code also appears in the directory
(this code can be regarded as tags/1.0/ A copy of MyAppProject). Note that branching and tagging are done using the Branch/tag... menu. The difference is that the directory of To Path is different. For an illustration, see the diagram of branching. However, the value of to path is different. At this time, branches The viewDidLoad code in /MyAppProject/HomeViewController is exactly the same as the viewDidLoad code in tags/1.0/MyAppProject/HomeViewController.
6. Switch the workspace, use the Xcode|Eclipse integrated tool to open the project under /branches/MyAppProject, and then debug and fix the bug on this basis. Note that the project must be opened in the branch
7. After the bug is fixed, submit the modified file first and go online with the client App. After the online is completed, tag branches/MyAppProject/ to the 1.0.1 directory (tags/1.0.1) (The operation steps are the same as step 3). After the tag operation is completed, you can see that tags/1.0.1/HomeViewController.viewDidLoad and branches/MyAppProject/HomeViewController.viewDidLoad are completely consistent. It is convenient to add a new tag to branches/MyAppProject. Next time, we will fix the bug again on this basis. So far, the bug fix has been completed; the code after fixing the bug is as follows:
[objc] view plain copy
View the code piece on CODE Derived to my code piece
- (void) viewDidLoad { [super viewDidLoad]; // ----------------------------------------- int y = 10; int result = 10 / y; NSLog(@"iOS APP 第一阶段开发完成了! 结果是:%ld", result); // End NSLog(@"1.0 版本闪退bug 已修复, 程序出现除0异常"); }
8. Next, merge branch and trunk. The steps are as follows:
Right-click branches/MyAppProject ------>TortoiseSVN
----> Merge...
---> Merge a range of revisions
----> Next ---> URL to merge from : file:///D:/TortoiseSVN/Repository/Repo-iOS/trunk/MyAppProject
----> Next
- ---> Merge
- (void) viewDidLoad { [super viewDidLoad]; // ----------------------------------------- int y = <strong>10</strong>; // <strong>可以看到branches分支中的代码已经合并到主线上了</strong> int result = 10 / y; NSLog(@"iOS APP 第一阶段开发完成了! 结果是:%ld", result); // End NSLog(@"<strong>1.0 版本闪退bug 已修复, 程序出现除0异常</strong>"); NSLog(@"其他同事在主线trunk中进行新需求开发..."); NSLog(@"其他同事在主线trunk中进行新需求开发..."); }10. At this point, the merge is completely completed. If you don’t want the source code in the branches directory, you can delete it. Then the programmer who modified the bug needs to switch the workspace to the main line and use Xcode to reopen trunk/ The MyAppProject project continues to develop new features that have not yet been completed. The SVN directory is as follows:
##Instructions:
1. Branch development and trunk development are two completely independent processes, and both can be developed at the same time
2. Since branch and trunk development are in parallel, they can submit files modified by the current project as many times as they like
The above is the detailed content of How to use svn. For more information, please follow other related articles on the PHP Chinese website!