I need to combine the functionality of two classes into one, but I am wondering can I combine their change history as well?
Both classes contains lots of previous changes, so I want to keep their change history in one place for reference. I can make a comment in the combined class, but in an IDE, it's not very easy to get the history of a deleted file.
To start a merge between the two heads, we use the hg merge command. We resolve the contents of hello. c This updates the working directory so that it contains changes from both heads, which is reflected in both the output of hg parents and the contents of hello.
hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.
To do this, you need to record the file merging as a merge changeset.
Say changeset 0 is your current head with files A and B which you want to merge into file C. To do this, rename your file A to C and commit as changeset 1, then update back to changeset 0, rename file B to C and commit this as changeset 2. Next, you merge these two changesets, combining their content and removing the remaining files A and B. This causes the file history of C to be registered as descending from both A and B. Finally you can rename file C back to A.
The resulting tree looks as follows:
0 [A, B] --- 1 [A, C] \
\ \
\ 2 [C, B] --- 3 [C] --- 4 [A]
Example command line flow:
$ hg init
$ echo a > a
$ echo b > b
$ hg add a b
$ hg commit -m "add files a and b"
$ hg mv a c
$ hg commit -m "rename a to c"
$ hg update 0
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg mv b c
$ hg commit -m "rename b to c"
created new head
$ hg merge
merging c
warning: conflicts during merge.
merging c incomplete! (edit conflicts, then use 'hg resolve --mark')
0 files updated, 0 files merged, 1 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
$ ls
c c.orig
$ cat c
<<<<<<< local
b
=======
a
>>>>>>> other
$ echo ab > c
$ hg resolve --mark c
$ hg commit -m "merge a and b into c"
$ hg mv c a
$ hg commit -m "rename c back to a"
And if you now type hg log -f a
you will notice that the history of both files is shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With