Show More
@@ -0,0 +1,265 | |||||
|
1 | # tagmerge.py - merge .hgtags files | |||
|
2 | # | |||
|
3 | # Copyright 2014 Angel Ezquerra <angel.ezquerra@gmail.com> | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms of the | |||
|
6 | # GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | # This module implements an automatic merge algorithm for mercurial's tag files | |||
|
9 | # | |||
|
10 | # The tagmerge algorithm implemented in this module is able to resolve most | |||
|
11 | # merge conflicts that currently would trigger a .hgtags merge conflict. The | |||
|
12 | # only case that it does not (and cannot) handle is that in which two tags point | |||
|
13 | # to different revisions on each merge parent _and_ their corresponding tag | |||
|
14 | # histories have the same rank (i.e. the same length). In all other cases the | |||
|
15 | # merge algorithm will choose the revision belonging to the parent with the | |||
|
16 | # highest ranked tag history. The merged tag history is the combination of both | |||
|
17 | # tag histories (special care is taken to try to combine common tag histories | |||
|
18 | # where possible). | |||
|
19 | # | |||
|
20 | # In addition to actually merging the tags from two parents, taking into | |||
|
21 | # account the base, the algorithm also tries to minimize the difference | |||
|
22 | # between the merged tag file and the first parent's tag file (i.e. it tries to | |||
|
23 | # make the merged tag order as as similar as possible to the first parent's tag | |||
|
24 | # file order). | |||
|
25 | # | |||
|
26 | # The algorithm works as follows: | |||
|
27 | # 1. read the tags from p1, p2 and the base | |||
|
28 | # - when reading the p1 tags, also get the line numbers associated to each | |||
|
29 | # tag node (these will be used to sort the merged tags in a way that | |||
|
30 | # minimizes the diff to p1). Ignore the file numbers when reading p2 and | |||
|
31 | # the base | |||
|
32 | # 2. recover the "lost tags" (i.e. those that are found in the base but not on | |||
|
33 | # p1 or p2) and add them back to p1 and/or p2 | |||
|
34 | # - at this point the only tags that are on p1 but not on p2 are those new | |||
|
35 | # tags that were introduced in p1. Same thing for the tags that are on p2 | |||
|
36 | # but not on p2 | |||
|
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 | |||
|
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: | |||
|
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 | |||
|
43 | # - for non conflicting tags: | |||
|
44 | # - choose which are the high and the low ranking nodes | |||
|
45 | # - the high ranking list of nodes is the one that is longer. | |||
|
46 | # In case of draw favor p1 | |||
|
47 | # - the merged node list is made of 3 parts: | |||
|
48 | # - first the nodes that are common to the beginning of both | |||
|
49 | # the low and the high ranking nodes | |||
|
50 | # - second the non common low ranking nodes | |||
|
51 | # - finally the non common high ranking nodes (with the last | |||
|
52 | # one being the merged tag node) | |||
|
53 | # - note that this is equivalent to putting the whole low ranking | |||
|
54 | # node list first, followed by the non common high ranking nodes | |||
|
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 | |||
|
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 | |||
|
59 | # from p1). This minimizes the diff between the merged and the p1 tag files | |||
|
60 | # This is donw by using the following algorithm | |||
|
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 | |||
|
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 | |||
|
65 | # - each group is associated with a line number coming from p1 | |||
|
66 | # - generate a "tag block" for each of the groups | |||
|
67 | # - a tag block is a set of consecutive "node tag" lines belonging to | |||
|
68 | # the same tag and which will be written next to each other on the | |||
|
69 | # merged tags file | |||
|
70 | # - sort the "tag blocks" according to their associated number line | |||
|
71 | # - put blocks whose nodes come all from p2 first | |||
|
72 | # - write the tag blocks in the sorted order | |||
|
73 | ||||
|
74 | import tags | |||
|
75 | import util | |||
|
76 | from node import nullid, hex | |||
|
77 | from i18n import _ | |||
|
78 | import operator | |||
|
79 | hexnullid = hex(nullid) | |||
|
80 | ||||
|
81 | def readtagsformerge(ui, repo, lines, fn='', keeplinenums=False): | |||
|
82 | '''read the .hgtags file into a structure that is suitable for merging | |||
|
83 | ||||
|
84 | Sepending on the keeplinenumbers flag, clear the line numbers associated | |||
|
85 | with each tag. Rhis is done because only the line numbers of the first | |||
|
86 | parent are useful for merging | |||
|
87 | ''' | |||
|
88 | filetags = tags._readtaghist(ui, repo, lines, fn=fn, recode=None, | |||
|
89 | calcnodelines=True)[1] | |||
|
90 | for tagname, taginfo in filetags.items(): | |||
|
91 | if not keeplinenums: | |||
|
92 | for el in taginfo: | |||
|
93 | el[1] = None | |||
|
94 | return filetags | |||
|
95 | ||||
|
96 | def grouptagnodesbyline(tagnodes): | |||
|
97 | ''' | |||
|
98 | Group nearby nodes (i.e. those that must be written next to each other) | |||
|
99 | ||||
|
100 | The input is a list of [node, position] pairs, corresponding to a given tag | |||
|
101 | The position is the line number where the node was found on the first parent | |||
|
102 | .hgtags file, or None for those nodes that came from the base or the second | |||
|
103 | parent .hgtags files. | |||
|
104 | ||||
|
105 | This function groups those [node, position] pairs, returning a list of | |||
|
106 | groups of nodes that must be written next to each other because their | |||
|
107 | positions are consecutive or have no position preference (because their | |||
|
108 | position is None). | |||
|
109 | ||||
|
110 | The result is a list of [position, [consecutive node list]] | |||
|
111 | ''' | |||
|
112 | firstlinenum = None | |||
|
113 | for hexnode, linenum in tagnodes: | |||
|
114 | firstlinenum = linenum | |||
|
115 | if firstlinenum is not None: | |||
|
116 | break | |||
|
117 | if firstlinenum is None: | |||
|
118 | return [[None, [el[0] for el in tagnodes]]] | |||
|
119 | tagnodes[0][1] = firstlinenum | |||
|
120 | groupednodes = [[firstlinenum, []]] | |||
|
121 | prevlinenum = firstlinenum | |||
|
122 | for hexnode, linenum in tagnodes: | |||
|
123 | if linenum is not None and linenum - prevlinenum > 1: | |||
|
124 | groupednodes.append([linenum, []]) | |||
|
125 | groupednodes[-1][1].append(hexnode) | |||
|
126 | if linenum is not None: | |||
|
127 | prevlinenum = linenum | |||
|
128 | return groupednodes | |||
|
129 | ||||
|
130 | def writemergedtags(repo, mergedtags): | |||
|
131 | ''' | |||
|
132 | write the merged tags while trying to minimize the diff to the first parent | |||
|
133 | ||||
|
134 | This function uses the ordering info stored on the merged tags dict to | |||
|
135 | generate an .hgtags file which is correct (in the sense that its contents | |||
|
136 | correspond to the result of the tag merge) while also being as close as | |||
|
137 | possible to the first parent's .hgtags file. | |||
|
138 | ''' | |||
|
139 | # group the node-tag pairs that must be written next to each other | |||
|
140 | for tname, taglist in mergedtags.items(): | |||
|
141 | mergedtags[tname] = grouptagnodesbyline(taglist) | |||
|
142 | ||||
|
143 | # convert the grouped merged tags dict into a format that resembles the | |||
|
144 | # final .hgtags file (i.e. a list of blocks of 'node tag' pairs) | |||
|
145 | def taglist2string(tlist, tname): | |||
|
146 | return '\n'.join(['%s %s' % (hexnode, tname) for hexnode in tlist]) | |||
|
147 | ||||
|
148 | finaltags = [] | |||
|
149 | for tname, tags in mergedtags.items(): | |||
|
150 | for block in tags: | |||
|
151 | block[1] = taglist2string(block[1], tname) | |||
|
152 | finaltags += tags | |||
|
153 | ||||
|
154 | # the tag groups are linked to a "position" that can be used to sort them | |||
|
155 | # before writing them | |||
|
156 | # the position is calculated to ensure that the diff of the merged .hgtags | |||
|
157 | # file to the first parent's .hgtags file is as small as possible | |||
|
158 | finaltags.sort(key=operator.itemgetter(0)) | |||
|
159 | ||||
|
160 | # finally we can join the sorted groups to get the final contents of the | |||
|
161 | # merged .hgtags file, and then write it to disk | |||
|
162 | mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags]) | |||
|
163 | fp = repo.wfile('.hgtags', 'wb') | |||
|
164 | fp.write(mergedtagstring + '\n') | |||
|
165 | fp.close() | |||
|
166 | ||||
|
167 | def singletagmerge(p1nodes, p2nodes): | |||
|
168 | ''' | |||
|
169 | merge the nodes corresponding to a single tag | |||
|
170 | ||||
|
171 | Note that the inputs are lists of node-linenum pairs (i.e. not just lists | |||
|
172 | of nodes) | |||
|
173 | ''' | |||
|
174 | if not p2nodes: | |||
|
175 | return p1nodes | |||
|
176 | if not p1nodes: | |||
|
177 | return p2nodes | |||
|
178 | ||||
|
179 | # there is no conflict unless both tags point to different revisions | |||
|
180 | # and have a non identical tag history | |||
|
181 | p1currentnode = p1nodes[-1][0] | |||
|
182 | p2currentnode = p2nodes[-1][0] | |||
|
183 | if p1currentnode != p2currentnode and len(p1nodes) == len(p2nodes): | |||
|
184 | # cannot merge two tags with same rank pointing to different nodes | |||
|
185 | return None | |||
|
186 | ||||
|
187 | # which are the highest ranking (hr) / lowest ranking (lr) nodes? | |||
|
188 | if len(p1nodes) >= len(p2nodes): | |||
|
189 | hrnodes, lrnodes = p1nodes, p2nodes | |||
|
190 | else: | |||
|
191 | hrnodes, lrnodes = p2nodes, p1nodes | |||
|
192 | ||||
|
193 | # the lowest ranking nodes will be written first, followed by the highest | |||
|
194 | # ranking nodes | |||
|
195 | # to avoid unwanted tag rank explosion we try to see if there are some | |||
|
196 | # common nodes that can be written only once | |||
|
197 | commonidx = len(lrnodes) | |||
|
198 | for n in range(len(lrnodes)): | |||
|
199 | if hrnodes[n][0] != lrnodes[n][0]: | |||
|
200 | commonidx = n | |||
|
201 | break | |||
|
202 | lrnodes[n][1] = p1nodes[n][1] | |||
|
203 | ||||
|
204 | # the merged node list has 3 parts: | |||
|
205 | # - common nodes | |||
|
206 | # - non common lowest ranking nodes | |||
|
207 | # - non common highest ranking nodes | |||
|
208 | # note that the common nodes plus the non common lowest ranking nodes is the | |||
|
209 | # whole list of lr nodes | |||
|
210 | return lrnodes + hrnodes[commonidx:] | |||
|
211 | ||||
|
212 | def merge(repo, fcd, fco, fca): | |||
|
213 | ''' | |||
|
214 | Merge the tags of two revisions, taking into account the base tags | |||
|
215 | Try to minimize the diff between the merged tags and the first parent tags | |||
|
216 | ''' | |||
|
217 | ui = repo.ui | |||
|
218 | # read the p1, p2 and base tags | |||
|
219 | # only keep the line numbers for the p1 tags | |||
|
220 | p1tags = readtagsformerge( | |||
|
221 | ui, repo, fcd.data().splitlines(), fn="p1 tags", | |||
|
222 | keeplinenums=True) | |||
|
223 | p2tags = readtagsformerge( | |||
|
224 | ui, repo, fco.data().splitlines(), fn="p2 tags", | |||
|
225 | keeplinenums=False) | |||
|
226 | basetags = readtagsformerge( | |||
|
227 | ui, repo, fca.data().splitlines(), fn="base tags", | |||
|
228 | keeplinenums=False) | |||
|
229 | ||||
|
230 | # recover the list of "lost tags" (i.e. those that were found on the base | |||
|
231 | # revision but not on one of the revisions being merged) | |||
|
232 | basetagset = set(basetags) | |||
|
233 | for n, pntags in enumerate((p1tags, p2tags)): | |||
|
234 | pntagset = set(pntags) | |||
|
235 | pnlosttagset = basetagset - pntagset | |||
|
236 | for t in pnlosttagset: | |||
|
237 | pntags[t] = basetags[t] | |||
|
238 | if pntags[t][-1][0] != hexnullid: | |||
|
239 | pntags[t].append([hexnullid, None]) | |||
|
240 | ||||
|
241 | conflictedtags = [] # for reporting purposes | |||
|
242 | mergedtags = util.sortdict(p1tags) | |||
|
243 | # sortdict does not implement iteritems() | |||
|
244 | for tname, p2nodes in p2tags.items(): | |||
|
245 | if tname not in mergedtags: | |||
|
246 | mergedtags[tname] = p2nodes | |||
|
247 | continue | |||
|
248 | p1nodes = mergedtags[tname] | |||
|
249 | mergednodes = singletagmerge(p1nodes, p2nodes) | |||
|
250 | if mergednodes is None: | |||
|
251 | conflictedtags.append(tname) | |||
|
252 | continue | |||
|
253 | mergedtags[tname] = mergednodes | |||
|
254 | ||||
|
255 | if conflictedtags: | |||
|
256 | numconflicts = len(conflictedtags) | |||
|
257 | ui.warn(_('automatic .hgtags merge failed\n' | |||
|
258 | 'the following %d tags are in conflict: %s\n') | |||
|
259 | % (numconflicts, ', '.join(sorted(conflictedtags)))) | |||
|
260 | return True, 1 | |||
|
261 | ||||
|
262 | writemergedtags(repo, mergedtags) | |||
|
263 | ui.note(_('.hgtags merged successfully\n')) | |||
|
264 | return False, 0 | |||
|
265 |
@@ -1,436 +1,447 | |||||
1 | # filemerge.py - file-level merge handling for Mercurial |
|
1 | # filemerge.py - file-level merge handling for Mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import short |
|
8 | from node import short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import util, simplemerge, match, error, templater, templatekw |
|
10 | import util, simplemerge, match, error, templater, templatekw | |
11 | import os, tempfile, re, filecmp |
|
11 | import os, tempfile, re, filecmp | |
|
12 | import tagmerge | |||
12 |
|
13 | |||
13 | def _toolstr(ui, tool, part, default=""): |
|
14 | def _toolstr(ui, tool, part, default=""): | |
14 | return ui.config("merge-tools", tool + "." + part, default) |
|
15 | return ui.config("merge-tools", tool + "." + part, default) | |
15 |
|
16 | |||
16 | def _toolbool(ui, tool, part, default=False): |
|
17 | def _toolbool(ui, tool, part, default=False): | |
17 | return ui.configbool("merge-tools", tool + "." + part, default) |
|
18 | return ui.configbool("merge-tools", tool + "." + part, default) | |
18 |
|
19 | |||
19 | def _toollist(ui, tool, part, default=[]): |
|
20 | def _toollist(ui, tool, part, default=[]): | |
20 | return ui.configlist("merge-tools", tool + "." + part, default) |
|
21 | return ui.configlist("merge-tools", tool + "." + part, default) | |
21 |
|
22 | |||
22 | internals = {} |
|
23 | internals = {} | |
23 |
|
24 | |||
24 | def internaltool(name, trymerge, onfailure=None): |
|
25 | def internaltool(name, trymerge, onfailure=None): | |
25 | '''return a decorator for populating internal merge tool table''' |
|
26 | '''return a decorator for populating internal merge tool table''' | |
26 | def decorator(func): |
|
27 | def decorator(func): | |
27 | fullname = 'internal:' + name |
|
28 | fullname = 'internal:' + name | |
28 | func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip() |
|
29 | func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip() | |
29 | internals[fullname] = func |
|
30 | internals[fullname] = func | |
30 | func.trymerge = trymerge |
|
31 | func.trymerge = trymerge | |
31 | func.onfailure = onfailure |
|
32 | func.onfailure = onfailure | |
32 | return func |
|
33 | return func | |
33 | return decorator |
|
34 | return decorator | |
34 |
|
35 | |||
35 | def _findtool(ui, tool): |
|
36 | def _findtool(ui, tool): | |
36 | if tool in internals: |
|
37 | if tool in internals: | |
37 | return tool |
|
38 | return tool | |
38 | for kn in ("regkey", "regkeyalt"): |
|
39 | for kn in ("regkey", "regkeyalt"): | |
39 | k = _toolstr(ui, tool, kn) |
|
40 | k = _toolstr(ui, tool, kn) | |
40 | if not k: |
|
41 | if not k: | |
41 | continue |
|
42 | continue | |
42 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) |
|
43 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) | |
43 | if p: |
|
44 | if p: | |
44 | p = util.findexe(p + _toolstr(ui, tool, "regappend")) |
|
45 | p = util.findexe(p + _toolstr(ui, tool, "regappend")) | |
45 | if p: |
|
46 | if p: | |
46 | return p |
|
47 | return p | |
47 | exe = _toolstr(ui, tool, "executable", tool) |
|
48 | exe = _toolstr(ui, tool, "executable", tool) | |
48 | return util.findexe(util.expandpath(exe)) |
|
49 | return util.findexe(util.expandpath(exe)) | |
49 |
|
50 | |||
50 | def _picktool(repo, ui, path, binary, symlink): |
|
51 | def _picktool(repo, ui, path, binary, symlink): | |
51 | def check(tool, pat, symlink, binary): |
|
52 | def check(tool, pat, symlink, binary): | |
52 | tmsg = tool |
|
53 | tmsg = tool | |
53 | if pat: |
|
54 | if pat: | |
54 | tmsg += " specified for " + pat |
|
55 | tmsg += " specified for " + pat | |
55 | if not _findtool(ui, tool): |
|
56 | if not _findtool(ui, tool): | |
56 | if pat: # explicitly requested tool deserves a warning |
|
57 | if pat: # explicitly requested tool deserves a warning | |
57 | ui.warn(_("couldn't find merge tool %s\n") % tmsg) |
|
58 | ui.warn(_("couldn't find merge tool %s\n") % tmsg) | |
58 | else: # configured but non-existing tools are more silent |
|
59 | else: # configured but non-existing tools are more silent | |
59 | ui.note(_("couldn't find merge tool %s\n") % tmsg) |
|
60 | ui.note(_("couldn't find merge tool %s\n") % tmsg) | |
60 | elif symlink and not _toolbool(ui, tool, "symlink"): |
|
61 | elif symlink and not _toolbool(ui, tool, "symlink"): | |
61 | ui.warn(_("tool %s can't handle symlinks\n") % tmsg) |
|
62 | ui.warn(_("tool %s can't handle symlinks\n") % tmsg) | |
62 | elif binary and not _toolbool(ui, tool, "binary"): |
|
63 | elif binary and not _toolbool(ui, tool, "binary"): | |
63 | ui.warn(_("tool %s can't handle binary\n") % tmsg) |
|
64 | ui.warn(_("tool %s can't handle binary\n") % tmsg) | |
64 | elif not util.gui() and _toolbool(ui, tool, "gui"): |
|
65 | elif not util.gui() and _toolbool(ui, tool, "gui"): | |
65 | ui.warn(_("tool %s requires a GUI\n") % tmsg) |
|
66 | ui.warn(_("tool %s requires a GUI\n") % tmsg) | |
66 | else: |
|
67 | else: | |
67 | return True |
|
68 | return True | |
68 | return False |
|
69 | return False | |
69 |
|
70 | |||
70 | # forcemerge comes from command line arguments, highest priority |
|
71 | # forcemerge comes from command line arguments, highest priority | |
71 | force = ui.config('ui', 'forcemerge') |
|
72 | force = ui.config('ui', 'forcemerge') | |
72 | if force: |
|
73 | if force: | |
73 | toolpath = _findtool(ui, force) |
|
74 | toolpath = _findtool(ui, force) | |
74 | if toolpath: |
|
75 | if toolpath: | |
75 | return (force, util.shellquote(toolpath)) |
|
76 | return (force, util.shellquote(toolpath)) | |
76 | else: |
|
77 | else: | |
77 | # mimic HGMERGE if given tool not found |
|
78 | # mimic HGMERGE if given tool not found | |
78 | return (force, force) |
|
79 | return (force, force) | |
79 |
|
80 | |||
80 | # HGMERGE takes next precedence |
|
81 | # HGMERGE takes next precedence | |
81 | hgmerge = os.environ.get("HGMERGE") |
|
82 | hgmerge = os.environ.get("HGMERGE") | |
82 | if hgmerge: |
|
83 | if hgmerge: | |
83 | return (hgmerge, hgmerge) |
|
84 | return (hgmerge, hgmerge) | |
84 |
|
85 | |||
85 | # then patterns |
|
86 | # then patterns | |
86 | for pat, tool in ui.configitems("merge-patterns"): |
|
87 | for pat, tool in ui.configitems("merge-patterns"): | |
87 | mf = match.match(repo.root, '', [pat]) |
|
88 | mf = match.match(repo.root, '', [pat]) | |
88 | if mf(path) and check(tool, pat, symlink, False): |
|
89 | if mf(path) and check(tool, pat, symlink, False): | |
89 | toolpath = _findtool(ui, tool) |
|
90 | toolpath = _findtool(ui, tool) | |
90 | return (tool, util.shellquote(toolpath)) |
|
91 | return (tool, util.shellquote(toolpath)) | |
91 |
|
92 | |||
92 | # then merge tools |
|
93 | # then merge tools | |
93 | tools = {} |
|
94 | tools = {} | |
94 | for k, v in ui.configitems("merge-tools"): |
|
95 | for k, v in ui.configitems("merge-tools"): | |
95 | t = k.split('.')[0] |
|
96 | t = k.split('.')[0] | |
96 | if t not in tools: |
|
97 | if t not in tools: | |
97 | tools[t] = int(_toolstr(ui, t, "priority", "0")) |
|
98 | tools[t] = int(_toolstr(ui, t, "priority", "0")) | |
98 | names = tools.keys() |
|
99 | names = tools.keys() | |
99 | tools = sorted([(-p, t) for t, p in tools.items()]) |
|
100 | tools = sorted([(-p, t) for t, p in tools.items()]) | |
100 | uimerge = ui.config("ui", "merge") |
|
101 | uimerge = ui.config("ui", "merge") | |
101 | if uimerge: |
|
102 | if uimerge: | |
102 | if uimerge not in names: |
|
103 | if uimerge not in names: | |
103 | return (uimerge, uimerge) |
|
104 | return (uimerge, uimerge) | |
104 | tools.insert(0, (None, uimerge)) # highest priority |
|
105 | tools.insert(0, (None, uimerge)) # highest priority | |
105 | tools.append((None, "hgmerge")) # the old default, if found |
|
106 | tools.append((None, "hgmerge")) # the old default, if found | |
106 | for p, t in tools: |
|
107 | for p, t in tools: | |
107 | if check(t, None, symlink, binary): |
|
108 | if check(t, None, symlink, binary): | |
108 | toolpath = _findtool(ui, t) |
|
109 | toolpath = _findtool(ui, t) | |
109 | return (t, util.shellquote(toolpath)) |
|
110 | return (t, util.shellquote(toolpath)) | |
110 |
|
111 | |||
111 | # internal merge or prompt as last resort |
|
112 | # internal merge or prompt as last resort | |
112 | if symlink or binary: |
|
113 | if symlink or binary: | |
113 | return "internal:prompt", None |
|
114 | return "internal:prompt", None | |
114 | return "internal:merge", None |
|
115 | return "internal:merge", None | |
115 |
|
116 | |||
116 | def _eoltype(data): |
|
117 | def _eoltype(data): | |
117 | "Guess the EOL type of a file" |
|
118 | "Guess the EOL type of a file" | |
118 | if '\0' in data: # binary |
|
119 | if '\0' in data: # binary | |
119 | return None |
|
120 | return None | |
120 | if '\r\n' in data: # Windows |
|
121 | if '\r\n' in data: # Windows | |
121 | return '\r\n' |
|
122 | return '\r\n' | |
122 | if '\r' in data: # Old Mac |
|
123 | if '\r' in data: # Old Mac | |
123 | return '\r' |
|
124 | return '\r' | |
124 | if '\n' in data: # UNIX |
|
125 | if '\n' in data: # UNIX | |
125 | return '\n' |
|
126 | return '\n' | |
126 | return None # unknown |
|
127 | return None # unknown | |
127 |
|
128 | |||
128 | def _matcheol(file, origfile): |
|
129 | def _matcheol(file, origfile): | |
129 | "Convert EOL markers in a file to match origfile" |
|
130 | "Convert EOL markers in a file to match origfile" | |
130 | tostyle = _eoltype(util.readfile(origfile)) |
|
131 | tostyle = _eoltype(util.readfile(origfile)) | |
131 | if tostyle: |
|
132 | if tostyle: | |
132 | data = util.readfile(file) |
|
133 | data = util.readfile(file) | |
133 | style = _eoltype(data) |
|
134 | style = _eoltype(data) | |
134 | if style: |
|
135 | if style: | |
135 | newdata = data.replace(style, tostyle) |
|
136 | newdata = data.replace(style, tostyle) | |
136 | if newdata != data: |
|
137 | if newdata != data: | |
137 | util.writefile(file, newdata) |
|
138 | util.writefile(file, newdata) | |
138 |
|
139 | |||
139 | @internaltool('prompt', False) |
|
140 | @internaltool('prompt', False) | |
140 | def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
141 | def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf): | |
141 | """Asks the user which of the local or the other version to keep as |
|
142 | """Asks the user which of the local or the other version to keep as | |
142 | the merged version.""" |
|
143 | the merged version.""" | |
143 | ui = repo.ui |
|
144 | ui = repo.ui | |
144 | fd = fcd.path() |
|
145 | fd = fcd.path() | |
145 |
|
146 | |||
146 | if ui.promptchoice(_(" no tool found to merge %s\n" |
|
147 | if ui.promptchoice(_(" no tool found to merge %s\n" | |
147 | "keep (l)ocal or take (o)ther?" |
|
148 | "keep (l)ocal or take (o)ther?" | |
148 | "$$ &Local $$ &Other") % fd, 0): |
|
149 | "$$ &Local $$ &Other") % fd, 0): | |
149 | return _iother(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
150 | return _iother(repo, mynode, orig, fcd, fco, fca, toolconf) | |
150 | else: |
|
151 | else: | |
151 | return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
152 | return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf) | |
152 |
|
153 | |||
153 | @internaltool('local', False) |
|
154 | @internaltool('local', False) | |
154 | def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
155 | def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf): | |
155 | """Uses the local version of files as the merged version.""" |
|
156 | """Uses the local version of files as the merged version.""" | |
156 | return 0 |
|
157 | return 0 | |
157 |
|
158 | |||
158 | @internaltool('other', False) |
|
159 | @internaltool('other', False) | |
159 | def _iother(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
160 | def _iother(repo, mynode, orig, fcd, fco, fca, toolconf): | |
160 | """Uses the other version of files as the merged version.""" |
|
161 | """Uses the other version of files as the merged version.""" | |
161 | repo.wwrite(fcd.path(), fco.data(), fco.flags()) |
|
162 | repo.wwrite(fcd.path(), fco.data(), fco.flags()) | |
162 | return 0 |
|
163 | return 0 | |
163 |
|
164 | |||
164 | @internaltool('fail', False) |
|
165 | @internaltool('fail', False) | |
165 | def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
166 | def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf): | |
166 | """ |
|
167 | """ | |
167 | Rather than attempting to merge files that were modified on both |
|
168 | Rather than attempting to merge files that were modified on both | |
168 | branches, it marks them as unresolved. The resolve command must be |
|
169 | branches, it marks them as unresolved. The resolve command must be | |
169 | used to resolve these conflicts.""" |
|
170 | used to resolve these conflicts.""" | |
170 | return 1 |
|
171 | return 1 | |
171 |
|
172 | |||
172 | def _premerge(repo, toolconf, files, labels=None): |
|
173 | def _premerge(repo, toolconf, files, labels=None): | |
173 | tool, toolpath, binary, symlink = toolconf |
|
174 | tool, toolpath, binary, symlink = toolconf | |
174 | if symlink: |
|
175 | if symlink: | |
175 | return 1 |
|
176 | return 1 | |
176 | a, b, c, back = files |
|
177 | a, b, c, back = files | |
177 |
|
178 | |||
178 | ui = repo.ui |
|
179 | ui = repo.ui | |
179 |
|
180 | |||
180 | # do we attempt to simplemerge first? |
|
181 | # do we attempt to simplemerge first? | |
181 | try: |
|
182 | try: | |
182 | premerge = _toolbool(ui, tool, "premerge", not binary) |
|
183 | premerge = _toolbool(ui, tool, "premerge", not binary) | |
183 | except error.ConfigError: |
|
184 | except error.ConfigError: | |
184 | premerge = _toolstr(ui, tool, "premerge").lower() |
|
185 | premerge = _toolstr(ui, tool, "premerge").lower() | |
185 | valid = 'keep'.split() |
|
186 | valid = 'keep'.split() | |
186 | if premerge not in valid: |
|
187 | if premerge not in valid: | |
187 | _valid = ', '.join(["'" + v + "'" for v in valid]) |
|
188 | _valid = ', '.join(["'" + v + "'" for v in valid]) | |
188 | raise error.ConfigError(_("%s.premerge not valid " |
|
189 | raise error.ConfigError(_("%s.premerge not valid " | |
189 | "('%s' is neither boolean nor %s)") % |
|
190 | "('%s' is neither boolean nor %s)") % | |
190 | (tool, premerge, _valid)) |
|
191 | (tool, premerge, _valid)) | |
191 |
|
192 | |||
192 | if premerge: |
|
193 | if premerge: | |
193 | r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels) |
|
194 | r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels) | |
194 | if not r: |
|
195 | if not r: | |
195 | ui.debug(" premerge successful\n") |
|
196 | ui.debug(" premerge successful\n") | |
196 | return 0 |
|
197 | return 0 | |
197 | if premerge != 'keep': |
|
198 | if premerge != 'keep': | |
198 | util.copyfile(back, a) # restore from backup and try again |
|
199 | util.copyfile(back, a) # restore from backup and try again | |
199 | return 1 # continue merging |
|
200 | return 1 # continue merging | |
200 |
|
201 | |||
201 | @internaltool('merge', True, |
|
202 | @internaltool('merge', True, | |
202 | _("merging %s incomplete! " |
|
203 | _("merging %s incomplete! " | |
203 | "(edit conflicts, then use 'hg resolve --mark')\n")) |
|
204 | "(edit conflicts, then use 'hg resolve --mark')\n")) | |
204 | def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
|
205 | def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | |
205 | """ |
|
206 | """ | |
206 | Uses the internal non-interactive simple merge algorithm for merging |
|
207 | Uses the internal non-interactive simple merge algorithm for merging | |
207 | files. It will fail if there are any conflicts and leave markers in |
|
208 | files. It will fail if there are any conflicts and leave markers in | |
208 | the partially merged file.""" |
|
209 | the partially merged file.""" | |
209 | tool, toolpath, binary, symlink = toolconf |
|
210 | tool, toolpath, binary, symlink = toolconf | |
210 | if symlink: |
|
211 | if symlink: | |
211 | repo.ui.warn(_('warning: internal:merge cannot merge symlinks ' |
|
212 | repo.ui.warn(_('warning: internal:merge cannot merge symlinks ' | |
212 | 'for %s\n') % fcd.path()) |
|
213 | 'for %s\n') % fcd.path()) | |
213 | return False, 1 |
|
214 | return False, 1 | |
214 | r = _premerge(repo, toolconf, files, labels=labels) |
|
215 | r = _premerge(repo, toolconf, files, labels=labels) | |
215 | if r: |
|
216 | if r: | |
216 | a, b, c, back = files |
|
217 | a, b, c, back = files | |
217 |
|
218 | |||
218 | ui = repo.ui |
|
219 | ui = repo.ui | |
219 |
|
220 | |||
220 | r = simplemerge.simplemerge(ui, a, b, c, label=labels, no_minimal=True) |
|
221 | r = simplemerge.simplemerge(ui, a, b, c, label=labels, no_minimal=True) | |
221 | return True, r |
|
222 | return True, r | |
222 | return False, 0 |
|
223 | return False, 0 | |
223 |
|
224 | |||
|
225 | @internaltool('tagmerge', True, | |||
|
226 | _("automatic tag merging of %s failed! " | |||
|
227 | "(use 'hg resolve --tool internal:merge' or another merge " | |||
|
228 | "tool of your choice)\n")) | |||
|
229 | def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | |||
|
230 | """ | |||
|
231 | Uses the internal tag merge algorithm (experimental). | |||
|
232 | """ | |||
|
233 | return tagmerge.merge(repo, fcd, fco, fca) | |||
|
234 | ||||
224 | @internaltool('dump', True) |
|
235 | @internaltool('dump', True) | |
225 | def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
|
236 | def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | |
226 | """ |
|
237 | """ | |
227 | Creates three versions of the files to merge, containing the |
|
238 | Creates three versions of the files to merge, containing the | |
228 | contents of local, other and base. These files can then be used to |
|
239 | contents of local, other and base. These files can then be used to | |
229 | perform a merge manually. If the file to be merged is named |
|
240 | perform a merge manually. If the file to be merged is named | |
230 | ``a.txt``, these files will accordingly be named ``a.txt.local``, |
|
241 | ``a.txt``, these files will accordingly be named ``a.txt.local``, | |
231 | ``a.txt.other`` and ``a.txt.base`` and they will be placed in the |
|
242 | ``a.txt.other`` and ``a.txt.base`` and they will be placed in the | |
232 | same directory as ``a.txt``.""" |
|
243 | same directory as ``a.txt``.""" | |
233 | r = _premerge(repo, toolconf, files, labels=labels) |
|
244 | r = _premerge(repo, toolconf, files, labels=labels) | |
234 | if r: |
|
245 | if r: | |
235 | a, b, c, back = files |
|
246 | a, b, c, back = files | |
236 |
|
247 | |||
237 | fd = fcd.path() |
|
248 | fd = fcd.path() | |
238 |
|
249 | |||
239 | util.copyfile(a, a + ".local") |
|
250 | util.copyfile(a, a + ".local") | |
240 | repo.wwrite(fd + ".other", fco.data(), fco.flags()) |
|
251 | repo.wwrite(fd + ".other", fco.data(), fco.flags()) | |
241 | repo.wwrite(fd + ".base", fca.data(), fca.flags()) |
|
252 | repo.wwrite(fd + ".base", fca.data(), fca.flags()) | |
242 | return False, r |
|
253 | return False, r | |
243 |
|
254 | |||
244 | def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
|
255 | def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | |
245 | r = _premerge(repo, toolconf, files, labels=labels) |
|
256 | r = _premerge(repo, toolconf, files, labels=labels) | |
246 | if r: |
|
257 | if r: | |
247 | tool, toolpath, binary, symlink = toolconf |
|
258 | tool, toolpath, binary, symlink = toolconf | |
248 | a, b, c, back = files |
|
259 | a, b, c, back = files | |
249 | out = "" |
|
260 | out = "" | |
250 | env = {'HG_FILE': fcd.path(), |
|
261 | env = {'HG_FILE': fcd.path(), | |
251 | 'HG_MY_NODE': short(mynode), |
|
262 | 'HG_MY_NODE': short(mynode), | |
252 | 'HG_OTHER_NODE': str(fco.changectx()), |
|
263 | 'HG_OTHER_NODE': str(fco.changectx()), | |
253 | 'HG_BASE_NODE': str(fca.changectx()), |
|
264 | 'HG_BASE_NODE': str(fca.changectx()), | |
254 | 'HG_MY_ISLINK': 'l' in fcd.flags(), |
|
265 | 'HG_MY_ISLINK': 'l' in fcd.flags(), | |
255 | 'HG_OTHER_ISLINK': 'l' in fco.flags(), |
|
266 | 'HG_OTHER_ISLINK': 'l' in fco.flags(), | |
256 | 'HG_BASE_ISLINK': 'l' in fca.flags(), |
|
267 | 'HG_BASE_ISLINK': 'l' in fca.flags(), | |
257 | } |
|
268 | } | |
258 |
|
269 | |||
259 | ui = repo.ui |
|
270 | ui = repo.ui | |
260 |
|
271 | |||
261 | args = _toolstr(ui, tool, "args", '$local $base $other') |
|
272 | args = _toolstr(ui, tool, "args", '$local $base $other') | |
262 | if "$output" in args: |
|
273 | if "$output" in args: | |
263 | out, a = a, back # read input from backup, write to original |
|
274 | out, a = a, back # read input from backup, write to original | |
264 | replace = {'local': a, 'base': b, 'other': c, 'output': out} |
|
275 | replace = {'local': a, 'base': b, 'other': c, 'output': out} | |
265 | args = util.interpolate(r'\$', replace, args, |
|
276 | args = util.interpolate(r'\$', replace, args, | |
266 | lambda s: util.shellquote(util.localpath(s))) |
|
277 | lambda s: util.shellquote(util.localpath(s))) | |
267 | r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, |
|
278 | r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, | |
268 | out=ui.fout) |
|
279 | out=ui.fout) | |
269 | return True, r |
|
280 | return True, r | |
270 | return False, 0 |
|
281 | return False, 0 | |
271 |
|
282 | |||
272 | def _formatconflictmarker(repo, ctx, template, label, pad): |
|
283 | def _formatconflictmarker(repo, ctx, template, label, pad): | |
273 | """Applies the given template to the ctx, prefixed by the label. |
|
284 | """Applies the given template to the ctx, prefixed by the label. | |
274 |
|
285 | |||
275 | Pad is the minimum width of the label prefix, so that multiple markers |
|
286 | Pad is the minimum width of the label prefix, so that multiple markers | |
276 | can have aligned templated parts. |
|
287 | can have aligned templated parts. | |
277 | """ |
|
288 | """ | |
278 | if ctx.node() is None: |
|
289 | if ctx.node() is None: | |
279 | ctx = ctx.p1() |
|
290 | ctx = ctx.p1() | |
280 |
|
291 | |||
281 | props = templatekw.keywords.copy() |
|
292 | props = templatekw.keywords.copy() | |
282 | props['templ'] = template |
|
293 | props['templ'] = template | |
283 | props['ctx'] = ctx |
|
294 | props['ctx'] = ctx | |
284 | props['repo'] = repo |
|
295 | props['repo'] = repo | |
285 | templateresult = template('conflictmarker', **props) |
|
296 | templateresult = template('conflictmarker', **props) | |
286 |
|
297 | |||
287 | label = ('%s:' % label).ljust(pad + 1) |
|
298 | label = ('%s:' % label).ljust(pad + 1) | |
288 | mark = '%s %s' % (label, templater.stringify(templateresult)) |
|
299 | mark = '%s %s' % (label, templater.stringify(templateresult)) | |
289 |
|
300 | |||
290 | if mark: |
|
301 | if mark: | |
291 | mark = mark.splitlines()[0] # split for safety |
|
302 | mark = mark.splitlines()[0] # split for safety | |
292 |
|
303 | |||
293 | # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') |
|
304 | # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') | |
294 | return util.ellipsis(mark, 80 - 8) |
|
305 | return util.ellipsis(mark, 80 - 8) | |
295 |
|
306 | |||
296 | _defaultconflictmarker = ('{node|short} ' + |
|
307 | _defaultconflictmarker = ('{node|short} ' + | |
297 | '{ifeq(tags, "tip", "", "{tags} ")}' + |
|
308 | '{ifeq(tags, "tip", "", "{tags} ")}' + | |
298 | '{if(bookmarks, "{bookmarks} ")}' + |
|
309 | '{if(bookmarks, "{bookmarks} ")}' + | |
299 | '{ifeq(branch, "default", "", "{branch} ")}' + |
|
310 | '{ifeq(branch, "default", "", "{branch} ")}' + | |
300 | '- {author|user}: {desc|firstline}') |
|
311 | '- {author|user}: {desc|firstline}') | |
301 |
|
312 | |||
302 | _defaultconflictlabels = ['local', 'other'] |
|
313 | _defaultconflictlabels = ['local', 'other'] | |
303 |
|
314 | |||
304 | def _formatlabels(repo, fcd, fco, labels): |
|
315 | def _formatlabels(repo, fcd, fco, labels): | |
305 | """Formats the given labels using the conflict marker template. |
|
316 | """Formats the given labels using the conflict marker template. | |
306 |
|
317 | |||
307 | Returns a list of formatted labels. |
|
318 | Returns a list of formatted labels. | |
308 | """ |
|
319 | """ | |
309 | cd = fcd.changectx() |
|
320 | cd = fcd.changectx() | |
310 | co = fco.changectx() |
|
321 | co = fco.changectx() | |
311 |
|
322 | |||
312 | ui = repo.ui |
|
323 | ui = repo.ui | |
313 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) |
|
324 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) | |
314 | template = templater.parsestring(template, quoted=False) |
|
325 | template = templater.parsestring(template, quoted=False) | |
315 | tmpl = templater.templater(None, cache={ 'conflictmarker' : template }) |
|
326 | tmpl = templater.templater(None, cache={ 'conflictmarker' : template }) | |
316 |
|
327 | |||
317 | pad = max(len(labels[0]), len(labels[1])) |
|
328 | pad = max(len(labels[0]), len(labels[1])) | |
318 |
|
329 | |||
319 | return [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), |
|
330 | return [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), | |
320 | _formatconflictmarker(repo, co, tmpl, labels[1], pad)] |
|
331 | _formatconflictmarker(repo, co, tmpl, labels[1], pad)] | |
321 |
|
332 | |||
322 | def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None): |
|
333 | def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None): | |
323 | """perform a 3-way merge in the working directory |
|
334 | """perform a 3-way merge in the working directory | |
324 |
|
335 | |||
325 | mynode = parent node before merge |
|
336 | mynode = parent node before merge | |
326 | orig = original local filename before merge |
|
337 | orig = original local filename before merge | |
327 | fco = other file context |
|
338 | fco = other file context | |
328 | fca = ancestor file context |
|
339 | fca = ancestor file context | |
329 | fcd = local file context for current/destination file |
|
340 | fcd = local file context for current/destination file | |
330 | """ |
|
341 | """ | |
331 |
|
342 | |||
332 | def temp(prefix, ctx): |
|
343 | def temp(prefix, ctx): | |
333 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) |
|
344 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) | |
334 | (fd, name) = tempfile.mkstemp(prefix=pre) |
|
345 | (fd, name) = tempfile.mkstemp(prefix=pre) | |
335 | data = repo.wwritedata(ctx.path(), ctx.data()) |
|
346 | data = repo.wwritedata(ctx.path(), ctx.data()) | |
336 | f = os.fdopen(fd, "wb") |
|
347 | f = os.fdopen(fd, "wb") | |
337 | f.write(data) |
|
348 | f.write(data) | |
338 | f.close() |
|
349 | f.close() | |
339 | return name |
|
350 | return name | |
340 |
|
351 | |||
341 | if not fco.cmp(fcd): # files identical? |
|
352 | if not fco.cmp(fcd): # files identical? | |
342 | return None |
|
353 | return None | |
343 |
|
354 | |||
344 | ui = repo.ui |
|
355 | ui = repo.ui | |
345 | fd = fcd.path() |
|
356 | fd = fcd.path() | |
346 | binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
|
357 | binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() | |
347 | symlink = 'l' in fcd.flags() + fco.flags() |
|
358 | symlink = 'l' in fcd.flags() + fco.flags() | |
348 | tool, toolpath = _picktool(repo, ui, fd, binary, symlink) |
|
359 | tool, toolpath = _picktool(repo, ui, fd, binary, symlink) | |
349 | ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % |
|
360 | ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % | |
350 | (tool, fd, binary, symlink)) |
|
361 | (tool, fd, binary, symlink)) | |
351 |
|
362 | |||
352 | if tool in internals: |
|
363 | if tool in internals: | |
353 | func = internals[tool] |
|
364 | func = internals[tool] | |
354 | trymerge = func.trymerge |
|
365 | trymerge = func.trymerge | |
355 | onfailure = func.onfailure |
|
366 | onfailure = func.onfailure | |
356 | else: |
|
367 | else: | |
357 | func = _xmerge |
|
368 | func = _xmerge | |
358 | trymerge = True |
|
369 | trymerge = True | |
359 | onfailure = _("merging %s failed!\n") |
|
370 | onfailure = _("merging %s failed!\n") | |
360 |
|
371 | |||
361 | toolconf = tool, toolpath, binary, symlink |
|
372 | toolconf = tool, toolpath, binary, symlink | |
362 |
|
373 | |||
363 | if not trymerge: |
|
374 | if not trymerge: | |
364 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
375 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) | |
365 |
|
376 | |||
366 | a = repo.wjoin(fd) |
|
377 | a = repo.wjoin(fd) | |
367 | b = temp("base", fca) |
|
378 | b = temp("base", fca) | |
368 | c = temp("other", fco) |
|
379 | c = temp("other", fco) | |
369 | back = a + ".orig" |
|
380 | back = a + ".orig" | |
370 | util.copyfile(a, back) |
|
381 | util.copyfile(a, back) | |
371 |
|
382 | |||
372 | if orig != fco.path(): |
|
383 | if orig != fco.path(): | |
373 | ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) |
|
384 | ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) | |
374 | else: |
|
385 | else: | |
375 | ui.status(_("merging %s\n") % fd) |
|
386 | ui.status(_("merging %s\n") % fd) | |
376 |
|
387 | |||
377 | ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) |
|
388 | ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) | |
378 |
|
389 | |||
379 | markerstyle = ui.config('ui', 'mergemarkers', 'basic') |
|
390 | markerstyle = ui.config('ui', 'mergemarkers', 'basic') | |
380 | if markerstyle == 'basic': |
|
391 | if markerstyle == 'basic': | |
381 | formattedlabels = _defaultconflictlabels |
|
392 | formattedlabels = _defaultconflictlabels | |
382 | else: |
|
393 | else: | |
383 | if not labels: |
|
394 | if not labels: | |
384 | labels = _defaultconflictlabels |
|
395 | labels = _defaultconflictlabels | |
385 |
|
396 | |||
386 | formattedlabels = _formatlabels(repo, fcd, fco, labels) |
|
397 | formattedlabels = _formatlabels(repo, fcd, fco, labels) | |
387 |
|
398 | |||
388 | needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, |
|
399 | needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, | |
389 | (a, b, c, back), labels=formattedlabels) |
|
400 | (a, b, c, back), labels=formattedlabels) | |
390 | if not needcheck: |
|
401 | if not needcheck: | |
391 | if r: |
|
402 | if r: | |
392 | if onfailure: |
|
403 | if onfailure: | |
393 | ui.warn(onfailure % fd) |
|
404 | ui.warn(onfailure % fd) | |
394 | else: |
|
405 | else: | |
395 | util.unlink(back) |
|
406 | util.unlink(back) | |
396 |
|
407 | |||
397 | util.unlink(b) |
|
408 | util.unlink(b) | |
398 | util.unlink(c) |
|
409 | util.unlink(c) | |
399 | return r |
|
410 | return r | |
400 |
|
411 | |||
401 | if not r and (_toolbool(ui, tool, "checkconflicts") or |
|
412 | if not r and (_toolbool(ui, tool, "checkconflicts") or | |
402 | 'conflicts' in _toollist(ui, tool, "check")): |
|
413 | 'conflicts' in _toollist(ui, tool, "check")): | |
403 | if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), |
|
414 | if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), | |
404 | re.MULTILINE): |
|
415 | re.MULTILINE): | |
405 | r = 1 |
|
416 | r = 1 | |
406 |
|
417 | |||
407 | checked = False |
|
418 | checked = False | |
408 | if 'prompt' in _toollist(ui, tool, "check"): |
|
419 | if 'prompt' in _toollist(ui, tool, "check"): | |
409 | checked = True |
|
420 | checked = True | |
410 | if ui.promptchoice(_("was merge of '%s' successful (yn)?" |
|
421 | if ui.promptchoice(_("was merge of '%s' successful (yn)?" | |
411 | "$$ &Yes $$ &No") % fd, 1): |
|
422 | "$$ &Yes $$ &No") % fd, 1): | |
412 | r = 1 |
|
423 | r = 1 | |
413 |
|
424 | |||
414 | if not r and not checked and (_toolbool(ui, tool, "checkchanged") or |
|
425 | if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | |
415 | 'changed' in _toollist(ui, tool, "check")): |
|
426 | 'changed' in _toollist(ui, tool, "check")): | |
416 | if filecmp.cmp(a, back): |
|
427 | if filecmp.cmp(a, back): | |
417 | if ui.promptchoice(_(" output file %s appears unchanged\n" |
|
428 | if ui.promptchoice(_(" output file %s appears unchanged\n" | |
418 | "was merge successful (yn)?" |
|
429 | "was merge successful (yn)?" | |
419 | "$$ &Yes $$ &No") % fd, 1): |
|
430 | "$$ &Yes $$ &No") % fd, 1): | |
420 | r = 1 |
|
431 | r = 1 | |
421 |
|
432 | |||
422 | if _toolbool(ui, tool, "fixeol"): |
|
433 | if _toolbool(ui, tool, "fixeol"): | |
423 | _matcheol(a, back) |
|
434 | _matcheol(a, back) | |
424 |
|
435 | |||
425 | if r: |
|
436 | if r: | |
426 | if onfailure: |
|
437 | if onfailure: | |
427 | ui.warn(onfailure % fd) |
|
438 | ui.warn(onfailure % fd) | |
428 | else: |
|
439 | else: | |
429 | util.unlink(back) |
|
440 | util.unlink(back) | |
430 |
|
441 | |||
431 | util.unlink(b) |
|
442 | util.unlink(b) | |
432 | util.unlink(c) |
|
443 | util.unlink(c) | |
433 | return r |
|
444 | return r | |
434 |
|
445 | |||
435 | # tell hggettext to extract docstrings from these functions: |
|
446 | # tell hggettext to extract docstrings from these functions: | |
436 | i18nfunctions = internals.values() |
|
447 | i18nfunctions = internals.values() |
@@ -1,405 +1,606 | |||||
1 | $ hg init test |
|
1 | $ hg init test | |
2 | $ cd test |
|
2 | $ cd test | |
3 |
|
3 | |||
4 | $ echo a > a |
|
4 | $ echo a > a | |
5 | $ hg add a |
|
5 | $ hg add a | |
6 | $ hg commit -m "test" |
|
6 | $ hg commit -m "test" | |
7 | $ hg history |
|
7 | $ hg history | |
8 | changeset: 0:acb14030fe0a |
|
8 | changeset: 0:acb14030fe0a | |
9 | tag: tip |
|
9 | tag: tip | |
10 | user: test |
|
10 | user: test | |
11 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
11 | date: Thu Jan 01 00:00:00 1970 +0000 | |
12 | summary: test |
|
12 | summary: test | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | $ hg tag ' ' |
|
15 | $ hg tag ' ' | |
16 | abort: tag names cannot consist entirely of whitespace |
|
16 | abort: tag names cannot consist entirely of whitespace | |
17 | [255] |
|
17 | [255] | |
18 |
|
18 | |||
19 | (this tests also that editor is not invoked, if '--edit' is not |
|
19 | (this tests also that editor is not invoked, if '--edit' is not | |
20 | specified) |
|
20 | specified) | |
21 |
|
21 | |||
22 | $ HGEDITOR=cat hg tag "bleah" |
|
22 | $ HGEDITOR=cat hg tag "bleah" | |
23 | $ hg history |
|
23 | $ hg history | |
24 | changeset: 1:d4f0d2909abc |
|
24 | changeset: 1:d4f0d2909abc | |
25 | tag: tip |
|
25 | tag: tip | |
26 | user: test |
|
26 | user: test | |
27 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
27 | date: Thu Jan 01 00:00:00 1970 +0000 | |
28 | summary: Added tag bleah for changeset acb14030fe0a |
|
28 | summary: Added tag bleah for changeset acb14030fe0a | |
29 |
|
29 | |||
30 | changeset: 0:acb14030fe0a |
|
30 | changeset: 0:acb14030fe0a | |
31 | tag: bleah |
|
31 | tag: bleah | |
32 | user: test |
|
32 | user: test | |
33 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
33 | date: Thu Jan 01 00:00:00 1970 +0000 | |
34 | summary: test |
|
34 | summary: test | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | $ echo foo >> .hgtags |
|
37 | $ echo foo >> .hgtags | |
38 | $ hg tag "bleah2" |
|
38 | $ hg tag "bleah2" | |
39 | abort: working copy of .hgtags is changed (please commit .hgtags manually) |
|
39 | abort: working copy of .hgtags is changed (please commit .hgtags manually) | |
40 | [255] |
|
40 | [255] | |
41 |
|
41 | |||
42 | $ hg revert .hgtags |
|
42 | $ hg revert .hgtags | |
43 | $ hg tag -r 0 x y z y y z |
|
43 | $ hg tag -r 0 x y z y y z | |
44 | abort: tag names must be unique |
|
44 | abort: tag names must be unique | |
45 | [255] |
|
45 | [255] | |
46 | $ hg tag tap nada dot tip |
|
46 | $ hg tag tap nada dot tip | |
47 | abort: the name 'tip' is reserved |
|
47 | abort: the name 'tip' is reserved | |
48 | [255] |
|
48 | [255] | |
49 | $ hg tag . |
|
49 | $ hg tag . | |
50 | abort: the name '.' is reserved |
|
50 | abort: the name '.' is reserved | |
51 | [255] |
|
51 | [255] | |
52 | $ hg tag null |
|
52 | $ hg tag null | |
53 | abort: the name 'null' is reserved |
|
53 | abort: the name 'null' is reserved | |
54 | [255] |
|
54 | [255] | |
55 | $ hg tag "bleah" |
|
55 | $ hg tag "bleah" | |
56 | abort: tag 'bleah' already exists (use -f to force) |
|
56 | abort: tag 'bleah' already exists (use -f to force) | |
57 | [255] |
|
57 | [255] | |
58 | $ hg tag "blecch" "bleah" |
|
58 | $ hg tag "blecch" "bleah" | |
59 | abort: tag 'bleah' already exists (use -f to force) |
|
59 | abort: tag 'bleah' already exists (use -f to force) | |
60 | [255] |
|
60 | [255] | |
61 |
|
61 | |||
62 | $ hg tag --remove "blecch" |
|
62 | $ hg tag --remove "blecch" | |
63 | abort: tag 'blecch' does not exist |
|
63 | abort: tag 'blecch' does not exist | |
64 | [255] |
|
64 | [255] | |
65 | $ hg tag --remove "bleah" "blecch" "blough" |
|
65 | $ hg tag --remove "bleah" "blecch" "blough" | |
66 | abort: tag 'blecch' does not exist |
|
66 | abort: tag 'blecch' does not exist | |
67 | [255] |
|
67 | [255] | |
68 |
|
68 | |||
69 | $ hg tag -r 0 "bleah0" |
|
69 | $ hg tag -r 0 "bleah0" | |
70 | $ hg tag -l -r 1 "bleah1" |
|
70 | $ hg tag -l -r 1 "bleah1" | |
71 | $ hg tag gack gawk gorp |
|
71 | $ hg tag gack gawk gorp | |
72 | $ hg tag -f gack |
|
72 | $ hg tag -f gack | |
73 | $ hg tag --remove gack gorp |
|
73 | $ hg tag --remove gack gorp | |
74 |
|
74 | |||
75 | $ hg tag "bleah " |
|
75 | $ hg tag "bleah " | |
76 | abort: tag 'bleah' already exists (use -f to force) |
|
76 | abort: tag 'bleah' already exists (use -f to force) | |
77 | [255] |
|
77 | [255] | |
78 | $ hg tag " bleah" |
|
78 | $ hg tag " bleah" | |
79 | abort: tag 'bleah' already exists (use -f to force) |
|
79 | abort: tag 'bleah' already exists (use -f to force) | |
80 | [255] |
|
80 | [255] | |
81 | $ hg tag " bleah" |
|
81 | $ hg tag " bleah" | |
82 | abort: tag 'bleah' already exists (use -f to force) |
|
82 | abort: tag 'bleah' already exists (use -f to force) | |
83 | [255] |
|
83 | [255] | |
84 | $ hg tag -r 0 " bleahbleah " |
|
84 | $ hg tag -r 0 " bleahbleah " | |
85 | $ hg tag -r 0 " bleah bleah " |
|
85 | $ hg tag -r 0 " bleah bleah " | |
86 |
|
86 | |||
87 | $ cat .hgtags |
|
87 | $ cat .hgtags | |
88 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah |
|
88 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah | |
89 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0 |
|
89 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0 | |
90 | 336fccc858a4eb69609a291105009e484a6b6b8d gack |
|
90 | 336fccc858a4eb69609a291105009e484a6b6b8d gack | |
91 | 336fccc858a4eb69609a291105009e484a6b6b8d gawk |
|
91 | 336fccc858a4eb69609a291105009e484a6b6b8d gawk | |
92 | 336fccc858a4eb69609a291105009e484a6b6b8d gorp |
|
92 | 336fccc858a4eb69609a291105009e484a6b6b8d gorp | |
93 | 336fccc858a4eb69609a291105009e484a6b6b8d gack |
|
93 | 336fccc858a4eb69609a291105009e484a6b6b8d gack | |
94 | 799667b6f2d9b957f73fa644a918c2df22bab58f gack |
|
94 | 799667b6f2d9b957f73fa644a918c2df22bab58f gack | |
95 | 799667b6f2d9b957f73fa644a918c2df22bab58f gack |
|
95 | 799667b6f2d9b957f73fa644a918c2df22bab58f gack | |
96 | 0000000000000000000000000000000000000000 gack |
|
96 | 0000000000000000000000000000000000000000 gack | |
97 | 336fccc858a4eb69609a291105009e484a6b6b8d gorp |
|
97 | 336fccc858a4eb69609a291105009e484a6b6b8d gorp | |
98 | 0000000000000000000000000000000000000000 gorp |
|
98 | 0000000000000000000000000000000000000000 gorp | |
99 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleahbleah |
|
99 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleahbleah | |
100 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah bleah |
|
100 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah bleah | |
101 |
|
101 | |||
102 | $ cat .hg/localtags |
|
102 | $ cat .hg/localtags | |
103 | d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 |
|
103 | d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 | |
104 |
|
104 | |||
105 | tagging on a non-head revision |
|
105 | tagging on a non-head revision | |
106 |
|
106 | |||
107 | $ hg update 0 |
|
107 | $ hg update 0 | |
108 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
108 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
109 | $ hg tag -l localblah |
|
109 | $ hg tag -l localblah | |
110 | $ hg tag "foobar" |
|
110 | $ hg tag "foobar" | |
111 | abort: not at a branch head (use -f to force) |
|
111 | abort: not at a branch head (use -f to force) | |
112 | [255] |
|
112 | [255] | |
113 | $ hg tag -f "foobar" |
|
113 | $ hg tag -f "foobar" | |
114 | $ cat .hgtags |
|
114 | $ cat .hgtags | |
115 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
115 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | |
116 | $ cat .hg/localtags |
|
116 | $ cat .hg/localtags | |
117 | d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 |
|
117 | d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 | |
118 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah |
|
118 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah | |
119 |
|
119 | |||
120 | $ hg tag -l 'xx |
|
120 | $ hg tag -l 'xx | |
121 | > newline' |
|
121 | > newline' | |
122 | abort: '\n' cannot be used in a name |
|
122 | abort: '\n' cannot be used in a name | |
123 | [255] |
|
123 | [255] | |
124 | $ hg tag -l 'xx:xx' |
|
124 | $ hg tag -l 'xx:xx' | |
125 | abort: ':' cannot be used in a name |
|
125 | abort: ':' cannot be used in a name | |
126 | [255] |
|
126 | [255] | |
127 |
|
127 | |||
128 | cloning local tags |
|
128 | cloning local tags | |
129 |
|
129 | |||
130 | $ cd .. |
|
130 | $ cd .. | |
131 | $ hg -R test log -r0:5 |
|
131 | $ hg -R test log -r0:5 | |
132 | changeset: 0:acb14030fe0a |
|
132 | changeset: 0:acb14030fe0a | |
133 | tag: bleah |
|
133 | tag: bleah | |
134 | tag: bleah bleah |
|
134 | tag: bleah bleah | |
135 | tag: bleah0 |
|
135 | tag: bleah0 | |
136 | tag: bleahbleah |
|
136 | tag: bleahbleah | |
137 | tag: foobar |
|
137 | tag: foobar | |
138 | tag: localblah |
|
138 | tag: localblah | |
139 | user: test |
|
139 | user: test | |
140 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
140 | date: Thu Jan 01 00:00:00 1970 +0000 | |
141 | summary: test |
|
141 | summary: test | |
142 |
|
142 | |||
143 | changeset: 1:d4f0d2909abc |
|
143 | changeset: 1:d4f0d2909abc | |
144 | tag: bleah1 |
|
144 | tag: bleah1 | |
145 | user: test |
|
145 | user: test | |
146 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
146 | date: Thu Jan 01 00:00:00 1970 +0000 | |
147 | summary: Added tag bleah for changeset acb14030fe0a |
|
147 | summary: Added tag bleah for changeset acb14030fe0a | |
148 |
|
148 | |||
149 | changeset: 2:336fccc858a4 |
|
149 | changeset: 2:336fccc858a4 | |
150 | tag: gawk |
|
150 | tag: gawk | |
151 | user: test |
|
151 | user: test | |
152 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
152 | date: Thu Jan 01 00:00:00 1970 +0000 | |
153 | summary: Added tag bleah0 for changeset acb14030fe0a |
|
153 | summary: Added tag bleah0 for changeset acb14030fe0a | |
154 |
|
154 | |||
155 | changeset: 3:799667b6f2d9 |
|
155 | changeset: 3:799667b6f2d9 | |
156 | user: test |
|
156 | user: test | |
157 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
157 | date: Thu Jan 01 00:00:00 1970 +0000 | |
158 | summary: Added tag gack, gawk, gorp for changeset 336fccc858a4 |
|
158 | summary: Added tag gack, gawk, gorp for changeset 336fccc858a4 | |
159 |
|
159 | |||
160 | changeset: 4:154eeb7c0138 |
|
160 | changeset: 4:154eeb7c0138 | |
161 | user: test |
|
161 | user: test | |
162 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
162 | date: Thu Jan 01 00:00:00 1970 +0000 | |
163 | summary: Added tag gack for changeset 799667b6f2d9 |
|
163 | summary: Added tag gack for changeset 799667b6f2d9 | |
164 |
|
164 | |||
165 | changeset: 5:b4bb47aaff09 |
|
165 | changeset: 5:b4bb47aaff09 | |
166 | user: test |
|
166 | user: test | |
167 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
167 | date: Thu Jan 01 00:00:00 1970 +0000 | |
168 | summary: Removed tag gack, gorp |
|
168 | summary: Removed tag gack, gorp | |
169 |
|
169 | |||
170 | $ hg clone -q -rbleah1 test test1 |
|
170 | $ hg clone -q -rbleah1 test test1 | |
171 | $ hg -R test1 parents --style=compact |
|
171 | $ hg -R test1 parents --style=compact | |
172 | 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test |
|
172 | 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test | |
173 | Added tag bleah for changeset acb14030fe0a |
|
173 | Added tag bleah for changeset acb14030fe0a | |
174 |
|
174 | |||
175 | $ hg clone -q -r5 test#bleah1 test2 |
|
175 | $ hg clone -q -r5 test#bleah1 test2 | |
176 | $ hg -R test2 parents --style=compact |
|
176 | $ hg -R test2 parents --style=compact | |
177 | 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test |
|
177 | 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test | |
178 | Removed tag gack, gorp |
|
178 | Removed tag gack, gorp | |
179 |
|
179 | |||
180 | $ hg clone -q -U test#bleah1 test3 |
|
180 | $ hg clone -q -U test#bleah1 test3 | |
181 | $ hg -R test3 parents --style=compact |
|
181 | $ hg -R test3 parents --style=compact | |
182 |
|
182 | |||
183 | $ cd test |
|
183 | $ cd test | |
184 |
|
184 | |||
185 | Issue601: hg tag doesn't do the right thing if .hgtags or localtags |
|
185 | Issue601: hg tag doesn't do the right thing if .hgtags or localtags | |
186 | doesn't end with EOL |
|
186 | doesn't end with EOL | |
187 |
|
187 | |||
188 | $ python << EOF |
|
188 | $ python << EOF | |
189 | > f = file('.hg/localtags'); last = f.readlines()[-1][:-1]; f.close() |
|
189 | > f = file('.hg/localtags'); last = f.readlines()[-1][:-1]; f.close() | |
190 | > f = file('.hg/localtags', 'w'); f.write(last); f.close() |
|
190 | > f = file('.hg/localtags', 'w'); f.write(last); f.close() | |
191 | > EOF |
|
191 | > EOF | |
192 | $ cat .hg/localtags; echo |
|
192 | $ cat .hg/localtags; echo | |
193 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah |
|
193 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah | |
194 | $ hg tag -l localnewline |
|
194 | $ hg tag -l localnewline | |
195 | $ cat .hg/localtags; echo |
|
195 | $ cat .hg/localtags; echo | |
196 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah |
|
196 | acb14030fe0a21b60322c440ad2d20cf7685a376 localblah | |
197 | c2899151f4e76890c602a2597a650a72666681bf localnewline |
|
197 | c2899151f4e76890c602a2597a650a72666681bf localnewline | |
198 |
|
198 | |||
199 |
|
199 | |||
200 | $ python << EOF |
|
200 | $ python << EOF | |
201 | > f = file('.hgtags'); last = f.readlines()[-1][:-1]; f.close() |
|
201 | > f = file('.hgtags'); last = f.readlines()[-1][:-1]; f.close() | |
202 | > f = file('.hgtags', 'w'); f.write(last); f.close() |
|
202 | > f = file('.hgtags', 'w'); f.write(last); f.close() | |
203 | > EOF |
|
203 | > EOF | |
204 | $ hg ci -m'broken manual edit of .hgtags' |
|
204 | $ hg ci -m'broken manual edit of .hgtags' | |
205 | $ cat .hgtags; echo |
|
205 | $ cat .hgtags; echo | |
206 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
206 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | |
207 | $ hg tag newline |
|
207 | $ hg tag newline | |
208 | $ cat .hgtags; echo |
|
208 | $ cat .hgtags; echo | |
209 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
209 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | |
210 | a0eea09de1eeec777b46f2085260a373b2fbc293 newline |
|
210 | a0eea09de1eeec777b46f2085260a373b2fbc293 newline | |
211 |
|
211 | |||
212 |
|
212 | |||
213 | tag and branch using same name |
|
213 | tag and branch using same name | |
214 |
|
214 | |||
215 | $ hg branch tag-and-branch-same-name |
|
215 | $ hg branch tag-and-branch-same-name | |
216 | marked working directory as branch tag-and-branch-same-name |
|
216 | marked working directory as branch tag-and-branch-same-name | |
217 | (branches are permanent and global, did you want a bookmark?) |
|
217 | (branches are permanent and global, did you want a bookmark?) | |
218 | $ hg ci -m"discouraged" |
|
218 | $ hg ci -m"discouraged" | |
219 | $ hg tag tag-and-branch-same-name |
|
219 | $ hg tag tag-and-branch-same-name | |
220 | warning: tag tag-and-branch-same-name conflicts with existing branch name |
|
220 | warning: tag tag-and-branch-same-name conflicts with existing branch name | |
221 |
|
221 | |||
222 | test custom commit messages |
|
222 | test custom commit messages | |
223 |
|
223 | |||
224 | $ cat > editor.sh << '__EOF__' |
|
224 | $ cat > editor.sh << '__EOF__' | |
225 | > echo "==== before editing" |
|
225 | > echo "==== before editing" | |
226 | > cat "$1" |
|
226 | > cat "$1" | |
227 | > echo "====" |
|
227 | > echo "====" | |
228 | > echo "custom tag message" > "$1" |
|
228 | > echo "custom tag message" > "$1" | |
229 | > echo "second line" >> "$1" |
|
229 | > echo "second line" >> "$1" | |
230 | > __EOF__ |
|
230 | > __EOF__ | |
231 |
|
231 | |||
232 | at first, test saving last-message.txt |
|
232 | at first, test saving last-message.txt | |
233 |
|
233 | |||
234 | (test that editor is not invoked before transaction starting) |
|
234 | (test that editor is not invoked before transaction starting) | |
235 |
|
235 | |||
236 | $ cat > .hg/hgrc << '__EOF__' |
|
236 | $ cat > .hg/hgrc << '__EOF__' | |
237 | > [hooks] |
|
237 | > [hooks] | |
238 | > # this failure occurs before editor invocation |
|
238 | > # this failure occurs before editor invocation | |
239 | > pretag.test-saving-lastmessage = false |
|
239 | > pretag.test-saving-lastmessage = false | |
240 | > __EOF__ |
|
240 | > __EOF__ | |
241 | $ rm -f .hg/last-message.txt |
|
241 | $ rm -f .hg/last-message.txt | |
242 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e |
|
242 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e | |
243 | abort: pretag.test-saving-lastmessage hook exited with status 1 |
|
243 | abort: pretag.test-saving-lastmessage hook exited with status 1 | |
244 | [255] |
|
244 | [255] | |
245 | $ cat .hg/last-message.txt |
|
245 | $ cat .hg/last-message.txt | |
246 | cat: .hg/last-message.txt: No such file or directory |
|
246 | cat: .hg/last-message.txt: No such file or directory | |
247 | [1] |
|
247 | [1] | |
248 |
|
248 | |||
249 | (test that editor is invoked and commit message is saved into |
|
249 | (test that editor is invoked and commit message is saved into | |
250 | "last-message.txt") |
|
250 | "last-message.txt") | |
251 |
|
251 | |||
252 | $ cat >> .hg/hgrc << '__EOF__' |
|
252 | $ cat >> .hg/hgrc << '__EOF__' | |
253 | > [hooks] |
|
253 | > [hooks] | |
254 | > pretag.test-saving-lastmessage = |
|
254 | > pretag.test-saving-lastmessage = | |
255 | > # this failure occurs after editor invocation |
|
255 | > # this failure occurs after editor invocation | |
256 | > pretxncommit.unexpectedabort = false |
|
256 | > pretxncommit.unexpectedabort = false | |
257 | > __EOF__ |
|
257 | > __EOF__ | |
258 |
|
258 | |||
259 | (this tests also that editor is invoked, if '--edit' is specified, |
|
259 | (this tests also that editor is invoked, if '--edit' is specified, | |
260 | regardless of '--message') |
|
260 | regardless of '--message') | |
261 |
|
261 | |||
262 | $ rm -f .hg/last-message.txt |
|
262 | $ rm -f .hg/last-message.txt | |
263 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e -m "foo bar" |
|
263 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e -m "foo bar" | |
264 | ==== before editing |
|
264 | ==== before editing | |
265 | foo bar |
|
265 | foo bar | |
266 |
|
266 | |||
267 |
|
267 | |||
268 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
268 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
269 | HG: Leave message empty to abort commit. |
|
269 | HG: Leave message empty to abort commit. | |
270 | HG: -- |
|
270 | HG: -- | |
271 | HG: user: test |
|
271 | HG: user: test | |
272 | HG: branch 'tag-and-branch-same-name' |
|
272 | HG: branch 'tag-and-branch-same-name' | |
273 | HG: changed .hgtags |
|
273 | HG: changed .hgtags | |
274 | ==== |
|
274 | ==== | |
275 | transaction abort! |
|
275 | transaction abort! | |
276 | rollback completed |
|
276 | rollback completed | |
277 | note: commit message saved in .hg/last-message.txt |
|
277 | note: commit message saved in .hg/last-message.txt | |
278 | abort: pretxncommit.unexpectedabort hook exited with status 1 |
|
278 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |
279 | [255] |
|
279 | [255] | |
280 | $ cat .hg/last-message.txt |
|
280 | $ cat .hg/last-message.txt | |
281 | custom tag message |
|
281 | custom tag message | |
282 | second line |
|
282 | second line | |
283 |
|
283 | |||
284 | $ cat >> .hg/hgrc << '__EOF__' |
|
284 | $ cat >> .hg/hgrc << '__EOF__' | |
285 | > [hooks] |
|
285 | > [hooks] | |
286 | > pretxncommit.unexpectedabort = |
|
286 | > pretxncommit.unexpectedabort = | |
287 | > __EOF__ |
|
287 | > __EOF__ | |
288 | $ hg status .hgtags |
|
288 | $ hg status .hgtags | |
289 | M .hgtags |
|
289 | M .hgtags | |
290 | $ hg revert --no-backup -q .hgtags |
|
290 | $ hg revert --no-backup -q .hgtags | |
291 |
|
291 | |||
292 | then, test custom commit message itself |
|
292 | then, test custom commit message itself | |
293 |
|
293 | |||
294 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e |
|
294 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e | |
295 | ==== before editing |
|
295 | ==== before editing | |
296 | Added tag custom-tag for changeset 75a534207be6 |
|
296 | Added tag custom-tag for changeset 75a534207be6 | |
297 |
|
297 | |||
298 |
|
298 | |||
299 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
299 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
300 | HG: Leave message empty to abort commit. |
|
300 | HG: Leave message empty to abort commit. | |
301 | HG: -- |
|
301 | HG: -- | |
302 | HG: user: test |
|
302 | HG: user: test | |
303 | HG: branch 'tag-and-branch-same-name' |
|
303 | HG: branch 'tag-and-branch-same-name' | |
304 | HG: changed .hgtags |
|
304 | HG: changed .hgtags | |
305 | ==== |
|
305 | ==== | |
306 | $ hg log -l1 --template "{desc}\n" |
|
306 | $ hg log -l1 --template "{desc}\n" | |
307 | custom tag message |
|
307 | custom tag message | |
308 | second line |
|
308 | second line | |
309 |
|
309 | |||
310 |
|
310 | |||
311 | local tag with .hgtags modified |
|
311 | local tag with .hgtags modified | |
312 |
|
312 | |||
313 | $ hg tag hgtags-modified |
|
313 | $ hg tag hgtags-modified | |
314 | $ hg rollback |
|
314 | $ hg rollback | |
315 | repository tip rolled back to revision 13 (undo commit) |
|
315 | repository tip rolled back to revision 13 (undo commit) | |
316 | working directory now based on revision 13 |
|
316 | working directory now based on revision 13 | |
317 | $ hg st |
|
317 | $ hg st | |
318 | M .hgtags |
|
318 | M .hgtags | |
319 | ? .hgtags.orig |
|
319 | ? .hgtags.orig | |
320 | ? editor.sh |
|
320 | ? editor.sh | |
321 | $ hg tag --local baz |
|
321 | $ hg tag --local baz | |
322 | $ hg revert --no-backup .hgtags |
|
322 | $ hg revert --no-backup .hgtags | |
323 |
|
323 | |||
324 |
|
324 | |||
325 | tagging when at named-branch-head that's not a topo-head |
|
325 | tagging when at named-branch-head that's not a topo-head | |
326 |
|
326 | |||
327 | $ hg up default |
|
327 | $ hg up default | |
328 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
328 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
329 | $ hg merge -t internal:local |
|
329 | $ hg merge -t internal:local | |
330 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
330 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
331 | (branch merge, don't forget to commit) |
|
331 | (branch merge, don't forget to commit) | |
332 | $ hg ci -m 'merge named branch' |
|
332 | $ hg ci -m 'merge named branch' | |
333 | $ hg up 13 |
|
333 | $ hg up 13 | |
334 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
334 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
335 | $ hg tag new-topo-head |
|
335 | $ hg tag new-topo-head | |
336 |
|
336 | |||
337 | tagging on null rev |
|
337 | tagging on null rev | |
338 |
|
338 | |||
339 | $ hg up null |
|
339 | $ hg up null | |
340 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
340 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
341 | $ hg tag nullrev |
|
341 | $ hg tag nullrev | |
342 | abort: not at a branch head (use -f to force) |
|
342 | abort: not at a branch head (use -f to force) | |
343 | [255] |
|
343 | [255] | |
344 |
|
344 | |||
345 | $ hg init empty |
|
345 | $ hg init empty | |
346 | $ hg tag -R empty nullrev |
|
346 | $ hg tag -R empty nullrev | |
347 | abort: cannot tag null revision |
|
347 | abort: cannot tag null revision | |
348 | [255] |
|
348 | [255] | |
349 |
|
349 | |||
350 | $ hg tag -R empty -r 00000000000 -f nulltag |
|
350 | $ hg tag -R empty -r 00000000000 -f nulltag | |
351 | abort: cannot tag null revision |
|
351 | abort: cannot tag null revision | |
352 | [255] |
|
352 | [255] | |
353 |
|
353 | |||
354 | $ cd .. |
|
354 | $ cd .. | |
355 |
|
355 | |||
356 | tagging on an uncommitted merge (issue2542) |
|
356 | tagging on an uncommitted merge (issue2542) | |
357 |
|
357 | |||
358 | $ hg init repo-tag-uncommitted-merge |
|
358 | $ hg init repo-tag-uncommitted-merge | |
359 | $ cd repo-tag-uncommitted-merge |
|
359 | $ cd repo-tag-uncommitted-merge | |
360 | $ echo c1 > f1 |
|
360 | $ echo c1 > f1 | |
361 | $ hg ci -Am0 |
|
361 | $ hg ci -Am0 | |
362 | adding f1 |
|
362 | adding f1 | |
363 | $ echo c2 > f2 |
|
363 | $ echo c2 > f2 | |
364 | $ hg ci -Am1 |
|
364 | $ hg ci -Am1 | |
365 | adding f2 |
|
365 | adding f2 | |
366 | $ hg co -q 0 |
|
366 | $ hg co -q 0 | |
367 | $ hg branch b1 |
|
367 | $ hg branch b1 | |
368 | marked working directory as branch b1 |
|
368 | marked working directory as branch b1 | |
369 | (branches are permanent and global, did you want a bookmark?) |
|
369 | (branches are permanent and global, did you want a bookmark?) | |
370 | $ hg ci -m2 |
|
370 | $ hg ci -m2 | |
371 | $ hg up default |
|
371 | $ hg up default | |
372 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
372 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
373 | $ hg merge b1 |
|
373 | $ hg merge b1 | |
374 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
374 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
375 | (branch merge, don't forget to commit) |
|
375 | (branch merge, don't forget to commit) | |
376 |
|
376 | |||
377 | $ hg tag t1 |
|
377 | $ hg tag t1 | |
378 | abort: uncommitted merge |
|
378 | abort: uncommitted merge | |
379 | [255] |
|
379 | [255] | |
380 | $ hg status |
|
380 | $ hg status | |
381 | $ hg tag --rev 1 t2 |
|
381 | $ hg tag --rev 1 t2 | |
382 | abort: uncommitted merge |
|
382 | abort: uncommitted merge | |
383 | [255] |
|
383 | [255] | |
384 | $ hg tag --rev 1 --local t3 |
|
384 | $ hg tag --rev 1 --local t3 | |
385 | $ hg tags -v |
|
385 | $ hg tags -v | |
386 | tip 2:2a156e8887cc |
|
386 | tip 2:2a156e8887cc | |
387 | t3 1:c3adabd1a5f4 local |
|
387 | t3 1:c3adabd1a5f4 local | |
388 |
|
388 | |||
389 | $ cd .. |
|
389 | $ cd .. | |
390 |
|
390 | |||
391 | commit hook on tag used to be run without write lock - issue3344 |
|
391 | commit hook on tag used to be run without write lock - issue3344 | |
392 |
|
392 | |||
393 | $ hg init repo-tag |
|
393 | $ hg init repo-tag | |
394 | $ touch repo-tag/test |
|
394 | $ touch repo-tag/test | |
395 | $ hg -R repo-tag commit -A -m "test" |
|
395 | $ hg -R repo-tag commit -A -m "test" | |
396 | adding test |
|
396 | adding test | |
397 | $ hg init repo-tag-target |
|
397 | $ hg init repo-tag-target | |
398 | $ hg -R repo-tag --config hooks.commit="\"hg\" push \"`pwd`/repo-tag-target\"" tag tag |
|
398 | $ hg -R repo-tag --config hooks.commit="\"hg\" push \"`pwd`/repo-tag-target\"" tag tag | |
399 | pushing to $TESTTMP/repo-tag-target (glob) |
|
399 | pushing to $TESTTMP/repo-tag-target (glob) | |
400 | searching for changes |
|
400 | searching for changes | |
401 | adding changesets |
|
401 | adding changesets | |
402 | adding manifests |
|
402 | adding manifests | |
403 | adding file changes |
|
403 | adding file changes | |
404 | added 2 changesets with 2 changes to 2 files |
|
404 | added 2 changesets with 2 changes to 2 files | |
405 |
|
405 | |||
|
406 | automatically merge resolvable tag conflicts (i.e. tags that differ in rank) | |||
|
407 | create two clones with some different tags as well as some common tags | |||
|
408 | check that we can merge tags that differ in rank | |||
|
409 | ||||
|
410 | $ hg init repo-automatic-tag-merge | |||
|
411 | $ cd repo-automatic-tag-merge | |||
|
412 | $ echo c0 > f0 | |||
|
413 | $ hg ci -A -m0 | |||
|
414 | adding f0 | |||
|
415 | $ hg tag tbase | |||
|
416 | $ cd .. | |||
|
417 | $ hg clone repo-automatic-tag-merge repo-automatic-tag-merge-clone | |||
|
418 | updating to branch default | |||
|
419 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
420 | $ cd repo-automatic-tag-merge-clone | |||
|
421 | $ echo c1 > f1 | |||
|
422 | $ hg ci -A -m1 | |||
|
423 | adding f1 | |||
|
424 | $ hg tag t1 t2 t3 | |||
|
425 | $ hg tag --remove t2 | |||
|
426 | $ hg tag t5 | |||
|
427 | $ echo c2 > f2 | |||
|
428 | $ hg ci -A -m2 | |||
|
429 | adding f2 | |||
|
430 | $ hg tag -f t3 | |||
|
431 | ||||
|
432 | $ cd ../repo-automatic-tag-merge | |||
|
433 | $ echo c3 > f3 | |||
|
434 | $ hg ci -A -m3 | |||
|
435 | adding f3 | |||
|
436 | $ hg tag -f t4 t5 t6 | |||
|
437 | $ hg tag --remove t5 | |||
|
438 | $ echo c4 > f4 | |||
|
439 | $ hg ci -A -m4 | |||
|
440 | adding f4 | |||
|
441 | $ hg tag t2 | |||
|
442 | $ hg tag -f t6 | |||
|
443 | ||||
|
444 | $ cd ../repo-automatic-tag-merge-clone | |||
|
445 | $ hg pull | |||
|
446 | pulling from $TESTTMP/repo-automatic-tag-merge (glob) | |||
|
447 | searching for changes | |||
|
448 | adding changesets | |||
|
449 | adding manifests | |||
|
450 | adding file changes | |||
|
451 | added 6 changesets with 6 changes to 3 files (+1 heads) | |||
|
452 | (run 'hg heads' to see heads, 'hg merge' to merge) | |||
|
453 | $ hg merge --tool internal:tagmerge | |||
|
454 | merging .hgtags | |||
|
455 | 2 files updated, 1 files merged, 0 files removed, 0 files unresolved | |||
|
456 | (branch merge, don't forget to commit) | |||
|
457 | $ hg status | |||
|
458 | M .hgtags | |||
|
459 | M f3 | |||
|
460 | M f4 | |||
|
461 | $ hg resolve -l | |||
|
462 | R .hgtags | |||
|
463 | $ cat .hgtags | |||
|
464 | 9aa4e1292a27a248f8d07339bed9931d54907be7 t4 | |||
|
465 | 9aa4e1292a27a248f8d07339bed9931d54907be7 t6 | |||
|
466 | 9aa4e1292a27a248f8d07339bed9931d54907be7 t6 | |||
|
467 | 09af2ce14077a94effef208b49a718f4836d4338 t6 | |||
|
468 | 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase | |||
|
469 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1 | |||
|
470 | 929bca7b18d067cbf3844c3896319a940059d748 t2 | |||
|
471 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
472 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
473 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
474 | 0000000000000000000000000000000000000000 t2 | |||
|
475 | 875517b4806a848f942811a315a5bce30804ae85 t5 | |||
|
476 | 9aa4e1292a27a248f8d07339bed9931d54907be7 t5 | |||
|
477 | 9aa4e1292a27a248f8d07339bed9931d54907be7 t5 | |||
|
478 | 0000000000000000000000000000000000000000 t5 | |||
|
479 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
480 | 79505d5360b07e3e79d1052e347e73c02b8afa5b t3 | |||
|
481 | ||||
|
482 | check that the merge tried to minimize the diff witht he first merge parent | |||
|
483 | ||||
|
484 | $ hg diff --git -r 'p1()' .hgtags | |||
|
485 | diff --git a/.hgtags b/.hgtags | |||
|
486 | --- a/.hgtags | |||
|
487 | +++ b/.hgtags | |||
|
488 | @@ -1,9 +1,17 @@ | |||
|
489 | +9aa4e1292a27a248f8d07339bed9931d54907be7 t4 | |||
|
490 | +9aa4e1292a27a248f8d07339bed9931d54907be7 t6 | |||
|
491 | +9aa4e1292a27a248f8d07339bed9931d54907be7 t6 | |||
|
492 | +09af2ce14077a94effef208b49a718f4836d4338 t6 | |||
|
493 | 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase | |||
|
494 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1 | |||
|
495 | +929bca7b18d067cbf3844c3896319a940059d748 t2 | |||
|
496 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
497 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
498 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
499 | 0000000000000000000000000000000000000000 t2 | |||
|
500 | 875517b4806a848f942811a315a5bce30804ae85 t5 | |||
|
501 | +9aa4e1292a27a248f8d07339bed9931d54907be7 t5 | |||
|
502 | +9aa4e1292a27a248f8d07339bed9931d54907be7 t5 | |||
|
503 | +0000000000000000000000000000000000000000 t5 | |||
|
504 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
505 | 79505d5360b07e3e79d1052e347e73c02b8afa5b t3 | |||
|
506 | ||||
|
507 | detect merge tag conflicts | |||
|
508 | ||||
|
509 | $ hg update -C -r tip | |||
|
510 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
511 | $ hg tag t7 | |||
|
512 | $ hg update -C -r 'first(sort(head()))' | |||
|
513 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
514 | $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags | |||
|
515 | $ hg commit -m "manually add conflicting t7 tag" | |||
|
516 | $ hg merge --tool internal:tagmerge | |||
|
517 | merging .hgtags | |||
|
518 | automatic .hgtags merge failed | |||
|
519 | the following 1 tags are in conflict: t7 | |||
|
520 | automatic tag merging of .hgtags failed! (use 'hg resolve --tool internal:merge' or another merge tool of your choice) | |||
|
521 | 2 files updated, 0 files merged, 0 files removed, 1 files unresolved | |||
|
522 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |||
|
523 | [1] | |||
|
524 | $ hg resolve -l | |||
|
525 | U .hgtags | |||
|
526 | $ cat .hgtags | |||
|
527 | 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase | |||
|
528 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1 | |||
|
529 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
530 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
531 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
532 | 0000000000000000000000000000000000000000 t2 | |||
|
533 | 875517b4806a848f942811a315a5bce30804ae85 t5 | |||
|
534 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
535 | 79505d5360b07e3e79d1052e347e73c02b8afa5b t3 | |||
|
536 | ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7 | |||
|
537 | ||||
|
538 | $ cd .. | |||
|
539 | ||||
|
540 | handle the loss of tags | |||
|
541 | ||||
|
542 | $ hg clone repo-automatic-tag-merge-clone repo-merge-lost-tags | |||
|
543 | updating to branch default | |||
|
544 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
545 | $ cd repo-merge-lost-tags | |||
|
546 | $ echo c5 > f5 | |||
|
547 | $ hg ci -A -m5 | |||
|
548 | adding f5 | |||
|
549 | $ hg tag -f t7 | |||
|
550 | $ hg update -r 'p1(t7)' | |||
|
551 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
552 | $ printf '' > .hgtags | |||
|
553 | $ hg commit -m 'delete all tags' | |||
|
554 | created new head | |||
|
555 | $ hg update -r 'max(t7::)' | |||
|
556 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
557 | $ hg merge -r tip --tool internal:tagmerge | |||
|
558 | merging .hgtags | |||
|
559 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |||
|
560 | (branch merge, don't forget to commit) | |||
|
561 | $ hg resolve -l | |||
|
562 | R .hgtags | |||
|
563 | $ cat .hgtags | |||
|
564 | 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase | |||
|
565 | 0000000000000000000000000000000000000000 tbase | |||
|
566 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1 | |||
|
567 | 0000000000000000000000000000000000000000 t1 | |||
|
568 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
569 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
570 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
571 | 0000000000000000000000000000000000000000 t2 | |||
|
572 | 875517b4806a848f942811a315a5bce30804ae85 t5 | |||
|
573 | 0000000000000000000000000000000000000000 t5 | |||
|
574 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
575 | 79505d5360b07e3e79d1052e347e73c02b8afa5b t3 | |||
|
576 | 0000000000000000000000000000000000000000 t3 | |||
|
577 | ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7 | |||
|
578 | 0000000000000000000000000000000000000000 t7 | |||
|
579 | ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7 | |||
|
580 | fd3a9e394ce3afb354a496323bf68ac1755a30de t7 | |||
|
581 | ||||
|
582 | also check that we minimize the diff with the 1st merge parent | |||
|
583 | ||||
|
584 | $ hg diff --git -r 'p1()' .hgtags | |||
|
585 | diff --git a/.hgtags b/.hgtags | |||
|
586 | --- a/.hgtags | |||
|
587 | +++ b/.hgtags | |||
|
588 | @@ -1,12 +1,17 @@ | |||
|
589 | 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase | |||
|
590 | +0000000000000000000000000000000000000000 tbase | |||
|
591 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1 | |||
|
592 | +0000000000000000000000000000000000000000 t1 | |||
|
593 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
594 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
595 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2 | |||
|
596 | 0000000000000000000000000000000000000000 t2 | |||
|
597 | 875517b4806a848f942811a315a5bce30804ae85 t5 | |||
|
598 | +0000000000000000000000000000000000000000 t5 | |||
|
599 | 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3 | |||
|
600 | 79505d5360b07e3e79d1052e347e73c02b8afa5b t3 | |||
|
601 | +0000000000000000000000000000000000000000 t3 | |||
|
602 | ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7 | |||
|
603 | +0000000000000000000000000000000000000000 t7 | |||
|
604 | ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7 | |||
|
605 | fd3a9e394ce3afb354a496323bf68ac1755a30de t7 | |||
|
606 |
General Comments 0
You need to be logged in to leave comments.
Login now