Perforce

From 탱이의 잡동사니
Revision as of 08:24, 9 May 2016 by Pchero (talk | contribs)
Jump to navigation Jump to search

Overview

형상 관리 툴 Peforce(p4) 사용법 정리.

Installation

아래 링크에서 다운받아서 사용하면 된다. 별도의 컴파일 작업이 필요하지 않다.

https://www.perforce.com/ko/downloads/helix

Environment variables

perforce 는 내부적으로 여러가지 환경 변수들을 가지고 있다. 이 환경변수를 수정함으로써, 기본접속 서버와 클라이언트등을 변경할 수 있다. 자세한 내용은 이곳<ref>http://www.perforce.com/perforce/doc.current/manuals/cmdref/envars.html</ref>에서 찾을 수 있다.

Settings

export 명령이 아닌, p4 명령어 set 를 이용해도 환경변수 설정과 확인이 가능하다.

$ p4 set P4CLIENT=client1
$ p4 set P4CLIENT
P4CLIENT=client1

Crucial variables

  • P4CLIENT
Name of current client workspace.

P4PORT

P4PASSWD

P4USER

Useful variables

P4CONFIG

P4DIFF

P4EDITOR

P4MERGE

P4CHARSET

P4TRUST

Esoteric variables

P4PAGER

PWD

TMP, TEMP

P4TICKETS

P4LANGUAGE

P4LOGINSSO

P4COMMANDCHARSET

P4DIFFUNICODE

P4MERGEUNICODE

P4CLIENTPATH

Server variables

P4AUDIT

P4JOURNAL

P4LOG

P4PORT

P4ROOT

P4DEBUG

P4NAME

P4SSLDIR

Commands

공통

perforce command 사용시 공통적으로 적용되는 사항 정리.

디렉토리

perforce 에서는 빈 디렉토리는 생성/변경/삭제가 불가능하다. 만약 디렉토리 내에, 파일이 하나도 없다면 해당 디렉토리는 자동으로 사라지게 된다.

...

만약 디렉토리내의 모든 파일을 선택해야 한다면, '...' 을 사용하면 된다.

help

도움말 내용을 보여준다. simple 입력시 자주 사용되는 명령어의 간단한 쓰임새를 보여준다. 자세한 명령어의 도움말을 보고자 한다면 p4 help <command> 를 입력하면 된다. 사용 가능한 모든 명령어를 보고자 할 때는, "p4 help commands" 를 입력하면 된다.

$ p4 help simple

    Most common Perforce client commands:

	client     Create or edit a client workspace specification and view

	add        Open files for adding to the depot
	edit       Open existing files for editing
	delete     Open existing files for removal from the depot
	opened     List open files 

	update     Update files in the current client workspace 
	resolve    Resolve updates to open workspace files

	submit     Submit open files to the depot
	revert     Revert open files and restore originals to workspace

branch

branch -- Create, modify, or delete a branch view specification 브랜치를 생성하고, 수정 및 삭제한다. 하지만 편의상 populate 옵션을 더 많이 사용한다.

$ p4 branch [-f] name
$ p4 branch -d [-f] name
$ p4 branch [ -S stream ] [ -P parent ] -o name
$ p4 branch -i [-f]

populate

populate -- Branch a set of files as a one-step operation 여러개의 파일들을 한번에 Branching 한다.

$ p4 populate [options] fromFile[rev] toFile
$ p4 populate [options] -b branch [-r] [toFile[rev] ...]
$ p4 populate [options] -b branch -s fromFile[rev] [toFile ...]
$ p4 populate [options] -S stream [-P parent] [-r] [toFile[rev] ...]
$ p4 populate -o <source>/... <destination>/...

$ p4 populate -o //depot/devel/sample/DEVELOP/... //depot/devel/sample/FEATURE_sample_test/...

-o

populate 명령어로 생성되게 되는 파일들의 항목들을 보여준다.

integrate

integrate -- Integrate one set of files into another

$ p4 integrate [options] fromFile[revRange] toFile
$ p4 integrate [options] -b branch [-r] [toFile[revRange] ...]
$ p4 integrate [options] -b branch -s fromFile[revRange] [toFile ...]
$ p4 integrate [options] -S stream [-r] [-P parent] [file[revRange] ...]

delete

지정된 파일을 삭제한다. 사실, perforce 에서는 파일 삭제가 없다. 단지 앞으로의 버전 컨트롤에서 제외될 뿐이다.

$ p4 delete [-c changelist#] [-n -v -k] file ...

-n 파일 삭제시 나타나게 될 결과를 표시한다. 실제로 파일을 삭제하지는 않는다.

-k client 에 설치된 파일의 변경없이 server에 있는 파일만을 삭제한다. 만약 서버와 클라이언트 간의 파일 불일치가 발견되면 경고를 표시한다.

-v 아직 sync 되지 않은 파일도 같이 삭제할 수 있도록 한다.

client

client 설정을 확인/수정 한다.

View 항목에 명시되어 있지 않은 디렉토리는 동기화되지 않는다. 만약 perforce 설정 이후, 특정 디텍토리가 동기화되지 않는다면, View 항목을 먼저 확인하자.

Client: stk_pbxdevelopment

Update: 2015/10/13 14:14:25

Access: 2015/10/13 14:12:39

Owner:  stk

Host:   test.pchero21.com

Description:
        Created by stk.

Root:   /home/stk

Options:        noallwrite noclobber compress unlocked nomodtime rmdir

SubmitOptions:  submitunchanged

LineEnd:        local

View:
        //depot/devel/helloworld/... //stk_pbxdevelopment/depot/devel/helloworld/...

changes, changelists

현재 위치한 디렉토리에서의 변경 내역을 보여준다. change 와 changeslists 는 모두 같은 옵션이다.

-m

단순히 p4 changes 를 입력하면 모든 변경 이력을 보여준다. -m 옵션 사용시 가장 최근에서부터 -m <count> 개 까지의 변경이력만을 보여준다.

$ p4 changes -m 1
Change 1692 on 2015/10/23 by pchero@pchero_dev 'Changed tmp file name path.'

-l, -L

변경이력의 상세 내용을 표시한다. 기본적으로 changes 옵션 사용시, 변경 이력의 제일 윗줄만을 표시한다. -l 옵션 사용시, 변경 이력의 상세 내용을 모두 확인할 수 있다. -L 옵션은 -l 옵션 내용과 같으나, 최대 250자 까지의 내용만을 표시한다.

clean

모든 submit되지 않은 변경 이력들을 원본으로 되돌린다.

$ p4 clean

깔끔히 정리하고 싶을 때 사용하면 좋다. 하지만.. rm -rf 명령어와 같은 힘을 지니고 있으므로 사용시 정말 조심해야 한다...

revert

변경/수정 된 내용을 다시 이전으로 되돌린다.

-a

Edit/Integrate/Unchanged/Missing 상태인 파일들만 이전상태로 복구한다. Integration pending 상태의 파일은 Open 상태로 남게된다.

-k

파일을 복구하는 것이 아닌, open 상태가 아닌것으로 변경한다. 즉, 파일에는 수정된 내용이 그대로 남아있지만 perforce 메타 데이터가 사라진 상태가 된다. 이후, p4 edit <filename> 을 하게 되면 수정된 내용을 그대로 살릴 수 있다. 혹은 p4 status 명령어로 현재 변경된 파일 목록을 확인할 수도 있다.

-c

특정 changelist 버전으로 되돌린다.

sync, flush, update

Client 를 서버 저장소와 동기화시킨다. flush 와 update 는 sync 와 다른 옵션과의 조합이다.

  • flush : sync -k
  • update : sync -s

ETC

Change the client(workspace) name

기본적으로, perforce에서 client(workspace) 이름을 변경할 수는 없다. 굳이 client 를 변경하고 싶다면, 다른 client 를 생성 후, 해당 client로 변경 뒤, 기존의 client 를 삭제하는 방법을 써야 한다.<ref>http://answers.perforce.com/articles/KB/3428</ref>

Problem	

How do I rename a client workspace?
Solution	
Perforce does not provide a rename mechanism for client workspaces. However, if a user does not have any files checked out the following procedure can be used to create a new workspace using the same specifications as the old one and update the server's meta data.

1. Use the old workspace as a template to create a new one.

p4 client -t old-workspace new-workspace

Double check that the Root: is the same for the old and new workspace.

2. Update the server metadata with the revisions synced to the new workspace.

p4 -c new-workspace sync -k @old-workspace

3. Check the list of files synced to the new client workspace.

p4 -c new-workspace have

4. Delete the old client workspace.

p4 client -d old-workspace

References

<references />