New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file content is lost during rebase when that new file is checked in at the same time as its parent folder in clearcase #57

Open
jslhcl opened this Issue Apr 22, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@jslhcl
Contributor

jslhcl commented Apr 22, 2015

Hi, charleso,

I run into this problem during executing "gitcc rebase" command. Let me elaborate the reproduce steps:

  1. check in a new file using some tools like CCRC (clear case remote client) which makes the version 1 of this file shares the same modified time as that in its parent folder
  2. then migrate that repository to git. After rebase the new file's content is lost, it becomes an empty file.

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[1] < 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[0][2].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:

  1. change
lambda x: x[1] < date

to

lambda x: x[1] <= date
  1. if the versions is empty after
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.

@charleso

This comment has been minimized.

Show comment
Hide comment
@charleso

charleso Apr 22, 2015

Owner

Hi @jslhcl,

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:

3b2998d

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.

Charles

Owner

charleso commented Apr 22, 2015

Hi @jslhcl,

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:

3b2998d

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.

Charles

@jslhcl

This comment has been minimized.

Show comment
Hide comment
@jslhcl

jslhcl Apr 23, 2015

Contributor

Hi, @charleso

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.

Thanks
Lei

Contributor

jslhcl commented Apr 23, 2015

Hi, @charleso

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.

Thanks
Lei

jslhcl added a commit to jslhcl/git-cc that referenced this issue Apr 24, 2015

charleso added a commit that referenced this issue Apr 24, 2015

Merge pull request #58 from jslhcl/master
#57, do not add empty file since it will overwrite the existing content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment