我只知道工作区是一个对象,它将服务器中的一组文件映射到用户文件系统上。
之前用过git,还不太懂流的概念。它和git中的分支一样吗?那么你将如何向 Git 用户解释流?
我只知道工作区是一个对象,它将服务器中的一组文件映射到用户文件系统上。
之前用过git,还不太懂流的概念。它和git中的分支一样吗?那么你将如何向 Git 用户解释流?
如果您已经熟悉 Perforce 的文件间分支系统(即 Perforce 中的每个“分支”是软件仓库中一组不同的文件),那么很容易将流理解为自动为您管理的分支。流定义了分支所在的 depot 目录、该分支的工作区视图是什么样的,以及更改如何传播到其他分支。(在非托管的“经典”分支中,这些概念存在于每个分支中,但并未正式化;流为所有这些操作提供了一层语法糖和流程执行。)
如果您完全不熟悉 Perforce 并且来自git
,是的,最简单的心理映射是“stream = branch”。使用p4 switch -c NEWBRANCH
代替git checkout -b NEWBRANCH
,和p4 switch BRANCH
代替git checkout BRANCH
。
这是一个演示(从头开始p4 init
)创建一个新流,对其进行更改,然后将该更改合并回主线:
C:\Perforce\test4>p4 init -C1 -n
Server bob-dvcs-1592407491 saved.
C:\Perforce\test4>p4 switch -l
main *
C:\Perforce\test4>echo "here's a test file" > foo
C:\Perforce\test4>p4 add foo
//stream/main/foo#1 - opened for add
C:\Perforce\test4>p4 submit -d "my first file!"
Submitting change 1.
Locking 1 files ...
add //stream/main/foo#1
Change 1 submitted.
C:\Perforce\test4>p4 switch -c dev
dev
C:\Perforce\test4>p4 switch -l
dev *
main
C:\Perforce\test4>p4 edit foo
//stream/dev/foo#1 - opened for edit
C:\Perforce\test4>echo "a change" >> foo
C:\Perforce\test4>p4 submit -d "my first edit!"
Submitting change 3.
Locking 1 files ...
edit //stream/dev/foo#2
Change 3 submitted.
C:\Perforce\test4>p4 filelog foo
//stream/dev/foo
... #2 change 3 edit on 2020/06/17 by bob@bob-dvcs-1592407491 (text) 'my first edit!'
... ... copy into //stream/main/foo#2
... #1 change 2 branch on 2020/06/17 by bob@bob-dvcs-1592407491 (text) 'Populate //stream/dev.'
... ... branch from //stream/main/foo#1
C:\Perforce\test4>p4 switch main
C:\Perforce\test4>cat foo
"here's a test file"
C:\Perforce\test4>p4 merge --from dev
//stream/main/foo#1 - integrate from //stream/dev/foo#2
... must resolve content from //stream/dev/foo#2
C:\Perforce\test4>p4 resolve -am
c:\Perforce\test4\foo - merging //stream/dev/foo#2
Diff chunks: 0 yours + 1 theirs + 0 both + 0 conflicting
//bob-dvcs-1592407491/foo - copy from //stream/dev/foo
C:\Perforce\test4>p4 submit -d "my first merge!"
Submitting change 4.
Locking 1 files ...
integrate //stream/main/foo#2
Change 4 submitted.
C:\Perforce\test4>cat foo
"here's a test file"
"a change"
C:\Perforce\test4>p4 filelog foo
//stream/main/foo
... #2 change 4 integrate on 2020/06/17 by bob@bob-dvcs-1592407491 (text) 'my first merge!'
... ... copy from //stream/dev/foo#2
... #1 change 1 add on 2020/06/17 by bob@bob-dvcs-1592407491 (text) 'my first file!'
... ... branch into //stream/dev/foo#1