• Tidak ada hasil yang ditemukan

New Ze Local Repository Network Working A Copy versity of Auck Local Working C “Central”

N/A
N/A
Protected

Academic year: 2023

Membagikan "New Ze Local Repository Network Working A Copy versity of Auck Local Working C “Central”"

Copied!
25
0
0

Teks penuh

(1)

/2012 73208/03/COMPSCI

Lab:

M i l

ealand

Mercurial

kland | New Zeversity of Auckv

1

(2)

First: Recap

/2012

p

• Distributed Version control

73208/03/COMPSCI ealandkland | New Zeversity of Auckv

(3)

Distributed V rsi n C ntr l

/2012

Version Control

All developers have their own local repository

73208/03/

(a.k.a. “decentralized version control”) 1. Developers work on their working copy

COMPSCI

2. Developers commit changes of the working copy to their own local repository first

ealand

3. Changes can be exchanged between repositories (“pushed” and “pulled”)

kland | New Ze

Local Repository

Network Working

A Copy

versity of Auck

Local Working

C “Central”

B

v Local

Repository

Copy Central

Repository

B

(4)

Push and Pull

/2012

Push

• Once developers have committed versions on their

l l it th h th t th

73208/03/

local repository, they can push them to another repo

• Versions are pushed from local branches into corresponding remote branches

COMPSCI

p g

• Like “commit” from one repo to another Pull

ealand

• Latest versions are pulled from remote branches and put into the corresponding local branches

• Like “update” from one repo to another

kland | New Ze Like update from one repo to another

Local Repository

Network Working

A Copy

versity of Auck Repository

L l py

Working

“C t l”

v Localg

Copy “Central”

B

(5)

Distributed V rsi n C ntr l

/2012

Version Control

• Local and remote repositories are technologically

73208/03/

identical.

• Chaining of repositories is possible.

COMPSCI

• Several personal repositories can be used:

• Good for testing of new commits:

ealand

• one repo for development, one for staging

kland | New Ze

Local Repository

Network Working

A Copy

versity of Auck

Local Working

C “Central”

v Local

Repository

Copy Central

Repository

(6)

Mercurial

/2012 • Open-source project, started around 2005

73208/03/ j

• Used for many open-source projects

COMPSCI • Every developer has a repository, which is a folder

• Repo folder contains working copy,

ealand

p g py,

and a subfolder .hg which contains the version data

• Versions are identified locally by natural numbers

kland | New Ze

and globally by hash values,

e.g. 5c240805ac2d9530b780cbd514574af398c0cdd6

G d l (T i H )

versity of Auck

• Good tool support (TortoiseHg)

• Fairly easy to use

v

(7)

Working with Hg

/2012

g g

1. Start by cloning existing repo, or creating new one

73208/03/ y g g p , g

– New repo has only “default branch” (like trunk)

– After cloning you have local copies of all branches

COMPSCI

f g y p f

of parent repo

2. Modify working copy and commit to create new

ealand

y g py

versions in your local repo

3. Pull to load new versions from parent repo into local

kland | New Ze

repo

– Does not change working

versity of Auck

copy

– Pulled versions are

put in separate branch

v put in separate branch

from your local versions 7

(8)

Most important tool: Tortoise xpl r r

/2012

explorer

• Integrated

73208/03/ g

control GUI for mercurial

COMPSCI

• In some of the lab tasks you are asked to explore the

ealand

to explore the

functions a bit on your own and figure

kland | New Ze your own and figure

out how certain things work!

versity of Auck

• After all, every GUI is intuitive, right?

v

(9)

commit

/2012 • Creates a new version on

h l l

73208/03/

the local repository.

• Best practices:

COMPSCI

• Always review your changes!

M k t dd

ealand

• Make sure to add new (a.k.a. untracked)

files

kland | New Ze files.

• One commit should be only one logical

versity of Auck be only one logical

change.

• Never break the build!

v

• Never break the tests. 9

(10)

Hg Pull

/2012

g

Pull regularly to stay up to date.

H itt d l l i

73208/03/

Have you committed local versions on some branch?

1 If no you can update to the latest

COMPSCI

1. If no, you can update to the latest pulled version

– Changes in working copy are

ealand

– Changes in working copy are merged with pulled version – Unless you choose to

kland | New Ze Unless you choose to

“discard local changes”

2. If you have committed local versions

versity of Auck f y

on some branch, they should be merged with pulled versions on

b h

v same branch

(11)

Lab Setup

/2012

p

• Create one repo: repo1

73208/03/ p p

• Create one file in the working copy of repo1

• Add it to version control, can you figure out how?

COMPSCI

, y f g

• Commit it.

• Clone the repo: repo2

ealand

Clone the repo repo2

kland | New Zeversity of Auckv

11

(12)

Lab Task 1

/2012 • Change a file in the working copy of repo1

73208/03/ g g py p

• Commit to repo1.

• What is on repo2?

COMPSCI

p

• Pull on repo 2. What do you see?

• Update on repo 2

ealand

Update on repo 2

kland | New Zeversity of Auckv

(13)

Hg Push

/2012

g

Push regularly to integrate your changes.

73208/03/ g y g y g

Have others committed versions on a remote branch that you have committed to locally?

COMPSCI

1. If no, push will succeed and the local versions will be in the remote repo

ealand

2. If yes, i.e. others have committed versions on a branch you have

itt d t l ll

kland | New Ze committed to locally:

– You need to merge your versions with their versions

versity of Auck with their versions

– When local branches and corresp.

remote branches are merged

v remote branches are merged,

push succeeds 13

(14)

Lab Task 2

/2012 • Change something in the working copy of repo2.

73208/03/ g g g py p

• Commit to repo2

• What is on repo1?

COMPSCI

p

• Push in repo 2 to repo1. What do you see?

ealandkland | New Zeversity of Auckv

(15)

Lab Task 3

/2012 • Change a file in the working copy of repo1

73208/03/ g g py p

• Commit to repo1.

• Change a different file in the working copy of repo2.

COMPSCI

g ff f g py f p

• Commit to repo2

• Pull on repo 2. What do you see?

ealand

Pull on repo 2. What do you see?

• Push in repo 2 to repo1. What happens?

kland | New Zeversity of Auckv

15

(16)

Lab Task 4

/2012 • Reproduce the conflict from Lab task 3:

73208/03/ p

• Use “merge” on repo2, applying it to the two latest commits. Can you figure out how to do that?

COMPSCI

• Push in repo 2 to repo1. What happens?

ealandkland | New Zeversity of Auckv

(17)

Lab Task 5

/2012 • Change a file in the working copy of repo1

73208/03/ g g py p

• Commit to repo1.

• Change a different file in the working copy of repo2.

COMPSCI

g ff f g py f p

• Pull on repo 2. What do you see?

• Update, using “merge local changes”

ealand

Update, using merge local changes

• Now commit on repo2.

• Push in repo 2 to repo1 What happens?

kland | New Ze Push in repo 2 to repo1. What happens?

• What is the difference in the version space to lab task 4?

versity of Auckv

17

(18)

Lab Task 6

/2012 • Change a file in the working copy of repo1

73208/03/ g g py p

• Commit to repo1.

• Change a different file in the working copy of repo2.

COMPSCI

g ff f g py f p

• Commit to repo2 under a named branch tryout

• Pull on repo 2. What do you see?

ealand

Pull on repo 2. What do you see?

• Push in repo 2 to repo1. What happens?

• What is the difference to before?

kland | New Ze What is the difference to before?

versity of Auckv

(19)

Lab Task 7

/2012 • Reproduce the final situation of Lab Task 6:

73208/03/ p

• Use merge on repo2, on default branch and tryout branch

COMPSCI

• Push in repo 2 to repo1. What happens?

• Compare with Lab Task 4

ealand

p

kland | New Zeversity of Auckv

19

(20)

Extensions Tab

/2012 73208/03/COMPSCI ealandkland | New Zeversity of Auckv

(21)

Extensions

/2012 • Transplant: Moving a commit from one branch to

another

73208/03/ another

• Strip: deleting one or several commits on a local repository

COMPSCI

repository.

ealandkland | New Zeversity of Auckv

21

(22)

Lab Task E1

/2012 • Reproduce the conflict from Lab task 3:

73208/03/ p

• Strip one head. Can you figure out how to do that?

• Push in repo 2 to repo1. What happens?

COMPSCI

p p pp

• Stripping changes is NOT the standard way to deal with conflicts, the standard way is merging.

ealand

y g g

kland | New Zeversity of Auckv

(23)

Lab Task E2

/2012 • Reproduce the conflict from Lab task 3:

73208/03/ p

• Transplant one head to the other branch. Can you figure out how to do that?

COMPSCI

• Strip one head, which one makes sense?

• Push in repo 2 to repo1.

ealand

p p

• Compare with merging.

kland | New Zeversity of Auckv

23

(24)

Work routine for committing

/2012

g

• If you think you are ready to commit

73208/03/ y y y

1. Run tests. If they fail, do not commit 2. Pull commits

COMPSCI

mm

3. If there are changes, update to the latest commit, back to 1.

ealand

4. Check all files that need to be committed.

5. Commit

kland | New Ze

6. Push (this is crucial, commit alone doesnt make it available for others.

versity of Auckv

(25)

Version Control Best Practices

/2012

Best Practices

1. Complete one change at a time and commit it

73208/03/

If you committing several changes together you cannot undo/redo them individually

If you don’t commit and your hard disk crashes

COMPSCI

If you don t commit and your hard disk crashes…

Continuous integration (see XP)

2. Only commit changes that preserve system integrity

ealand

y g p y g y

No “breaking changes” that make compilation or tests fail 3. Commit only source files (e.g. not .class files)

kland | New Ze

4. Write a log entry for each change What has been changed and why 5 Communicate with the other developers

versity of Auck 5. Communicate with the other developers

See who else is working on a part before changing it Discuss and agree on a design

v

25

g g

Follow the project guidelines & specifications

Referensi

Dokumen terkait

There are two versions of the community response to the application of health protocols during the pandemic, among others: some of the public apply health protocols

Abstract – The purpose of this paper is to introduce the variable of Travel Motivation (TRMT), Travel Constraints (TCON), and Destination Image (DI) with Push-Pull Motivation