具有增量本地Perforce SCL(类似于Git)的单个文件

huangapple go评论42阅读模式
英文:

Have incremental local perforce scls similar to git for a single file

问题

考虑我有一个名为developers.txt的文件。
我想要做的是(而且我可以在git中很好地完成这个任务)
有3-4个提交,每个提交添加1行。

commit 2ad54bfe954006bafcb209f06ac0c12091d297c8 (HEAD -> main)
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:57 2023 +0530

    作者 #3 添加

developers.txt

commit 26cabf7fa07154b19deff41c5cbb07bf0782bde7
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:43 2023 +0530

    作者 #2 添加

developers.txt

commit d9e57385b505e2e02a8dc6064466c3974f22e66d
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:23 2023 +0530

    作者 #1 添加

developers.txt

commit 03e7f4abddfa26b4b0518994c81e0a724ba1a778
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:03:56 2023 +0530

    添加标题

developers.txt
% cat developers.txt 
作者:
1. Arthur
2. Canon
3. Doyle

我想知道的是,在使用Perforce时是否有这样的增量本地工作空间开发方法?
我想要SCL#3位于SCL#2SCL#1等的顶部,但每个SCL都将用于同一个文件,即developers.txt

英文:

Consider i have a file called developers.txt
What i want to do is (and i could do it in git neatly)
have 3-4 commits, each adding 1 line per commit

commit 2ad54bfe954006bafcb209f06ac0c12091d297c8 (HEAD -> main)
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:57 2023 +0530

    author #3 added

developers.txt

commit 26cabf7fa07154b19deff41c5cbb07bf0782bde7
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:43 2023 +0530

    author #2 added

developers.txt

commit d9e57385b505e2e02a8dc6064466c3974f22e66d
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:04:23 2023 +0530

    author #1 added

developers.txt

commit 03e7f4abddfa26b4b0518994c81e0a724ba1a778
Author: Anuraag <anuraag@something.com>
Date:   Thu Jun 1 15:03:56 2023 +0530

    adds heading

developers.txt
% cat developers.txt 
Authors:
1. Arthur
2. Canon
3. Doyle

What i want to know is, is there such an incremental local workspace development method when using perforce?
I want to have SCL#3 to be on top of SCL#2, SCL#1 etc.. but each SCL will be for the same file, in this case developers.txt

答案1

得分: 0

是的,这只是基本版本控制,应该在任何版本控制系统中表现类似。每个版本都是在前一个版本的基础上构建。

C:\Perforce\test>echo Authors:>developers.txt

C:\Perforce\test>p4 add developers.txt
//stream/main/developers.txt#1 - opened for add

C:\Perforce\test>p4 submit -d "adds heading"
Submitting change 460.
Locking 1 files ...
add //stream/main/developers.txt#1
Change 460 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#1 - opened for edit

C:\Perforce\test>echo 1. Arthur>>developers.txt

C:\Perforce\test>p4 submit -d "author #1 added"
Submitting change 461.
Locking 1 files ...
edit //stream/main/developers.txt#2
Change 461 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#2 - opened for edit

C:\Perforce\test>echo 2. Conan>>developers.txt

C:\Perforce\test>p4 submit -d "author #2 added"
Submitting change 462.
Locking 1 files ...
edit //stream/main/developers.txt#3
Change 462 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#3 - opened for edit

C:\Perforce\test>echo 3. Doyle>>developers.txt

C:\Perforce\test>p4 submit -d "author #3 added"
Submitting change 463.
Locking 1 files ...
edit //stream/main/developers.txt#4
Change 463 submitted.

现在我们有了带有4个版本的 developers.txt。我们可以看到头版本包含了前面的4个更改。

C:\Perforce\test>cat developers.txt
Authors:
1. Arthur
2. Conan
3. Doyle

我们可以看到它的历史记录,以更改列表的形式显示对其进行的更改。

C:\Perforce\test>p4 filelog developers.txt
//stream/main/developers.txt
... #4 change 463 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #3 added'
... #3 change 462 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #2 added'
... #2 change 461 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #1 added'
... #1 change 460 add on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'adds heading'

我们可以使用 annotate 命令查看文件的内容及其与历史记录的上下文,即每行内容是在哪个版本/更改列表中添加的。

C:\Perforce\test>p4 annotate developers.txt
//stream/main/developers.txt#4 - edit change 463 (text)
1: Authors:
2: 1. Arthur
3: 2. Conan
4: 3. Doyle

C:\Perforce\test>p4 annotate -c developers.txt
//stream/main/shelves/developers.txt#4 - edit change 463 (text)
460: Authors:
461: 1. Arthur
462: 2. Conan
463: 3. Doyle
英文:

Yes, this is just basic versioning and should behave similarly across any version control system. Every version builds on the one before it.

C:\Perforce\test>echo Authors:>developers.txt

C:\Perforce\test>p4 add developers.txt
//stream/main/developers.txt#1 - opened for add

C:\Perforce\test>p4 submit -d "adds heading"
Submitting change 460.
Locking 1 files ...
add //stream/main/developers.txt#1
Change 460 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#1 - opened for edit

C:\Perforce\test>echo 1. Arthur>>developers.txt

C:\Perforce\test>p4 submit -d "author #1 added"
Submitting change 461.
Locking 1 files ...
edit //stream/main/developers.txt#2
Change 461 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#2 - opened for edit

C:\Perforce\test>echo 2. Conan>>developers.txt

C:\Perforce\test>p4 submit -d "author #2 added"
Submitting change 462.
Locking 1 files ...
edit //stream/main/developers.txt#3
Change 462 submitted.

C:\Perforce\test>p4 edit developers.txt
//stream/main/developers.txt#3 - opened for edit

C:\Perforce\test>echo 3. Doyle>>developers.txt

C:\Perforce\test>p4 submit -d "author #3 added"
Submitting change 463.
Locking 1 files ...
edit //stream/main/developers.txt#4
Change 463 submitted.

Now we have our developers.txt with 4 versions. We can see that the head revision contains all 4 changes:

C:\Perforce\test>cat developers.txt
Authors:
1. Arthur
2. Conan
3. Doyle

We can see its history as a list of the changes made to it:

C:\Perforce\test>p4 filelog developers.txt
//stream/main/developers.txt
... #4 change 463 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #3 added'
... #3 change 462 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #2 added'
... #2 change 461 edit on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'author #1 added'
... #1 change 460 add on 2023/06/01 by Samwise@Samwise-dvcs-1509687817 (text) 'adds heading'

And we can annotate the file to see the content of the file in context of the history, i.e. which revision/changelist added each line of content:

C:\Perforce\test>p4 annotate developers.txt
//stream/main/developers.txt#4 - edit change 463 (text)
1: Authors:
2: 1. Arthur
3: 2. Conan
4: 3. Doyle

C:\Perforce\test>p4 annotate -c developers.txt
//stream/main/shelves/developers.txt#4 - edit change 463 (text)
460: Authors:
461: 1. Arthur
462: 2. Conan
463: 3. Doyle

huangapple
  • 本文由 发表于 2023年6月1日 17:39:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76380562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定