顯示具有 hg 標籤的文章。 顯示所有文章
顯示具有 hg 標籤的文章。 顯示所有文章

2013年6月25日 星期二

hg-svn 速度極慢的原因

簡短說明

使用 hg-svn 時, 底層需要操作 svn 的 python 模組。hg-svn 有封裝兩組不同的實作, 在 Ubuntu 下的套件分別是 python-subvertpy 和 python-subversion。記者要裝 python-subvertpy, 個人試用的感覺, 前者比後者快了百倍以上吧。

冗長苦水心得

每次用 hg-svn 更新一堆檔案時 (大概數十個左右), 不管是 push 還是 pull 都相當地久, 有時等上一小時都不會好, 但用 strace 看, 持續有些動靜, 但是不知道在做什麼。

原本以為這是 hg 和 svn 溝通的極限, 今天問一下 cmd 平時用 git-svn 速度如何, 結果 cmd 說沒特別感到慢過, 當場試了一下, 果真迅速無比。差點想跳糟到 git-svn 陣營, 更何況安裝容易, sudo aptitude install git-svn 就結束了。

回家後想想不太甘心, 就用老方法在 hg-svn 原始碼內塞 print 找看看瓶頸卡在那裡 (慢到這種程度不太可能是 CPU bound, 不適合用 perf 之類的工具找)。

雖然有找到瓶頸, 但是找得過程中發覺 hg-svn 使用兩個不同的模組作為 svn 的接口, 一個是我原本用 svnwrap/svn_swig_wrapper.py, 對應到 Ubuntu 的套件為 python-subversion。另一個是 svnwrap/subvertpy_wrapper.py, 對應到的套件為 python-subvertpy, 而且 hg-svn 優先使用 python-subvertpy

接著查 python-subvertpy:

$ aptitude show python-subvertpy
...
Description: Alternative Python bindings for Subversion
 Python bindings for the Subversion version control system. The aim of these bindings is to be fast, complete and to provide an API that feels native to Python programmers.
...

真相大白, 改用 python-subvertpy 後, 龜速更新的問題就好了。

2013-07-17 更新

今天疑似用了 hg mv 後踏到 subvertpy 的 bug, hg push 時出現 exception:

subvertpy.SubversionException: ("'...' path not found", 160013)

後來改回用 python-subversion 的套件就可正常 push。所以說提供兩種實作做為選擇, 還是有好處的, 至少一個不行時有個希望試看另一個。

2012年2月11日 星期六

使用 hg-svn

參照《WorkingWithSubversion - Mercurial》, 前置動作是要裝 python-subversion。用了一陣子覺得滿順的。不過得等 hg rebase --svn 出現 conflict, 看看有沒有無縫銜接 kdiff3 + resolve conflict, 才可以更放心使用。

2010年1月23日 星期六

在 Ubuntu 下裝 git 和 mercurial

我習慣用 aptitude 安裝, 基本上換用 apt-get 應該也沒問題, 兩者的基本參數一樣。

git

注意 package 名稱不是 git
  1. aptitude install git-core
可以用 "aptitude search git" 找到含有 git 字樣的 package, 再用 "aptitude show X" 了解細節, 找出正確的 package。

Mercurial

hg resolve ( merge 失敗時會用到這個指令, 必備指令) 是 2008/12 才有的功能, mercurial v1.1 後才有 , 但 Ubuntu 8.04 的 Mercural 是 0.9.5-3, 所以得用 easy_install 裝新版的 Mercurial。作法:
  1. sudo aptitude install python2.5  # 或 2.6
  2. sudo aptitude install python-dev libc6-dev
  3. sudo aptitude install python-setuptools # or install easy_install's egg
  4. sudo easy_install -U mercurial
  5. hg --version  # 查看版本
接著安裝 bash completion, 這樣打 "hg " 後就可以按 tab 補指令, 如同平時用 bash 指令一般:
  1. sudo aptitude install bash-completion
  2. mkdir ~/.hg_files
  3. wget http://jucr.opensolaris.org/files/1166/3597/ext-source/bash-completion-hg -O ~/.hg_files/bash-completion-hg
  4. echo "source ~/.hg_files/bash-completion-hg" >> ~/.bashrc
我不知道「官方」版的 bash-completion-hg 放那, 這個是我 google "mercurial bash completion" 找到的。

    在 Fedora 下裝 id-utils

    Fedora 似乎因為執行檔撞名,而沒有提供 id-utils 的套件 ,但這是使用 gj 的必要套件,只好自己編。從官網抓好 tarball ,解開來編譯 (./configure && make)就是了。 但編譯後會遇到錯誤: ./stdio.h:10...