Jump to content

Undeleting can be hard in Plastic 4


Soho

Recommended Posts

I have been writing with support about undeleting files in Plastic 4 (thanks for quick support by the way) and I want to share some of my observations with you regarding undeleting files.

When if comes to undeleting files there seems to numerous pitfalls with Plastic 4 if you expect the behavior of Plastic 3. This probably has to do with a completely new directory tree model.

Here is a simple use case that may cause some headache (CS = changeset).

CS1: Add A in “MyFolder”. Delete B in “MyFolder”. Modify C in MyFolder.

CS2: Modify A, Modify C.

CS3: Undelete B

How do you undelete B?

It is not as easy as it seems.

You may think that you could simply use "Browse repository on changeset CS1", click-history on B and select "revert to this revision", but you can't. That is, you have the menu options, but selecting "revert" on a deleted file does nothing. (You get a dialog asking if you are sure, and after clicking OK, nothing has happened).

You may also want to try reverting the whole folder, but that doesn't do anything either.

How about merging into another branch, undoing the deletion of "B" before checking in?

I think that was very possible with Plastic 3, but in Plastic 4 you cannot partially check in a merge.

So how about a subtractive merge with CS1?

In this case it might actually work. The subtractive merge will detect a conflict with A, that was added in CS1, since A was changed in CS2. This gives you the option to not reverting adding A (saving A), while still reverting the deletion of C.

The subtractive merge comes with a price though. You only get to override the subtraction for files with a conflict. This means that if you have files that have been added, but not changed, or last changed in the changeset, those changes will be lost in the subtraction. You may override changes, but added, but unchanged files will be lost.

In most cases this is acceptable, but you could also imagine complex cases, where the added, but unchanged file was merged to another branch where it was changed. When you later want to merge with that branch, the changeset with the subtractive merge will cause the file to be deleted. It may be possible to save it with some creative cherry picking, but it is not easy.

Finally it would probably be possible to rescue the deleted file by cherry picking all changed and added files into another branch, but it would be an ugly operation. Since you cannot cherry pick from the "CS1" changeset without picking the deletion, you have to pick from later changesets. This could get ugly, if the CS1 changeset contains the last change for some files. In that case you may have to make dummy changes to all the files you want to save, to make them appear in clean changesets you can cherry pick from.

In Plastic 3, you could just checkout all the files you wanted and make a forced checkin without changes, but I cannot find that option in Plastic 4. Unchanged files are automatically undone. There may be a way to override this behavior that I haven't found.

I hope the Plastic developers will make some changes to make it a little less painful to undelete files. After all this is one of the points of having a version control system; to recover mistakes without too much hassle. Also, this used to be much easier in Plastic 3, so it feels like a set back.

Link to comment
Share on other sites

A follow up:

It appears that you actually can revert folders, but only if you select "History" on a file in the items explorer. If you use history from the "Browse repository" view, it doesn't work even though the history is the same. It looks like a bug.

The revert saves you in many scenarios, since you, as opposed to a merge, can choose to revert only some files. It can still be quite tricky in more complicated scenarios.

Link to comment
Share on other sites

Hi, Soho:

We'll publish a blogpost soon explaining how to cope with this, because may be a well-known problem. By parts:

- The history view opened from the repository browser seems not to work well, at least the revert option. We'll investigate what's happening there. Nevertheless, there are easier options to perform a revert: from the items view, open the history view and then revert to the desired revision. That works.

- Regarding how to recover deleted files, it's true that we still don't have a "Deleted items" view, as we had in Plastic 3, so it seems that it's not easy to recover a deleted file. In the meantime, you can:

1.- Revert to the latest directory version that loaded the deleted file. Take into account that Plastic versions directories, and this entity stores the information about what files are loaded where. This solution has a counterpart: all the changes done between the reverted revision and the current one will be lost, so the files added or deleted between the current situation back to the reverted version will be "undone". Take care of this.

2.- You can delete the changeset where the item was deleted, if it was done recently. Remember that all the changes done in that changeset will be lost and the changeset needs to be the last one on the branch and the changest cannot start a merge link or be labelled.

3.- The third option would be to start a new branch from the immediate changeset before the deletion and then interval cherrypick all the changes after the deletion but not including the changeset where the deletion took place. You'll also discard the rest of the changes done in that changeset, indeed. Take into account that subtractive merges and cherry picks must be done very very carefully and checking the results before checkin and populating the changes to other branches / changesets.

Anyway, it's true that we still don't provide a clean option to recover files and we'll try to fix it in the near future.

Best,

Luis

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...