Friday, May 24, 2013

How to enable convert extension into Mercurial ?

Advanced users of Mercurial can be aided with the use of Mercurial extensions. Extensions allow the integration of powerful new features directly into the Mercurial core. 
 
Built-in help on extensions is available with 'hg help extensions'. To get help about an enabled extension, run 'hg help <extension-name>'.

Convert Extension

The Convert extension converts repositories from other SCMs (or even Mercurial itself) into Mercurial repositories, with options for filtering and renaming. It can also be used to filter Mercurial repositories to get subsets of an existing one.
The current release supports the following repository types as sources:
  • CVS
  • Subversion
  • Git
  • Darcs
  • Monotone
  • Bazaar
  • GNU Arch
  • Mercurial
  • Perforce
Convert extension comes up together with Mercurial. To enable convert extension, add following lines in your configuration file, Edit your $HOME/.hgrcwhich look like:
 
[extensions]
hgext.convert=




Lets begin by downloading the latest revision of the repository. Mercurial will download it from the remote repository with the full history.

[root@localhost Desktop]# hg convert svn://svn.repo.com/frontend/mxlLayer mxl_test
initializing destination mxl_test repository
scanning source...
sorting...
converting...
9 creating new repository for mxl Service layer.
8 * Fixed 500 error while creating tenant
7 * Javadocs added
6 * Renamed MXLLayerLog.xml back to logback.xml
5 1. Change return type of createTenant from long to MXLServiceResponse in TenantController.java
4 Added 3 new Api's:
3 Added target to ignore list
2 Added start/stop functionality.
1 Changed code according to review comments.
0 1.Added test cases for TenanatController Api's:1.CreateTenant 2.GetProtalInfo 3. GetApplications.


We are done! If you cd to the newly created mxl_test directory, you will be entering a fully fledged, history-preserved Mercurial repository, consisting of the exact same files as the Subversion repository.

[root@localhost mxl_test]# hg update # update to pull all repositories.
26 files updated, 0 files merged, 0 files removed, 0 files unresolved

[root@localhost mxl_test]# hg log # All log entry are preserved.
changeset: 9:08614ddd43c7
branch: mxlLayer
tag: tip
user: ankush
date: Fri Dec 28 16:19:17 2012 +0000
summary: 1.Added test cases for TenanatController Api's:1.CreateTenant 2.GetProtalInfo 3. GetApplications.
changeset: 8:c59c6dedf445
branch: mxlLayer
user: pravin
date: Fri Dec 28 13:54:15 2012 +0000
summary: Changed code according to review comments.
changeset: 7:7b863092bf77
branch: mxlLayer
user: abdul
date: Fri Dec 28 09:55:34 2012 +0000
summary: Added start/stop functionality.
changeset: 6:14064cef906d
branch: mxlLayer
user: deepak

date: Thu Dec 27 16:12:38 2012 +0000
summary: Added target to ignore list
changeset: 5:2a450c99b687
branch: mxlLayer
user: pravin
date: Thu Dec 27 15:10:07 2012 +0000
summary: Added 3 new Api's:
changeset: 4:681d8882361e
branch: mxlLayer
user: abdul
date: Thu Dec 27 13:09:46 2012 +0000
summary: 1. Change return type of createTenant from long to MXLServiceResponse in TenantController.java
changeset: 3:dc92af2b2e48
branch: mxlLayer
user: deepak
date: Thu Dec 27 08:54:07 2012 +0000
summary: * Renamed MXLLayerLog.xml back to logback.xml
changeset: 2:628fd78ee782
branch: mxlLayer
user: deepak
date: Thu Dec 27 05:52:43 2012 +0000
summary: * Javadocs added
changeset: 1:7513eadc9761
branch: mxlLayer
user: deepak
date: Wed Dec 26 15:39:08 2012 +0000
summary: * Fixed 500 error while creating tenant
changeset: 0:bc1f1d1f6a30
branch: mxlLayer
user: abdul
date: Wed Dec 26 14:11:55 2012 +0000
summary: creating new repository for mxl Service layer.











Basic commands of Mercurial

These commands are very much to the subversion.

1. Creating a repository (hg init)

 Create a mercurial repository in an empty directory by using the init command:
[root@localhost ~]# mkdir Test
[root@localhost ~]# cd Test
[root@localhost Test]# hg init
[root@localhost Test]# ls -lar
total 12
drwxr-xr-x. 3 root root 4096 May 21 06:42 .hg
dr-xr-x---. 36 root root 4096 May 21 06:40 ..
drwxr-xr-x. 3 root root 4096 May 21 06:42 .

Now there is an empty repository created, locally in your directory. The repository contains both a
working copy, and the repository data (the history information).

2. Adding a file (hg add)

Schedule a file for addition
[root@localhost Test]# echo "Testing1" >>test.txt
[root@localhost Test]# ls -lar
total 16
-rw-r--r--. 1 root root 9 May 21 06:47 test.txt
drwxr-xr-x. 3 root root 4096 May 21 06:42 .hg
dr-xr-x---. 36 root root 4096 May 21 06:40 ..
drwxr-xr-x. 3 root root 4096 May 21 06:47 .
[root@localhost Test]# hg add
adding test.txt

3. Committing a file (hg commit)

Commit command is used to save your changes in the current repository.
[root@localhost Test]# hg commit -m "my first commit"

4. Inspecting History (hg log)

Log command is used to see all changes in your repository.
[root@localhost Test]# hg log
changeset: 0:1b9e0c6235b3
tag: tip
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:49:51 2013 -0700
summary: my first commit

We can aslo look at parts of the history by specify revision ranges:
[root@localhost Test]# hg log -r 1
changeset: 1:c5ed72928a5e
tag: tip
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:59:28 2013 -0700
summary: second commit
[root@localhost Test]# hg log -r 1:2 # From 1 to 2
[root@localhost Test]# hg log -r :1 # Up to, and including 1.
[root@localhost Test]# hg log -r 2: # From, and including 2

5. Status (hg status)

Status command is used to tells us about modified, removed, or renamed files.
[root@localhost Test]# echo "testing2" >>test2.txt # creating new file
[root@localhost Test]# hg status # test2 is unknown to hg
? test2.txt
[root@localhost Test]# hg add # Adding test2 to hg
adding test2.txt
[root@localhost Test]# hg status #test2 is not yet committed.
A test2.txt

6. Remove Command (hg rm)

Remove command is used to remove the file.
[root@localhost Test]# hg rm test.txt
[root@localhost Test]# hg status
R test.txt
[root@localhost Test]# hg commit -m "removing test.txt file"
[root@localhost Test]# hg log
changeset: 2:689cfc786a1c
tag: tip
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 22:35:30 2013 -0700
summary: removing test.txt file
changeset: 1:c5ed72928a5e
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:59:28 2013 -0700
summary: second commit
changeset: 0:1b9e0c6235b3
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:49:51 2013 -0700
summary: my first commit

7. Update (hg update)

To check where we are right now ? Use the identity command to check :
[root@localhost Test]# hg identify -n
2

Use update command to update the repository :

[root@localhost Test]# hg update # repository is upto date
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

To update at some specific revision use '-r'

[root@localhost Test]# hg update -r 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[root@localhost Test]# ls
test2.txt test.txt

8. Tag Command (hg tag)

Tag command is used to assign your own symbolic names to specific revisions.
[root@localhost Test]# hg tags
tip 2:689cfc786a1c

[root@localhost Test]# hg log
changeset: 2:689cfc786a1c
tag: tip
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 22:35:30 2013 -0700
summary: removing test.txt file
changeset: 1:c5ed72928a5e
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:59:28 2013 -0700
summary: second commit
changeset: 0:1b9e0c6235b3
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:49:51 2013 -0700
summary: my first commit

[root@localhost Test]# hg tag -r 1 adding-tag-to-r1 # Adding tag at revision 1

[root@localhost Test]# hg log
changeset: 3:ccb2abafd599
tag: tip
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 22:48:34 2013 -0700
summary: Added tag adding-tag-to-r1 for changeset c5ed72928a5e
changeset: 2:689cfc786a1c
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 22:35:30 2013 -0700
summary: removing test.txt file
changeset: 1:c5ed72928a5e
tag: adding-tag-to-r1 #tag added to revision 1
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:59:28 2013 -0700
summary: second commit
changeset: 0:1b9e0c6235b3
user: abdul waheed abdulwaheed18@gmail.com
date: Tue May 21 06:49:51 2013 -0700
summary: my first commit

9. Diff command (hg diff)

Diff command will show difference between the working and repository revision.
[root@localhost Test]# ls
test2.txt
[root@localhost Test]# vi test2.txt
[root@localhost Test]# hg diff # showing diff for file test2.txt
diff -r 689cfc786a1c test2.txt
--- a/test2.txt Tue May 21 22:35:30 2013 -0700
+++ b/test2.txt Tue May 21 22:52:54 2013 -0700
@@ -1,1 +1,2 @@
testing2
+Adding one more line to check diff

10. Pull command (hg pull)

Pull command is used to get all changes from another repository into the current one.
[root@localhost Test]# hg pull https://bitbucket.org/abdulwaheed18/testing

11. Push Command (hg push)

Push command is used to send all changes from your repository to another one.
[root@localhost Test]# hg push https://bitbucket.org/abdulwaheed18/testing

12. Clone Command (hg clone)

Clone command is used to makes a clone of a repository with the complete project history. It makes a complete copy of another repository so that we will have our own local, private one to work in.
[root@localhost test_clone]# hg clone https://bitbucket.org/abdulwaheed18/testing # garbbing testing
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
http authorization required
realm: Bitbucket.org HTTP
user: abdulwaheed18
password:
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
destination directory: testing
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
requesting all changes
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

[root@localhost test_clone]# ls # we got local copy of testing
testing

[root@localhost testing]# hg log # local copy with the history
changeset: 1:07c9802fabde
tag: tip
user: abdulwaheed18@gmail.com
date: Tue May 21 02:35:52 2013 -0700
summary: commiting second tym
changeset: 0:7aafa4bde466
user: abdulwaheed18@gmail.com
date: Tue May 21 02:00:18 2013 -0700
summary: test

[root@localhost testing]# hg summary # gives the repository information
parent: 1:07c9802fabde tip
commiting second tym
branch: default
commit: (clean)
update: (current)

13. Help Command (hg help)

Last but not least, Help command will give you the detail explanation of all commands supported by Mercurial.
hg help” will give list of all command.
To check particular command use “hg help <command_name>




Installation and configuration of Mercurial

Installation

Windows :

The best version of Mercurial for Windows is TortoiseHg, which can be found at http://tortoisehg.bitbucket.org/ . This package has no external dependencies. It “just works.” It provides both command-line and graphical user interfaces.
After installation, you will have a right-click menu in Windows Explorer that gives you access to the graphical tools. After logging out and in again, you will also have a hg and a thg program available in a Command Prompt. You can use the thg program to start the graphical TortoiseHg tools.

Command-line : (figure 1)



GUI : (figure2)


Linux :

You can install Mercurial on Linux using package manager -
yum install *mercurial*
but installing it from package manager not assure you the latest version of mercurial.
So, You can install the latest version(2.6) from source http://mercurial.selenic.com/release , unpack it and run make install to install it.
If you get any issue like “error: command 'gcc' failed with exit status 1 ” then install following thing

            yum install python

Check the correct version of devel and install it :

           yum search python | grep -i devel
           yum install python-devel.x86_64
           yum install python-docutils

To find out whether the Mercurial is installed properly. Check hg version command. If the Mercurial is installed properly, You can see the version information as below (figure 3) :


Configuration

Once your setup is ready, You have to add username in the configuration file.

Linux :

create new file having name “.hgrc” under $HOME directory and
[ui]
username =Firstname Lastname <example@example.org>

(Figure 4)


Windows:

create new file having name “Mercurial.ini” under $HOME directory and add
[ui]
username =Firstname Lastname <example@example.org>

To confirm, You have added username correctly, Run hg debuginstall command. You will get the message “No problem detected.”

How TOPT Works: Generating OTPs Without Internet Connection

Introduction Have you ever wondered how authentication apps like RSA Authenticator generate One-Time Passwords (OTPs) without requiring an i...