Running Mercurial on a Flash Drive?
Asked Answered
A

3

29

So I do a lot of work on a school computer. We can't install anything but we have most of our tools on our flash drives but I was wondering if there's a way to get Command Prompt to use Mercurial off of my Flash Drive. Let's say in theory that Mercurial's files were on my flash drive, where would I go from there?

Aesthetically answered 15/12, 2009 at 0:7 Comment(0)
C
25

Say your flash drive was drive G: and your Mercurial executables are in G:\mercurial

Open a command prompt and enter:

set PATH=%PATH%;G:\mercurial

Proceed to use hg as normal

This should work, in theory. If you're on a *nix computer, you would do something like this (given /media/FLASHDRIVE is the path to your flash drive):

export PATH=$PATH:/media/FLASHDRIVE/mercurial

Hope that helps!

EDIT

In response to the comment below:

@ECHO OFF
REM Mercurial enabler :)
set PATH=%PATH%;G:\mercurial
cmd.exe

Should do it :)

Culhert answered 15/12, 2009 at 0:12 Comment(2)
That worked! Thanks but got another question! Is there any way to incorporate that into a .bat file so I'd just open that and have it open command prompt and run that at the same time?Aesthetically
You sir, are an instant winrar. Thank you and I greatly appreciate it!Aesthetically
S
26

To make Bryan's solution "truly" portable in Windows 2000/XP/Vista/7, assuming the BAT file is inside Mercurial's directory, use:

set PATH=%PATH%;%~dp0%

So, no more hardcoded paths.

Selina answered 7/1, 2010 at 18:33 Comment(2)
Ya, we noticed the previous code was kind of un-portable but we fixed it. The code here looks different from ours though, what exactly does %~dp0% do/stand for?Aesthetically
The above's pretty good, actually. That crazy %~dp0% basically evaluates to the path of the currently running bat fileCulhert
C
25

Say your flash drive was drive G: and your Mercurial executables are in G:\mercurial

Open a command prompt and enter:

set PATH=%PATH%;G:\mercurial

Proceed to use hg as normal

This should work, in theory. If you're on a *nix computer, you would do something like this (given /media/FLASHDRIVE is the path to your flash drive):

export PATH=$PATH:/media/FLASHDRIVE/mercurial

Hope that helps!

EDIT

In response to the comment below:

@ECHO OFF
REM Mercurial enabler :)
set PATH=%PATH%;G:\mercurial
cmd.exe

Should do it :)

Culhert answered 15/12, 2009 at 0:12 Comment(2)
That worked! Thanks but got another question! Is there any way to incorporate that into a .bat file so I'd just open that and have it open command prompt and run that at the same time?Aesthetically
You sir, are an instant winrar. Thank you and I greatly appreciate it!Aesthetically
D
23

download the tortoise hg .msi setup

msiexec /a tortoisehg-1.1.4-hg-1.6.4-x64.msi /qb TARGETDIR=f:\hg-temp

it will extract the tortise hg files to f:\hg-temp path,

goto f:\hg-temp\PFiles\TortoiseHg and copy it to F:\hg

Delete f:\hg-temp\PFiles\TortoiseHg

Then add f:\hg to your path

set PATH=%PATH%;f:\hg

(f:\ is your flash drive)

Diocese answered 9/10, 2010 at 7:13 Comment(1)
I still use this method to produce a portable tortoisehg. One thing I would add is that if you don't have administrative rights, you can "advertise" the product to yourself, allowing you to unpack it. Just run msiexec /ju tortoisehg-(version).msi prior to the above.Tellurate

© 2022 - 2024 — McMap. All rights reserved.