s.matushonok
s.matushonok

Reputation: 7585

How can I commit only part of a file in Perforce?

How are you doing this task in Perforce ?

Upvotes: 18

Views: 3195

Answers (3)

Alejandro Celery
Alejandro Celery

Reputation: 1

AFAIK you can't. I can't fault perforce for not having that feature as it's quite old software, but I can most certainly despise it for it. "We don't use perforce around here, right?" is a perfectly good question for my next job interview. The first distributed VCS I used was Mercurial, then I switched to git on the basis of this feature alone.

Upvotes: 0

Benlitz
Benlitz

Reputation: 2002

Yes, you can't do that.

The only thing you can do would be:

  • shelve your file without reverting it
  • open the diff of your file, and remove any other changes that those you want to submit
  • submit the resulting file which contains only the part you wanted to
  • unshelve the shelved version of the file
  • get the latest revision of it, and resolve (P4 should be able to auto-resolve it)

Then you still have the file in checkout, with the other modifications.

Upvotes: 25

Christian.K
Christian.K

Reputation: 49320

You can't. As with some other version control systems, you operate on a per file basis. That is, a single file is the smallest entity / unit of work possible.

I'd think that they all act on the presumption that changes to a file are atomic (most good version control systems will even use a commit of multiple files as an atomic operation).

If you only want to commit some parts, you essentially have to create a copy of your modified file, where you reset all those parts that you don't want to change back to their original content/text. Or better yet, only change one thing at a time and eventually separately commit those changes.

Upvotes: 10

Related Questions