|
|
How to Use Mercurial (hg) RepositoriesIntroductionTwo kinds of source repositories are hosted at opensolaris.org:
centralized and distributed. The centralized source management
model uses the Subversion
(SVN) source control management program. See the Subversion
help page for information. Repositories managed in a distributed fashion use the Mercurial
source control management program. This page describes
Mercurial. The first sections are for developers. The
section at the end for Project Leads is labeled "For Project Leads". How to install MercurialMercurial is part of Solaris Express releases, starting with Build 88. If you have an older version of Solaris download the SUNWmercurial package from the SCM downloads page, Building from source codeThe Mercurial Wiki has details on building Mercurial from source. Mercurial is primarily written in Python, but some of the extensions are in C. How to get commit access to opensolaris.org Mercurial repositoriesDevelopers with commit rights will access repositories through their opensolaris.org accounts. Commit rights are managed by Project Leaders. If you do not have an account, sign up to acquire one. Additionally, you will have to provide a Secure Shell (SSH) public key. For anonymous access to a repository, use the user name 'anon'. ProxiesIf you are behind a firewall that requires that SSH connections be tunnelled through a SOCKS proxy, then your $HOME/.ssh/config file needs to contain a directive like:
If you are a Sun employee who needs information about available SOCKS proxies, you can check this internal web page. How to get started with MercurialGeneral information about Mercurial and how to use it is available at the Mercurial website. There you will find a quickstart guide, a tutorial for new users, a FAQ, 'tips and tricks' and more. Information for engineers transitioning from TeamWare is available on the How To Transition from Teamware to Mercurial page. A few common operations are illustrated below, using the ON Nevada repository as an example. UsageThe Mercurial program is named hg (the chemical symbol for Mercury). Every Mercurial command starts with
The help command can be used to get more information about any command.
Getting an initial copyUse Mercurial's
Updating a child repositoryUse Mercurial's
Otherwise, you'll get output informing you of the number of changesets
involved:
Using hg bundles of the ON repositoryOpenSolaris mercurial repositories are sometimes provided as "bundles" with a .hg extension. There are two types of bundles - Changesets and Incremental. Changeset bundles are complete standalone bundles. To get a working copy of this bundle, download it from the opensolaris.org downloads page and do the following steps.
Incremental bundles are typically named as "on-hg-bundle_yyyymmdd-YYYYMMDD.hg" and contain only incremental changes. They can only be applied to a working copy which contains all changesets upto yyyymmdd and no more. This is verified before the unbundling process by checking the parent property (hg parent) of the bundle. You can apply an incremental bundle to a working copy using the following commands
Once you have a working copy, you can clone it and do other operations described below.
Editing filesThere is no equivalent of the sccs edit or wx edit. Mercurial automatically keeps track of modified files.Adding filesThe equivalent of the wx create command to add files to the workspace is the add command.
These files will be added to the repository on the next commit.
Examining differencesThe equivalent of the sccs diffs and the wx diffs commands is the diff command.
Without any arguments, hg diff will print out the differences between all modified files in the repository.
Differences between files are shown using the unified diff format.
Commiting the changesThe equivalent of the sccs delget and wx delget commands is the commit command.
This command drops us into an editor (configured using the EDITOR and HGEDITOR environment variables) where we can add the putback comments. Once we save the changes and quit the editor, the changes are committed to the repository.
Putting back the changes to the parent repositoryAll changes up to this point have been in the working clone repository. The changes can be put back to the parent repository using the push command.
This is the equivalent of the Teamware command "putback -p /ws/onnv-gate".It is not mandatory to provide the path to the repository to push the changes to. If no repository is specified, the changes will be pushed to the repository we cloned from. The equivalent of the " putback -n" command is Mercurial's "outgoing" command.
For Project Leads: How to set up a Mercurial repositoryThe creation of a Mercurial repository on opensolaris.org is done through the webpages. You have to be a project leader to create a new repository. On the main page for a project, there is an item called "SCM Management". This item will lead you to the SCM configuration page. Choose "Add Repository". You will be asked to provide a name for the repository, a notification email address, the repository type (Subversion or Mercurial), and whether anonymous access is allowed. Click the "Add" button to add the repository. After the repository has been created successfully, a short summary of the repository name and properties will be shown. You can click the name of the repository in this summary to add/remove committers. The URL for the repository will be of the format
Where "projectname" is the name of your project and "reponame" the name of the newly created repository. "user" can be "anon" or the opensolaris.org username of someone who has commit rights to the repository. There is currently no support for deleting repositories via the website. If you own a repository that you want to go away, please send mail to tonic dash ops at sun dot com. |