##// END OF EJS Templates
merge-tools: fixed typos...
Martin Geisler -
r12804:e0e8b123 stable
parent child Browse files
Show More
@@ -1,167 +1,167
1 import os, sys, textwrap
1 import os, sys, textwrap
2 # import from the live mercurial repo
2 # import from the live mercurial repo
3 sys.path.insert(0, "..")
3 sys.path.insert(0, "..")
4 # fall back to pure modules if required C extensions are not available
4 # fall back to pure modules if required C extensions are not available
5 sys.path.append(os.path.join('..', 'mercurial', 'pure'))
5 sys.path.append(os.path.join('..', 'mercurial', 'pure'))
6 from mercurial import demandimport; demandimport.enable()
6 from mercurial import demandimport; demandimport.enable()
7 from mercurial import encoding
7 from mercurial import encoding
8 from mercurial.commands import table, globalopts
8 from mercurial.commands import table, globalopts
9 from mercurial.i18n import _
9 from mercurial.i18n import _
10 from mercurial.help import helptable
10 from mercurial.help import helptable
11 from mercurial import extensions
11 from mercurial import extensions
12
12
13 def get_desc(docstr):
13 def get_desc(docstr):
14 if not docstr:
14 if not docstr:
15 return "", ""
15 return "", ""
16 # sanitize
16 # sanitize
17 docstr = docstr.strip("\n")
17 docstr = docstr.strip("\n")
18 docstr = docstr.rstrip()
18 docstr = docstr.rstrip()
19 shortdesc = docstr.splitlines()[0].strip()
19 shortdesc = docstr.splitlines()[0].strip()
20
20
21 i = docstr.find("\n")
21 i = docstr.find("\n")
22 if i != -1:
22 if i != -1:
23 desc = docstr[i + 2:]
23 desc = docstr[i + 2:]
24 else:
24 else:
25 desc = shortdesc
25 desc = shortdesc
26
26
27 desc = textwrap.dedent(desc)
27 desc = textwrap.dedent(desc)
28
28
29 return (shortdesc, desc)
29 return (shortdesc, desc)
30
30
31 def get_opts(opts):
31 def get_opts(opts):
32 for opt in opts:
32 for opt in opts:
33 if len(opt) == 5:
33 if len(opt) == 5:
34 shortopt, longopt, default, desc, optlabel = opt
34 shortopt, longopt, default, desc, optlabel = opt
35 else:
35 else:
36 shortopt, longopt, default, desc = opt
36 shortopt, longopt, default, desc = opt
37 allopts = []
37 allopts = []
38 if shortopt:
38 if shortopt:
39 allopts.append("-%s" % shortopt)
39 allopts.append("-%s" % shortopt)
40 if longopt:
40 if longopt:
41 allopts.append("--%s" % longopt)
41 allopts.append("--%s" % longopt)
42 desc += default and _(" (default: %s)") % default or ""
42 desc += default and _(" (default: %s)") % default or ""
43 yield(", ".join(allopts), desc)
43 yield(", ".join(allopts), desc)
44
44
45 def get_cmd(cmd, cmdtable):
45 def get_cmd(cmd, cmdtable):
46 d = {}
46 d = {}
47 attr = cmdtable[cmd]
47 attr = cmdtable[cmd]
48 cmds = cmd.lstrip("^").split("|")
48 cmds = cmd.lstrip("^").split("|")
49
49
50 d['cmd'] = cmds[0]
50 d['cmd'] = cmds[0]
51 d['aliases'] = cmd.split("|")[1:]
51 d['aliases'] = cmd.split("|")[1:]
52 d['desc'] = get_desc(attr[0].__doc__)
52 d['desc'] = get_desc(attr[0].__doc__)
53 d['opts'] = list(get_opts(attr[1]))
53 d['opts'] = list(get_opts(attr[1]))
54
54
55 s = 'hg ' + cmds[0]
55 s = 'hg ' + cmds[0]
56 if len(attr) > 2:
56 if len(attr) > 2:
57 if not attr[2].startswith('hg'):
57 if not attr[2].startswith('hg'):
58 s += ' ' + attr[2]
58 s += ' ' + attr[2]
59 else:
59 else:
60 s = attr[2]
60 s = attr[2]
61 d['synopsis'] = s.strip()
61 d['synopsis'] = s.strip()
62
62
63 return d
63 return d
64
64
65 def section(ui, s):
65 def section(ui, s):
66 ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
66 ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
67
67
68 def subsection(ui, s):
68 def subsection(ui, s):
69 ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s)))
69 ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s)))
70
70
71 def subsubsection(ui, s):
71 def subsubsection(ui, s):
72 ui.write("%s\n%s\n\n" % (s, "." * encoding.colwidth(s)))
72 ui.write("%s\n%s\n\n" % (s, "." * encoding.colwidth(s)))
73
73
74 def subsubsubsection(ui, s):
74 def subsubsubsection(ui, s):
75 ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s)))
75 ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s)))
76
76
77
77
78 def show_doc(ui):
78 def show_doc(ui):
79 # print options
79 # print options
80 section(ui, _("Options"))
80 section(ui, _("Options"))
81 for optstr, desc in get_opts(globalopts):
81 for optstr, desc in get_opts(globalopts):
82 ui.write("%s\n%s\n\n" % (optstr, desc))
82 ui.write("%s\n%s\n\n" % (optstr, desc))
83
83
84 # print cmds
84 # print cmds
85 section(ui, _("Commands"))
85 section(ui, _("Commands"))
86 commandprinter(ui, table, subsection)
86 commandprinter(ui, table, subsection)
87
87
88 # print topics
88 # print topics
89 for names, sec, doc in helptable:
89 for names, sec, doc in helptable:
90 for name in names:
90 for name in names:
91 ui.write(".. _%s:\n" % name)
91 ui.write(".. _%s:\n" % name)
92 ui.write("\n")
92 ui.write("\n")
93 section(ui, sec)
93 section(ui, sec)
94 if hasattr(doc, '__call__'):
94 if hasattr(doc, '__call__'):
95 doc = doc()
95 doc = doc()
96 ui.write(doc)
96 ui.write(doc)
97 ui.write("\n")
97 ui.write("\n")
98
98
99 section(ui, _("Extensions"))
99 section(ui, _("Extensions"))
100 ui.write(_("This section contains help for extensions that is distributed "
100 ui.write(_("This section contains help for extensions that are distributed "
101 "together with Mercurial. Help for other extensions is available "
101 "together with Mercurial. Help for other extensions is available "
102 "in the help system."))
102 "in the help system."))
103 ui.write("\n\n"
103 ui.write("\n\n"
104 ".. contents::\n"
104 ".. contents::\n"
105 " :class: htmlonly\n"
105 " :class: htmlonly\n"
106 " :local:\n"
106 " :local:\n"
107 " :depth: 1\n\n")
107 " :depth: 1\n\n")
108
108
109 for extensionname in sorted(allextensionnames()):
109 for extensionname in sorted(allextensionnames()):
110 mod = extensions.load(None, extensionname, None)
110 mod = extensions.load(None, extensionname, None)
111 subsection(ui, extensionname)
111 subsection(ui, extensionname)
112 ui.write("%s\n\n" % mod.__doc__)
112 ui.write("%s\n\n" % mod.__doc__)
113 cmdtable = getattr(mod, 'cmdtable', None)
113 cmdtable = getattr(mod, 'cmdtable', None)
114 if cmdtable:
114 if cmdtable:
115 subsubsection(ui, _('Commands'))
115 subsubsection(ui, _('Commands'))
116 commandprinter(ui, cmdtable, subsubsubsection)
116 commandprinter(ui, cmdtable, subsubsubsection)
117
117
118 def commandprinter(ui, cmdtable, sectionfunc):
118 def commandprinter(ui, cmdtable, sectionfunc):
119 h = {}
119 h = {}
120 for c, attr in cmdtable.items():
120 for c, attr in cmdtable.items():
121 f = c.split("|")[0]
121 f = c.split("|")[0]
122 f = f.lstrip("^")
122 f = f.lstrip("^")
123 h[f] = c
123 h[f] = c
124 cmds = h.keys()
124 cmds = h.keys()
125 cmds.sort()
125 cmds.sort()
126
126
127 for f in cmds:
127 for f in cmds:
128 if f.startswith("debug"):
128 if f.startswith("debug"):
129 continue
129 continue
130 d = get_cmd(h[f], cmdtable)
130 d = get_cmd(h[f], cmdtable)
131 sectionfunc(ui, d['cmd'])
131 sectionfunc(ui, d['cmd'])
132 # synopsis
132 # synopsis
133 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
133 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
134 ui.write("\n")
134 ui.write("\n")
135 # description
135 # description
136 ui.write("%s\n\n" % d['desc'][1])
136 ui.write("%s\n\n" % d['desc'][1])
137 # options
137 # options
138 opt_output = list(d['opts'])
138 opt_output = list(d['opts'])
139 if opt_output:
139 if opt_output:
140 opts_len = max([len(line[0]) for line in opt_output])
140 opts_len = max([len(line[0]) for line in opt_output])
141 ui.write(_("options:\n\n"))
141 ui.write(_("options:\n\n"))
142 for optstr, desc in opt_output:
142 for optstr, desc in opt_output:
143 if desc:
143 if desc:
144 s = "%-*s %s" % (opts_len, optstr, desc)
144 s = "%-*s %s" % (opts_len, optstr, desc)
145 else:
145 else:
146 s = optstr
146 s = optstr
147 ui.write("%s\n" % s)
147 ui.write("%s\n" % s)
148 ui.write("\n")
148 ui.write("\n")
149 # aliases
149 # aliases
150 if d['aliases']:
150 if d['aliases']:
151 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
151 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
152
152
153
153
154 def allextensionnames():
154 def allextensionnames():
155 extensionnames = []
155 extensionnames = []
156
156
157 extensionsdictionary = extensions.enabled()[0]
157 extensionsdictionary = extensions.enabled()[0]
158 extensionnames.extend(extensionsdictionary.keys())
158 extensionnames.extend(extensionsdictionary.keys())
159
159
160 extensionsdictionary = extensions.disabled()[0]
160 extensionsdictionary = extensions.disabled()[0]
161 extensionnames.extend(extensionsdictionary.keys())
161 extensionnames.extend(extensionsdictionary.keys())
162
162
163 return extensionnames
163 return extensionnames
164
164
165
165
166 if __name__ == "__main__":
166 if __name__ == "__main__":
167 show_doc(sys.stdout)
167 show_doc(sys.stdout)
@@ -1,85 +1,86
1 To merge files Mercurial uses merge tools.
1 To merge files Mercurial uses merge tools.
2
2
3 A merge tool combines two different versions of a file into a merged
3 A merge tool combines two different versions of a file into a merged
4 file. Merge tools are given the two files and the greatest common
4 file. Merge tools are given the two files and the greatest common
5 ancestor of the two file versions, so they can determine the changes
5 ancestor of the two file versions, so they can determine the changes
6 made on both branches.
6 made on both branches.
7
7
8 The merge tools are used both for :hg:`resolve` and :hg:`merge`.
8 The merge tools are used both for :hg:`resolve` and :hg:`merge`.
9
9
10 Usually, the merge tool tries to automatically, by combining all the
10 Usually, the merge tool tries to automatically reconcile the files by
11 non-overlapping changes that occurred separately in the two different
11 combining all the non-overlapping changes that occurred separately in
12 the two different
12 evolutions of the same initial base file. Furthermore, some
13 evolutions of the same initial base file. Furthermore, some
13 interactive merge programs make it easier to manually resolve
14 interactive merge programs make it easier to manually resolve
14 conflicting merges, either in a graphical way, or by inserting some
15 conflicting merges, either in a graphical way, or by inserting some
15 conflict markers. Mercurial does not include any interactive merge
16 conflict markers. Mercurial does not include any interactive merge
16 programs but relies on external tools for that. External merge tools
17 programs but relies on external tools for that. External merge tools
17 and their properties and usage is configured in merge-tools section -
18 and their properties and usage is configured in merge-tools section -
18 see hgrc(5).
19 see hgrc(5).
19
20
20 There are a some internal merge tools which can be used. The internal
21 There are a some internal merge tools which can be used. The internal
21 merge tools are:
22 merge tools are:
22
23
23 ``internal:merge``
24 ``internal:merge``
24 Uses the internal non-interactive merge tool for merging files.
25 Uses the internal non-interactive merge tool for merging files.
25
26
26 ``internal:fail``
27 ``internal:fail``
27 Rather than attempting to merge files that were modified on both
28 Rather than attempting to merge files that were modified on both
28 branches, it marks these files as unresolved. Then the resolve
29 branches, it marks these files as unresolved. Then the resolve
29 command must be used to mark files resolved.
30 command must be used to mark files resolved.
30
31
31 ``internal:local``
32 ``internal:local``
32 Uses the local version of files as the merged version.
33 Uses the local version of files as the merged version.
33
34
34 ``internal:other``
35 ``internal:other``
35 Uses the remote version of files as the merged version.
36 Uses the remote version of files as the merged version.
36
37
37 ``internal:prompt``
38 ``internal:prompt``
38 Asks the user which of the local or the other version to keep as
39 Asks the user which of the local or the other version to keep as
39 the merged version.
40 the merged version.
40
41
41 ``internal:dump``
42 ``internal:dump``
42 Creates three versions of the files to merge, containing the
43 Creates three versions of the files to merge, containing the
43 contents of local, other and base. These files can then be used to
44 contents of local, other and base. These files can then be used to
44 perform a merge manually. If the file merged is name ``a.txt``,
45 perform a merge manually. If the file to be merged is named
45 these files will accordingly be named ``a.txt.local``,
46 ``a.txt``, these files will accordingly be named ``a.txt.local``,
46 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
47 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
47 same directory as the file to merge.
48 same directory as ``a.txt``.
48
49
49 How Mercurial decides which merge program to use
50 How Mercurial decides which merge program to use
50
51
51 1. If the ``HGMERGE`` environment variable is present, it is used. If
52 1. If the ``HGMERGE`` environment variable is present, it is used. If
52 specified it must be either an executable path or the name of an
53 specified it must be either an executable path or the name of an
53 application in your executable search path.
54 application in your executable search path.
54
55
55 2. If the filename of the file to be merged matches any of the
56 2. If the filename of the file to be merged matches any of the
56 patterns in the merge-patterns configuration section, then the
57 patterns in the merge-patterns configuration section, then the
57 corresponding merge tool is used, unless the file to be merged is a
58 corresponding merge tool is used, unless the file to be merged is a
58 symlink. Here binary capabilities of the merge tool are not
59 symlink. Here binary capabilities of the merge tool are not
59 considered.
60 considered.
60
61
61 3. If ui.merge is set, it is used.
62 3. If ui.merge is set, it is used.
62
63
63 4. If any merge tools are present in the merge-tools configuration
64 4. If any merge tools are present in the merge-tools configuration
64 section, and any of the tools can be found on the system, the
65 section, and any of the tools can be found on the system, the
65 priority settings are used to determine which one to use. Binary,
66 priority settings are used to determine which one to use. Binary,
66 symlink and GUI capabilities do also have to match.
67 symlink and GUI capabilities do also have to match.
67
68
68 5. If a program named ``hgmerge`` exists on the system, it is used.
69 5. If a program named ``hgmerge`` exists on the system, it is used.
69
70
70 6. If the file to be merged is not binary and is not a symlink, then
71 6. If the file to be merged is not binary and is not a symlink, then
71 ``internal:merge`` is used.
72 ``internal:merge`` is used.
72
73
73 7. The merge fails.
74 7. The merge fails.
74
75
75 .. note::
76 .. note::
76 After selecting a merge program, Mercurial will by default attempt
77 After selecting a merge program, Mercurial will by default attempt
77 to merge the files using a simple merge algorithm first, to see if
78 to merge the files using a simple merge algorithm first, to see if
78 they can be merged without conflicts. Only if there are conflicting
79 they can be merged without conflicts. Only if there are conflicting
79 changes Mercurial will actually execute the merge program. Whether
80 changes Mercurial will actually execute the merge program. Whether
80 to use the simple merge algorithm first can be controlled be the
81 to use the simple merge algorithm first can be controlled by the
81 premerge setting of the merge tool, which is enabled by default
82 premerge setting of the merge tool. Premerge is enabled by default
82 unless the file is binary or symlink.
83 unless the file is binary or symlink.
83
84
84 See the merge-tools and ui sections of hgrc(5) for details on
85 See the merge-tools and ui sections of hgrc(5) for details on
85 configuration of merge tools.
86 configuration of merge tools.
General Comments 0
You need to be logged in to leave comments. Login now