简体   繁体   English

在 Ubuntu 上安装 Mercurial 的正确方法

[英]Correct way to install Mercurial on Ubuntu

I am kind of new to both, Mercurial and Ubuntu.我对 Mercurial 和 Ubuntu 都很陌生。

I seem to have awkwardly installed a few other software packages already, so I wanted to see how others would go about doing this.我似乎已经笨拙地安装了一些其他软件包,所以我想看看其他人会怎么做。

Should I use the apt-get command?我应该使用 apt-get 命令吗? If so, how would I use it in this case?如果是这样,在这种情况下我将如何使用它? Where is the best place to install Mercurial on my file system, and how do I make it part of my shell (I am thinking svn-ish) so I can properly check things in and update?在我的文件系统上安装 Mercurial 的最佳位置在哪里,我如何使它成为我的 shell 的一部分(我在想 svn-ish),以便我可以正确地检查和更新?

Thanks, Alex谢谢,亚历克斯

Just use:只需使用:

sudo apt-get install mercurial

It should install it in the default folder and update your environment variables correctly.它应该将其安装在默认文件夹中并正确更新您的环境变量。 then you should be able to use 'hg' from the command line, just like svn, although Hg is a much better source control tool.那么您应该能够从命令行使用 'hg',就像 svn 一样,尽管 Hg 是一个更好的源代码控制工具。

NEW ANSWER新答案

Previously I was pointing to TortoiseHG PPA, which also contained Mercurial.之前我指的是 TortoiseHG PPA,其中也包含 Mercurial。 For now (year 2015) the more recent version of Mercurial is in another PPA, specific for Mercurial only.目前(2015 年)最新版本的 Mercurial 位于另一个 PPA 中,仅适用于 Mercurial。

Important note: this version is incompatible with TortoiseHG, and Tortoise will be REMOVED, if you install the more recent Mercurial!重要提示:此版本与 TortoiseHG 不兼容,如果您安装更新的 Mercurial,Tortoise 将被删除!

If you don't care of Tortoise and just want more recent Mercurial package, use next command to install:如果您不关心 Tortoise 并且只想要更新的 Mercurial 包,请使用下一个命令进行安装:

sudo add-apt-repository -y ppa:mercurial-ppa/releases
sudo apt-get update
sudo apt-get install -y mercurial

However, this won't give you the absolutely latest version either.但是,这也不会为您提供绝对最新的版本。 To enjoy the latest version, you may want to install it via PIP:要享受最新版本,您可能需要通过 PIP 安装它:

sudo apt-get install -y python-pip python-dev
sudo pip install mercurial --upgrade

This would give you the very latest version (3.6.2 vs 3.3.2 from the PPA).这将为您提供最新版本(来自 PPA 的 3.6.2 与 3.3.2)。 Seems this one is also not compatible with TortoiseHG from the repos.似乎这个也与存储库中的 TortoiseHG 不兼容。


OLD ANSWER旧答案

Though available from default repos, the version there is outdated.尽管可以从默认存储库中获得,但那里的版本已经过时。 At the time of writing: 2.2.2 vs 2.5.2.在撰写本文时:2.2.2 与 2.5.2。 So I would recommend to use the PPA:所以我建议使用 PPA:

sudo add-apt-repository -y ppa:tortoisehg-ppa/releases
sudo apt-get update
sudo apt-get install mercurial tortoisehg

TortoiseHG is not required, but is recommended. TortoiseHG 不是必需的,但建议使用。

Yeah you can install it by just是的,你可以安装它

sudo apt-get install mercurial

but for me it gave very old version (2.0.2).但对我来说,它提供了非常旧的版本(2.0.2)。 You can check this by hg version .您可以通过hg version进行检查。 To get the newer version you can do要获得较新的版本,您可以这样做

sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U mercurial

Now I have 3.0.1 version现在我有 3.0.1 版本

aniket@ubuntu:~$ hg version
Mercurial Distributed SCM (version 3.0.1)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2014 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

More details : Installing Mercurial on Linux更多细节: 在 Linux 上安装 Mercurial

PS: Above link goes to my personal blog which has additional details. PS:以上链接转到我的个人博客,其中包含更多详细信息。

Mercurial is available from the Universe repositories. Mercurial 可从 Universe 存储库中获得。 Enable that repository in USC if it's not already enabled.如果尚未启用,请在 USC 中启用该存储库。 Then just type the following into a terminal.然后只需在终端中键入以下内容。

sudo apt-get install mercurial

The configuration file is saved in /etc/mercurial/hgrc You can configure mercurial by editing that file.配置文件保存在 /etc/mercurial/hgrc 您可以通过编辑该文件来配置 mercurial。 To open that file in gedit type the following command要在 gedit 中打开该文件,请键入以下命令

sudo gksudo gedit /etc/mercurial/hgrc

If you are using an older version of Ubuntu (12.04 perhaps?), use the Mercurial PPA .如果您使用的是旧版本的 Ubuntu(也许是 12.04?),请使用Mercurial PPA

sudo add-apt-repository ppa:mercurial-ppa/releases
sudo apt-get update
sudo apt-get install mercurial

As of this writing, this installs mercurial 3.0.1 on Ubuntu 12.04 for example.在撰写本文时,这会在 Ubuntu 12.04 上安装 mercurial 3.0.1。

just to let everyone know,只为让大家知道
sudo apt-get install mercurial
is delivering version 3.0.1 (latest as the time of writing this post)正在交付 3.0.1 版(截至撰写本文时最新)
so no need to try other stuff as this is everything you'll need.所以无需尝试其他东西,因为这就是您所需要的一切。

The Mercurial version in the Ubuntu repository is relatively old. Ubuntu 存储库中的 Mercurial 版本相对较旧。 I tried to use the PPA, to get more recent version.我尝试使用 PPA,以获得更新的版本。 But Ubuntu complains that "The repository ... does not have a Release file" and disables it.但是 Ubuntu 抱怨“存储库......没有发布文件”并禁用它。 Then I used alternative way to install latest Mercurial version:然后我使用替代方法来安装最新的 Mercurial 版本:

sudo pip3 install mercurial --upgrade

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM