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