0

Recently I have to work with perforce, and encounter some problem I never met in git. When I am using git, I will make commits corresponding to functional changes before pushing to the remote. I may later squash some commits and push, since the upstream may require a complete set of functional units.

However, when working with perforce, seems that I cannot achieve the above. Seems that a file can only exist in a pending changelist, while I want to store the changes in several pending changelists before submitting. For example, I want to have function A, B, C in a file staged into three commits in git. In perforce, I cannot find a way to do it unless I submit a changelist containing A first, and submit a changelist containing B, and then C.

My problem seems to be similar to this one, but it is already two years before and I am wondering if there is new or better approach to do it.

Update: Perforce website said that p4sandbox provides off-line work similar to git. Can I use this to achieve my goal?

Community
  • 1
  • 1
Ivan Xiao
  • 1,919
  • 3
  • 19
  • 30

2 Answers2

0

Sandbox is definitely nice. Myself, I use shelves for this. I keep each set of related changes in a single shelf, and I can work with each shelf independently.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
0

If I understand your workflow correctly, you want to make multiple sequential changes to the same file, but only push the final results of all the changes to the main code base? To me, that sounds like what a branch is for in Perforce. Where I work, we have a designated location in the depot for these branches. The sandboxes may have partial or incomplete changes committed to them, with the understanding that it doesn't (yet) belong in the main code. Then, when the development is done, the results are integrated from the branch back to the main code.

The only potential drawback to this is that all the files and their changes are also stored on the central server, instead of being on the local machine. That could be good or bad, depending on your perspective.

Caleb Huitt - cjhuitt
  • 14,785
  • 3
  • 42
  • 49