简体   繁体   中英

Query about mercurial heads diagram and heads counting

I need to understand in which of the following lines the number of heads are change. Im finding it hard to understand what is going on in line 15.. I know that when a repository doesn't have the same change-sets when pulling or pushing from another repository so there is +1 head.

My diagram looks like this when i tried to solve it:

Line 12: push from clone2 to main repository

Line 15: push from Clone2 to Clone1 (because r3 doesn't similar to r1)

Line 17: pull r2 & r1 from main repository, since r1 and r3 already there, i've added r2 .

Total heads created: +3

main repository: O--------r2

                   \----r1

Clone 1: O--------r1

             \---r3

             \---r2

Clone 2: O------r2---------r3

           \--r1--/

The mercurial commands are below:

1: /home/user> hg clone http://remoteserver/mainrepository clone1

2: /home/user> hg clone http://remoteserver/mainrepository clone2

3: /home/user> cd clone1

4: /home/user/clone1> echo one > a.txt

5: /home/user/clone1> hg add a.txt

6: /home/user/clone1> hg commit -m "Added a file"

7: /home/user/clone1> cd ../clone2

8: /home/user/clone2> echo two > b.txt

9: /home/user/clone2> hg add b.txt

10: /home/user/clone2> hg commit -m "Added a file"

11: /home/user/clone2> hg pull ../clone1

12: /home/user/clone2> hg push -f

13: /home/user/clone2> hg merge

14: /home/user/clone2> hg commit -m "Merged"

15: /home/user/clone2> hg push -f ../clone1

16: /home/user/clone2> cd ../clone1

17: /home/user/clone1> hg pull

While planetmaker's answer in linked question is perfectly full and valid, I'll note some mistakes, omissions and wrong assumptions in this situation

  1. Clone2 got head+1 on step 11
 >hg pull ..\\Clone1 pulling from ..\\Clone1 searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads)
  1. Main got head+1 on step 12
 >hg push -f pushing to Z:\\Main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files (+1 heads)

http://i.imgur.com/KKNU39d.png

  1. Clone2 got head-1 on step 14
  2. Clone1 DOES NOT got head+1 on step 15 (mergeset pushed, with previous heads in Clone2 as parents of mergeset), at this step Clone1 is equal (in DAG-terms) to Clone2
 >hg push -f ..\\Clone1 pushing to ..\\Clone1 searching for changes adding changesets adding manifests adding file changes added 2 changesets with 1 changes to 1 files

http://i.imgur.com/9bY0URS.png

  1. Steps 16-17 DO NOTHING , because Clone1 DAG is fuller than Main (it has mergeset from Clone2 on top of main-history)
 >hg pull pulling from Z:\\Main searching for changes no changes found
  1. In order to have full history in Main you must to push to it from any of clones ( -f not needed and useless) to have mergeset as new single head in repository
>hg push pushing to Z:\\Main searching for changes adding changesets adding manifests adding file changes added 1 changesets with 0 changes to 0 files (-1 heads)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM