Mercurial and TortoiseHg getting started tutorials Source: http://www.keakon.cn/bbs/thread-1865-1-1.html
Among distributed version management tools, Git and Mercurial are the most popular tools. The well-known Linux uses Git for source code management, while Python and Firefox use Hg (you can find a bunch of projects using Hg here ).
1. Why?Distributed configuration management
2. Why choose Mercurial?
Because Git's main advantage lies in its branches, and localization does not require too many branches, Git's support for Windows seems to be inferior to Mercurial, and ssh is more troublesome than http, which is hard to be used by members of the localization group; another special reason is that Hg is mainly implemented in Python (a small part is implemented in C ).
Hg also has a serious drawback: it does not support the branch targeting a single folder. If you want to build a branch for script translation and rebuild, you must copy the entire repository. for translation, image files are not what they need.
Appendix: Google also published Analysis of Git and Mercurial, which shows why Google Code decided to support Hg rather than Git.
Git advantages:
- Client storage control. You can delete any version without having to consider the subsequent version of the branch.
- Unlimited number of parent nodes. Hg can only be divided into two branches at a time. Merging N branches requires many operations. Git has no restrictions.
- Supports rebase. It can move the current version to the latest branch. For example, assume that a local database is developing a new feature of 1.0, and the baseline has been upgraded to 1.1. Generally, it needs to be merged to 1.1, and rebase can avoid this operation.
Advantages of Hg:
- Learning curve. Due to many factors, Git has a steep learning curve than Hg.
- Windows is supported.
- Maintenance. Git needs regular maintenance.
- History cannot be violated. Git is very powerful and can do almost anything, so it will also lose historical information.
It seems that Git is technically better than Hg, but because the implementation of file operations depends on the operating system, porting to Bigtable will be troublesome; in addition, Hg has a good HTTP-based stateless pushing and pulling, which is easy to integrate with Google's architecture (almost all Google services are based on HTTP ).
Google also provides test data specifically, indicating that Git is one order of magnitude slower than Hg When HTTP is used. (Two numbers are mentioned, which are 22 times slower and 12 times slower .)
3. Where can I host code for free:
- GitHub: This website is famous for its MB free space built with RoR. It supports Git, but does not support Hg (although there are plug-ins, it is too troublesome to teach others ), there is no private library.
- Bitbucket: This is created using Django. You can create a private library, free space of MB, and support for Hg.
- ProjectLocker: only (unlimited) Private libraries, free space of MB, support for SVN and Git, but only 5 users. Closed-source project recommendation, but obviously not suitable for a large tomo Chinese group.
- Unfuddle: Free Space of MB. It supports SVN and Git and can only have one database and two users.
In the end, I chose the smallest bitbucket, because it is almost enough.
(Note: Google Code now supports Hg, but it can only host source Code and cannot be used for other purposes, so I can only give up. However, if you are developing open-source software, Google Code is the most generous. You can also send a mail application to expand the quota, but occasionally get GFW .)
4.TortoiseHgInstallation
Then we started to install the software. I am used to SVN turtles, so I still chose TortoiseHg ).
Currently, this version supports Windows XP, Vista, and Windows 7, so you do not have to worry about compatibility.
The installation is very simple. After the installation is complete, you need to restart (in fact, you can also use it without restarting ).
If you like the command line, you can also enter hg in CMD to try.
5. LetTortoiseHgDisplay Chinese characters on the Interface
You need to create an environment variable "LANGUAGE" (in system attributes) with the value "zh_CN ".
Then you have to go to this folder: C: \ Program Files \ TortoiseHg \ cmenu_i18n to import the thg-cmenu-zh_CN.reg file.
After the modification, the software interface and command line (hg and hgtk) are now in Chinese, but the right-click menu is still in English. Restart or log out to become Chinese.
6. Basic Mercurial operations
Before using Mercurial, we recommend that you take a look at the Mercurial tutorial to learn about several terms.
InitIt refers to initialization, that is, creating an empty warehouse.
CloneIt refers to the creation of a repository. The source can be a repository represented by an http or ssh link, or a local repository.
CommitSubmit, that is, accept all changes, and use the current version as the latest version (also called tip ). Note that this submission is different from the centralized SCM. It only submits the local repository, and the local repository records all changes in detail (called Change set or change set ). Therefore, it is okay to submit multiple times because it does not affect others' warehouses. If you are afraid of affecting yourself, you can clone a duplicate and then rewrite and submit it.
RevertIt refers to restoration, that is, withdrawal of all changes and recovery to the unchanged state. You cannot find it in the right-click menu.
Pull means to Pull the changes that are available in other warehouses but not in the current warehouse to the current warehouse. However, this only adds a change set, and the file will not be changed. (The change set has a unique hash ID, so it is easy to differentiate .)
UpdateIt means update. When other Change sets are obtained and the changes need to be consistent with those of other warehouses, You can execute the changes.
PushIs to upload the change set of the current warehouse to another warehouse. Other repositories must support this operation and may need to be verified. If it is pushed from the local warehouse A to the local warehouse B, it is equivalent to using B pull. In addition, push does not update the repository version, because it is shared, and you can directly select the desired version.
MergeMerge. When a file is modified multiple times and stored in multiple warehouses, a unified version must be obtained and merged. For translation, a text may be distributed to multiple people at the same time, so you only need to accept the changes made by each person during the merge.
If you want to learn more, read Mercurial: The Definitive Guide.
After the introduction of these terms, you can look at the usage methods written by others:
Git Vs Mercurial hg? Remote Collaborative Development and distributed SCM solution selection!
CodeBeamer + Mercurial Practical Operation Manual
Of course, that PDF document is also useful.
However, for the sake of the comrades in the localization group, I 'd like to explain how to complete the operation.
First, go to my bitbucket homepage and find the FamilyProject project.
The following are some tips:
Reference:
Clone this repository (size: 4.3 MB): HTTPS/SSH
$ Hg clone https: // keakon@bitbucket.org/keakon/familyproject/
Create a folder named FamilyProject anywhere on your hard disk.
Go to the folder, right-click the blank space, and select "clone" from the TortoiseHg menu ".
Fill in the address you just saw in the Source Path: https: // keakon@bitbucket.org/keakon/familyproject/, and then click the "clone" button, wait until the download is complete.
After the download is complete, you have a complete project file, and you can modify it.
Next, perform a clone operation and copy it to another local repository. The method is very simple. It is the same as the previous clone, but fill in the generated folder in the source path, and fill in the new folder in the target path:
This operation should be completed in 1 or 2 seconds, because it is a local copy.
Then open a file in FamilyProject in a text editor, such as SNR02.ISF.
In the following 1st sentence, we will find that: ● 0001 ● too many errors were lost.
Change it to: Read failed.
Right-click the FamilyProject folder and select "HG submit ".
The modified files and specific differences are listed. Enter the description and click Submit.
Open the file with the same name in FamilyProject-new, and find the 2nd sentence: ● 0002 ● deleted too many characters.
Change it to: Read failed.
Then perform the same commit operation.
Now you have two different branches in two warehouses, so you can see how to merge them.
Right-click the FamilyProject folder and select "HG repository Browser ".
Enter the address of the new warehouse in the address bar and click "pull change set:
At this time, you will find that the latest tip version has changed to the version in FamilyProject-new and has an additional branch.
However, it remains unchanged after opening the file. In this case, right-click the change set at the top and select "Update" (you can also select "pull and update" in the previous step to automatically complete the operation) to switch the version.
Note that the version has been listed, and there are several prompts, such as the change set number, the change set hash ID, description, and whether it is the default or tip version.
Click the "Update" button after confirmation. Then you will find that your file has changed to the version in FamilyProject-new, but your changes are lost (don't be nervous, file is not lost ).
The reason is very simple. The update is only to switch the version of the change set and will not be merged. If you want to switch back to your version, right-click the change set below and select "Update.
However, my goal is to merge rather than update, so we will continue to describe the merge below.
The operation is simple. Right-click 2nd branches and select "merge.
Click "merge.
Since the changes are different, there is no conflict, and the merger is successful. Click Submit.
In this case, the changes are listed. "-" indicates deletion, and "+" indicates addition. We can see that the two changes are correct, so we don't need to do anything else, just click the "Submit" button.
Let's take a look at the change set. The branches have been merged, and your files have been updated.
However, the files in FamilyProject-new are still old versions.
If you don't need it, simply delete the folder. If you want to continue using the folder, open its "HG repository Browser" and select "pull and update ", click "pull change set:
After the operation, the two warehouses are exactly the same, and you can continue other operations.
If you have finished the modification and need to pass it to others, you need to push it to others or ask others to come to pull. This operation is actually similar to the operation in the Local warehouse.
The simplest method is to publish to a local Web server.
Right-click the folder and choose TortoiseHg-Web server ":
A window appears (as mentioned above, it is easy to see that it is written in Python), but don't worry, you have to click "Configure" to set it:
Set "SSL encryption push" to "False" because you do not have an SSL certificate. Enter the Allowed User Name in "allow push". In order to save the trouble, enter "*" to allow everyone to push. The following encoding must also be the same as the file encoding, so as to avoid gibberish during online file viewing.
Return after confirmation. Enter a number smaller than 65535 in the port. The default value is 8000. Then click "start.
After it is started, you can access it through a browser. The address is http: // your IP: Port Number /.
Next, try pushing.
Open the FamilyProject-new folder, change the file, and submit it.
This time I don't need a repository browser, because it is too large, and I switched to a small "synchronization" Operation:
Enter the address you just accessed in the browser, and click "push" to complete the push.
Then you can go to the FamilyProject folder to view the change set. If necessary, you can perform the update and merge operations as mentioned above.
However, this IP address may be inaccessible from the outside, or may be caused by the gateway or firewall settings, so that your Web server cannot be accessed by others.
A temporary solution is mail. But before that, you have to change the email settings.
Right-click the folder and choose TortoiseHg-global settings ":
Fill in your email information in "email:
Here is the configuration instructions for Gmail. Just fill in the other settings.
Note that the password is the logon password of the mailbox. If you fill it out, it will be saved in plain text, so if your computer is still in use, do not fill it out, but you need to manually enter the password when sending the mail.
Return to the synchronization window after configuration. Click "mail" and enter the mail content. Check the attachment and click send.
However, if the network is poor, it is likely to fail. After successful, the recipient will receive an email containing an attachment of the. patch type.
However, TortoiseHg does not support importing the patch file and can only be executed through the command line.
The receiver can run CMD, switch to the warehouse to be imported, and then execute the following command:
Reference:
Hg import patch file name
Of course, the command line is terrible for some people, so another method is to create your own repository in bitbucket.
You can register an account or use OpenID.
Log on to the FamilyProject and click the fork link.
Fork refers to creating a copy based on my repository. Similar to clone, it is only performed remotely.
On the New Page, enter the project name, click "Advanced settings", perform more settings, and click "Create fork" to Create a project.
Like local clone, the remote fork completes in a few seconds and is automatically redirected to this repository. (The result shows that this warehouse is actually half-sized, so it seems that the space usage is very strange .)
Next, you can operate the repository in the same way as the self-built Web server.
When you need to notify others after the change, go to the FamilyProject project again and click the "pull request" button.
Enter the email content on the new page, attach your repository address, and select the person to be notified. Then, click "Send request" to Send the email.
The recipient of the email can go to your warehouse to perform the pull Operation to obtain the update.
The merge and other operations are also mentioned before, so we will not repeat them.
If the space is insufficient, creating an account is the most convenient method.
Of course, you can also go to the "Admin" label and click the "Delete repository" button in the lower right corner to Delete unnecessary warehouses.
In addition, there is a "Repository management" link. after entering the link, you can perform the strip operation to delete unnecessary versions.
However, it seems that no space is added after deletion, so it's depressing... So I sent a mail to the customer service, but it hasn't been done for a whole day. Our communication frequency is about 2 hours...