View
249
Download
0
Embed Size (px)
Citation preview
Revision Control
Контроль версий – процесс управления множественными версиями некоторого документа или документов.
Множество имен:– Revision Control (RCS)– Software Configuration Management (SCM)– Source Code Management– Source Code Control or Source Control– Version Control (VCS)
Так или иначе, это используют все
Но у многих это вызывает головную боль:– MyProject1 – MyProject.backup – MyProject.old – MyProject.oldest – …
Используйте адекватные задаче инструменты!
Плюсы
Отслеживает все изменения в проекте. Для каждого изменения известно:– Кто его сделал?– Зачем?– Когда?– Что именно было изменено?
Упрощает совместную разработку.
Плюсы (продолжение)
Помогает справиться с ошибками:– Всегда можно вернуться назад во времени– Поможет эффективно идентифицировать
момент, когда была внесена ошибка
Помогает одновременно работать над несколькими версиями проекта.
Базовые понятия
Repository Working copy Revision (changeset) Tag Trunk (default branch) Branch Check in (commit) Check out (update)
Quick start! Cloning existing project
$ hg clone http://selenic.com/hg mercurial-repo …$ cd mercurial-repo $ hg parents changeset: 6907:6dcbe191a9b5 tag: tip user: Matt Mackall <[email protected]> date: Mon Aug 18 16:50:36 2008 -0500 summary: Fix up tests
Quick start!Setting up new project
$ cd project/ $ hg init # creates .hg … # edit .hgignore$ hg status # show all non-ignored files $ hg add # add those 'unknown' files $ hg commit # commit all changes$ hg parents # see the current revision
Quick start!Sharing the changes
$ hg pull # update an existing repo
$ hg serve -n “My repo” # export your current repo via # HTTP with browsable
# interface on port 8000
$ hg push # push changes to a remote repo
Quick start!Getting help and info
$ hg version
$ hg help # list subcommands$ hg help init # get help on init subcommand$ hg help -v init # get even more info
$ hg log # view revision history$ hg parents # view working dir parents$ hg status # view working dir file status
Что почитать дальше?
http://mercurial.selenic.com/wiki/– http://mercurial.selenic.com/wiki/QuickStart– http://mercurial.selenic.com/wiki/Tutorial
http://hgbook.red-bean.com/read/
Step 1. Installation
Install mercurial– $ apt-get install mercurial – $ emerge mercurial
And confirm the installation– $ hg version
– version should be above 1.1
Step 2. Generating auth keys
Run:– $ ssh-keygen– this will generate two files:
~/.ssh/id_rsa - your private key~/.ssh/id_rsa.pub - your public key
Share generated public keys with me– for example, place the key into /tmp/<your_name>/
on parallels.nsu.ru server
Step 3. Customize Mercurial
I will add your public keys as trusted ones on server with repository– this will take several moments…
Meanwhile please setup your ~/.hgrc
# This is a Mercurial configuration file. [ui]
username = Firstname Lastname <[email protected]>
Step 4. Clone the repo
It’s easy:– $ hg clone ssh://[email protected]/chimera work
Let’s see what’s inside:– $ cd work/– $ ls -al – $ hg log – $ hg log -v -r 3 # -r 1 -r 4 # -r 2:3 # -r 82e5 #
– $ hg parents
Step 5. Fix the bug
Try to compile the project– $ make
Fix the bug by editing hello.c Commit changes
– $ hg status # review your changes– $ hg commit # don’t forget sensible comment!
– $ hg tip # here’s our commit
Step 6. Put changes back to server
First, receive possible changes from server!– $ hg incoming # see what will be pulled– $ hg pull
Update / resolve conflicts / do nothing– $ hg update # if working copy has no uncommited
# changes– $ hg heads # otherwise you end up with 2+ heads– $ hg merge # merge them, then commit!
Push merged changes back to server– $ hg push