2014年5月2日 星期五

世代交替

漸漸感受到世代交替的重要性,公司(政府)能不能轉型,往往在於是否改革方能用新的方式 ,作法或技術來處理同樣的問題。

如果還是想拿舊的方式,態度面對新的產業,有時直接會被產業淘汰掉,淘汰的速度比較像是溫水煮青蛙,慢慢的但你發現時已經無力回天。

工程技術人員也一樣,如果只是在公司把事情完成,沒有嘗試與其他技術人員交流,尤其是新創公司的開發者,他們往往會用新的技術與工具來加速開發,等到你想換另一份工作時,就會發現怎麼產業完全不同,自己會的東西已經沒有需求!


看到50多歲還能在矽谷打拼的工程師,真的是不簡單!希望自己到那年紀還能有這樣的熱誠,但口袋可以麥可麥克!

2014年5月1日 星期四

Git and git-p4

Perforce is great source version tool for owner of company, because it's centralize control and can track each client behavior. But I don't like it anymore.
So I used Git to manage my local repo that is sync from perforce server. Use git to track my local commits and use p4/p4v to submit changes to Perforce server. But the work flow will complex and waste time(file always locks to read only with p4).

Few couple months passed, I found the tool git-p4 that can manage p4 repo like remote git branch. That similar like git-svn tool (git 與 git-svn 簡單教學)

The git-p4 is wrote by python and it integrates to git source tree. you need turn off the compile flag(ON_PYTHON) when you compiling git. In official build on git website, the NO_PYTHON is enable, so you can't use it with git-p4.

$ git p4
fatal: git was built without support for git-p4 (NO_PYTHON=1).

Please clone the git and switch to tag v1.9.2
$ git clone https://github.com/git/git
$ git checkout v1.9.2 -b v1.9.2

Follow INSTALL document to compile and install git, Please make sure the python already install in your environment (NO_PYTHON will turn OFF when you compile)
$ make prefix=/usr all 
$ sudo make prefix=/usr install

Check your git and git-p4 are ready to use

$ git --version
git version 1.9.2

$ git-p4
usage: /usr/bin/git-p4  [options]

valid commands: clone, rollback, debug, commit, rebase, branches, sync, submit

Try /usr/bin/git-p4  --help for command specific help.

Add p4 alias to your ~/.gitconfig

[alias]
    p4 = !/usr/bin/git-p4

Don't forget your p4 command and environemnt

$ export P4CLIENT=[your_client_name]
$ export P4HOST=[perforce_server_ip]:1666
$ export P4USER=[login_user_name]
$ export P4EDITOR=vim


Now, you can clone a proj from perforce.

# Clone a repository and covert all change list to git log
$ git p4 clone //depot/path/project@all myproject

# Clone a repository without log
$ git p4 clone //depot/path/project myproject
  
# Do some work and commit to your local git repo
$ git add foo.py
$ git commit foo.py
# Submit your local commit to remote repo (Perforce server)
# git p4 will create a change list for commit
$ git p4 submit

# Synchronize with Perforce (almost like 'git fetch' and 'get pull')
$ git p4 rebase
All done, enjoy it! :)