Chimera - nsu.ru
Download
Report
Transcript Chimera - nsu.ru
Chimera
(22.07.10)
Системы Контроля Версий
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)
Что такое репозиторий?
VCS vs. DVCS
VCS
–
–
–
CVS
Subversion
Perforce
DVCS
–
–
–
Git
Mercurial
Bazaar
Mercurial
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
…
$ hg status
$ hg add
$ hg commit
$ hg parents
#
#
#
#
#
#
creates .hg
edit .hgignore
show all non-ignored files
add those 'unknown' files
commit all changes
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
$ hg help init
$ hg help -v init
# list subcommands
# get help on init subcommand
# get even more info
$ hg log
$ hg parents
$ hg status
# view revision history
# view working dir parents
# 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/
Mercurial Tutorial
Alternative: TortoiseHG
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
~/.ssh/id_rsa.pub
- your private key
- 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]/hello2 work
Let’s see what’s inside:
–
$
$
$
$
–
$ hg parents
–
–
–
cd work/
ls -al
hg log
hg log -v -r 3
# -r 1 -r 4 # -r 2:3 # -r 82e5 #
Step 5. Fix the bug (obsolete )
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!
–
–
# see what will be pulled
Update / resolve conflicts / do nothing
–
$ hg update
–
$ hg heads
$ hg merge
–
$ hg incoming
$ hg pull
#
#
#
#
if working copy has no uncommited
changes
otherwise you end up with 2+ heads
merge them, then commit!
Push merged changes back to server
–
$ hg push
Hm…