Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
file content is lost during rebase when that new file is checked in at the same time as its parent folder in clearcase #57
I run into this problem during executing "gitcc rebase" command. Let me elaborate the reproduce steps:
I think the reason is that:
when check in a new file in clearcase, it will automatically add two versions: version 0 (with the type mkelemversion, which is an empty file) and version 1 (with the type checkinversion, which contains the real content), and if we check in the new file with some tool like CCRC, the file's parent folder will be automatically checked in, so the check in time of version 1 and the folder is the same (the check in time of version 0 is a little earlier)
Then in the rebase.py code, first the version 1 of that file is checked in through Changeset.add(), then we will check in the folder through Uncataloged.add(), in this function:
class Uncataloged(Changeset): def add(self, files): ...... history = filter(None, history.split('\n')) # contains version1 and version0 all_versions = self.parse_history(history) date = cc_exec(['describe', '-fmt', '%Nd', dir]) actual_versions = self.filter_versions(all_versions, lambda x: x < date) # version1 is filtered out since its date is the same as that in folder versions = self.checkin_versions(actual_versions) #version 0 is also filtered out, versions is empty now if not versions: print("No proper versions of '%s' file. Check if it is empty." % added) versions = self.empty_file_versions(actual_versions) #version 0 is added back if not versions: print("It appears that you may be missing a branch in the includes section of your gitcc config for file '%s'." % added) continue self._add(added, versions.strip()) # this file becomes blank since version 1 is overwritten by version 0
As the comments in the code above, the file's content is lost since it is overwritten by the empty file version 0.
I think there are two possible solutions:
lambda x: x < date
lambda x: x <= date
versions = self.checkin_versions(actual_versions)
just continue and do not add the empty version file back.
I prefer No.2 since the 1st solution will cause a duplicate commit for version 1.
What do you think? Thanks.
Honestly? I haven't use git-cc in about 5 years and I'm afraid I can't remember what the original intention is for the code.
I have a suspicion it used to work before this change:
If you checkout the commit before that you may find it works.
In any case, there isn't much I can do I'm afraid. :( Feel free to fork and make the changes you see fit.
Yes, you are right, it is due to issue #20 . But I don't think it is an issue. As far as I know, if you create a new branch and add a new file in the new branch, not only the version 0 and version 1 will be added in the new branch, but also version 0 (empty file) will be added in the origin branch.
in #20's case, XieDong added the file in the "css_refactor" branch, there should be no such file in the main branch, but due to some mechanism in clear case, this file is added into main branch as an empty file.
So I don't think we should add this empty file back after migrating. Let me fork and make the change.