I used Visual Studio Code (VSC) at work, and like usual, I view a file, such as
Foo.react.js
and use Save As
Bar.react.js
so as to create a new component file using Foo.react.js as a template.
However, when it got to CI/CD (Jenkins) and the push to production server stage, the file Bar.react.js had merge conflict with itself, which is strange, because why would a new file that only I created and edited conflict with itself?
Talking to the hg and CI/CD team, they told me that VSC (in my company) does an hg cp when we use Save As, and it treated Bar.react.js to follow the history of Foo.react.js.
So possibly somebody also modified Foo.react.js, and some lines in Bar.react.js conflicted with it.
I was also told that I can use hg forget Bar.react.js and then hg add Bar.react.js to fix the issue.
So the question is:
What exactly does
hg cpdo and why would it want to track history for a new file using an old file?Is it true that I can only do
hg forget Bar.react.jsand thenhg add Bar.react.jsfor the current commit and push, to fix the issue? If I didn't usehg forgetandhg addand then fixed that merge conflict and now all the files are finally in the repo, canFoo.react.jsstill conflict withBar.react.jsin the future?
The reason I think for (2), they may not conflict with each other in the future is that, if I do hg forget and hg add after all files are in the repo, then hg treats that as "nothing changed" and I cannot even commit. If I hg forget and commit, and then hg add and commit again, and now I want to land and push this, the CI/CD would say that the hg forget commit does not pass the CI/CD tests (missing component), so I really wonder if I need to go through the hg forget and hg add because it seems nobody ever does that as nobody ever stated how it can be done once the files are all in the repo now.
So it becomes:
Now that all files are in the repo now, do I still need to do hg forget Bar.react.js and then hg add Bar.react.js so that these two files do not conflict with each other in the future. If I need to do the hg forget and hg add, how should it be done?
Tracking history of renamed files is very useful.
Say you been working on
button.jsxfor many years, and then it's renamed tocolorButton.jsx. Without tracking history across renames, when looking at the history of colorButton.jsx, you would only see the history since it was renamed, as it would be considered a new file. Since button.jsx is no longer in the working directory, it might also be hard to know where the old history was.copying / duplicating files is not as common, but I guess if you do want to duplicate the file, and maintain the common history it would be useful.
one can also break the association between the two files with:
hg rename --forget colorButton.jsxNote:
one can read about this by typing
hg help renameor
hg help copy