NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Integrating Mercurial with PHPEd
Veteran

Joined: 30 Aug 2006
Posts: 116
Reply with quote
This is a very basic integration, but should make your life MUCH easier if you are using Mercurial (Hg). This is a work in progress and I anticipate better things when TortoiseHG 0.4 or 0.5 come out.

Background

Mercurial is a great DVCS (Distributed Version Control System) that is mostly a command line tool, with windows integration using the excellent TortoiseHg tool. I've gotten VERY USED to using keyboard shortcuts within PHPEd to commit single file commits into CVS (I hit CTL-SHIFT-M to open up a CVS commit dialog within PHPEd) and wanted to do the same thing for Mercurial, which we're considering switching to.

This tutorial should save you some time since I figured out the commands necessary. Also, previously it was impossible to to integrate Mercurial with PHPEd due to a bug in Mercurial, which was very promptly fixed by the Mercurial devs when I reported it to their mailing list.

Keep in mind that using TortoiseHg already gives you tortoise functionality in PHPEd's file browser, but my problem is that I like keyboard shortcuts.

Requirements:


  • Mercurial 1.0 or greater. Previous versions (eg Mercurial 0.9.5) DO NOT work due to a bug that was fixed for 1.0. The version here works: http://mercurial.berkwood.com/
  • I'm using PHPEd 5.2. Your mileage may vary if you are using 4.x


What to do: Creating a Commit Shortcut

  • Install Mercurial if you have not already. I've installed mine to c:\development\Mercurial\
  • Go to PHPEd Settings > Tools > Integration
  • Create a new menu called "Hg" (or Mercurial or whatever you want to call it)
  • Create a new Sub Menu called "Hg Commit"
  • Edit "Hg Commit" with the following settings:

    • Execute with "Shell"
    • Command line: c:\development\Mercurial\hg.exe commit @Name@ --cwd @Path@
    • Check off "Show this command in File Bar popup" (optional)
    • Shortcut: CTL-SHIFT-M (or anything you like)
    • Check off Redirect Error stream to Log Window and Redirect Output to Window



Now if you are editing a file all you have to do is type your shortcut to commit it. It will open up Notepad, which you type your commit message into, and save/close, and it will commit. Commit results and errors are output into PHPEd's Log. Pretty handy!

To setup nifty Annotate and Log features you do exactly as above except the command lines are:

Code:

c:\development\Mercurial\hg.exe annotate -un @Name@ --cwd @Path@


and

Code:

c:\development\Mercurial\hg.exe log @Name@ --cwd @Path@


For the annotate I used some options so it would include the name of the author for each line (by default Hg doesn't show this, while CVS does).

After using the above Make the following changes:


  • Make sure Redirect Output to log window is NOT CHECKED
  • Save Output to file: c:\windows\temp\hg_log.txt
  • Check off Open File and enter "c:\windows\temp\hg_log.txt" under "In editor"


The above steps opens up the log entry results in PHPEd. Very handy for me!

Hope this helps. When TortoiseHg 0.4 or 0.5 is working fine we can create integration with its handy "visual log" and, more importantly, QCT based visual commits which will let you open up a commit dialog to commit multiple files in one go.
View user's profileFind all posts by rudderSend private message


Joined: 07 Mar 2007
Posts: 26
Reply with quote
Thanks a lot for posting the steps. Ill try and follow it and see it if works.

Are there any updates, im using TortoiseHg 0.8
View user's profileFind all posts by Ibn SaeedSend private message


Joined: 07 Mar 2007
Posts: 26
Reply with quote
I followed your steps

But the Commit did not work

I get the foollwing error:

Quote:
Script Failed to run command "D:\Program", error code: 2, system description: "The system cannot find the file specified. 2:11:32 PM


Here are my Commit Settings:
Command Line: D:\Program Files\TortoiseHg\hg.exe commit @Name@ --cwd @Path@

Execute with: Shell
View user's profileFind all posts by Ibn SaeedSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
You need to put the D:\Program Files\TortoiseHg\hg.exe between quotes:

"D:\Program Files\TortoiseHg\hg.exe" commit @Name@ --cwd @Path@

As stated in the error the shell attempts to execute D:\Program, which is an invalid command
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 26
Reply with quote
Blizz wrote:
You need to put the D:\Program Files\TortoiseHg\hg.exe between quotes:

"D:\Program Files\TortoiseHg\hg.exe" commit @Name@ --cwd @Path@

As stated in the error the shell attempts to execute D:\Program, which is an invalid command



That was the problem. It works fine now.

Now, is it possible to use Notepad++ or TortoiseHg's own Commit window instead of using Notepad
View user's profileFind all posts by Ibn SaeedSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
That would be a TortoiseHG option and not something I can help you with as I don't know the program.
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 26
Reply with quote
Blizz wrote:
That would be a TortoiseHG option and not something I can help you with as I don't know the program.


Presently, the above integration for Mercurial, brings up Notepad when Committing changes. It asks for summary of the commit.

What i like is that instead of opening notepad, it should open some other program.
View user's profileFind all posts by Ibn SaeedSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Yes and I understood what you were asking but as I said, IF it is possible you'd have to configure that in TortoiseHG and not in PhpED.
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 26
Reply with quote
Blizz wrote:
Yes and I understood what you were asking but as I said, IF it is possible you'd have to configure that in TortoiseHG and not in PhpED.


Ok Thanks.

Can PHPed integrate Mercurial support such as they have to CVS. Netbeans has a good integration.
View user's profileFind all posts by Ibn SaeedSend private message


Joined: 24 Jun 2011
Posts: 4
Reply with quote
Hi guys,

For those who want to use the Mercurial's graphical client to commit (TortoiseHg) within their favorite PHP IDE, here's a simple workaround for Windows plateforms :
You need to download and install a small program : SlickRun (a command line using a list of personnal keywords) Look here :

Here's an example (with the default keybord shortcuts)
Call SlickRun : WIN+Q
Type : setup
Click : New MagicWord
Create something like this :
MagicWord : hgProjectName
Filename : C:\Program Files\TortoiseHg\thgw.exe
Start Mode : Default windows
Startup Path : D:\projects\myProject\www <-- Here's the path to your project's root
Parameters : commit


Then all you have to do to commit is :
Call SlickRun : WIN+Q
Type : hgProjectName

Enjoy Smile
View user's profileFind all posts by xysyoSend private message
Integrating Mercurial with PHPEd
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic