37 # 3. take all tags that are only on p1 or only on p2 (but not on the base) |
37 # 3. take all tags that are only on p1 or only on p2 (but not on the base) |
38 # - Note that these are the tags that were introduced between base and p1 |
38 # - Note that these are the tags that were introduced between base and p1 |
39 # and between base and p2, possibly on separate clones |
39 # and between base and p2, possibly on separate clones |
40 # 4. for each tag found both on p1 and p2 perform the following merge algorithm: |
40 # 4. for each tag found both on p1 and p2 perform the following merge algorithm: |
41 # - the tags conflict if their tag "histories" have the same "rank" (i.e. |
41 # - the tags conflict if their tag "histories" have the same "rank" (i.e. |
42 # length) _AND_ the last (current) tag is _NOT_ the same |
42 # length) AND the last (current) tag is NOT the same |
43 # - for non conflicting tags: |
43 # - for non conflicting tags: |
44 # - choose which are the high and the low ranking nodes |
44 # - choose which are the high and the low ranking nodes |
45 # - the high ranking list of nodes is the one that is longer. |
45 # - the high ranking list of nodes is the one that is longer. |
46 # In case of draw favor p1 |
46 # In case of draw favor p1 |
47 # - the merged node list is made of 3 parts: |
47 # - the merged node list is made of 3 parts: |
55 # - note that during the merge we keep the "node line numbers", which will |
55 # - note that during the merge we keep the "node line numbers", which will |
56 # be used when writing the merged tags to the tag file |
56 # be used when writing the merged tags to the tag file |
57 # 5. write the merged tags taking into account to their positions in the first |
57 # 5. write the merged tags taking into account to their positions in the first |
58 # parent (i.e. try to keep the relative ordering of the nodes that come |
58 # parent (i.e. try to keep the relative ordering of the nodes that come |
59 # from p1). This minimizes the diff between the merged and the p1 tag files |
59 # from p1). This minimizes the diff between the merged and the p1 tag files |
60 # This is donw by using the following algorithm |
60 # This is done by using the following algorithm |
61 # - group the nodes for a given tag that must be written next to each other |
61 # - group the nodes for a given tag that must be written next to each other |
62 # - A: nodes that come from consecutive lines on p1 |
62 # - A: nodes that come from consecutive lines on p1 |
63 # - B: nodes that come from p2 (i.e. whose associated line number is |
63 # - B: nodes that come from p2 (i.e. whose associated line number is |
64 # None) and are next to one of the a nodes in A |
64 # None) and are next to one of the a nodes in A |
65 # - each group is associated with a line number coming from p1 |
65 # - each group is associated with a line number coming from p1 |
79 hexnullid = hex(nullid) |
79 hexnullid = hex(nullid) |
80 |
80 |
81 def readtagsformerge(ui, repo, lines, fn='', keeplinenums=False): |
81 def readtagsformerge(ui, repo, lines, fn='', keeplinenums=False): |
82 '''read the .hgtags file into a structure that is suitable for merging |
82 '''read the .hgtags file into a structure that is suitable for merging |
83 |
83 |
84 Sepending on the keeplinenumbers flag, clear the line numbers associated |
84 Depending on the keeplinenums flag, clear the line numbers associated |
85 with each tag. Rhis is done because only the line numbers of the first |
85 with each tag. This is done because only the line numbers of the first |
86 parent are useful for merging |
86 parent are useful for merging. |
87 ''' |
87 ''' |
88 filetags = tagsmod._readtaghist(ui, repo, lines, fn=fn, recode=None, |
88 filetags = tagsmod._readtaghist(ui, repo, lines, fn=fn, recode=None, |
89 calcnodelines=True)[1] |
89 calcnodelines=True)[1] |
90 for tagname, taginfo in filetags.items(): |
90 for tagname, taginfo in filetags.items(): |
91 if not keeplinenums: |
91 if not keeplinenums: |