mercurialとsshと私

2008/06/18 by demuyan · コメントする
カテゴリー: 日常 
  このエントリーを含むはてなブックマーク この記事をクリップ! コメントを見る

mercurialを使ってMacOS X(Tiger)にあるリモートリポジトリを取得するときに、いくつかの問題が発生した。 忘れないうちに内容と対策をメモしておく。

ssh接続でhg:command not find

ssh経由でmercurialのリモートリポジトリを更新と同じ現象が発生した。

1
 % hg clone ssh://user_name@xxx.xxx.xxx//home/xxxx/xxx

remote: zsh: command not found: hg abort: no suitable response from remote hg!abort: no suitable response from remote hg!

原因は、ssh経由のコマンドは$HOME/.xxxファイルを読んでくれない事。 対策としては、sshdのPermitUserEnvironmentをyesにして有効にし、サーバ側の$HOME/.ssh/environmentにPATHを記述しておくとよいみたい。

ということで、/etc/sshd_configを PermitUserEnvironment yes に変更して

1
% printenv | egrep '^PATH=' > ~/.ssh/environment

とenvironmentを作成した。 参考サイトはここ

x-mac-japaneseって何?

今度はabort: unknown encoding: X-MAC-JAPANESEなーんて言われてしまう。これはMacOS X特有の問題らしい。解決方法は

  • mercurialのソースコードを直接書き換える
  • 設定ファイルで文字のエンコード設定を指定する

の2つがあるみたい。今回はソースコードの書き換えで対応。

mercurialのソースコードを書き換える

util.pyにある

1
 _encoding = locale.getpreferredencoding() or 'ascii'

1
2
 #_encoding = locale.getpreferredencoding() or 'ascii'
  _encoding = 'utf-8'

と強制的に書き換える方法。 ま、今回はutf-8しか使うつもりないからこれで十分。MacPortsからインストールした場合、util.pyは/opt/local/lib/python2.5/site-packages/mercurial/にある。

設定ファイルで文字エンコードを指定

こっちは試していないのだが、こういう方法もあるらしい。 $HOME/.hgrcに

1
2
3
4
5
6
7
8
9
10
[defaults]
 add = --encoding=utf-8
 clone = --encoding=utf-8
 commit = --encoding=utf-8
 init = --encoding=utf-8
 pull = --encoding=utf-8
 push = --encoding=utf-8
 remove = --encoding=utf-8
 revert = --encoding=utf-8
 update = --encoding=utf-8

を追加する。

ソースコードを書き換えるのが嫌だという方はこちらをどうぞ。

こちらもあわせてどうぞ

Comments

コメントをどうぞ...





Trackback URL

Get Adobe Flash playerPlugin by wpburn.com wordpress themes