3.1. Overview
The following will be a short Eclipse Java development cycle using the command line interface of mercurial.
You will first create a new Mercurial repository, create a new Java project and commit the changes to your mercurial repository.
The command for mercurial is "hg".
Check that you are using Mercurial version 1.3 or higher:
hg --version
Create and switch to your desired work directory .
Initialize a new mercurial repository with:
hg clone https://yourproject.googlecode.com/hg/ name_of_directory_for_the_clone
Tip
If you have an existing project you could clone, e.g. create a copy of, your repository via the following command.
hg clone https://yourproject.googlecode.com/hg/ name_of_directory_for_the_clone
Eclipse creates a lot of metadata with regards to the current status of the Eclipse workbench. Also Eclipse creates compiled version in the directory bin. This data should not be placed in the mercurial repository. Create the file ".hgignore" in the same directory as the hg project.
# switch to regexp syntax.
syntax: regexp
^\.metadata
^de.vogella.mercurial.firstproject/bin$
Start Eclipse and use the new directory as workspace. Create a new Java project "de.vogella.mercurial.firstproject". Create the following Java class.
package de.vogella.mercurial.firstproject;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Hello Mercurial");
}
}
Add the project to Mercurial.
hg commit -A -m 'Commit with automatic addremove'
Commit.
hg commit -m "Create new project"
If you have checked out the Mercurial project from another site you can push your changes to the repository.
hg push
Check the history via:
hg log
Rename your Java class to "TestNewName" and create a new class "Test2".
package de.vogella.mercurial.firstproject;
public class Test2 {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Hello Mercurial");
System.out.println("This is a new class");
}
}
Add the the new files to Mercurial.
hg commit -A -m 'Commit with automatic addremove'
A rename in Java removes the old file. Mercurial will report these files as missing (hg status). You can use the following command to automatically add the new files and remove the deleted.
Add the the new files to Mercurial.
hg addremove
You can now commit. The -A flag in the commit command would also automatically add and remove new files.
hg add .
To see the changes use the status command. diff we show the differences.
hg log
hg diff
0 comments:
Post a Comment