Difference between revisions of "Mercurial-nexj"

From CDOT Wiki
Jump to: navigation, search
(Notes)
 
(12 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
[[Category:NexJ_Express_Continuous_Integration]]
 +
 
<big><big> Continuous Integration Project - Mercurial</big></big>
 
<big><big> Continuous Integration Project - Mercurial</big></big>
{{NexJ_Express Index}}
+
 
 
==Introductions & Tutorials==
 
==Introductions & Tutorials==
 
: Main website @ http://mercurial.selenic.com/  
 
: Main website @ http://mercurial.selenic.com/  
Line 7: Line 9:
 
: Understanding Mercurial @ http://mercurial.selenic.com/wiki/UnderstandingMercurial
 
: Understanding Mercurial @ http://mercurial.selenic.com/wiki/UnderstandingMercurial
 
: Tutorial-wiki @ http://mercurial.selenic.com/wiki/Tutorial
 
: Tutorial-wiki @ http://mercurial.selenic.com/wiki/Tutorial
 +
: Good [http://stevelosh.com/blog/ Blog] about Mercurial
  
 
==Installation==
 
==Installation==
 
: Installing in windows[http://www.codza.com/mercurial-with-ssh-setup-on-windows]
 
: Installing in windows[http://www.codza.com/mercurial-with-ssh-setup-on-windows]
 
: More about installation [http://www.aventinesolutions.nl/mediawiki/index.php/Quick_Tip:_Getting_Started_with_Mercurial]
 
: More about installation [http://www.aventinesolutions.nl/mediawiki/index.php/Quick_Tip:_Getting_Started_with_Mercurial]
 +
: To be able to run Mercurial in Cygwin, execute hgtk.exe in TortoiseHG root.
 +
: Cloning in Eclipse using ssh [http://youarepeople.blogspot.com/2008/10/mercurial-eclipse-over-ssh.html]
  
 
==Mercurial on Eclipse==
 
==Mercurial on Eclipse==
Line 16: Line 21:
 
: Eclipse-Mercurial Video [http://blogs.intland.com/main/entry/39]-[http://code.google.com/p/hgeclipse-demo/ Demo]
 
: Eclipse-Mercurial Video [http://blogs.intland.com/main/entry/39]-[http://code.google.com/p/hgeclipse-demo/ Demo]
 
: Documentation for Eclipse-Mercurial [http://bitbucket.org/mercurialeclipse/main/wiki/Documentation]
 
: Documentation for Eclipse-Mercurial [http://bitbucket.org/mercurialeclipse/main/wiki/Documentation]
 +
: Cloning a repo in Eclipse using SSH [http://youarepeople.blogspot.com/2008/10/mercurial-eclipse-over-ssh.html]
  
 
==Notes==
 
==Notes==
Line 57: Line 63:
 
: Then merge with the revision of the branch you want to merge with: <code> hg merge -r 3 </code>
 
: Then merge with the revision of the branch you want to merge with: <code> hg merge -r 3 </code>
 
: Don't forget to commit this merge!
 
: Don't forget to commit this merge!
 
+
:'''Tips'''
 +
:-''To create a branch in the working directory and then pushed it to the main remote repo:''
 +
:: <code> hg branch ws </code>
 +
:: <code > hg ci -m 'created a new branch' </code>
 +
:: <code> hg push --new-branch </code>
 
* Webserver:  
 
* Webserver:  
 
:To start a web server of a specific repository, do: <code> hg serve --port 8000 </code> and open the domain name with port number in a browser, or right click on the folder and use TortoiseHg Web Server option.
 
:To start a web server of a specific repository, do: <code> hg serve --port 8000 </code> and open the domain name with port number in a browser, or right click on the folder and use TortoiseHg Web Server option.
Line 67: Line 77:
 
<source lang=java>
 
<source lang=java>
 
hg clone http://domain:port/postgreSQL NexJExpress/work/ws
 
hg clone http://domain:port/postgreSQL NexJExpress/work/ws
 +
//or use ssh
 +
hg clone ssh://domain/mercurial/postgreSQL  // hard links was used to create a link to the main repo located at domain -D:\mercurial\postgreSQL
 
</source>
 
</source>
'''possible Errors'''
+
:'''possible Errors'''
:''I get an error while cloning a remote repository via ssh''
+
:-''I get an error while cloning a remote repository via ssh''
 
:If your remote repository is cloned thusly
 
:If your remote repository is cloned thusly
<source lang=java>
 
  hg clone ssh://USER@REMOTE/path/to/repo
 
</source>
 
 
:And, you find that after successful ssh authentication you get the error message remote: abort: repository path/to/repo not found! , then you need to know the following:
 
:And, you find that after successful ssh authentication you get the error message remote: abort: repository path/to/repo not found! , then you need to know the following:
 
::Mercurial's remote repository syntax differs from syntax of other well known programs such as rsync, cvs - both of which use a : character to delimit USER@REMOTE from the path component (/path/to/repo).
 
::Mercurial's remote repository syntax differs from syntax of other well known programs such as rsync, cvs - both of which use a : character to delimit USER@REMOTE from the path component (/path/to/repo).
Line 81: Line 90:
 
::In your ~/.hgrc file, set a remotecmd value in the [ui] section giving the exact path to hg.
 
::In your ~/.hgrc file, set a remotecmd value in the [ui] section giving the exact path to hg.
 
::On the server, create a ~/.ssh/environment file that defines an appropriate PATH, and add PermitUserEnvironment yes to /etc/sshd_config.  
 
::On the server, create a ~/.ssh/environment file that defines an appropriate PATH, and add PermitUserEnvironment yes to /etc/sshd_config.  
'':I get an "ssl required" error message when trying to push changes''
+
:-''I get an "ssl required" error message when trying to push changes''
 
:That's because allowing anonymous, unauthenticated HTTP clients to push changes into your repository would be a huge security hole. If you are on a private network and you know that all HTTP clients are trustworthy, you can add
 
:That's because allowing anonymous, unauthenticated HTTP clients to push changes into your repository would be a huge security hole. If you are on a private network and you know that all HTTP clients are trustworthy, you can add
 
<source lang=java>
 
<source lang=java>
Line 89: Line 98:
 
to .hg/hgrc on the server-side repository. (See also [http://mercurial.selenic.com/wiki/HgWebDirStepByStep HgWebDirStepByStep].)
 
to .hg/hgrc on the server-side repository. (See also [http://mercurial.selenic.com/wiki/HgWebDirStepByStep HgWebDirStepByStep].)
 
There's a reason for requiring SSL, however. If you do not trust the network you are using do not change this.
 
There's a reason for requiring SSL, however. If you do not trust the network you are using do not change this.
 
==Challenges==
 
* 1- First challenge is how to trim history of a repository.
 
: We have a Mercurial repository called A. We want to clone repo A and create a new repo called B.
 
: It's possible to use 'init' and create a new repo and just copy the files from repo A and add them.
 
: This way the revision number will reset. And we will start repo B from the tip of the repo A.
 
: The problem appears if we want to clone just the tip of the repo A and keep the same revision number of the 'tip'.
 
: Here are some links that we went through, but no success yet.
 
:[http://mercurial.selenic.com/wiki/EditingHistory Trimming History]
 
:[http://www.selenic.com/mercurial/hgrc.5.html .hgrc file]
 
:[http://mercurial.selenic.com/wiki/TipsAndTricks mq strip changeset]
 
:[http://mercurial.selenic.com/wiki/EditingHistory Editing History!!]
 

Latest revision as of 15:36, 22 January 2011


Continuous Integration Project - Mercurial

Introductions & Tutorials

Main website @ http://mercurial.selenic.com/
Mozilla Mercurial @ https://wiki.mozilla.org/Mercurial_on_Windows
compare version control tools [1]
Understanding Mercurial @ http://mercurial.selenic.com/wiki/UnderstandingMercurial
Tutorial-wiki @ http://mercurial.selenic.com/wiki/Tutorial
Good Blog about Mercurial

Installation

Installing in windows[2]
More about installation [3]
To be able to run Mercurial in Cygwin, execute hgtk.exe in TortoiseHG root.
Cloning in Eclipse using ssh [4]

Mercurial on Eclipse

Eclipse-Mercurial [5]
Eclipse-Mercurial Video [6]-Demo
Documentation for Eclipse-Mercurial [7]
Cloning a repo in Eclipse using SSH [8]

Notes

The Definitive Guide, is a documentation for hg (PDF or Html).
TortoiseHg Documentation [9]
Creating a Version Control Repository [10]
Mozilla Mercurial [11]
1- The .hg directory is the “real” repository, and all of the files and directories that coexist with it are said to live in the working directory.
An easy way to remember the distinction is that the repository contains the history of your project, while the working directory contains a snapshot of your project at a particular point in history.
2- The hg log command gives us a view of the history of changes in the repository. By default, this command prints a brief paragraph of output for each change to the project that was recorded.
Each of these recorded events are called a changeset, because it can contain a record of changes to several files. Changeset is also referred to aschange,cset,revision or rev.
3- Changeset field has the format of a number (identifier, which is only valid in that repository) followed by a colon, followed by a hexadecimal (or hex) string. These are identifiers for the changeset.
The hex string is a unique identifier: the same hex string will always refer to the same changeset in every copy of this repository. The number is shorter and easier to type than the hex string, but it isn't unique: the same number in two different clones of a repository may identify different changesets. changeset: 0:0a04b987be5a
4- Mercurial uses revision numbers purely as a convenient shorthand. If you need to discuss a changeset with someone, or make a record of a changeset for some other reason (for example, in a bug report), use the hexadecimal identifier.
5- Some changesets, have a tag field. A tag is another way to identify a changeset, by giving it an easy-to-remember name. tag: tip
6- To get the changeset id of the tipmost changeset of a remote repository you can do: When it changes, you have new changesets in the remote repository.[12]
> hg id -i -r tip http://www.selenic.com/repo/hello 
[[[link-to-a-page]]]
[url=http://example.com]Example[/url]
82e55d328c8c
7- Some aliases:
st = status / ci = commit /
8- mq tutorial [13]
9- ant task for hg ANT4HG
  • Clone a remote repository
hg clone http://domain:port/postgreSQL NexJExpress/work/ws
  • Branch & Merge [14]
To create a new branch: hg branch ws
Then commit it: hg ci -m 'added branch ws'
To see all branches: hg branches
To switch between branches: hg update ws
To clone a branch to local directory: hg clone -b ws work workCopy/work
After commit a change to the copy of code, just push it hg push, it will be pushed to ws branch in main repository
In main repository if you want to merge these 2 branches first see how many heads you have hg heads
Then merge with the revision of the branch you want to merge with: hg merge -r 3
Don't forget to commit this merge!
Tips
-To create a branch in the working directory and then pushed it to the main remote repo:
hg branch ws
hg ci -m 'created a new branch'
hg push --new-branch
  • Webserver:
To start a web server of a specific repository, do: hg serve --port 8000 and open the domain name with port number in a browser, or right click on the folder and use TortoiseHg Web Server option.
  • Templates:
using templates for getting customized output
  • Remote Repository
to Clone a remote repository:
hg clone http://domain:port/postgreSQL NexJExpress/work/ws
//or use ssh
hg clone ssh://domain/mercurial/postgreSQL   // hard links was used to create a link to the main repo located at domain -D:\mercurial\postgreSQL
possible Errors
-I get an error while cloning a remote repository via ssh
If your remote repository is cloned thusly
And, you find that after successful ssh authentication you get the error message remote: abort: repository path/to/repo not found! , then you need to know the following:
Mercurial's remote repository syntax differs from syntax of other well known programs such as rsync, cvs - both of which use a : character to delimit USER@REMOTE from the path component (/path/to/repo).
The path to the remote repository is relative to $HOME of USER. i.e., it is ~USER/path/to/repo .
Remember to use hg -v clone ssh://USER@REMOTE/path/to/repo and observe the remote command being executed via the ssh channel
On the other hand, if the error message is remote: bash: line 1: hg: command not found, the problem is that the environment used by ssh does not have hg in its PATH. There are two ways to deal with this problem:
In your ~/.hgrc file, set a remotecmd value in the [ui] section giving the exact path to hg.
On the server, create a ~/.ssh/environment file that defines an appropriate PATH, and add PermitUserEnvironment yes to /etc/sshd_config.
-I get an "ssl required" error message when trying to push changes
That's because allowing anonymous, unauthenticated HTTP clients to push changes into your repository would be a huge security hole. If you are on a private network and you know that all HTTP clients are trustworthy, you can add
[web]
push_ssl = false

to .hg/hgrc on the server-side repository. (See also HgWebDirStepByStep.) There's a reason for requiring SSL, however. If you do not trust the network you are using do not change this.