作者:张华 发表于:2014-11-19
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
( http://blog.csdn.net/quqi99 )
精通git, 但不怎么熟悉bzr, 下面记录如何使用自己的分支进行开发, 然后合并到主分支的常用bzr命令.
Edit your ~/.ssh/config file (if one doesn't exist simply create a new one) and add the following:
Host bazaar.launchpad.net
IdentityFile ~/.ssh/phykey
User zhhuabj
1, creating my own copy of another branch, can see my branch in my launchpad https://code.launchpad.net/~xxxxx
bzr branch lp:~openstack-charmers/charms/trusty/quantum-gateway/next lp:~xxxx/charms/trusty/quantum-gateway/lpxxx
bzr merge lp:~openstack-charmers/charms/trusty/quantum-gateway/next
if there is conflict, bzr resolve
once you bzr merge, but not commit, if want to merge again, it will occur 'pending merge' by 'bzr status', can remove them by below commands.
bzr revert -r 86
bzr uncommit -r 86
bzr revert --forget-merge
2, pulling my own branch into local machine
bzr branch lp:~zhhuabj/charms/trusty/quantum-gateway/lp74646 quantum-gateway
3, Updaing my own branch from the main branch
cd quantum-gateway && bzr pull && bzr merge
bzr info
bzr pull --remember <>
4, local operation
bzr revert .pydevproject
bzr diff > diff
bzr commit -m 'modify MTU of tunnel nic more than 1500'
bzr push lp:~xxx/charms/trusty/neutron-openvswitch/mtu # --overwrite
5, merge local branch into main develop branch in launchpad.
develop branch, lp:~openstack-charmers/charms/trusty/nova-compute/next
stable branch, lp:charms/trusty/nova-compute
6, eg:
bzr branch lp:charm-helpers
nosetests -v tests
cat > msg << EOF
Commit Info
EOF
bzr merge lp:charm-helpers
bzr uncommit
bzr commit -F ./msg
bzr push lp:~xxxx/charm-helpers/lpxxxx --overwrite
#update the code if charm-helpers has been merged
bzr merge lp:charm-helpers
python ../charm-helpers/tools/charm_helpers_sync/charm_helpers_sync.py -c ./charm-helpers-hooks.yaml
7, 在bzr中使用ssh,需要 ~/.gitconfig文件中追加下列内容后,才能执行诸如命令: git clone lp:~xxx/+git/xxxxxx
$ cat ~/.gitconfig
[user]
email = <email>
name = <name>
[core]
editor = vim
[gitreview]
username = <lauchpd_id>
[url "git+ssh://<lauchpd_id>@git.launchpad.net/"]
insteadof = lp:
8, download k8s charm code by: charm pull cs:~containers/kubernetes-master , but it just download the code from the charm store, the real repo is https://github.com/juju-solutions/kubernetes/tree/master/cluster/juju/layers/kubernetes-master
9, create personal git repo in lp, and use lp to review code
git clone git+ssh://zhhuabj@git.launchpad.net/layer-snap
# 注意,这里有一个坑,下面链接不应该有+git,并且layer-snap必须和lp里实际的工程名字相同。
#如果有+git的话,提交PR时, 原本指定target是https://git.launchpad.net/layer-snap, 但它会自动变回~zhhuabj/+git/layer-snap:master
#并且可能会报这种错误”'~zhhuabj/+git/layer-snap:lp1847574 is not mergeable into layer-snap:master'“
# git remote add zhhuabj git+ssh://zhhuabj@git.launchpad.net/~zhhuabj/+git/layer-snap
git remote add zhhuabj git+ssh://zhhuabj@git.launchpad.net/~zhhuabj/layer-snap
git push --set-upstream zhhuabj master #https://code.launchpad.net/~zhhuabj/+git
git remote -v
git branch -a
git fetch --all
git fetch --all --prune
git checkout -b lp1847574
#modify lib/charms/layer/snap.py
git add -u
git commit -m 'test'
git commit --amend --author="Zhang Hua <joshua.zhang@canonical.com>"
git push --set-upstream zhhuabj lp1847574
# Propose for merging - https://code.launchpad.net/~zhhuabj/+git/layer-snap/+ref/lp1847574
target repository -> other: https://git.launchpad.net/layer-snap
target branch: refs/heads/master
#target repository -> other: ~openstack-charm-testers/xxxstack-bundles/+git/xxxstack-bundles
Reference
1, http://wiki.bazaar.canonical.com/zh/Bzr%E4%BB%8B%E7%BB%8D
2, http://www.ibm.com/developerworks/cn/aix/library/au-spunix_bazaar/
3, http://doc.bazaar.canonical.com/latest/en/mini-tutorial/
4, https://dev.launchpad.net/UsingMergeProposals
5, https://wiki.canonical.com/Launchpad/DogfoodingStackedLaunchpad