790 likes | 939 Views
Revision Control with TortoiseHg. Team usage. (Team use). CS2103 – Software Engineering. Prepared by: Steve Teo Contributors: Tong Huu Khiem. Sections . Setting up the remote repo on Google Code Cloning the remote repo Syncing the local repository with the remote repo
E N D
Revision Control with TortoiseHg Team usage (Team use) CS2103 – Software Engineering Prepared by: Steve Teo Contributors: Tong HuuKhiem
Sections • Setting up the remote repo on Google Code • Cloning the remote repo • Syncing the local repository with the remote repo • Configuring the username • Pushing changesets • Pulling changesets • Merging changesets • Resolving merge conflict • DRCS workflows
Step 1 Setting up the remote repo on Google Code
Setup a Google Code Repository In this guide, we shall use the excellent open source hosting site Google Code as an example. There are other Mercurial repository-hosting sites such as BitBucketathttps://bitbucket.org/, which offers free repositories with various features and restrictions. First, sign up for a new project athttp://code.google.com/hosting/ Choose Mercurial as your version control system
Setup a Google Code Repository Go to Sourcetab -> Checkout Remember to note downthe repository URL Take note of your repository URL And your password (this is different from your Gmail password)
Setup a Google Code Repository You need this password to push changeset to Google Code You can access all the project you have here
Setup a Google Code repository Browse the code in your repository by going to Sourcetab-> Browse Files will shows up as you commit code
Setup a Google Code repository View all the changes in your project by going to Sourcetab-> Changes A commit graph will shows up as you commit code
Setup a Google Code repository Go to the Administertab -> Sharing and add your team members as owners or committersunder Emails of your team members go here
Setup a Google Code repository You can configure it to send activity notifications to your Google group (if you set up one for your team) under Administertab-> Source Add your team’s google group email here
Step 2 Cloning the remote repo
Clone a repository If you already have an existing repository of the project on Google Code (set up by one of your team members), you can cloneit from the Google Code repository to your hard disk. Otherwise,skip to Step 3 Right-click on a new folder and select TortoiseHg - Clone
Clone a repository Cloningallows you to duplicate the entire repository, copying all the existing contents to the destination as well as the whole revision history. Paste the Google Code repo URL here. This slide explains where to find the Google code repo URL.
Step 3 Syncing the local repository with the remote repo
Sync a local repository with a remote repo If you have an existing local repository, you can also configure it to sync with the repo on Google Code Click Synchronize
Sync a local repository with a remote repo Add the Google Code repository URL as the default path Choose https Use “code.google.com” Use the relative URL Save Use “default” for alias
Sync a local repository with a remote repo You can also configure Post-Pull behaviorfor repositories Select Post Pull Update option will make TortoiseHg automatically update your repository whenever you pull some change
Step 4 Configuring the username
Configure username for accountability In a team setting, you need to identify yourself when committing so that you and your teammates know what you committed Select a repository and choose Repository Settings
Configure username for accountability Unser Commitgroup, enter the username & email that you want to associate your commits with Use “name <email>” here
Configure username for accountability You can also set the username in the global settings. If there are no repository-specific settings specified, Mercurial will use the global settings. This affects every repository on your computer
Configure username for accountability From now on, your name will show up in subsequent commits This commit username can be different from your Google Code username Commits now have the author which you have just specified
Step 5 Pushing changesets
Pushing changesets Push update your changes from the local repo to a remote repo pushchanges Team’s Central Repo Member A’s Local Repo • A revisionis the set of changes whenever a push is performed. Each revision is given a number. A revisionis also known as a changeset. In this tutorial, we will use both terms interchangeably. • A revision contains other important information such as the author of the changes and the summary of each change. • Each successful commit will result in a new revision. • Each revision will definitely have one or more revision for its parent except for the first revision, which will have zero.
Push changesets After making some commits to our local repository, we are ready to push all of them into our Central Repository for the first time. Right click on your local repo and choose Hg Workbench
Push changesets In Hg Workbench, we will first previewthe commits that are to be pushed. Click here to preview which changes will be going to the repo Click Detect outgoing changes. This will compare the local and remote repository, finding changes to be pushed
Push changesets TortoiseHg will find all the changes that need to be pushed Click Push to upload these to Google Code These are the changes that is going to be pushed
Push changesets Then you will need to authenticate TortoiseHg to reach your Google code repository Enter your Google code username
Push changesets And your Google code password, as well. This is not your Google password. This slide explains where to get this password. Enter your Google Code password
Push changesets If the commits are pushed successfully, there will be no errors. You can look at the output logfor more info in any case. Success
Push changesets You can also do a quick verification of the success of your commits by detecting changes for pushing again This directly push changes, without checking. Not recommended for now Click here Your commit was pushed
Push changesets Go to your Google code repository, check the Sourcetab-> Changes You should see that your commits were pushed successfully here
Push changesets If you find it a chore to enter your login details every time you push changes or pull from a private repository which you have pull access from, you can store your login detailsusing TortoiseHg. Click “Synchronize” to open the sync panel at the bottom Click on the lock to openthe security panel Key in your Google account details
Step 6 Pulling changesets
Update/Merge Pulling changes only retrieves changes from the remote repository into the local repository. However, the working copy is not updated in a Pull operation. You need to update the working copy to the latest version by using the Updatecommand. If there are multiple heads (i.e. same file modified by multiple persons), you need to use the merge command instead. pullchanges Team’s Central Repo Member A’s Local Repo Member A’s Working Copy update Update changes
Pulling and pushing (Diagram) In the above model, Member A commits some changes and pushes them to the Central Repository.Member A then informs the team to pull his changes off the Central Repository. Member B decides to do so and merges the changes from the Central Repository into his own repository.If any other member wishes to have the latest stable code, all they have to do is to pull off the Central Repository. Member B’s Local Repo Member B Team’s CentralRepo 4. pulland merge 3. Tells him to pull Member A’s Local Repo Member A 2. pushchanges 1. makes some changes and commit
Pull & update changes Let’s say Greg have pushed his code. Now his friend, Holly decides to pull the changes into her currently empty local repository. Again, open Hg Workbench
Pull & update changes In Hg Workbench, you can check for new changes from repository Check for changes from Google Code
Pull & update changes When new changes are detected, you can accept and download them Click to download changes below
Pull & update changes The changes have been pulled into the local repository. However, we still need to update the working copy to the latest changes. This means there are changes that is more up-to-date (2 and 3). You will need to update
Pull & update changes You can update in Hg Workbench or right-click on the repository and use the popup menu Click Update to openthe update dialog
Pull & update changes Use the default option to update to the latest changes
Pull & update changes Here’s the view after the update.
Pull & Update changes • Finding it so troublesome to pull and then update? You can configure TortoiseHg to update for you by simply configuring the Post-Pull behavioras listed in Step 3: Sync a local repository with a remote repo • Summary: • Pullingonly pulls the changesets into the local repository. • You still need to updatethe working copywith the new changesets. • Keep repeating this to yourself: Pull and Update
Step 7 Merging changesets
Merge changesets • You may encounter this common scenarioGreg pushed his code to the repository. Then Holly & Rowley pulled and updated Greg’s code. Rowley then made some changes, committed and pushed them. Meanwhile, Holly also made her own changes and was about to push the code. • This can be summarized in the following timeline
Merge changeset Team Repository (Google Code) Pushed Greg Commit new code Pulled & Updated Pushed Rowley Try to push Pulled & Updated Commit new code Holly time
Merge changesets In this situation, Hollycan’t push. She must merge his changes with Rowley’s This is how Google Code look like after Rowley has pushed his code
Merge changesets Here, Holly check her code and detected one changesetthat needs to be pushed
Merge changesets When she push, however, there was an error. This is because she needs to pull Rowley’s code first