Show More
@@ -1,7232 +1,7242 b'' | |||||
1 | # commands.py - command processing for mercurial |
|
1 | # commands.py - command processing for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005-2007 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 __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import difflib |
|
10 | import difflib | |
11 | import errno |
|
11 | import errno | |
12 | import operator |
|
12 | import operator | |
13 | import os |
|
13 | import os | |
14 | import random |
|
14 | import random | |
15 | import re |
|
15 | import re | |
16 | import shlex |
|
16 | import shlex | |
17 | import socket |
|
17 | import socket | |
18 | import string |
|
18 | import string | |
19 | import sys |
|
19 | import sys | |
20 | import tempfile |
|
20 | import tempfile | |
21 | import time |
|
21 | import time | |
22 |
|
22 | |||
23 | from .i18n import _ |
|
23 | from .i18n import _ | |
24 | from .node import ( |
|
24 | from .node import ( | |
25 | bin, |
|
25 | bin, | |
26 | hex, |
|
26 | hex, | |
27 | nullhex, |
|
27 | nullhex, | |
28 | nullid, |
|
28 | nullid, | |
29 | nullrev, |
|
29 | nullrev, | |
30 | short, |
|
30 | short, | |
31 | ) |
|
31 | ) | |
32 | from . import ( |
|
32 | from . import ( | |
33 | archival, |
|
33 | archival, | |
34 | bookmarks, |
|
34 | bookmarks, | |
35 | bundle2, |
|
35 | bundle2, | |
36 | changegroup, |
|
36 | changegroup, | |
37 | cmdutil, |
|
37 | cmdutil, | |
38 | commandserver, |
|
38 | commandserver, | |
39 | copies, |
|
39 | copies, | |
40 | dagparser, |
|
40 | dagparser, | |
41 | dagutil, |
|
41 | dagutil, | |
42 | destutil, |
|
42 | destutil, | |
43 | discovery, |
|
43 | discovery, | |
44 | encoding, |
|
44 | encoding, | |
45 | error, |
|
45 | error, | |
46 | exchange, |
|
46 | exchange, | |
47 | extensions, |
|
47 | extensions, | |
48 | fileset, |
|
48 | fileset, | |
49 | formatter, |
|
49 | formatter, | |
50 | graphmod, |
|
50 | graphmod, | |
51 | hbisect, |
|
51 | hbisect, | |
52 | help, |
|
52 | help, | |
53 | hg, |
|
53 | hg, | |
54 | hgweb, |
|
54 | hgweb, | |
55 | localrepo, |
|
55 | localrepo, | |
56 | lock as lockmod, |
|
56 | lock as lockmod, | |
57 | merge as mergemod, |
|
57 | merge as mergemod, | |
58 | minirst, |
|
58 | minirst, | |
59 | obsolete, |
|
59 | obsolete, | |
60 | patch, |
|
60 | patch, | |
61 | phases, |
|
61 | phases, | |
62 | policy, |
|
62 | policy, | |
63 | pvec, |
|
63 | pvec, | |
64 | pycompat, |
|
64 | pycompat, | |
65 | repair, |
|
65 | repair, | |
66 | revlog, |
|
66 | revlog, | |
67 | revset, |
|
67 | revset, | |
68 | scmutil, |
|
68 | scmutil, | |
69 | setdiscovery, |
|
69 | setdiscovery, | |
70 | sshserver, |
|
70 | sshserver, | |
71 | sslutil, |
|
71 | sslutil, | |
72 | streamclone, |
|
72 | streamclone, | |
73 | templatekw, |
|
73 | templatekw, | |
74 | templater, |
|
74 | templater, | |
75 | treediscovery, |
|
75 | treediscovery, | |
76 | ui as uimod, |
|
76 | ui as uimod, | |
77 | util, |
|
77 | util, | |
78 | ) |
|
78 | ) | |
79 |
|
79 | |||
80 | release = lockmod.release |
|
80 | release = lockmod.release | |
81 |
|
81 | |||
82 | table = {} |
|
82 | table = {} | |
83 |
|
83 | |||
84 | command = cmdutil.command(table) |
|
84 | command = cmdutil.command(table) | |
85 |
|
85 | |||
86 | # label constants |
|
86 | # label constants | |
87 | # until 3.5, bookmarks.current was the advertised name, not |
|
87 | # until 3.5, bookmarks.current was the advertised name, not | |
88 | # bookmarks.active, so we must use both to avoid breaking old |
|
88 | # bookmarks.active, so we must use both to avoid breaking old | |
89 | # custom styles |
|
89 | # custom styles | |
90 | activebookmarklabel = 'bookmarks.active bookmarks.current' |
|
90 | activebookmarklabel = 'bookmarks.active bookmarks.current' | |
91 |
|
91 | |||
92 | # common command options |
|
92 | # common command options | |
93 |
|
93 | |||
94 | globalopts = [ |
|
94 | globalopts = [ | |
95 | ('R', 'repository', '', |
|
95 | ('R', 'repository', '', | |
96 | _('repository root directory or name of overlay bundle file'), |
|
96 | _('repository root directory or name of overlay bundle file'), | |
97 | _('REPO')), |
|
97 | _('REPO')), | |
98 | ('', 'cwd', '', |
|
98 | ('', 'cwd', '', | |
99 | _('change working directory'), _('DIR')), |
|
99 | _('change working directory'), _('DIR')), | |
100 | ('y', 'noninteractive', None, |
|
100 | ('y', 'noninteractive', None, | |
101 | _('do not prompt, automatically pick the first choice for all prompts')), |
|
101 | _('do not prompt, automatically pick the first choice for all prompts')), | |
102 | ('q', 'quiet', None, _('suppress output')), |
|
102 | ('q', 'quiet', None, _('suppress output')), | |
103 | ('v', 'verbose', None, _('enable additional output')), |
|
103 | ('v', 'verbose', None, _('enable additional output')), | |
104 | ('', 'config', [], |
|
104 | ('', 'config', [], | |
105 | _('set/override config option (use \'section.name=value\')'), |
|
105 | _('set/override config option (use \'section.name=value\')'), | |
106 | _('CONFIG')), |
|
106 | _('CONFIG')), | |
107 | ('', 'debug', None, _('enable debugging output')), |
|
107 | ('', 'debug', None, _('enable debugging output')), | |
108 | ('', 'debugger', None, _('start debugger')), |
|
108 | ('', 'debugger', None, _('start debugger')), | |
109 | ('', 'encoding', encoding.encoding, _('set the charset encoding'), |
|
109 | ('', 'encoding', encoding.encoding, _('set the charset encoding'), | |
110 | _('ENCODE')), |
|
110 | _('ENCODE')), | |
111 | ('', 'encodingmode', encoding.encodingmode, |
|
111 | ('', 'encodingmode', encoding.encodingmode, | |
112 | _('set the charset encoding mode'), _('MODE')), |
|
112 | _('set the charset encoding mode'), _('MODE')), | |
113 | ('', 'traceback', None, _('always print a traceback on exception')), |
|
113 | ('', 'traceback', None, _('always print a traceback on exception')), | |
114 | ('', 'time', None, _('time how long the command takes')), |
|
114 | ('', 'time', None, _('time how long the command takes')), | |
115 | ('', 'profile', None, _('print command execution profile')), |
|
115 | ('', 'profile', None, _('print command execution profile')), | |
116 | ('', 'version', None, _('output version information and exit')), |
|
116 | ('', 'version', None, _('output version information and exit')), | |
117 | ('h', 'help', None, _('display help and exit')), |
|
117 | ('h', 'help', None, _('display help and exit')), | |
118 | ('', 'hidden', False, _('consider hidden changesets')), |
|
118 | ('', 'hidden', False, _('consider hidden changesets')), | |
119 | ] |
|
119 | ] | |
120 |
|
120 | |||
121 | dryrunopts = [('n', 'dry-run', None, |
|
121 | dryrunopts = [('n', 'dry-run', None, | |
122 | _('do not perform actions, just print output'))] |
|
122 | _('do not perform actions, just print output'))] | |
123 |
|
123 | |||
124 | remoteopts = [ |
|
124 | remoteopts = [ | |
125 | ('e', 'ssh', '', |
|
125 | ('e', 'ssh', '', | |
126 | _('specify ssh command to use'), _('CMD')), |
|
126 | _('specify ssh command to use'), _('CMD')), | |
127 | ('', 'remotecmd', '', |
|
127 | ('', 'remotecmd', '', | |
128 | _('specify hg command to run on the remote side'), _('CMD')), |
|
128 | _('specify hg command to run on the remote side'), _('CMD')), | |
129 | ('', 'insecure', None, |
|
129 | ('', 'insecure', None, | |
130 | _('do not verify server certificate (ignoring web.cacerts config)')), |
|
130 | _('do not verify server certificate (ignoring web.cacerts config)')), | |
131 | ] |
|
131 | ] | |
132 |
|
132 | |||
133 | walkopts = [ |
|
133 | walkopts = [ | |
134 | ('I', 'include', [], |
|
134 | ('I', 'include', [], | |
135 | _('include names matching the given patterns'), _('PATTERN')), |
|
135 | _('include names matching the given patterns'), _('PATTERN')), | |
136 | ('X', 'exclude', [], |
|
136 | ('X', 'exclude', [], | |
137 | _('exclude names matching the given patterns'), _('PATTERN')), |
|
137 | _('exclude names matching the given patterns'), _('PATTERN')), | |
138 | ] |
|
138 | ] | |
139 |
|
139 | |||
140 | commitopts = [ |
|
140 | commitopts = [ | |
141 | ('m', 'message', '', |
|
141 | ('m', 'message', '', | |
142 | _('use text as commit message'), _('TEXT')), |
|
142 | _('use text as commit message'), _('TEXT')), | |
143 | ('l', 'logfile', '', |
|
143 | ('l', 'logfile', '', | |
144 | _('read commit message from file'), _('FILE')), |
|
144 | _('read commit message from file'), _('FILE')), | |
145 | ] |
|
145 | ] | |
146 |
|
146 | |||
147 | commitopts2 = [ |
|
147 | commitopts2 = [ | |
148 | ('d', 'date', '', |
|
148 | ('d', 'date', '', | |
149 | _('record the specified date as commit date'), _('DATE')), |
|
149 | _('record the specified date as commit date'), _('DATE')), | |
150 | ('u', 'user', '', |
|
150 | ('u', 'user', '', | |
151 | _('record the specified user as committer'), _('USER')), |
|
151 | _('record the specified user as committer'), _('USER')), | |
152 | ] |
|
152 | ] | |
153 |
|
153 | |||
154 | # hidden for now |
|
154 | # hidden for now | |
155 | formatteropts = [ |
|
155 | formatteropts = [ | |
156 | ('T', 'template', '', |
|
156 | ('T', 'template', '', | |
157 | _('display with template (EXPERIMENTAL)'), _('TEMPLATE')), |
|
157 | _('display with template (EXPERIMENTAL)'), _('TEMPLATE')), | |
158 | ] |
|
158 | ] | |
159 |
|
159 | |||
160 | templateopts = [ |
|
160 | templateopts = [ | |
161 | ('', 'style', '', |
|
161 | ('', 'style', '', | |
162 | _('display using template map file (DEPRECATED)'), _('STYLE')), |
|
162 | _('display using template map file (DEPRECATED)'), _('STYLE')), | |
163 | ('T', 'template', '', |
|
163 | ('T', 'template', '', | |
164 | _('display with template'), _('TEMPLATE')), |
|
164 | _('display with template'), _('TEMPLATE')), | |
165 | ] |
|
165 | ] | |
166 |
|
166 | |||
167 | logopts = [ |
|
167 | logopts = [ | |
168 | ('p', 'patch', None, _('show patch')), |
|
168 | ('p', 'patch', None, _('show patch')), | |
169 | ('g', 'git', None, _('use git extended diff format')), |
|
169 | ('g', 'git', None, _('use git extended diff format')), | |
170 | ('l', 'limit', '', |
|
170 | ('l', 'limit', '', | |
171 | _('limit number of changes displayed'), _('NUM')), |
|
171 | _('limit number of changes displayed'), _('NUM')), | |
172 | ('M', 'no-merges', None, _('do not show merges')), |
|
172 | ('M', 'no-merges', None, _('do not show merges')), | |
173 | ('', 'stat', None, _('output diffstat-style summary of changes')), |
|
173 | ('', 'stat', None, _('output diffstat-style summary of changes')), | |
174 | ('G', 'graph', None, _("show the revision DAG")), |
|
174 | ('G', 'graph', None, _("show the revision DAG")), | |
175 | ] + templateopts |
|
175 | ] + templateopts | |
176 |
|
176 | |||
177 | diffopts = [ |
|
177 | diffopts = [ | |
178 | ('a', 'text', None, _('treat all files as text')), |
|
178 | ('a', 'text', None, _('treat all files as text')), | |
179 | ('g', 'git', None, _('use git extended diff format')), |
|
179 | ('g', 'git', None, _('use git extended diff format')), | |
180 | ('', 'nodates', None, _('omit dates from diff headers')) |
|
180 | ('', 'nodates', None, _('omit dates from diff headers')) | |
181 | ] |
|
181 | ] | |
182 |
|
182 | |||
183 | diffwsopts = [ |
|
183 | diffwsopts = [ | |
184 | ('w', 'ignore-all-space', None, |
|
184 | ('w', 'ignore-all-space', None, | |
185 | _('ignore white space when comparing lines')), |
|
185 | _('ignore white space when comparing lines')), | |
186 | ('b', 'ignore-space-change', None, |
|
186 | ('b', 'ignore-space-change', None, | |
187 | _('ignore changes in the amount of white space')), |
|
187 | _('ignore changes in the amount of white space')), | |
188 | ('B', 'ignore-blank-lines', None, |
|
188 | ('B', 'ignore-blank-lines', None, | |
189 | _('ignore changes whose lines are all blank')), |
|
189 | _('ignore changes whose lines are all blank')), | |
190 | ] |
|
190 | ] | |
191 |
|
191 | |||
192 | diffopts2 = [ |
|
192 | diffopts2 = [ | |
193 | ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')), |
|
193 | ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')), | |
194 | ('p', 'show-function', None, _('show which function each change is in')), |
|
194 | ('p', 'show-function', None, _('show which function each change is in')), | |
195 | ('', 'reverse', None, _('produce a diff that undoes the changes')), |
|
195 | ('', 'reverse', None, _('produce a diff that undoes the changes')), | |
196 | ] + diffwsopts + [ |
|
196 | ] + diffwsopts + [ | |
197 | ('U', 'unified', '', |
|
197 | ('U', 'unified', '', | |
198 | _('number of lines of context to show'), _('NUM')), |
|
198 | _('number of lines of context to show'), _('NUM')), | |
199 | ('', 'stat', None, _('output diffstat-style summary of changes')), |
|
199 | ('', 'stat', None, _('output diffstat-style summary of changes')), | |
200 | ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')), |
|
200 | ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')), | |
201 | ] |
|
201 | ] | |
202 |
|
202 | |||
203 | mergetoolopts = [ |
|
203 | mergetoolopts = [ | |
204 | ('t', 'tool', '', _('specify merge tool')), |
|
204 | ('t', 'tool', '', _('specify merge tool')), | |
205 | ] |
|
205 | ] | |
206 |
|
206 | |||
207 | similarityopts = [ |
|
207 | similarityopts = [ | |
208 | ('s', 'similarity', '', |
|
208 | ('s', 'similarity', '', | |
209 | _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY')) |
|
209 | _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY')) | |
210 | ] |
|
210 | ] | |
211 |
|
211 | |||
212 | subrepoopts = [ |
|
212 | subrepoopts = [ | |
213 | ('S', 'subrepos', None, |
|
213 | ('S', 'subrepos', None, | |
214 | _('recurse into subrepositories')) |
|
214 | _('recurse into subrepositories')) | |
215 | ] |
|
215 | ] | |
216 |
|
216 | |||
217 | debugrevlogopts = [ |
|
217 | debugrevlogopts = [ | |
218 | ('c', 'changelog', False, _('open changelog')), |
|
218 | ('c', 'changelog', False, _('open changelog')), | |
219 | ('m', 'manifest', False, _('open manifest')), |
|
219 | ('m', 'manifest', False, _('open manifest')), | |
220 | ('', 'dir', '', _('open directory manifest')), |
|
220 | ('', 'dir', '', _('open directory manifest')), | |
221 | ] |
|
221 | ] | |
222 |
|
222 | |||
223 | # Commands start here, listed alphabetically |
|
223 | # Commands start here, listed alphabetically | |
224 |
|
224 | |||
225 | @command('^add', |
|
225 | @command('^add', | |
226 | walkopts + subrepoopts + dryrunopts, |
|
226 | walkopts + subrepoopts + dryrunopts, | |
227 | _('[OPTION]... [FILE]...'), |
|
227 | _('[OPTION]... [FILE]...'), | |
228 | inferrepo=True) |
|
228 | inferrepo=True) | |
229 | def add(ui, repo, *pats, **opts): |
|
229 | def add(ui, repo, *pats, **opts): | |
230 | """add the specified files on the next commit |
|
230 | """add the specified files on the next commit | |
231 |
|
231 | |||
232 | Schedule files to be version controlled and added to the |
|
232 | Schedule files to be version controlled and added to the | |
233 | repository. |
|
233 | repository. | |
234 |
|
234 | |||
235 | The files will be added to the repository at the next commit. To |
|
235 | The files will be added to the repository at the next commit. To | |
236 | undo an add before that, see :hg:`forget`. |
|
236 | undo an add before that, see :hg:`forget`. | |
237 |
|
237 | |||
238 | If no names are given, add all files to the repository (except |
|
238 | If no names are given, add all files to the repository (except | |
239 | files matching ``.hgignore``). |
|
239 | files matching ``.hgignore``). | |
240 |
|
240 | |||
241 | .. container:: verbose |
|
241 | .. container:: verbose | |
242 |
|
242 | |||
243 | Examples: |
|
243 | Examples: | |
244 |
|
244 | |||
245 | - New (unknown) files are added |
|
245 | - New (unknown) files are added | |
246 | automatically by :hg:`add`:: |
|
246 | automatically by :hg:`add`:: | |
247 |
|
247 | |||
248 | $ ls |
|
248 | $ ls | |
249 | foo.c |
|
249 | foo.c | |
250 | $ hg status |
|
250 | $ hg status | |
251 | ? foo.c |
|
251 | ? foo.c | |
252 | $ hg add |
|
252 | $ hg add | |
253 | adding foo.c |
|
253 | adding foo.c | |
254 | $ hg status |
|
254 | $ hg status | |
255 | A foo.c |
|
255 | A foo.c | |
256 |
|
256 | |||
257 | - Specific files to be added can be specified:: |
|
257 | - Specific files to be added can be specified:: | |
258 |
|
258 | |||
259 | $ ls |
|
259 | $ ls | |
260 | bar.c foo.c |
|
260 | bar.c foo.c | |
261 | $ hg status |
|
261 | $ hg status | |
262 | ? bar.c |
|
262 | ? bar.c | |
263 | ? foo.c |
|
263 | ? foo.c | |
264 | $ hg add bar.c |
|
264 | $ hg add bar.c | |
265 | $ hg status |
|
265 | $ hg status | |
266 | A bar.c |
|
266 | A bar.c | |
267 | ? foo.c |
|
267 | ? foo.c | |
268 |
|
268 | |||
269 | Returns 0 if all files are successfully added. |
|
269 | Returns 0 if all files are successfully added. | |
270 | """ |
|
270 | """ | |
271 |
|
271 | |||
272 | m = scmutil.match(repo[None], pats, opts) |
|
272 | m = scmutil.match(repo[None], pats, opts) | |
273 | rejected = cmdutil.add(ui, repo, m, "", False, **opts) |
|
273 | rejected = cmdutil.add(ui, repo, m, "", False, **opts) | |
274 | return rejected and 1 or 0 |
|
274 | return rejected and 1 or 0 | |
275 |
|
275 | |||
276 | @command('addremove', |
|
276 | @command('addremove', | |
277 | similarityopts + subrepoopts + walkopts + dryrunopts, |
|
277 | similarityopts + subrepoopts + walkopts + dryrunopts, | |
278 | _('[OPTION]... [FILE]...'), |
|
278 | _('[OPTION]... [FILE]...'), | |
279 | inferrepo=True) |
|
279 | inferrepo=True) | |
280 | def addremove(ui, repo, *pats, **opts): |
|
280 | def addremove(ui, repo, *pats, **opts): | |
281 | """add all new files, delete all missing files |
|
281 | """add all new files, delete all missing files | |
282 |
|
282 | |||
283 | Add all new files and remove all missing files from the |
|
283 | Add all new files and remove all missing files from the | |
284 | repository. |
|
284 | repository. | |
285 |
|
285 | |||
286 | Unless names are given, new files are ignored if they match any of |
|
286 | Unless names are given, new files are ignored if they match any of | |
287 | the patterns in ``.hgignore``. As with add, these changes take |
|
287 | the patterns in ``.hgignore``. As with add, these changes take | |
288 | effect at the next commit. |
|
288 | effect at the next commit. | |
289 |
|
289 | |||
290 | Use the -s/--similarity option to detect renamed files. This |
|
290 | Use the -s/--similarity option to detect renamed files. This | |
291 | option takes a percentage between 0 (disabled) and 100 (files must |
|
291 | option takes a percentage between 0 (disabled) and 100 (files must | |
292 | be identical) as its parameter. With a parameter greater than 0, |
|
292 | be identical) as its parameter. With a parameter greater than 0, | |
293 | this compares every removed file with every added file and records |
|
293 | this compares every removed file with every added file and records | |
294 | those similar enough as renames. Detecting renamed files this way |
|
294 | those similar enough as renames. Detecting renamed files this way | |
295 | can be expensive. After using this option, :hg:`status -C` can be |
|
295 | can be expensive. After using this option, :hg:`status -C` can be | |
296 | used to check which files were identified as moved or renamed. If |
|
296 | used to check which files were identified as moved or renamed. If | |
297 | not specified, -s/--similarity defaults to 100 and only renames of |
|
297 | not specified, -s/--similarity defaults to 100 and only renames of | |
298 | identical files are detected. |
|
298 | identical files are detected. | |
299 |
|
299 | |||
300 | .. container:: verbose |
|
300 | .. container:: verbose | |
301 |
|
301 | |||
302 | Examples: |
|
302 | Examples: | |
303 |
|
303 | |||
304 | - A number of files (bar.c and foo.c) are new, |
|
304 | - A number of files (bar.c and foo.c) are new, | |
305 | while foobar.c has been removed (without using :hg:`remove`) |
|
305 | while foobar.c has been removed (without using :hg:`remove`) | |
306 | from the repository:: |
|
306 | from the repository:: | |
307 |
|
307 | |||
308 | $ ls |
|
308 | $ ls | |
309 | bar.c foo.c |
|
309 | bar.c foo.c | |
310 | $ hg status |
|
310 | $ hg status | |
311 | ! foobar.c |
|
311 | ! foobar.c | |
312 | ? bar.c |
|
312 | ? bar.c | |
313 | ? foo.c |
|
313 | ? foo.c | |
314 | $ hg addremove |
|
314 | $ hg addremove | |
315 | adding bar.c |
|
315 | adding bar.c | |
316 | adding foo.c |
|
316 | adding foo.c | |
317 | removing foobar.c |
|
317 | removing foobar.c | |
318 | $ hg status |
|
318 | $ hg status | |
319 | A bar.c |
|
319 | A bar.c | |
320 | A foo.c |
|
320 | A foo.c | |
321 | R foobar.c |
|
321 | R foobar.c | |
322 |
|
322 | |||
323 | - A file foobar.c was moved to foo.c without using :hg:`rename`. |
|
323 | - A file foobar.c was moved to foo.c without using :hg:`rename`. | |
324 | Afterwards, it was edited slightly:: |
|
324 | Afterwards, it was edited slightly:: | |
325 |
|
325 | |||
326 | $ ls |
|
326 | $ ls | |
327 | foo.c |
|
327 | foo.c | |
328 | $ hg status |
|
328 | $ hg status | |
329 | ! foobar.c |
|
329 | ! foobar.c | |
330 | ? foo.c |
|
330 | ? foo.c | |
331 | $ hg addremove --similarity 90 |
|
331 | $ hg addremove --similarity 90 | |
332 | removing foobar.c |
|
332 | removing foobar.c | |
333 | adding foo.c |
|
333 | adding foo.c | |
334 | recording removal of foobar.c as rename to foo.c (94% similar) |
|
334 | recording removal of foobar.c as rename to foo.c (94% similar) | |
335 | $ hg status -C |
|
335 | $ hg status -C | |
336 | A foo.c |
|
336 | A foo.c | |
337 | foobar.c |
|
337 | foobar.c | |
338 | R foobar.c |
|
338 | R foobar.c | |
339 |
|
339 | |||
340 | Returns 0 if all files are successfully added. |
|
340 | Returns 0 if all files are successfully added. | |
341 | """ |
|
341 | """ | |
342 | try: |
|
342 | try: | |
343 | sim = float(opts.get('similarity') or 100) |
|
343 | sim = float(opts.get('similarity') or 100) | |
344 | except ValueError: |
|
344 | except ValueError: | |
345 | raise error.Abort(_('similarity must be a number')) |
|
345 | raise error.Abort(_('similarity must be a number')) | |
346 | if sim < 0 or sim > 100: |
|
346 | if sim < 0 or sim > 100: | |
347 | raise error.Abort(_('similarity must be between 0 and 100')) |
|
347 | raise error.Abort(_('similarity must be between 0 and 100')) | |
348 | matcher = scmutil.match(repo[None], pats, opts) |
|
348 | matcher = scmutil.match(repo[None], pats, opts) | |
349 | return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0) |
|
349 | return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0) | |
350 |
|
350 | |||
351 | @command('^annotate|blame', |
|
351 | @command('^annotate|blame', | |
352 | [('r', 'rev', '', _('annotate the specified revision'), _('REV')), |
|
352 | [('r', 'rev', '', _('annotate the specified revision'), _('REV')), | |
353 | ('', 'follow', None, |
|
353 | ('', 'follow', None, | |
354 | _('follow copies/renames and list the filename (DEPRECATED)')), |
|
354 | _('follow copies/renames and list the filename (DEPRECATED)')), | |
355 | ('', 'no-follow', None, _("don't follow copies and renames")), |
|
355 | ('', 'no-follow', None, _("don't follow copies and renames")), | |
356 | ('a', 'text', None, _('treat all files as text')), |
|
356 | ('a', 'text', None, _('treat all files as text')), | |
357 | ('u', 'user', None, _('list the author (long with -v)')), |
|
357 | ('u', 'user', None, _('list the author (long with -v)')), | |
358 | ('f', 'file', None, _('list the filename')), |
|
358 | ('f', 'file', None, _('list the filename')), | |
359 | ('d', 'date', None, _('list the date (short with -q)')), |
|
359 | ('d', 'date', None, _('list the date (short with -q)')), | |
360 | ('n', 'number', None, _('list the revision number (default)')), |
|
360 | ('n', 'number', None, _('list the revision number (default)')), | |
361 | ('c', 'changeset', None, _('list the changeset')), |
|
361 | ('c', 'changeset', None, _('list the changeset')), | |
362 | ('l', 'line-number', None, _('show line number at the first appearance')) |
|
362 | ('l', 'line-number', None, _('show line number at the first appearance')) | |
363 | ] + diffwsopts + walkopts + formatteropts, |
|
363 | ] + diffwsopts + walkopts + formatteropts, | |
364 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'), |
|
364 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'), | |
365 | inferrepo=True) |
|
365 | inferrepo=True) | |
366 | def annotate(ui, repo, *pats, **opts): |
|
366 | def annotate(ui, repo, *pats, **opts): | |
367 | """show changeset information by line for each file |
|
367 | """show changeset information by line for each file | |
368 |
|
368 | |||
369 | List changes in files, showing the revision id responsible for |
|
369 | List changes in files, showing the revision id responsible for | |
370 | each line. |
|
370 | each line. | |
371 |
|
371 | |||
372 | This command is useful for discovering when a change was made and |
|
372 | This command is useful for discovering when a change was made and | |
373 | by whom. |
|
373 | by whom. | |
374 |
|
374 | |||
375 | If you include --file, --user, or --date, the revision number is |
|
375 | If you include --file, --user, or --date, the revision number is | |
376 | suppressed unless you also include --number. |
|
376 | suppressed unless you also include --number. | |
377 |
|
377 | |||
378 | Without the -a/--text option, annotate will avoid processing files |
|
378 | Without the -a/--text option, annotate will avoid processing files | |
379 | it detects as binary. With -a, annotate will annotate the file |
|
379 | it detects as binary. With -a, annotate will annotate the file | |
380 | anyway, although the results will probably be neither useful |
|
380 | anyway, although the results will probably be neither useful | |
381 | nor desirable. |
|
381 | nor desirable. | |
382 |
|
382 | |||
383 | Returns 0 on success. |
|
383 | Returns 0 on success. | |
384 | """ |
|
384 | """ | |
385 | if not pats: |
|
385 | if not pats: | |
386 | raise error.Abort(_('at least one filename or pattern is required')) |
|
386 | raise error.Abort(_('at least one filename or pattern is required')) | |
387 |
|
387 | |||
388 | if opts.get('follow'): |
|
388 | if opts.get('follow'): | |
389 | # --follow is deprecated and now just an alias for -f/--file |
|
389 | # --follow is deprecated and now just an alias for -f/--file | |
390 | # to mimic the behavior of Mercurial before version 1.5 |
|
390 | # to mimic the behavior of Mercurial before version 1.5 | |
391 | opts['file'] = True |
|
391 | opts['file'] = True | |
392 |
|
392 | |||
393 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
393 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
394 |
|
394 | |||
395 | fm = ui.formatter('annotate', opts) |
|
395 | fm = ui.formatter('annotate', opts) | |
396 | if ui.quiet: |
|
396 | if ui.quiet: | |
397 | datefunc = util.shortdate |
|
397 | datefunc = util.shortdate | |
398 | else: |
|
398 | else: | |
399 | datefunc = util.datestr |
|
399 | datefunc = util.datestr | |
400 | if ctx.rev() is None: |
|
400 | if ctx.rev() is None: | |
401 | def hexfn(node): |
|
401 | def hexfn(node): | |
402 | if node is None: |
|
402 | if node is None: | |
403 | return None |
|
403 | return None | |
404 | else: |
|
404 | else: | |
405 | return fm.hexfunc(node) |
|
405 | return fm.hexfunc(node) | |
406 | if opts.get('changeset'): |
|
406 | if opts.get('changeset'): | |
407 | # omit "+" suffix which is appended to node hex |
|
407 | # omit "+" suffix which is appended to node hex | |
408 | def formatrev(rev): |
|
408 | def formatrev(rev): | |
409 | if rev is None: |
|
409 | if rev is None: | |
410 | return '%d' % ctx.p1().rev() |
|
410 | return '%d' % ctx.p1().rev() | |
411 | else: |
|
411 | else: | |
412 | return '%d' % rev |
|
412 | return '%d' % rev | |
413 | else: |
|
413 | else: | |
414 | def formatrev(rev): |
|
414 | def formatrev(rev): | |
415 | if rev is None: |
|
415 | if rev is None: | |
416 | return '%d+' % ctx.p1().rev() |
|
416 | return '%d+' % ctx.p1().rev() | |
417 | else: |
|
417 | else: | |
418 | return '%d ' % rev |
|
418 | return '%d ' % rev | |
419 | def formathex(hex): |
|
419 | def formathex(hex): | |
420 | if hex is None: |
|
420 | if hex is None: | |
421 | return '%s+' % fm.hexfunc(ctx.p1().node()) |
|
421 | return '%s+' % fm.hexfunc(ctx.p1().node()) | |
422 | else: |
|
422 | else: | |
423 | return '%s ' % hex |
|
423 | return '%s ' % hex | |
424 | else: |
|
424 | else: | |
425 | hexfn = fm.hexfunc |
|
425 | hexfn = fm.hexfunc | |
426 | formatrev = formathex = str |
|
426 | formatrev = formathex = str | |
427 |
|
427 | |||
428 | opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), |
|
428 | opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), | |
429 | ('number', ' ', lambda x: x[0].rev(), formatrev), |
|
429 | ('number', ' ', lambda x: x[0].rev(), formatrev), | |
430 | ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex), |
|
430 | ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex), | |
431 | ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), |
|
431 | ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), | |
432 | ('file', ' ', lambda x: x[0].path(), str), |
|
432 | ('file', ' ', lambda x: x[0].path(), str), | |
433 | ('line_number', ':', lambda x: x[1], str), |
|
433 | ('line_number', ':', lambda x: x[1], str), | |
434 | ] |
|
434 | ] | |
435 | fieldnamemap = {'number': 'rev', 'changeset': 'node'} |
|
435 | fieldnamemap = {'number': 'rev', 'changeset': 'node'} | |
436 |
|
436 | |||
437 | if (not opts.get('user') and not opts.get('changeset') |
|
437 | if (not opts.get('user') and not opts.get('changeset') | |
438 | and not opts.get('date') and not opts.get('file')): |
|
438 | and not opts.get('date') and not opts.get('file')): | |
439 | opts['number'] = True |
|
439 | opts['number'] = True | |
440 |
|
440 | |||
441 | linenumber = opts.get('line_number') is not None |
|
441 | linenumber = opts.get('line_number') is not None | |
442 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
|
442 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): | |
443 | raise error.Abort(_('at least one of -n/-c is required for -l')) |
|
443 | raise error.Abort(_('at least one of -n/-c is required for -l')) | |
444 |
|
444 | |||
445 | if fm.isplain(): |
|
445 | if fm.isplain(): | |
446 | def makefunc(get, fmt): |
|
446 | def makefunc(get, fmt): | |
447 | return lambda x: fmt(get(x)) |
|
447 | return lambda x: fmt(get(x)) | |
448 | else: |
|
448 | else: | |
449 | def makefunc(get, fmt): |
|
449 | def makefunc(get, fmt): | |
450 | return get |
|
450 | return get | |
451 | funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap |
|
451 | funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap | |
452 | if opts.get(op)] |
|
452 | if opts.get(op)] | |
453 | funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
|
453 | funcmap[0] = (funcmap[0][0], '') # no separator in front of first column | |
454 | fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap |
|
454 | fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap | |
455 | if opts.get(op)) |
|
455 | if opts.get(op)) | |
456 |
|
456 | |||
457 | def bad(x, y): |
|
457 | def bad(x, y): | |
458 | raise error.Abort("%s: %s" % (x, y)) |
|
458 | raise error.Abort("%s: %s" % (x, y)) | |
459 |
|
459 | |||
460 | m = scmutil.match(ctx, pats, opts, badfn=bad) |
|
460 | m = scmutil.match(ctx, pats, opts, badfn=bad) | |
461 |
|
461 | |||
462 | follow = not opts.get('no_follow') |
|
462 | follow = not opts.get('no_follow') | |
463 | diffopts = patch.difffeatureopts(ui, opts, section='annotate', |
|
463 | diffopts = patch.difffeatureopts(ui, opts, section='annotate', | |
464 | whitespace=True) |
|
464 | whitespace=True) | |
465 | for abs in ctx.walk(m): |
|
465 | for abs in ctx.walk(m): | |
466 | fctx = ctx[abs] |
|
466 | fctx = ctx[abs] | |
467 | if not opts.get('text') and util.binary(fctx.data()): |
|
467 | if not opts.get('text') and util.binary(fctx.data()): | |
468 | fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) |
|
468 | fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) | |
469 | continue |
|
469 | continue | |
470 |
|
470 | |||
471 | lines = fctx.annotate(follow=follow, linenumber=linenumber, |
|
471 | lines = fctx.annotate(follow=follow, linenumber=linenumber, | |
472 | diffopts=diffopts) |
|
472 | diffopts=diffopts) | |
473 | if not lines: |
|
473 | if not lines: | |
474 | continue |
|
474 | continue | |
475 | formats = [] |
|
475 | formats = [] | |
476 | pieces = [] |
|
476 | pieces = [] | |
477 |
|
477 | |||
478 | for f, sep in funcmap: |
|
478 | for f, sep in funcmap: | |
479 | l = [f(n) for n, dummy in lines] |
|
479 | l = [f(n) for n, dummy in lines] | |
480 | if fm.isplain(): |
|
480 | if fm.isplain(): | |
481 | sizes = [encoding.colwidth(x) for x in l] |
|
481 | sizes = [encoding.colwidth(x) for x in l] | |
482 | ml = max(sizes) |
|
482 | ml = max(sizes) | |
483 | formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) |
|
483 | formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) | |
484 | else: |
|
484 | else: | |
485 | formats.append(['%s' for x in l]) |
|
485 | formats.append(['%s' for x in l]) | |
486 | pieces.append(l) |
|
486 | pieces.append(l) | |
487 |
|
487 | |||
488 | for f, p, l in zip(zip(*formats), zip(*pieces), lines): |
|
488 | for f, p, l in zip(zip(*formats), zip(*pieces), lines): | |
489 | fm.startitem() |
|
489 | fm.startitem() | |
490 | fm.write(fields, "".join(f), *p) |
|
490 | fm.write(fields, "".join(f), *p) | |
491 | fm.write('line', ": %s", l[1]) |
|
491 | fm.write('line', ": %s", l[1]) | |
492 |
|
492 | |||
493 | if not lines[-1][1].endswith('\n'): |
|
493 | if not lines[-1][1].endswith('\n'): | |
494 | fm.plain('\n') |
|
494 | fm.plain('\n') | |
495 |
|
495 | |||
496 | fm.end() |
|
496 | fm.end() | |
497 |
|
497 | |||
498 | @command('archive', |
|
498 | @command('archive', | |
499 | [('', 'no-decode', None, _('do not pass files through decoders')), |
|
499 | [('', 'no-decode', None, _('do not pass files through decoders')), | |
500 | ('p', 'prefix', '', _('directory prefix for files in archive'), |
|
500 | ('p', 'prefix', '', _('directory prefix for files in archive'), | |
501 | _('PREFIX')), |
|
501 | _('PREFIX')), | |
502 | ('r', 'rev', '', _('revision to distribute'), _('REV')), |
|
502 | ('r', 'rev', '', _('revision to distribute'), _('REV')), | |
503 | ('t', 'type', '', _('type of distribution to create'), _('TYPE')), |
|
503 | ('t', 'type', '', _('type of distribution to create'), _('TYPE')), | |
504 | ] + subrepoopts + walkopts, |
|
504 | ] + subrepoopts + walkopts, | |
505 | _('[OPTION]... DEST')) |
|
505 | _('[OPTION]... DEST')) | |
506 | def archive(ui, repo, dest, **opts): |
|
506 | def archive(ui, repo, dest, **opts): | |
507 | '''create an unversioned archive of a repository revision |
|
507 | '''create an unversioned archive of a repository revision | |
508 |
|
508 | |||
509 | By default, the revision used is the parent of the working |
|
509 | By default, the revision used is the parent of the working | |
510 | directory; use -r/--rev to specify a different revision. |
|
510 | directory; use -r/--rev to specify a different revision. | |
511 |
|
511 | |||
512 | The archive type is automatically detected based on file |
|
512 | The archive type is automatically detected based on file | |
513 | extension (to override, use -t/--type). |
|
513 | extension (to override, use -t/--type). | |
514 |
|
514 | |||
515 | .. container:: verbose |
|
515 | .. container:: verbose | |
516 |
|
516 | |||
517 | Examples: |
|
517 | Examples: | |
518 |
|
518 | |||
519 | - create a zip file containing the 1.0 release:: |
|
519 | - create a zip file containing the 1.0 release:: | |
520 |
|
520 | |||
521 | hg archive -r 1.0 project-1.0.zip |
|
521 | hg archive -r 1.0 project-1.0.zip | |
522 |
|
522 | |||
523 | - create a tarball excluding .hg files:: |
|
523 | - create a tarball excluding .hg files:: | |
524 |
|
524 | |||
525 | hg archive project.tar.gz -X ".hg*" |
|
525 | hg archive project.tar.gz -X ".hg*" | |
526 |
|
526 | |||
527 | Valid types are: |
|
527 | Valid types are: | |
528 |
|
528 | |||
529 | :``files``: a directory full of files (default) |
|
529 | :``files``: a directory full of files (default) | |
530 | :``tar``: tar archive, uncompressed |
|
530 | :``tar``: tar archive, uncompressed | |
531 | :``tbz2``: tar archive, compressed using bzip2 |
|
531 | :``tbz2``: tar archive, compressed using bzip2 | |
532 | :``tgz``: tar archive, compressed using gzip |
|
532 | :``tgz``: tar archive, compressed using gzip | |
533 | :``uzip``: zip archive, uncompressed |
|
533 | :``uzip``: zip archive, uncompressed | |
534 | :``zip``: zip archive, compressed using deflate |
|
534 | :``zip``: zip archive, compressed using deflate | |
535 |
|
535 | |||
536 | The exact name of the destination archive or directory is given |
|
536 | The exact name of the destination archive or directory is given | |
537 | using a format string; see :hg:`help export` for details. |
|
537 | using a format string; see :hg:`help export` for details. | |
538 |
|
538 | |||
539 | Each member added to an archive file has a directory prefix |
|
539 | Each member added to an archive file has a directory prefix | |
540 | prepended. Use -p/--prefix to specify a format string for the |
|
540 | prepended. Use -p/--prefix to specify a format string for the | |
541 | prefix. The default is the basename of the archive, with suffixes |
|
541 | prefix. The default is the basename of the archive, with suffixes | |
542 | removed. |
|
542 | removed. | |
543 |
|
543 | |||
544 | Returns 0 on success. |
|
544 | Returns 0 on success. | |
545 | ''' |
|
545 | ''' | |
546 |
|
546 | |||
547 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
547 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
548 | if not ctx: |
|
548 | if not ctx: | |
549 | raise error.Abort(_('no working directory: please specify a revision')) |
|
549 | raise error.Abort(_('no working directory: please specify a revision')) | |
550 | node = ctx.node() |
|
550 | node = ctx.node() | |
551 | dest = cmdutil.makefilename(repo, dest, node) |
|
551 | dest = cmdutil.makefilename(repo, dest, node) | |
552 | if os.path.realpath(dest) == repo.root: |
|
552 | if os.path.realpath(dest) == repo.root: | |
553 | raise error.Abort(_('repository root cannot be destination')) |
|
553 | raise error.Abort(_('repository root cannot be destination')) | |
554 |
|
554 | |||
555 | kind = opts.get('type') or archival.guesskind(dest) or 'files' |
|
555 | kind = opts.get('type') or archival.guesskind(dest) or 'files' | |
556 | prefix = opts.get('prefix') |
|
556 | prefix = opts.get('prefix') | |
557 |
|
557 | |||
558 | if dest == '-': |
|
558 | if dest == '-': | |
559 | if kind == 'files': |
|
559 | if kind == 'files': | |
560 | raise error.Abort(_('cannot archive plain files to stdout')) |
|
560 | raise error.Abort(_('cannot archive plain files to stdout')) | |
561 | dest = cmdutil.makefileobj(repo, dest) |
|
561 | dest = cmdutil.makefileobj(repo, dest) | |
562 | if not prefix: |
|
562 | if not prefix: | |
563 | prefix = os.path.basename(repo.root) + '-%h' |
|
563 | prefix = os.path.basename(repo.root) + '-%h' | |
564 |
|
564 | |||
565 | prefix = cmdutil.makefilename(repo, prefix, node) |
|
565 | prefix = cmdutil.makefilename(repo, prefix, node) | |
566 | matchfn = scmutil.match(ctx, [], opts) |
|
566 | matchfn = scmutil.match(ctx, [], opts) | |
567 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
|
567 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), | |
568 | matchfn, prefix, subrepos=opts.get('subrepos')) |
|
568 | matchfn, prefix, subrepos=opts.get('subrepos')) | |
569 |
|
569 | |||
570 | @command('backout', |
|
570 | @command('backout', | |
571 | [('', 'merge', None, _('merge with old dirstate parent after backout')), |
|
571 | [('', 'merge', None, _('merge with old dirstate parent after backout')), | |
572 | ('', 'commit', None, |
|
572 | ('', 'commit', None, | |
573 | _('commit if no conflicts were encountered (DEPRECATED)')), |
|
573 | _('commit if no conflicts were encountered (DEPRECATED)')), | |
574 | ('', 'no-commit', None, _('do not commit')), |
|
574 | ('', 'no-commit', None, _('do not commit')), | |
575 | ('', 'parent', '', |
|
575 | ('', 'parent', '', | |
576 | _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), |
|
576 | _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), | |
577 | ('r', 'rev', '', _('revision to backout'), _('REV')), |
|
577 | ('r', 'rev', '', _('revision to backout'), _('REV')), | |
578 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
578 | ('e', 'edit', False, _('invoke editor on commit messages')), | |
579 | ] + mergetoolopts + walkopts + commitopts + commitopts2, |
|
579 | ] + mergetoolopts + walkopts + commitopts + commitopts2, | |
580 | _('[OPTION]... [-r] REV')) |
|
580 | _('[OPTION]... [-r] REV')) | |
581 | def backout(ui, repo, node=None, rev=None, **opts): |
|
581 | def backout(ui, repo, node=None, rev=None, **opts): | |
582 | '''reverse effect of earlier changeset |
|
582 | '''reverse effect of earlier changeset | |
583 |
|
583 | |||
584 | Prepare a new changeset with the effect of REV undone in the |
|
584 | Prepare a new changeset with the effect of REV undone in the | |
585 | current working directory. If no conflicts were encountered, |
|
585 | current working directory. If no conflicts were encountered, | |
586 | it will be committed immediately. |
|
586 | it will be committed immediately. | |
587 |
|
587 | |||
588 | If REV is the parent of the working directory, then this new changeset |
|
588 | If REV is the parent of the working directory, then this new changeset | |
589 | is committed automatically (unless --no-commit is specified). |
|
589 | is committed automatically (unless --no-commit is specified). | |
590 |
|
590 | |||
591 | .. note:: |
|
591 | .. note:: | |
592 |
|
592 | |||
593 | :hg:`backout` cannot be used to fix either an unwanted or |
|
593 | :hg:`backout` cannot be used to fix either an unwanted or | |
594 | incorrect merge. |
|
594 | incorrect merge. | |
595 |
|
595 | |||
596 | .. container:: verbose |
|
596 | .. container:: verbose | |
597 |
|
597 | |||
598 | Examples: |
|
598 | Examples: | |
599 |
|
599 | |||
600 | - Reverse the effect of the parent of the working directory. |
|
600 | - Reverse the effect of the parent of the working directory. | |
601 | This backout will be committed immediately:: |
|
601 | This backout will be committed immediately:: | |
602 |
|
602 | |||
603 | hg backout -r . |
|
603 | hg backout -r . | |
604 |
|
604 | |||
605 | - Reverse the effect of previous bad revision 23:: |
|
605 | - Reverse the effect of previous bad revision 23:: | |
606 |
|
606 | |||
607 | hg backout -r 23 |
|
607 | hg backout -r 23 | |
608 |
|
608 | |||
609 | - Reverse the effect of previous bad revision 23 and |
|
609 | - Reverse the effect of previous bad revision 23 and | |
610 | leave changes uncommitted:: |
|
610 | leave changes uncommitted:: | |
611 |
|
611 | |||
612 | hg backout -r 23 --no-commit |
|
612 | hg backout -r 23 --no-commit | |
613 | hg commit -m "Backout revision 23" |
|
613 | hg commit -m "Backout revision 23" | |
614 |
|
614 | |||
615 | By default, the pending changeset will have one parent, |
|
615 | By default, the pending changeset will have one parent, | |
616 | maintaining a linear history. With --merge, the pending |
|
616 | maintaining a linear history. With --merge, the pending | |
617 | changeset will instead have two parents: the old parent of the |
|
617 | changeset will instead have two parents: the old parent of the | |
618 | working directory and a new child of REV that simply undoes REV. |
|
618 | working directory and a new child of REV that simply undoes REV. | |
619 |
|
619 | |||
620 | Before version 1.7, the behavior without --merge was equivalent |
|
620 | Before version 1.7, the behavior without --merge was equivalent | |
621 | to specifying --merge followed by :hg:`update --clean .` to |
|
621 | to specifying --merge followed by :hg:`update --clean .` to | |
622 | cancel the merge and leave the child of REV as a head to be |
|
622 | cancel the merge and leave the child of REV as a head to be | |
623 | merged separately. |
|
623 | merged separately. | |
624 |
|
624 | |||
625 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
625 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
626 |
|
626 | |||
627 | See :hg:`help revert` for a way to restore files to the state |
|
627 | See :hg:`help revert` for a way to restore files to the state | |
628 | of another revision. |
|
628 | of another revision. | |
629 |
|
629 | |||
630 | Returns 0 on success, 1 if nothing to backout or there are unresolved |
|
630 | Returns 0 on success, 1 if nothing to backout or there are unresolved | |
631 | files. |
|
631 | files. | |
632 | ''' |
|
632 | ''' | |
633 | wlock = lock = None |
|
633 | wlock = lock = None | |
634 | try: |
|
634 | try: | |
635 | wlock = repo.wlock() |
|
635 | wlock = repo.wlock() | |
636 | lock = repo.lock() |
|
636 | lock = repo.lock() | |
637 | return _dobackout(ui, repo, node, rev, **opts) |
|
637 | return _dobackout(ui, repo, node, rev, **opts) | |
638 | finally: |
|
638 | finally: | |
639 | release(lock, wlock) |
|
639 | release(lock, wlock) | |
640 |
|
640 | |||
641 | def _dobackout(ui, repo, node=None, rev=None, **opts): |
|
641 | def _dobackout(ui, repo, node=None, rev=None, **opts): | |
642 | if opts.get('commit') and opts.get('no_commit'): |
|
642 | if opts.get('commit') and opts.get('no_commit'): | |
643 | raise error.Abort(_("cannot use --commit with --no-commit")) |
|
643 | raise error.Abort(_("cannot use --commit with --no-commit")) | |
644 | if opts.get('merge') and opts.get('no_commit'): |
|
644 | if opts.get('merge') and opts.get('no_commit'): | |
645 | raise error.Abort(_("cannot use --merge with --no-commit")) |
|
645 | raise error.Abort(_("cannot use --merge with --no-commit")) | |
646 |
|
646 | |||
647 | if rev and node: |
|
647 | if rev and node: | |
648 | raise error.Abort(_("please specify just one revision")) |
|
648 | raise error.Abort(_("please specify just one revision")) | |
649 |
|
649 | |||
650 | if not rev: |
|
650 | if not rev: | |
651 | rev = node |
|
651 | rev = node | |
652 |
|
652 | |||
653 | if not rev: |
|
653 | if not rev: | |
654 | raise error.Abort(_("please specify a revision to backout")) |
|
654 | raise error.Abort(_("please specify a revision to backout")) | |
655 |
|
655 | |||
656 | date = opts.get('date') |
|
656 | date = opts.get('date') | |
657 | if date: |
|
657 | if date: | |
658 | opts['date'] = util.parsedate(date) |
|
658 | opts['date'] = util.parsedate(date) | |
659 |
|
659 | |||
660 | cmdutil.checkunfinished(repo) |
|
660 | cmdutil.checkunfinished(repo) | |
661 | cmdutil.bailifchanged(repo) |
|
661 | cmdutil.bailifchanged(repo) | |
662 | node = scmutil.revsingle(repo, rev).node() |
|
662 | node = scmutil.revsingle(repo, rev).node() | |
663 |
|
663 | |||
664 | op1, op2 = repo.dirstate.parents() |
|
664 | op1, op2 = repo.dirstate.parents() | |
665 | if not repo.changelog.isancestor(node, op1): |
|
665 | if not repo.changelog.isancestor(node, op1): | |
666 | raise error.Abort(_('cannot backout change that is not an ancestor')) |
|
666 | raise error.Abort(_('cannot backout change that is not an ancestor')) | |
667 |
|
667 | |||
668 | p1, p2 = repo.changelog.parents(node) |
|
668 | p1, p2 = repo.changelog.parents(node) | |
669 | if p1 == nullid: |
|
669 | if p1 == nullid: | |
670 | raise error.Abort(_('cannot backout a change with no parents')) |
|
670 | raise error.Abort(_('cannot backout a change with no parents')) | |
671 | if p2 != nullid: |
|
671 | if p2 != nullid: | |
672 | if not opts.get('parent'): |
|
672 | if not opts.get('parent'): | |
673 | raise error.Abort(_('cannot backout a merge changeset')) |
|
673 | raise error.Abort(_('cannot backout a merge changeset')) | |
674 | p = repo.lookup(opts['parent']) |
|
674 | p = repo.lookup(opts['parent']) | |
675 | if p not in (p1, p2): |
|
675 | if p not in (p1, p2): | |
676 | raise error.Abort(_('%s is not a parent of %s') % |
|
676 | raise error.Abort(_('%s is not a parent of %s') % | |
677 | (short(p), short(node))) |
|
677 | (short(p), short(node))) | |
678 | parent = p |
|
678 | parent = p | |
679 | else: |
|
679 | else: | |
680 | if opts.get('parent'): |
|
680 | if opts.get('parent'): | |
681 | raise error.Abort(_('cannot use --parent on non-merge changeset')) |
|
681 | raise error.Abort(_('cannot use --parent on non-merge changeset')) | |
682 | parent = p1 |
|
682 | parent = p1 | |
683 |
|
683 | |||
684 | # the backout should appear on the same branch |
|
684 | # the backout should appear on the same branch | |
685 | branch = repo.dirstate.branch() |
|
685 | branch = repo.dirstate.branch() | |
686 | bheads = repo.branchheads(branch) |
|
686 | bheads = repo.branchheads(branch) | |
687 | rctx = scmutil.revsingle(repo, hex(parent)) |
|
687 | rctx = scmutil.revsingle(repo, hex(parent)) | |
688 | if not opts.get('merge') and op1 != node: |
|
688 | if not opts.get('merge') and op1 != node: | |
689 | dsguard = cmdutil.dirstateguard(repo, 'backout') |
|
689 | dsguard = cmdutil.dirstateguard(repo, 'backout') | |
690 | try: |
|
690 | try: | |
691 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
691 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | |
692 | 'backout') |
|
692 | 'backout') | |
693 | stats = mergemod.update(repo, parent, True, True, node, False) |
|
693 | stats = mergemod.update(repo, parent, True, True, node, False) | |
694 | repo.setparents(op1, op2) |
|
694 | repo.setparents(op1, op2) | |
695 | dsguard.close() |
|
695 | dsguard.close() | |
696 | hg._showstats(repo, stats) |
|
696 | hg._showstats(repo, stats) | |
697 | if stats[3]: |
|
697 | if stats[3]: | |
698 | repo.ui.status(_("use 'hg resolve' to retry unresolved " |
|
698 | repo.ui.status(_("use 'hg resolve' to retry unresolved " | |
699 | "file merges\n")) |
|
699 | "file merges\n")) | |
700 | return 1 |
|
700 | return 1 | |
701 | finally: |
|
701 | finally: | |
702 | ui.setconfig('ui', 'forcemerge', '', '') |
|
702 | ui.setconfig('ui', 'forcemerge', '', '') | |
703 | lockmod.release(dsguard) |
|
703 | lockmod.release(dsguard) | |
704 | else: |
|
704 | else: | |
705 | hg.clean(repo, node, show_stats=False) |
|
705 | hg.clean(repo, node, show_stats=False) | |
706 | repo.dirstate.setbranch(branch) |
|
706 | repo.dirstate.setbranch(branch) | |
707 | cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) |
|
707 | cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) | |
708 |
|
708 | |||
709 | if opts.get('no_commit'): |
|
709 | if opts.get('no_commit'): | |
710 | msg = _("changeset %s backed out, " |
|
710 | msg = _("changeset %s backed out, " | |
711 | "don't forget to commit.\n") |
|
711 | "don't forget to commit.\n") | |
712 | ui.status(msg % short(node)) |
|
712 | ui.status(msg % short(node)) | |
713 | return 0 |
|
713 | return 0 | |
714 |
|
714 | |||
715 | def commitfunc(ui, repo, message, match, opts): |
|
715 | def commitfunc(ui, repo, message, match, opts): | |
716 | editform = 'backout' |
|
716 | editform = 'backout' | |
717 | e = cmdutil.getcommiteditor(editform=editform, **opts) |
|
717 | e = cmdutil.getcommiteditor(editform=editform, **opts) | |
718 | if not message: |
|
718 | if not message: | |
719 | # we don't translate commit messages |
|
719 | # we don't translate commit messages | |
720 | message = "Backed out changeset %s" % short(node) |
|
720 | message = "Backed out changeset %s" % short(node) | |
721 | e = cmdutil.getcommiteditor(edit=True, editform=editform) |
|
721 | e = cmdutil.getcommiteditor(edit=True, editform=editform) | |
722 | return repo.commit(message, opts.get('user'), opts.get('date'), |
|
722 | return repo.commit(message, opts.get('user'), opts.get('date'), | |
723 | match, editor=e) |
|
723 | match, editor=e) | |
724 | newnode = cmdutil.commit(ui, repo, commitfunc, [], opts) |
|
724 | newnode = cmdutil.commit(ui, repo, commitfunc, [], opts) | |
725 | if not newnode: |
|
725 | if not newnode: | |
726 | ui.status(_("nothing changed\n")) |
|
726 | ui.status(_("nothing changed\n")) | |
727 | return 1 |
|
727 | return 1 | |
728 | cmdutil.commitstatus(repo, newnode, branch, bheads) |
|
728 | cmdutil.commitstatus(repo, newnode, branch, bheads) | |
729 |
|
729 | |||
730 | def nice(node): |
|
730 | def nice(node): | |
731 | return '%d:%s' % (repo.changelog.rev(node), short(node)) |
|
731 | return '%d:%s' % (repo.changelog.rev(node), short(node)) | |
732 | ui.status(_('changeset %s backs out changeset %s\n') % |
|
732 | ui.status(_('changeset %s backs out changeset %s\n') % | |
733 | (nice(repo.changelog.tip()), nice(node))) |
|
733 | (nice(repo.changelog.tip()), nice(node))) | |
734 | if opts.get('merge') and op1 != node: |
|
734 | if opts.get('merge') and op1 != node: | |
735 | hg.clean(repo, op1, show_stats=False) |
|
735 | hg.clean(repo, op1, show_stats=False) | |
736 | ui.status(_('merging with changeset %s\n') |
|
736 | ui.status(_('merging with changeset %s\n') | |
737 | % nice(repo.changelog.tip())) |
|
737 | % nice(repo.changelog.tip())) | |
738 | try: |
|
738 | try: | |
739 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
739 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | |
740 | 'backout') |
|
740 | 'backout') | |
741 | return hg.merge(repo, hex(repo.changelog.tip())) |
|
741 | return hg.merge(repo, hex(repo.changelog.tip())) | |
742 | finally: |
|
742 | finally: | |
743 | ui.setconfig('ui', 'forcemerge', '', '') |
|
743 | ui.setconfig('ui', 'forcemerge', '', '') | |
744 | return 0 |
|
744 | return 0 | |
745 |
|
745 | |||
746 | @command('bisect', |
|
746 | @command('bisect', | |
747 | [('r', 'reset', False, _('reset bisect state')), |
|
747 | [('r', 'reset', False, _('reset bisect state')), | |
748 | ('g', 'good', False, _('mark changeset good')), |
|
748 | ('g', 'good', False, _('mark changeset good')), | |
749 | ('b', 'bad', False, _('mark changeset bad')), |
|
749 | ('b', 'bad', False, _('mark changeset bad')), | |
750 | ('s', 'skip', False, _('skip testing changeset')), |
|
750 | ('s', 'skip', False, _('skip testing changeset')), | |
751 | ('e', 'extend', False, _('extend the bisect range')), |
|
751 | ('e', 'extend', False, _('extend the bisect range')), | |
752 | ('c', 'command', '', _('use command to check changeset state'), _('CMD')), |
|
752 | ('c', 'command', '', _('use command to check changeset state'), _('CMD')), | |
753 | ('U', 'noupdate', False, _('do not update to target'))], |
|
753 | ('U', 'noupdate', False, _('do not update to target'))], | |
754 | _("[-gbsr] [-U] [-c CMD] [REV]")) |
|
754 | _("[-gbsr] [-U] [-c CMD] [REV]")) | |
755 | def bisect(ui, repo, rev=None, extra=None, command=None, |
|
755 | def bisect(ui, repo, rev=None, extra=None, command=None, | |
756 | reset=None, good=None, bad=None, skip=None, extend=None, |
|
756 | reset=None, good=None, bad=None, skip=None, extend=None, | |
757 | noupdate=None): |
|
757 | noupdate=None): | |
758 | """subdivision search of changesets |
|
758 | """subdivision search of changesets | |
759 |
|
759 | |||
760 | This command helps to find changesets which introduce problems. To |
|
760 | This command helps to find changesets which introduce problems. To | |
761 | use, mark the earliest changeset you know exhibits the problem as |
|
761 | use, mark the earliest changeset you know exhibits the problem as | |
762 | bad, then mark the latest changeset which is free from the problem |
|
762 | bad, then mark the latest changeset which is free from the problem | |
763 | as good. Bisect will update your working directory to a revision |
|
763 | as good. Bisect will update your working directory to a revision | |
764 | for testing (unless the -U/--noupdate option is specified). Once |
|
764 | for testing (unless the -U/--noupdate option is specified). Once | |
765 | you have performed tests, mark the working directory as good or |
|
765 | you have performed tests, mark the working directory as good or | |
766 | bad, and bisect will either update to another candidate changeset |
|
766 | bad, and bisect will either update to another candidate changeset | |
767 | or announce that it has found the bad revision. |
|
767 | or announce that it has found the bad revision. | |
768 |
|
768 | |||
769 | As a shortcut, you can also use the revision argument to mark a |
|
769 | As a shortcut, you can also use the revision argument to mark a | |
770 | revision as good or bad without checking it out first. |
|
770 | revision as good or bad without checking it out first. | |
771 |
|
771 | |||
772 | If you supply a command, it will be used for automatic bisection. |
|
772 | If you supply a command, it will be used for automatic bisection. | |
773 | The environment variable HG_NODE will contain the ID of the |
|
773 | The environment variable HG_NODE will contain the ID of the | |
774 | changeset being tested. The exit status of the command will be |
|
774 | changeset being tested. The exit status of the command will be | |
775 | used to mark revisions as good or bad: status 0 means good, 125 |
|
775 | used to mark revisions as good or bad: status 0 means good, 125 | |
776 | means to skip the revision, 127 (command not found) will abort the |
|
776 | means to skip the revision, 127 (command not found) will abort the | |
777 | bisection, and any other non-zero exit status means the revision |
|
777 | bisection, and any other non-zero exit status means the revision | |
778 | is bad. |
|
778 | is bad. | |
779 |
|
779 | |||
780 | .. container:: verbose |
|
780 | .. container:: verbose | |
781 |
|
781 | |||
782 | Some examples: |
|
782 | Some examples: | |
783 |
|
783 | |||
784 | - start a bisection with known bad revision 34, and good revision 12:: |
|
784 | - start a bisection with known bad revision 34, and good revision 12:: | |
785 |
|
785 | |||
786 | hg bisect --bad 34 |
|
786 | hg bisect --bad 34 | |
787 | hg bisect --good 12 |
|
787 | hg bisect --good 12 | |
788 |
|
788 | |||
789 | - advance the current bisection by marking current revision as good or |
|
789 | - advance the current bisection by marking current revision as good or | |
790 | bad:: |
|
790 | bad:: | |
791 |
|
791 | |||
792 | hg bisect --good |
|
792 | hg bisect --good | |
793 | hg bisect --bad |
|
793 | hg bisect --bad | |
794 |
|
794 | |||
795 | - mark the current revision, or a known revision, to be skipped (e.g. if |
|
795 | - mark the current revision, or a known revision, to be skipped (e.g. if | |
796 | that revision is not usable because of another issue):: |
|
796 | that revision is not usable because of another issue):: | |
797 |
|
797 | |||
798 | hg bisect --skip |
|
798 | hg bisect --skip | |
799 | hg bisect --skip 23 |
|
799 | hg bisect --skip 23 | |
800 |
|
800 | |||
801 | - skip all revisions that do not touch directories ``foo`` or ``bar``:: |
|
801 | - skip all revisions that do not touch directories ``foo`` or ``bar``:: | |
802 |
|
802 | |||
803 | hg bisect --skip "!( file('path:foo') & file('path:bar') )" |
|
803 | hg bisect --skip "!( file('path:foo') & file('path:bar') )" | |
804 |
|
804 | |||
805 | - forget the current bisection:: |
|
805 | - forget the current bisection:: | |
806 |
|
806 | |||
807 | hg bisect --reset |
|
807 | hg bisect --reset | |
808 |
|
808 | |||
809 | - use 'make && make tests' to automatically find the first broken |
|
809 | - use 'make && make tests' to automatically find the first broken | |
810 | revision:: |
|
810 | revision:: | |
811 |
|
811 | |||
812 | hg bisect --reset |
|
812 | hg bisect --reset | |
813 | hg bisect --bad 34 |
|
813 | hg bisect --bad 34 | |
814 | hg bisect --good 12 |
|
814 | hg bisect --good 12 | |
815 | hg bisect --command "make && make tests" |
|
815 | hg bisect --command "make && make tests" | |
816 |
|
816 | |||
817 | - see all changesets whose states are already known in the current |
|
817 | - see all changesets whose states are already known in the current | |
818 | bisection:: |
|
818 | bisection:: | |
819 |
|
819 | |||
820 | hg log -r "bisect(pruned)" |
|
820 | hg log -r "bisect(pruned)" | |
821 |
|
821 | |||
822 | - see the changeset currently being bisected (especially useful |
|
822 | - see the changeset currently being bisected (especially useful | |
823 | if running with -U/--noupdate):: |
|
823 | if running with -U/--noupdate):: | |
824 |
|
824 | |||
825 | hg log -r "bisect(current)" |
|
825 | hg log -r "bisect(current)" | |
826 |
|
826 | |||
827 | - see all changesets that took part in the current bisection:: |
|
827 | - see all changesets that took part in the current bisection:: | |
828 |
|
828 | |||
829 | hg log -r "bisect(range)" |
|
829 | hg log -r "bisect(range)" | |
830 |
|
830 | |||
831 | - you can even get a nice graph:: |
|
831 | - you can even get a nice graph:: | |
832 |
|
832 | |||
833 | hg log --graph -r "bisect(range)" |
|
833 | hg log --graph -r "bisect(range)" | |
834 |
|
834 | |||
835 | See :hg:`help revsets` for more about the `bisect()` keyword. |
|
835 | See :hg:`help revsets` for more about the `bisect()` keyword. | |
836 |
|
836 | |||
837 | Returns 0 on success. |
|
837 | Returns 0 on success. | |
838 | """ |
|
838 | """ | |
839 | # backward compatibility |
|
839 | # backward compatibility | |
840 | if rev in "good bad reset init".split(): |
|
840 | if rev in "good bad reset init".split(): | |
841 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
|
841 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) | |
842 | cmd, rev, extra = rev, extra, None |
|
842 | cmd, rev, extra = rev, extra, None | |
843 | if cmd == "good": |
|
843 | if cmd == "good": | |
844 | good = True |
|
844 | good = True | |
845 | elif cmd == "bad": |
|
845 | elif cmd == "bad": | |
846 | bad = True |
|
846 | bad = True | |
847 | else: |
|
847 | else: | |
848 | reset = True |
|
848 | reset = True | |
849 | elif extra or good + bad + skip + reset + extend + bool(command) > 1: |
|
849 | elif extra or good + bad + skip + reset + extend + bool(command) > 1: | |
850 | raise error.Abort(_('incompatible arguments')) |
|
850 | raise error.Abort(_('incompatible arguments')) | |
851 |
|
851 | |||
852 | cmdutil.checkunfinished(repo) |
|
852 | cmdutil.checkunfinished(repo) | |
853 |
|
853 | |||
854 | if reset: |
|
854 | if reset: | |
855 | hbisect.resetstate(repo) |
|
855 | hbisect.resetstate(repo) | |
856 | return |
|
856 | return | |
857 |
|
857 | |||
858 | state = hbisect.load_state(repo) |
|
858 | state = hbisect.load_state(repo) | |
859 |
|
859 | |||
860 | # update state |
|
860 | # update state | |
861 | if good or bad or skip: |
|
861 | if good or bad or skip: | |
862 | if rev: |
|
862 | if rev: | |
863 | nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])] |
|
863 | nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])] | |
864 | else: |
|
864 | else: | |
865 | nodes = [repo.lookup('.')] |
|
865 | nodes = [repo.lookup('.')] | |
866 | if good: |
|
866 | if good: | |
867 | state['good'] += nodes |
|
867 | state['good'] += nodes | |
868 | elif bad: |
|
868 | elif bad: | |
869 | state['bad'] += nodes |
|
869 | state['bad'] += nodes | |
870 | elif skip: |
|
870 | elif skip: | |
871 | state['skip'] += nodes |
|
871 | state['skip'] += nodes | |
872 | hbisect.save_state(repo, state) |
|
872 | hbisect.save_state(repo, state) | |
873 | if not (state['good'] and state['bad']): |
|
873 | if not (state['good'] and state['bad']): | |
874 | return |
|
874 | return | |
875 |
|
875 | |||
876 | def mayupdate(repo, node, show_stats=True): |
|
876 | def mayupdate(repo, node, show_stats=True): | |
877 | """common used update sequence""" |
|
877 | """common used update sequence""" | |
878 | if noupdate: |
|
878 | if noupdate: | |
879 | return |
|
879 | return | |
880 | cmdutil.bailifchanged(repo) |
|
880 | cmdutil.bailifchanged(repo) | |
881 | return hg.clean(repo, node, show_stats=show_stats) |
|
881 | return hg.clean(repo, node, show_stats=show_stats) | |
882 |
|
882 | |||
883 | displayer = cmdutil.show_changeset(ui, repo, {}) |
|
883 | displayer = cmdutil.show_changeset(ui, repo, {}) | |
884 |
|
884 | |||
885 | if command: |
|
885 | if command: | |
886 | changesets = 1 |
|
886 | changesets = 1 | |
887 | if noupdate: |
|
887 | if noupdate: | |
888 | try: |
|
888 | try: | |
889 | node = state['current'][0] |
|
889 | node = state['current'][0] | |
890 | except LookupError: |
|
890 | except LookupError: | |
891 | raise error.Abort(_('current bisect revision is unknown - ' |
|
891 | raise error.Abort(_('current bisect revision is unknown - ' | |
892 | 'start a new bisect to fix')) |
|
892 | 'start a new bisect to fix')) | |
893 | else: |
|
893 | else: | |
894 | node, p2 = repo.dirstate.parents() |
|
894 | node, p2 = repo.dirstate.parents() | |
895 | if p2 != nullid: |
|
895 | if p2 != nullid: | |
896 | raise error.Abort(_('current bisect revision is a merge')) |
|
896 | raise error.Abort(_('current bisect revision is a merge')) | |
897 | if rev: |
|
897 | if rev: | |
898 | node = repo[scmutil.revsingle(repo, rev, node)].node() |
|
898 | node = repo[scmutil.revsingle(repo, rev, node)].node() | |
899 | try: |
|
899 | try: | |
900 | while changesets: |
|
900 | while changesets: | |
901 | # update state |
|
901 | # update state | |
902 | state['current'] = [node] |
|
902 | state['current'] = [node] | |
903 | hbisect.save_state(repo, state) |
|
903 | hbisect.save_state(repo, state) | |
904 | status = ui.system(command, environ={'HG_NODE': hex(node)}) |
|
904 | status = ui.system(command, environ={'HG_NODE': hex(node)}) | |
905 | if status == 125: |
|
905 | if status == 125: | |
906 | transition = "skip" |
|
906 | transition = "skip" | |
907 | elif status == 0: |
|
907 | elif status == 0: | |
908 | transition = "good" |
|
908 | transition = "good" | |
909 | # status < 0 means process was killed |
|
909 | # status < 0 means process was killed | |
910 | elif status == 127: |
|
910 | elif status == 127: | |
911 | raise error.Abort(_("failed to execute %s") % command) |
|
911 | raise error.Abort(_("failed to execute %s") % command) | |
912 | elif status < 0: |
|
912 | elif status < 0: | |
913 | raise error.Abort(_("%s killed") % command) |
|
913 | raise error.Abort(_("%s killed") % command) | |
914 | else: |
|
914 | else: | |
915 | transition = "bad" |
|
915 | transition = "bad" | |
916 | state[transition].append(node) |
|
916 | state[transition].append(node) | |
917 | ctx = repo[node] |
|
917 | ctx = repo[node] | |
918 | ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition)) |
|
918 | ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition)) | |
919 | hbisect.checkstate(state) |
|
919 | hbisect.checkstate(state) | |
920 | # bisect |
|
920 | # bisect | |
921 | nodes, changesets, bgood = hbisect.bisect(repo.changelog, state) |
|
921 | nodes, changesets, bgood = hbisect.bisect(repo.changelog, state) | |
922 | # update to next check |
|
922 | # update to next check | |
923 | node = nodes[0] |
|
923 | node = nodes[0] | |
924 | mayupdate(repo, node, show_stats=False) |
|
924 | mayupdate(repo, node, show_stats=False) | |
925 | finally: |
|
925 | finally: | |
926 | state['current'] = [node] |
|
926 | state['current'] = [node] | |
927 | hbisect.save_state(repo, state) |
|
927 | hbisect.save_state(repo, state) | |
928 | hbisect.printresult(ui, repo, state, displayer, nodes, bgood) |
|
928 | hbisect.printresult(ui, repo, state, displayer, nodes, bgood) | |
929 | return |
|
929 | return | |
930 |
|
930 | |||
931 | hbisect.checkstate(state) |
|
931 | hbisect.checkstate(state) | |
932 |
|
932 | |||
933 | # actually bisect |
|
933 | # actually bisect | |
934 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
934 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) | |
935 | if extend: |
|
935 | if extend: | |
936 | if not changesets: |
|
936 | if not changesets: | |
937 | extendnode = hbisect.extendrange(repo, state, nodes, good) |
|
937 | extendnode = hbisect.extendrange(repo, state, nodes, good) | |
938 | if extendnode is not None: |
|
938 | if extendnode is not None: | |
939 | ui.write(_("Extending search to changeset %d:%s\n") |
|
939 | ui.write(_("Extending search to changeset %d:%s\n") | |
940 | % (extendnode.rev(), extendnode)) |
|
940 | % (extendnode.rev(), extendnode)) | |
941 | state['current'] = [extendnode.node()] |
|
941 | state['current'] = [extendnode.node()] | |
942 | hbisect.save_state(repo, state) |
|
942 | hbisect.save_state(repo, state) | |
943 | return mayupdate(repo, extendnode.node()) |
|
943 | return mayupdate(repo, extendnode.node()) | |
944 | raise error.Abort(_("nothing to extend")) |
|
944 | raise error.Abort(_("nothing to extend")) | |
945 |
|
945 | |||
946 | if changesets == 0: |
|
946 | if changesets == 0: | |
947 | hbisect.printresult(ui, repo, state, displayer, nodes, good) |
|
947 | hbisect.printresult(ui, repo, state, displayer, nodes, good) | |
948 | else: |
|
948 | else: | |
949 | assert len(nodes) == 1 # only a single node can be tested next |
|
949 | assert len(nodes) == 1 # only a single node can be tested next | |
950 | node = nodes[0] |
|
950 | node = nodes[0] | |
951 | # compute the approximate number of remaining tests |
|
951 | # compute the approximate number of remaining tests | |
952 | tests, size = 0, 2 |
|
952 | tests, size = 0, 2 | |
953 | while size <= changesets: |
|
953 | while size <= changesets: | |
954 | tests, size = tests + 1, size * 2 |
|
954 | tests, size = tests + 1, size * 2 | |
955 | rev = repo.changelog.rev(node) |
|
955 | rev = repo.changelog.rev(node) | |
956 | ui.write(_("Testing changeset %d:%s " |
|
956 | ui.write(_("Testing changeset %d:%s " | |
957 | "(%d changesets remaining, ~%d tests)\n") |
|
957 | "(%d changesets remaining, ~%d tests)\n") | |
958 | % (rev, short(node), changesets, tests)) |
|
958 | % (rev, short(node), changesets, tests)) | |
959 | state['current'] = [node] |
|
959 | state['current'] = [node] | |
960 | hbisect.save_state(repo, state) |
|
960 | hbisect.save_state(repo, state) | |
961 | return mayupdate(repo, node) |
|
961 | return mayupdate(repo, node) | |
962 |
|
962 | |||
963 | @command('bookmarks|bookmark', |
|
963 | @command('bookmarks|bookmark', | |
964 | [('f', 'force', False, _('force')), |
|
964 | [('f', 'force', False, _('force')), | |
965 | ('r', 'rev', '', _('revision for bookmark action'), _('REV')), |
|
965 | ('r', 'rev', '', _('revision for bookmark action'), _('REV')), | |
966 | ('d', 'delete', False, _('delete a given bookmark')), |
|
966 | ('d', 'delete', False, _('delete a given bookmark')), | |
967 | ('m', 'rename', '', _('rename a given bookmark'), _('OLD')), |
|
967 | ('m', 'rename', '', _('rename a given bookmark'), _('OLD')), | |
968 | ('i', 'inactive', False, _('mark a bookmark inactive')), |
|
968 | ('i', 'inactive', False, _('mark a bookmark inactive')), | |
969 | ] + formatteropts, |
|
969 | ] + formatteropts, | |
970 | _('hg bookmarks [OPTIONS]... [NAME]...')) |
|
970 | _('hg bookmarks [OPTIONS]... [NAME]...')) | |
971 | def bookmark(ui, repo, *names, **opts): |
|
971 | def bookmark(ui, repo, *names, **opts): | |
972 | '''create a new bookmark or list existing bookmarks |
|
972 | '''create a new bookmark or list existing bookmarks | |
973 |
|
973 | |||
974 | Bookmarks are labels on changesets to help track lines of development. |
|
974 | Bookmarks are labels on changesets to help track lines of development. | |
975 | Bookmarks are unversioned and can be moved, renamed and deleted. |
|
975 | Bookmarks are unversioned and can be moved, renamed and deleted. | |
976 | Deleting or moving a bookmark has no effect on the associated changesets. |
|
976 | Deleting or moving a bookmark has no effect on the associated changesets. | |
977 |
|
977 | |||
978 | Creating or updating to a bookmark causes it to be marked as 'active'. |
|
978 | Creating or updating to a bookmark causes it to be marked as 'active'. | |
979 | The active bookmark is indicated with a '*'. |
|
979 | The active bookmark is indicated with a '*'. | |
980 | When a commit is made, the active bookmark will advance to the new commit. |
|
980 | When a commit is made, the active bookmark will advance to the new commit. | |
981 | A plain :hg:`update` will also advance an active bookmark, if possible. |
|
981 | A plain :hg:`update` will also advance an active bookmark, if possible. | |
982 | Updating away from a bookmark will cause it to be deactivated. |
|
982 | Updating away from a bookmark will cause it to be deactivated. | |
983 |
|
983 | |||
984 | Bookmarks can be pushed and pulled between repositories (see |
|
984 | Bookmarks can be pushed and pulled between repositories (see | |
985 | :hg:`help push` and :hg:`help pull`). If a shared bookmark has |
|
985 | :hg:`help push` and :hg:`help pull`). If a shared bookmark has | |
986 | diverged, a new 'divergent bookmark' of the form 'name@path' will |
|
986 | diverged, a new 'divergent bookmark' of the form 'name@path' will | |
987 | be created. Using :hg:`merge` will resolve the divergence. |
|
987 | be created. Using :hg:`merge` will resolve the divergence. | |
988 |
|
988 | |||
989 | A bookmark named '@' has the special property that :hg:`clone` will |
|
989 | A bookmark named '@' has the special property that :hg:`clone` will | |
990 | check it out by default if it exists. |
|
990 | check it out by default if it exists. | |
991 |
|
991 | |||
992 | .. container:: verbose |
|
992 | .. container:: verbose | |
993 |
|
993 | |||
994 | Examples: |
|
994 | Examples: | |
995 |
|
995 | |||
996 | - create an active bookmark for a new line of development:: |
|
996 | - create an active bookmark for a new line of development:: | |
997 |
|
997 | |||
998 | hg book new-feature |
|
998 | hg book new-feature | |
999 |
|
999 | |||
1000 | - create an inactive bookmark as a place marker:: |
|
1000 | - create an inactive bookmark as a place marker:: | |
1001 |
|
1001 | |||
1002 | hg book -i reviewed |
|
1002 | hg book -i reviewed | |
1003 |
|
1003 | |||
1004 | - create an inactive bookmark on another changeset:: |
|
1004 | - create an inactive bookmark on another changeset:: | |
1005 |
|
1005 | |||
1006 | hg book -r .^ tested |
|
1006 | hg book -r .^ tested | |
1007 |
|
1007 | |||
1008 | - rename bookmark turkey to dinner:: |
|
1008 | - rename bookmark turkey to dinner:: | |
1009 |
|
1009 | |||
1010 | hg book -m turkey dinner |
|
1010 | hg book -m turkey dinner | |
1011 |
|
1011 | |||
1012 | - move the '@' bookmark from another branch:: |
|
1012 | - move the '@' bookmark from another branch:: | |
1013 |
|
1013 | |||
1014 | hg book -f @ |
|
1014 | hg book -f @ | |
1015 | ''' |
|
1015 | ''' | |
1016 | force = opts.get('force') |
|
1016 | force = opts.get('force') | |
1017 | rev = opts.get('rev') |
|
1017 | rev = opts.get('rev') | |
1018 | delete = opts.get('delete') |
|
1018 | delete = opts.get('delete') | |
1019 | rename = opts.get('rename') |
|
1019 | rename = opts.get('rename') | |
1020 | inactive = opts.get('inactive') |
|
1020 | inactive = opts.get('inactive') | |
1021 |
|
1021 | |||
1022 | def checkformat(mark): |
|
1022 | def checkformat(mark): | |
1023 | mark = mark.strip() |
|
1023 | mark = mark.strip() | |
1024 | if not mark: |
|
1024 | if not mark: | |
1025 | raise error.Abort(_("bookmark names cannot consist entirely of " |
|
1025 | raise error.Abort(_("bookmark names cannot consist entirely of " | |
1026 | "whitespace")) |
|
1026 | "whitespace")) | |
1027 | scmutil.checknewlabel(repo, mark, 'bookmark') |
|
1027 | scmutil.checknewlabel(repo, mark, 'bookmark') | |
1028 | return mark |
|
1028 | return mark | |
1029 |
|
1029 | |||
1030 | def checkconflict(repo, mark, cur, force=False, target=None): |
|
1030 | def checkconflict(repo, mark, cur, force=False, target=None): | |
1031 | if mark in marks and not force: |
|
1031 | if mark in marks and not force: | |
1032 | if target: |
|
1032 | if target: | |
1033 | if marks[mark] == target and target == cur: |
|
1033 | if marks[mark] == target and target == cur: | |
1034 | # re-activating a bookmark |
|
1034 | # re-activating a bookmark | |
1035 | return |
|
1035 | return | |
1036 | anc = repo.changelog.ancestors([repo[target].rev()]) |
|
1036 | anc = repo.changelog.ancestors([repo[target].rev()]) | |
1037 | bmctx = repo[marks[mark]] |
|
1037 | bmctx = repo[marks[mark]] | |
1038 | divs = [repo[b].node() for b in marks |
|
1038 | divs = [repo[b].node() for b in marks | |
1039 | if b.split('@', 1)[0] == mark.split('@', 1)[0]] |
|
1039 | if b.split('@', 1)[0] == mark.split('@', 1)[0]] | |
1040 |
|
1040 | |||
1041 | # allow resolving a single divergent bookmark even if moving |
|
1041 | # allow resolving a single divergent bookmark even if moving | |
1042 | # the bookmark across branches when a revision is specified |
|
1042 | # the bookmark across branches when a revision is specified | |
1043 | # that contains a divergent bookmark |
|
1043 | # that contains a divergent bookmark | |
1044 | if bmctx.rev() not in anc and target in divs: |
|
1044 | if bmctx.rev() not in anc and target in divs: | |
1045 | bookmarks.deletedivergent(repo, [target], mark) |
|
1045 | bookmarks.deletedivergent(repo, [target], mark) | |
1046 | return |
|
1046 | return | |
1047 |
|
1047 | |||
1048 | deletefrom = [b for b in divs |
|
1048 | deletefrom = [b for b in divs | |
1049 | if repo[b].rev() in anc or b == target] |
|
1049 | if repo[b].rev() in anc or b == target] | |
1050 | bookmarks.deletedivergent(repo, deletefrom, mark) |
|
1050 | bookmarks.deletedivergent(repo, deletefrom, mark) | |
1051 | if bookmarks.validdest(repo, bmctx, repo[target]): |
|
1051 | if bookmarks.validdest(repo, bmctx, repo[target]): | |
1052 | ui.status(_("moving bookmark '%s' forward from %s\n") % |
|
1052 | ui.status(_("moving bookmark '%s' forward from %s\n") % | |
1053 | (mark, short(bmctx.node()))) |
|
1053 | (mark, short(bmctx.node()))) | |
1054 | return |
|
1054 | return | |
1055 | raise error.Abort(_("bookmark '%s' already exists " |
|
1055 | raise error.Abort(_("bookmark '%s' already exists " | |
1056 | "(use -f to force)") % mark) |
|
1056 | "(use -f to force)") % mark) | |
1057 | if ((mark in repo.branchmap() or mark == repo.dirstate.branch()) |
|
1057 | if ((mark in repo.branchmap() or mark == repo.dirstate.branch()) | |
1058 | and not force): |
|
1058 | and not force): | |
1059 | raise error.Abort( |
|
1059 | raise error.Abort( | |
1060 | _("a bookmark cannot have the name of an existing branch")) |
|
1060 | _("a bookmark cannot have the name of an existing branch")) | |
1061 |
|
1061 | |||
1062 | if delete and rename: |
|
1062 | if delete and rename: | |
1063 | raise error.Abort(_("--delete and --rename are incompatible")) |
|
1063 | raise error.Abort(_("--delete and --rename are incompatible")) | |
1064 | if delete and rev: |
|
1064 | if delete and rev: | |
1065 | raise error.Abort(_("--rev is incompatible with --delete")) |
|
1065 | raise error.Abort(_("--rev is incompatible with --delete")) | |
1066 | if rename and rev: |
|
1066 | if rename and rev: | |
1067 | raise error.Abort(_("--rev is incompatible with --rename")) |
|
1067 | raise error.Abort(_("--rev is incompatible with --rename")) | |
1068 | if not names and (delete or rev): |
|
1068 | if not names and (delete or rev): | |
1069 | raise error.Abort(_("bookmark name required")) |
|
1069 | raise error.Abort(_("bookmark name required")) | |
1070 |
|
1070 | |||
1071 | if delete or rename or names or inactive: |
|
1071 | if delete or rename or names or inactive: | |
1072 | wlock = lock = tr = None |
|
1072 | wlock = lock = tr = None | |
1073 | try: |
|
1073 | try: | |
1074 | wlock = repo.wlock() |
|
1074 | wlock = repo.wlock() | |
1075 | lock = repo.lock() |
|
1075 | lock = repo.lock() | |
1076 | cur = repo.changectx('.').node() |
|
1076 | cur = repo.changectx('.').node() | |
1077 | marks = repo._bookmarks |
|
1077 | marks = repo._bookmarks | |
1078 | if delete: |
|
1078 | if delete: | |
1079 | tr = repo.transaction('bookmark') |
|
1079 | tr = repo.transaction('bookmark') | |
1080 | for mark in names: |
|
1080 | for mark in names: | |
1081 | if mark not in marks: |
|
1081 | if mark not in marks: | |
1082 | raise error.Abort(_("bookmark '%s' does not exist") % |
|
1082 | raise error.Abort(_("bookmark '%s' does not exist") % | |
1083 | mark) |
|
1083 | mark) | |
1084 | if mark == repo._activebookmark: |
|
1084 | if mark == repo._activebookmark: | |
1085 | bookmarks.deactivate(repo) |
|
1085 | bookmarks.deactivate(repo) | |
1086 | del marks[mark] |
|
1086 | del marks[mark] | |
1087 |
|
1087 | |||
1088 | elif rename: |
|
1088 | elif rename: | |
1089 | tr = repo.transaction('bookmark') |
|
1089 | tr = repo.transaction('bookmark') | |
1090 | if not names: |
|
1090 | if not names: | |
1091 | raise error.Abort(_("new bookmark name required")) |
|
1091 | raise error.Abort(_("new bookmark name required")) | |
1092 | elif len(names) > 1: |
|
1092 | elif len(names) > 1: | |
1093 | raise error.Abort(_("only one new bookmark name allowed")) |
|
1093 | raise error.Abort(_("only one new bookmark name allowed")) | |
1094 | mark = checkformat(names[0]) |
|
1094 | mark = checkformat(names[0]) | |
1095 | if rename not in marks: |
|
1095 | if rename not in marks: | |
1096 | raise error.Abort(_("bookmark '%s' does not exist") |
|
1096 | raise error.Abort(_("bookmark '%s' does not exist") | |
1097 | % rename) |
|
1097 | % rename) | |
1098 | checkconflict(repo, mark, cur, force) |
|
1098 | checkconflict(repo, mark, cur, force) | |
1099 | marks[mark] = marks[rename] |
|
1099 | marks[mark] = marks[rename] | |
1100 | if repo._activebookmark == rename and not inactive: |
|
1100 | if repo._activebookmark == rename and not inactive: | |
1101 | bookmarks.activate(repo, mark) |
|
1101 | bookmarks.activate(repo, mark) | |
1102 | del marks[rename] |
|
1102 | del marks[rename] | |
1103 | elif names: |
|
1103 | elif names: | |
1104 | tr = repo.transaction('bookmark') |
|
1104 | tr = repo.transaction('bookmark') | |
1105 | newact = None |
|
1105 | newact = None | |
1106 | for mark in names: |
|
1106 | for mark in names: | |
1107 | mark = checkformat(mark) |
|
1107 | mark = checkformat(mark) | |
1108 | if newact is None: |
|
1108 | if newact is None: | |
1109 | newact = mark |
|
1109 | newact = mark | |
1110 | if inactive and mark == repo._activebookmark: |
|
1110 | if inactive and mark == repo._activebookmark: | |
1111 | bookmarks.deactivate(repo) |
|
1111 | bookmarks.deactivate(repo) | |
1112 | return |
|
1112 | return | |
1113 | tgt = cur |
|
1113 | tgt = cur | |
1114 | if rev: |
|
1114 | if rev: | |
1115 | tgt = scmutil.revsingle(repo, rev).node() |
|
1115 | tgt = scmutil.revsingle(repo, rev).node() | |
1116 | checkconflict(repo, mark, cur, force, tgt) |
|
1116 | checkconflict(repo, mark, cur, force, tgt) | |
1117 | marks[mark] = tgt |
|
1117 | marks[mark] = tgt | |
1118 | if not inactive and cur == marks[newact] and not rev: |
|
1118 | if not inactive and cur == marks[newact] and not rev: | |
1119 | bookmarks.activate(repo, newact) |
|
1119 | bookmarks.activate(repo, newact) | |
1120 | elif cur != tgt and newact == repo._activebookmark: |
|
1120 | elif cur != tgt and newact == repo._activebookmark: | |
1121 | bookmarks.deactivate(repo) |
|
1121 | bookmarks.deactivate(repo) | |
1122 | elif inactive: |
|
1122 | elif inactive: | |
1123 | if len(marks) == 0: |
|
1123 | if len(marks) == 0: | |
1124 | ui.status(_("no bookmarks set\n")) |
|
1124 | ui.status(_("no bookmarks set\n")) | |
1125 | elif not repo._activebookmark: |
|
1125 | elif not repo._activebookmark: | |
1126 | ui.status(_("no active bookmark\n")) |
|
1126 | ui.status(_("no active bookmark\n")) | |
1127 | else: |
|
1127 | else: | |
1128 | bookmarks.deactivate(repo) |
|
1128 | bookmarks.deactivate(repo) | |
1129 | if tr is not None: |
|
1129 | if tr is not None: | |
1130 | marks.recordchange(tr) |
|
1130 | marks.recordchange(tr) | |
1131 | tr.close() |
|
1131 | tr.close() | |
1132 | finally: |
|
1132 | finally: | |
1133 | lockmod.release(tr, lock, wlock) |
|
1133 | lockmod.release(tr, lock, wlock) | |
1134 | else: # show bookmarks |
|
1134 | else: # show bookmarks | |
1135 | fm = ui.formatter('bookmarks', opts) |
|
1135 | fm = ui.formatter('bookmarks', opts) | |
1136 | hexfn = fm.hexfunc |
|
1136 | hexfn = fm.hexfunc | |
1137 | marks = repo._bookmarks |
|
1137 | marks = repo._bookmarks | |
1138 | if len(marks) == 0 and fm.isplain(): |
|
1138 | if len(marks) == 0 and fm.isplain(): | |
1139 | ui.status(_("no bookmarks set\n")) |
|
1139 | ui.status(_("no bookmarks set\n")) | |
1140 | for bmark, n in sorted(marks.iteritems()): |
|
1140 | for bmark, n in sorted(marks.iteritems()): | |
1141 | active = repo._activebookmark |
|
1141 | active = repo._activebookmark | |
1142 | if bmark == active: |
|
1142 | if bmark == active: | |
1143 | prefix, label = '*', activebookmarklabel |
|
1143 | prefix, label = '*', activebookmarklabel | |
1144 | else: |
|
1144 | else: | |
1145 | prefix, label = ' ', '' |
|
1145 | prefix, label = ' ', '' | |
1146 |
|
1146 | |||
1147 | fm.startitem() |
|
1147 | fm.startitem() | |
1148 | if not ui.quiet: |
|
1148 | if not ui.quiet: | |
1149 | fm.plain(' %s ' % prefix, label=label) |
|
1149 | fm.plain(' %s ' % prefix, label=label) | |
1150 | fm.write('bookmark', '%s', bmark, label=label) |
|
1150 | fm.write('bookmark', '%s', bmark, label=label) | |
1151 | pad = " " * (25 - encoding.colwidth(bmark)) |
|
1151 | pad = " " * (25 - encoding.colwidth(bmark)) | |
1152 | fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s', |
|
1152 | fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s', | |
1153 | repo.changelog.rev(n), hexfn(n), label=label) |
|
1153 | repo.changelog.rev(n), hexfn(n), label=label) | |
1154 | fm.data(active=(bmark == active)) |
|
1154 | fm.data(active=(bmark == active)) | |
1155 | fm.plain('\n') |
|
1155 | fm.plain('\n') | |
1156 | fm.end() |
|
1156 | fm.end() | |
1157 |
|
1157 | |||
1158 | @command('branch', |
|
1158 | @command('branch', | |
1159 | [('f', 'force', None, |
|
1159 | [('f', 'force', None, | |
1160 | _('set branch name even if it shadows an existing branch')), |
|
1160 | _('set branch name even if it shadows an existing branch')), | |
1161 | ('C', 'clean', None, _('reset branch name to parent branch name'))], |
|
1161 | ('C', 'clean', None, _('reset branch name to parent branch name'))], | |
1162 | _('[-fC] [NAME]')) |
|
1162 | _('[-fC] [NAME]')) | |
1163 | def branch(ui, repo, label=None, **opts): |
|
1163 | def branch(ui, repo, label=None, **opts): | |
1164 | """set or show the current branch name |
|
1164 | """set or show the current branch name | |
1165 |
|
1165 | |||
1166 | .. note:: |
|
1166 | .. note:: | |
1167 |
|
1167 | |||
1168 | Branch names are permanent and global. Use :hg:`bookmark` to create a |
|
1168 | Branch names are permanent and global. Use :hg:`bookmark` to create a | |
1169 | light-weight bookmark instead. See :hg:`help glossary` for more |
|
1169 | light-weight bookmark instead. See :hg:`help glossary` for more | |
1170 | information about named branches and bookmarks. |
|
1170 | information about named branches and bookmarks. | |
1171 |
|
1171 | |||
1172 | With no argument, show the current branch name. With one argument, |
|
1172 | With no argument, show the current branch name. With one argument, | |
1173 | set the working directory branch name (the branch will not exist |
|
1173 | set the working directory branch name (the branch will not exist | |
1174 | in the repository until the next commit). Standard practice |
|
1174 | in the repository until the next commit). Standard practice | |
1175 | recommends that primary development take place on the 'default' |
|
1175 | recommends that primary development take place on the 'default' | |
1176 | branch. |
|
1176 | branch. | |
1177 |
|
1177 | |||
1178 | Unless -f/--force is specified, branch will not let you set a |
|
1178 | Unless -f/--force is specified, branch will not let you set a | |
1179 | branch name that already exists. |
|
1179 | branch name that already exists. | |
1180 |
|
1180 | |||
1181 | Use -C/--clean to reset the working directory branch to that of |
|
1181 | Use -C/--clean to reset the working directory branch to that of | |
1182 | the parent of the working directory, negating a previous branch |
|
1182 | the parent of the working directory, negating a previous branch | |
1183 | change. |
|
1183 | change. | |
1184 |
|
1184 | |||
1185 | Use the command :hg:`update` to switch to an existing branch. Use |
|
1185 | Use the command :hg:`update` to switch to an existing branch. Use | |
1186 | :hg:`commit --close-branch` to mark this branch head as closed. |
|
1186 | :hg:`commit --close-branch` to mark this branch head as closed. | |
1187 | When all heads of a branch are closed, the branch will be |
|
1187 | When all heads of a branch are closed, the branch will be | |
1188 | considered closed. |
|
1188 | considered closed. | |
1189 |
|
1189 | |||
1190 | Returns 0 on success. |
|
1190 | Returns 0 on success. | |
1191 | """ |
|
1191 | """ | |
1192 | if label: |
|
1192 | if label: | |
1193 | label = label.strip() |
|
1193 | label = label.strip() | |
1194 |
|
1194 | |||
1195 | if not opts.get('clean') and not label: |
|
1195 | if not opts.get('clean') and not label: | |
1196 | ui.write("%s\n" % repo.dirstate.branch()) |
|
1196 | ui.write("%s\n" % repo.dirstate.branch()) | |
1197 | return |
|
1197 | return | |
1198 |
|
1198 | |||
1199 | with repo.wlock(): |
|
1199 | with repo.wlock(): | |
1200 | if opts.get('clean'): |
|
1200 | if opts.get('clean'): | |
1201 | label = repo[None].p1().branch() |
|
1201 | label = repo[None].p1().branch() | |
1202 | repo.dirstate.setbranch(label) |
|
1202 | repo.dirstate.setbranch(label) | |
1203 | ui.status(_('reset working directory to branch %s\n') % label) |
|
1203 | ui.status(_('reset working directory to branch %s\n') % label) | |
1204 | elif label: |
|
1204 | elif label: | |
1205 | if not opts.get('force') and label in repo.branchmap(): |
|
1205 | if not opts.get('force') and label in repo.branchmap(): | |
1206 | if label not in [p.branch() for p in repo[None].parents()]: |
|
1206 | if label not in [p.branch() for p in repo[None].parents()]: | |
1207 | raise error.Abort(_('a branch of the same name already' |
|
1207 | raise error.Abort(_('a branch of the same name already' | |
1208 | ' exists'), |
|
1208 | ' exists'), | |
1209 | # i18n: "it" refers to an existing branch |
|
1209 | # i18n: "it" refers to an existing branch | |
1210 | hint=_("use 'hg update' to switch to it")) |
|
1210 | hint=_("use 'hg update' to switch to it")) | |
1211 | scmutil.checknewlabel(repo, label, 'branch') |
|
1211 | scmutil.checknewlabel(repo, label, 'branch') | |
1212 | repo.dirstate.setbranch(label) |
|
1212 | repo.dirstate.setbranch(label) | |
1213 | ui.status(_('marked working directory as branch %s\n') % label) |
|
1213 | ui.status(_('marked working directory as branch %s\n') % label) | |
1214 |
|
1214 | |||
1215 | # find any open named branches aside from default |
|
1215 | # find any open named branches aside from default | |
1216 | others = [n for n, h, t, c in repo.branchmap().iterbranches() |
|
1216 | others = [n for n, h, t, c in repo.branchmap().iterbranches() | |
1217 | if n != "default" and not c] |
|
1217 | if n != "default" and not c] | |
1218 | if not others: |
|
1218 | if not others: | |
1219 | ui.status(_('(branches are permanent and global, ' |
|
1219 | ui.status(_('(branches are permanent and global, ' | |
1220 | 'did you want a bookmark?)\n')) |
|
1220 | 'did you want a bookmark?)\n')) | |
1221 |
|
1221 | |||
1222 | @command('branches', |
|
1222 | @command('branches', | |
1223 | [('a', 'active', False, |
|
1223 | [('a', 'active', False, | |
1224 | _('show only branches that have unmerged heads (DEPRECATED)')), |
|
1224 | _('show only branches that have unmerged heads (DEPRECATED)')), | |
1225 | ('c', 'closed', False, _('show normal and closed branches')), |
|
1225 | ('c', 'closed', False, _('show normal and closed branches')), | |
1226 | ] + formatteropts, |
|
1226 | ] + formatteropts, | |
1227 | _('[-c]')) |
|
1227 | _('[-c]')) | |
1228 | def branches(ui, repo, active=False, closed=False, **opts): |
|
1228 | def branches(ui, repo, active=False, closed=False, **opts): | |
1229 | """list repository named branches |
|
1229 | """list repository named branches | |
1230 |
|
1230 | |||
1231 | List the repository's named branches, indicating which ones are |
|
1231 | List the repository's named branches, indicating which ones are | |
1232 | inactive. If -c/--closed is specified, also list branches which have |
|
1232 | inactive. If -c/--closed is specified, also list branches which have | |
1233 | been marked closed (see :hg:`commit --close-branch`). |
|
1233 | been marked closed (see :hg:`commit --close-branch`). | |
1234 |
|
1234 | |||
1235 | Use the command :hg:`update` to switch to an existing branch. |
|
1235 | Use the command :hg:`update` to switch to an existing branch. | |
1236 |
|
1236 | |||
1237 | Returns 0. |
|
1237 | Returns 0. | |
1238 | """ |
|
1238 | """ | |
1239 |
|
1239 | |||
1240 | fm = ui.formatter('branches', opts) |
|
1240 | fm = ui.formatter('branches', opts) | |
1241 | hexfunc = fm.hexfunc |
|
1241 | hexfunc = fm.hexfunc | |
1242 |
|
1242 | |||
1243 | allheads = set(repo.heads()) |
|
1243 | allheads = set(repo.heads()) | |
1244 | branches = [] |
|
1244 | branches = [] | |
1245 | for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): |
|
1245 | for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): | |
1246 | isactive = not isclosed and bool(set(heads) & allheads) |
|
1246 | isactive = not isclosed and bool(set(heads) & allheads) | |
1247 | branches.append((tag, repo[tip], isactive, not isclosed)) |
|
1247 | branches.append((tag, repo[tip], isactive, not isclosed)) | |
1248 | branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), |
|
1248 | branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), | |
1249 | reverse=True) |
|
1249 | reverse=True) | |
1250 |
|
1250 | |||
1251 | for tag, ctx, isactive, isopen in branches: |
|
1251 | for tag, ctx, isactive, isopen in branches: | |
1252 | if active and not isactive: |
|
1252 | if active and not isactive: | |
1253 | continue |
|
1253 | continue | |
1254 | if isactive: |
|
1254 | if isactive: | |
1255 | label = 'branches.active' |
|
1255 | label = 'branches.active' | |
1256 | notice = '' |
|
1256 | notice = '' | |
1257 | elif not isopen: |
|
1257 | elif not isopen: | |
1258 | if not closed: |
|
1258 | if not closed: | |
1259 | continue |
|
1259 | continue | |
1260 | label = 'branches.closed' |
|
1260 | label = 'branches.closed' | |
1261 | notice = _(' (closed)') |
|
1261 | notice = _(' (closed)') | |
1262 | else: |
|
1262 | else: | |
1263 | label = 'branches.inactive' |
|
1263 | label = 'branches.inactive' | |
1264 | notice = _(' (inactive)') |
|
1264 | notice = _(' (inactive)') | |
1265 | current = (tag == repo.dirstate.branch()) |
|
1265 | current = (tag == repo.dirstate.branch()) | |
1266 | if current: |
|
1266 | if current: | |
1267 | label = 'branches.current' |
|
1267 | label = 'branches.current' | |
1268 |
|
1268 | |||
1269 | fm.startitem() |
|
1269 | fm.startitem() | |
1270 | fm.write('branch', '%s', tag, label=label) |
|
1270 | fm.write('branch', '%s', tag, label=label) | |
1271 | rev = ctx.rev() |
|
1271 | rev = ctx.rev() | |
1272 | padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0) |
|
1272 | padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0) | |
1273 | fmt = ' ' * padsize + ' %d:%s' |
|
1273 | fmt = ' ' * padsize + ' %d:%s' | |
1274 | fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()), |
|
1274 | fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()), | |
1275 | label='log.changeset changeset.%s' % ctx.phasestr()) |
|
1275 | label='log.changeset changeset.%s' % ctx.phasestr()) | |
1276 | fm.data(active=isactive, closed=not isopen, current=current) |
|
1276 | fm.data(active=isactive, closed=not isopen, current=current) | |
1277 | if not ui.quiet: |
|
1277 | if not ui.quiet: | |
1278 | fm.plain(notice) |
|
1278 | fm.plain(notice) | |
1279 | fm.plain('\n') |
|
1279 | fm.plain('\n') | |
1280 | fm.end() |
|
1280 | fm.end() | |
1281 |
|
1281 | |||
1282 | @command('bundle', |
|
1282 | @command('bundle', | |
1283 | [('f', 'force', None, _('run even when the destination is unrelated')), |
|
1283 | [('f', 'force', None, _('run even when the destination is unrelated')), | |
1284 | ('r', 'rev', [], _('a changeset intended to be added to the destination'), |
|
1284 | ('r', 'rev', [], _('a changeset intended to be added to the destination'), | |
1285 | _('REV')), |
|
1285 | _('REV')), | |
1286 | ('b', 'branch', [], _('a specific branch you would like to bundle'), |
|
1286 | ('b', 'branch', [], _('a specific branch you would like to bundle'), | |
1287 | _('BRANCH')), |
|
1287 | _('BRANCH')), | |
1288 | ('', 'base', [], |
|
1288 | ('', 'base', [], | |
1289 | _('a base changeset assumed to be available at the destination'), |
|
1289 | _('a base changeset assumed to be available at the destination'), | |
1290 | _('REV')), |
|
1290 | _('REV')), | |
1291 | ('a', 'all', None, _('bundle all changesets in the repository')), |
|
1291 | ('a', 'all', None, _('bundle all changesets in the repository')), | |
1292 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')), |
|
1292 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')), | |
1293 | ] + remoteopts, |
|
1293 | ] + remoteopts, | |
1294 | _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')) |
|
1294 | _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')) | |
1295 | def bundle(ui, repo, fname, dest=None, **opts): |
|
1295 | def bundle(ui, repo, fname, dest=None, **opts): | |
1296 | """create a changegroup file |
|
1296 | """create a changegroup file | |
1297 |
|
1297 | |||
1298 | Generate a changegroup file collecting changesets to be added |
|
1298 | Generate a changegroup file collecting changesets to be added | |
1299 | to a repository. |
|
1299 | to a repository. | |
1300 |
|
1300 | |||
1301 | To create a bundle containing all changesets, use -a/--all |
|
1301 | To create a bundle containing all changesets, use -a/--all | |
1302 | (or --base null). Otherwise, hg assumes the destination will have |
|
1302 | (or --base null). Otherwise, hg assumes the destination will have | |
1303 | all the nodes you specify with --base parameters. Otherwise, hg |
|
1303 | all the nodes you specify with --base parameters. Otherwise, hg | |
1304 | will assume the repository has all the nodes in destination, or |
|
1304 | will assume the repository has all the nodes in destination, or | |
1305 | default-push/default if no destination is specified. |
|
1305 | default-push/default if no destination is specified. | |
1306 |
|
1306 | |||
1307 | You can change bundle format with the -t/--type option. You can |
|
1307 | You can change bundle format with the -t/--type option. You can | |
1308 | specify a compression, a bundle version or both using a dash |
|
1308 | specify a compression, a bundle version or both using a dash | |
1309 | (comp-version). The available compression methods are: none, bzip2, |
|
1309 | (comp-version). The available compression methods are: none, bzip2, | |
1310 | and gzip (by default, bundles are compressed using bzip2). The |
|
1310 | and gzip (by default, bundles are compressed using bzip2). The | |
1311 | available formats are: v1, v2 (default to most suitable). |
|
1311 | available formats are: v1, v2 (default to most suitable). | |
1312 |
|
1312 | |||
1313 | The bundle file can then be transferred using conventional means |
|
1313 | The bundle file can then be transferred using conventional means | |
1314 | and applied to another repository with the unbundle or pull |
|
1314 | and applied to another repository with the unbundle or pull | |
1315 | command. This is useful when direct push and pull are not |
|
1315 | command. This is useful when direct push and pull are not | |
1316 | available or when exporting an entire repository is undesirable. |
|
1316 | available or when exporting an entire repository is undesirable. | |
1317 |
|
1317 | |||
1318 | Applying bundles preserves all changeset contents including |
|
1318 | Applying bundles preserves all changeset contents including | |
1319 | permissions, copy/rename information, and revision history. |
|
1319 | permissions, copy/rename information, and revision history. | |
1320 |
|
1320 | |||
1321 | Returns 0 on success, 1 if no changes found. |
|
1321 | Returns 0 on success, 1 if no changes found. | |
1322 | """ |
|
1322 | """ | |
1323 | revs = None |
|
1323 | revs = None | |
1324 | if 'rev' in opts: |
|
1324 | if 'rev' in opts: | |
1325 | revstrings = opts['rev'] |
|
1325 | revstrings = opts['rev'] | |
1326 | revs = scmutil.revrange(repo, revstrings) |
|
1326 | revs = scmutil.revrange(repo, revstrings) | |
1327 | if revstrings and not revs: |
|
1327 | if revstrings and not revs: | |
1328 | raise error.Abort(_('no commits to bundle')) |
|
1328 | raise error.Abort(_('no commits to bundle')) | |
1329 |
|
1329 | |||
1330 | bundletype = opts.get('type', 'bzip2').lower() |
|
1330 | bundletype = opts.get('type', 'bzip2').lower() | |
1331 | try: |
|
1331 | try: | |
1332 | bcompression, cgversion, params = exchange.parsebundlespec( |
|
1332 | bcompression, cgversion, params = exchange.parsebundlespec( | |
1333 | repo, bundletype, strict=False) |
|
1333 | repo, bundletype, strict=False) | |
1334 | except error.UnsupportedBundleSpecification as e: |
|
1334 | except error.UnsupportedBundleSpecification as e: | |
1335 | raise error.Abort(str(e), |
|
1335 | raise error.Abort(str(e), | |
1336 | hint=_("see 'hg help bundle' for supported " |
|
1336 | hint=_("see 'hg help bundle' for supported " | |
1337 | "values for --type")) |
|
1337 | "values for --type")) | |
1338 |
|
1338 | |||
1339 | # Packed bundles are a pseudo bundle format for now. |
|
1339 | # Packed bundles are a pseudo bundle format for now. | |
1340 | if cgversion == 's1': |
|
1340 | if cgversion == 's1': | |
1341 | raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'), |
|
1341 | raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'), | |
1342 | hint=_("use 'hg debugcreatestreamclonebundle'")) |
|
1342 | hint=_("use 'hg debugcreatestreamclonebundle'")) | |
1343 |
|
1343 | |||
1344 | if opts.get('all'): |
|
1344 | if opts.get('all'): | |
1345 | if dest: |
|
1345 | if dest: | |
1346 | raise error.Abort(_("--all is incompatible with specifying " |
|
1346 | raise error.Abort(_("--all is incompatible with specifying " | |
1347 | "a destination")) |
|
1347 | "a destination")) | |
1348 | if opts.get('base'): |
|
1348 | if opts.get('base'): | |
1349 | ui.warn(_("ignoring --base because --all was specified\n")) |
|
1349 | ui.warn(_("ignoring --base because --all was specified\n")) | |
1350 | base = ['null'] |
|
1350 | base = ['null'] | |
1351 | else: |
|
1351 | else: | |
1352 | base = scmutil.revrange(repo, opts.get('base')) |
|
1352 | base = scmutil.revrange(repo, opts.get('base')) | |
1353 | # TODO: get desired bundlecaps from command line. |
|
1353 | # TODO: get desired bundlecaps from command line. | |
1354 | bundlecaps = None |
|
1354 | bundlecaps = None | |
1355 | if cgversion not in changegroup.supportedoutgoingversions(repo): |
|
1355 | if cgversion not in changegroup.supportedoutgoingversions(repo): | |
1356 | raise error.Abort(_("repository does not support bundle version %s") % |
|
1356 | raise error.Abort(_("repository does not support bundle version %s") % | |
1357 | cgversion) |
|
1357 | cgversion) | |
1358 |
|
1358 | |||
1359 | if base: |
|
1359 | if base: | |
1360 | if dest: |
|
1360 | if dest: | |
1361 | raise error.Abort(_("--base is incompatible with specifying " |
|
1361 | raise error.Abort(_("--base is incompatible with specifying " | |
1362 | "a destination")) |
|
1362 | "a destination")) | |
1363 | common = [repo.lookup(rev) for rev in base] |
|
1363 | common = [repo.lookup(rev) for rev in base] | |
1364 | heads = revs and map(repo.lookup, revs) or None |
|
1364 | heads = revs and map(repo.lookup, revs) or None | |
1365 | outgoing = discovery.outgoing(repo, common, heads) |
|
1365 | outgoing = discovery.outgoing(repo, common, heads) | |
1366 | cg = changegroup.getchangegroup(repo, 'bundle', outgoing, |
|
1366 | cg = changegroup.getchangegroup(repo, 'bundle', outgoing, | |
1367 | bundlecaps=bundlecaps, |
|
1367 | bundlecaps=bundlecaps, | |
1368 | version=cgversion) |
|
1368 | version=cgversion) | |
1369 | outgoing = None |
|
1369 | outgoing = None | |
1370 | else: |
|
1370 | else: | |
1371 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
1371 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
1372 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
1372 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
1373 | other = hg.peer(repo, opts, dest) |
|
1373 | other = hg.peer(repo, opts, dest) | |
1374 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) |
|
1374 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) | |
1375 | heads = revs and map(repo.lookup, revs) or revs |
|
1375 | heads = revs and map(repo.lookup, revs) or revs | |
1376 | outgoing = discovery.findcommonoutgoing(repo, other, |
|
1376 | outgoing = discovery.findcommonoutgoing(repo, other, | |
1377 | onlyheads=heads, |
|
1377 | onlyheads=heads, | |
1378 | force=opts.get('force'), |
|
1378 | force=opts.get('force'), | |
1379 | portable=True) |
|
1379 | portable=True) | |
1380 | cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, |
|
1380 | cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, | |
1381 | bundlecaps, version=cgversion) |
|
1381 | bundlecaps, version=cgversion) | |
1382 | if not cg: |
|
1382 | if not cg: | |
1383 | scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) |
|
1383 | scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) | |
1384 | return 1 |
|
1384 | return 1 | |
1385 |
|
1385 | |||
1386 | if cgversion == '01': #bundle1 |
|
1386 | if cgversion == '01': #bundle1 | |
1387 | if bcompression is None: |
|
1387 | if bcompression is None: | |
1388 | bcompression = 'UN' |
|
1388 | bcompression = 'UN' | |
1389 | bversion = 'HG10' + bcompression |
|
1389 | bversion = 'HG10' + bcompression | |
1390 | bcompression = None |
|
1390 | bcompression = None | |
1391 | else: |
|
1391 | else: | |
1392 | assert cgversion == '02' |
|
1392 | assert cgversion == '02' | |
1393 | bversion = 'HG20' |
|
1393 | bversion = 'HG20' | |
1394 |
|
1394 | |||
1395 | bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression) |
|
1395 | bundle2.writebundle(ui, cg, fname, bversion, compression=bcompression) | |
1396 |
|
1396 | |||
1397 | @command('cat', |
|
1397 | @command('cat', | |
1398 | [('o', 'output', '', |
|
1398 | [('o', 'output', '', | |
1399 | _('print output to file with formatted name'), _('FORMAT')), |
|
1399 | _('print output to file with formatted name'), _('FORMAT')), | |
1400 | ('r', 'rev', '', _('print the given revision'), _('REV')), |
|
1400 | ('r', 'rev', '', _('print the given revision'), _('REV')), | |
1401 | ('', 'decode', None, _('apply any matching decode filter')), |
|
1401 | ('', 'decode', None, _('apply any matching decode filter')), | |
1402 | ] + walkopts, |
|
1402 | ] + walkopts, | |
1403 | _('[OPTION]... FILE...'), |
|
1403 | _('[OPTION]... FILE...'), | |
1404 | inferrepo=True) |
|
1404 | inferrepo=True) | |
1405 | def cat(ui, repo, file1, *pats, **opts): |
|
1405 | def cat(ui, repo, file1, *pats, **opts): | |
1406 | """output the current or given revision of files |
|
1406 | """output the current or given revision of files | |
1407 |
|
1407 | |||
1408 | Print the specified files as they were at the given revision. If |
|
1408 | Print the specified files as they were at the given revision. If | |
1409 | no revision is given, the parent of the working directory is used. |
|
1409 | no revision is given, the parent of the working directory is used. | |
1410 |
|
1410 | |||
1411 | Output may be to a file, in which case the name of the file is |
|
1411 | Output may be to a file, in which case the name of the file is | |
1412 | given using a format string. The formatting rules as follows: |
|
1412 | given using a format string. The formatting rules as follows: | |
1413 |
|
1413 | |||
1414 | :``%%``: literal "%" character |
|
1414 | :``%%``: literal "%" character | |
1415 | :``%s``: basename of file being printed |
|
1415 | :``%s``: basename of file being printed | |
1416 | :``%d``: dirname of file being printed, or '.' if in repository root |
|
1416 | :``%d``: dirname of file being printed, or '.' if in repository root | |
1417 | :``%p``: root-relative path name of file being printed |
|
1417 | :``%p``: root-relative path name of file being printed | |
1418 | :``%H``: changeset hash (40 hexadecimal digits) |
|
1418 | :``%H``: changeset hash (40 hexadecimal digits) | |
1419 | :``%R``: changeset revision number |
|
1419 | :``%R``: changeset revision number | |
1420 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
1420 | :``%h``: short-form changeset hash (12 hexadecimal digits) | |
1421 | :``%r``: zero-padded changeset revision number |
|
1421 | :``%r``: zero-padded changeset revision number | |
1422 | :``%b``: basename of the exporting repository |
|
1422 | :``%b``: basename of the exporting repository | |
1423 |
|
1423 | |||
1424 | Returns 0 on success. |
|
1424 | Returns 0 on success. | |
1425 | """ |
|
1425 | """ | |
1426 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
1426 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
1427 | m = scmutil.match(ctx, (file1,) + pats, opts) |
|
1427 | m = scmutil.match(ctx, (file1,) + pats, opts) | |
1428 |
|
1428 | |||
1429 | return cmdutil.cat(ui, repo, ctx, m, '', **opts) |
|
1429 | return cmdutil.cat(ui, repo, ctx, m, '', **opts) | |
1430 |
|
1430 | |||
1431 | @command('^clone', |
|
1431 | @command('^clone', | |
1432 | [('U', 'noupdate', None, _('the clone will include an empty working ' |
|
1432 | [('U', 'noupdate', None, _('the clone will include an empty working ' | |
1433 | 'directory (only a repository)')), |
|
1433 | 'directory (only a repository)')), | |
1434 | ('u', 'updaterev', '', _('revision, tag, or branch to check out'), |
|
1434 | ('u', 'updaterev', '', _('revision, tag, or branch to check out'), | |
1435 | _('REV')), |
|
1435 | _('REV')), | |
1436 | ('r', 'rev', [], _('include the specified changeset'), _('REV')), |
|
1436 | ('r', 'rev', [], _('include the specified changeset'), _('REV')), | |
1437 | ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), |
|
1437 | ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), | |
1438 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
1438 | ('', 'pull', None, _('use pull protocol to copy metadata')), | |
1439 | ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), |
|
1439 | ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), | |
1440 | ] + remoteopts, |
|
1440 | ] + remoteopts, | |
1441 | _('[OPTION]... SOURCE [DEST]'), |
|
1441 | _('[OPTION]... SOURCE [DEST]'), | |
1442 | norepo=True) |
|
1442 | norepo=True) | |
1443 | def clone(ui, source, dest=None, **opts): |
|
1443 | def clone(ui, source, dest=None, **opts): | |
1444 | """make a copy of an existing repository |
|
1444 | """make a copy of an existing repository | |
1445 |
|
1445 | |||
1446 | Create a copy of an existing repository in a new directory. |
|
1446 | Create a copy of an existing repository in a new directory. | |
1447 |
|
1447 | |||
1448 | If no destination directory name is specified, it defaults to the |
|
1448 | If no destination directory name is specified, it defaults to the | |
1449 | basename of the source. |
|
1449 | basename of the source. | |
1450 |
|
1450 | |||
1451 | The location of the source is added to the new repository's |
|
1451 | The location of the source is added to the new repository's | |
1452 | ``.hg/hgrc`` file, as the default to be used for future pulls. |
|
1452 | ``.hg/hgrc`` file, as the default to be used for future pulls. | |
1453 |
|
1453 | |||
1454 | Only local paths and ``ssh://`` URLs are supported as |
|
1454 | Only local paths and ``ssh://`` URLs are supported as | |
1455 | destinations. For ``ssh://`` destinations, no working directory or |
|
1455 | destinations. For ``ssh://`` destinations, no working directory or | |
1456 | ``.hg/hgrc`` will be created on the remote side. |
|
1456 | ``.hg/hgrc`` will be created on the remote side. | |
1457 |
|
1457 | |||
1458 | If the source repository has a bookmark called '@' set, that |
|
1458 | If the source repository has a bookmark called '@' set, that | |
1459 | revision will be checked out in the new repository by default. |
|
1459 | revision will be checked out in the new repository by default. | |
1460 |
|
1460 | |||
1461 | To check out a particular version, use -u/--update, or |
|
1461 | To check out a particular version, use -u/--update, or | |
1462 | -U/--noupdate to create a clone with no working directory. |
|
1462 | -U/--noupdate to create a clone with no working directory. | |
1463 |
|
1463 | |||
1464 | To pull only a subset of changesets, specify one or more revisions |
|
1464 | To pull only a subset of changesets, specify one or more revisions | |
1465 | identifiers with -r/--rev or branches with -b/--branch. The |
|
1465 | identifiers with -r/--rev or branches with -b/--branch. The | |
1466 | resulting clone will contain only the specified changesets and |
|
1466 | resulting clone will contain only the specified changesets and | |
1467 | their ancestors. These options (or 'clone src#rev dest') imply |
|
1467 | their ancestors. These options (or 'clone src#rev dest') imply | |
1468 | --pull, even for local source repositories. |
|
1468 | --pull, even for local source repositories. | |
1469 |
|
1469 | |||
1470 | .. note:: |
|
1470 | .. note:: | |
1471 |
|
1471 | |||
1472 | Specifying a tag will include the tagged changeset but not the |
|
1472 | Specifying a tag will include the tagged changeset but not the | |
1473 | changeset containing the tag. |
|
1473 | changeset containing the tag. | |
1474 |
|
1474 | |||
1475 | .. container:: verbose |
|
1475 | .. container:: verbose | |
1476 |
|
1476 | |||
1477 | For efficiency, hardlinks are used for cloning whenever the |
|
1477 | For efficiency, hardlinks are used for cloning whenever the | |
1478 | source and destination are on the same filesystem (note this |
|
1478 | source and destination are on the same filesystem (note this | |
1479 | applies only to the repository data, not to the working |
|
1479 | applies only to the repository data, not to the working | |
1480 | directory). Some filesystems, such as AFS, implement hardlinking |
|
1480 | directory). Some filesystems, such as AFS, implement hardlinking | |
1481 | incorrectly, but do not report errors. In these cases, use the |
|
1481 | incorrectly, but do not report errors. In these cases, use the | |
1482 | --pull option to avoid hardlinking. |
|
1482 | --pull option to avoid hardlinking. | |
1483 |
|
1483 | |||
1484 | In some cases, you can clone repositories and the working |
|
1484 | In some cases, you can clone repositories and the working | |
1485 | directory using full hardlinks with :: |
|
1485 | directory using full hardlinks with :: | |
1486 |
|
1486 | |||
1487 | $ cp -al REPO REPOCLONE |
|
1487 | $ cp -al REPO REPOCLONE | |
1488 |
|
1488 | |||
1489 | This is the fastest way to clone, but it is not always safe. The |
|
1489 | This is the fastest way to clone, but it is not always safe. The | |
1490 | operation is not atomic (making sure REPO is not modified during |
|
1490 | operation is not atomic (making sure REPO is not modified during | |
1491 | the operation is up to you) and you have to make sure your |
|
1491 | the operation is up to you) and you have to make sure your | |
1492 | editor breaks hardlinks (Emacs and most Linux Kernel tools do |
|
1492 | editor breaks hardlinks (Emacs and most Linux Kernel tools do | |
1493 | so). Also, this is not compatible with certain extensions that |
|
1493 | so). Also, this is not compatible with certain extensions that | |
1494 | place their metadata under the .hg directory, such as mq. |
|
1494 | place their metadata under the .hg directory, such as mq. | |
1495 |
|
1495 | |||
1496 | Mercurial will update the working directory to the first applicable |
|
1496 | Mercurial will update the working directory to the first applicable | |
1497 | revision from this list: |
|
1497 | revision from this list: | |
1498 |
|
1498 | |||
1499 | a) null if -U or the source repository has no changesets |
|
1499 | a) null if -U or the source repository has no changesets | |
1500 | b) if -u . and the source repository is local, the first parent of |
|
1500 | b) if -u . and the source repository is local, the first parent of | |
1501 | the source repository's working directory |
|
1501 | the source repository's working directory | |
1502 | c) the changeset specified with -u (if a branch name, this means the |
|
1502 | c) the changeset specified with -u (if a branch name, this means the | |
1503 | latest head of that branch) |
|
1503 | latest head of that branch) | |
1504 | d) the changeset specified with -r |
|
1504 | d) the changeset specified with -r | |
1505 | e) the tipmost head specified with -b |
|
1505 | e) the tipmost head specified with -b | |
1506 | f) the tipmost head specified with the url#branch source syntax |
|
1506 | f) the tipmost head specified with the url#branch source syntax | |
1507 | g) the revision marked with the '@' bookmark, if present |
|
1507 | g) the revision marked with the '@' bookmark, if present | |
1508 | h) the tipmost head of the default branch |
|
1508 | h) the tipmost head of the default branch | |
1509 | i) tip |
|
1509 | i) tip | |
1510 |
|
1510 | |||
1511 | When cloning from servers that support it, Mercurial may fetch |
|
1511 | When cloning from servers that support it, Mercurial may fetch | |
1512 | pre-generated data from a server-advertised URL. When this is done, |
|
1512 | pre-generated data from a server-advertised URL. When this is done, | |
1513 | hooks operating on incoming changesets and changegroups may fire twice, |
|
1513 | hooks operating on incoming changesets and changegroups may fire twice, | |
1514 | once for the bundle fetched from the URL and another for any additional |
|
1514 | once for the bundle fetched from the URL and another for any additional | |
1515 | data not fetched from this URL. In addition, if an error occurs, the |
|
1515 | data not fetched from this URL. In addition, if an error occurs, the | |
1516 | repository may be rolled back to a partial clone. This behavior may |
|
1516 | repository may be rolled back to a partial clone. This behavior may | |
1517 | change in future releases. See :hg:`help -e clonebundles` for more. |
|
1517 | change in future releases. See :hg:`help -e clonebundles` for more. | |
1518 |
|
1518 | |||
1519 | Examples: |
|
1519 | Examples: | |
1520 |
|
1520 | |||
1521 | - clone a remote repository to a new directory named hg/:: |
|
1521 | - clone a remote repository to a new directory named hg/:: | |
1522 |
|
1522 | |||
1523 | hg clone https://www.mercurial-scm.org/repo/hg/ |
|
1523 | hg clone https://www.mercurial-scm.org/repo/hg/ | |
1524 |
|
1524 | |||
1525 | - create a lightweight local clone:: |
|
1525 | - create a lightweight local clone:: | |
1526 |
|
1526 | |||
1527 | hg clone project/ project-feature/ |
|
1527 | hg clone project/ project-feature/ | |
1528 |
|
1528 | |||
1529 | - clone from an absolute path on an ssh server (note double-slash):: |
|
1529 | - clone from an absolute path on an ssh server (note double-slash):: | |
1530 |
|
1530 | |||
1531 | hg clone ssh://user@server//home/projects/alpha/ |
|
1531 | hg clone ssh://user@server//home/projects/alpha/ | |
1532 |
|
1532 | |||
1533 | - do a high-speed clone over a LAN while checking out a |
|
1533 | - do a high-speed clone over a LAN while checking out a | |
1534 | specified version:: |
|
1534 | specified version:: | |
1535 |
|
1535 | |||
1536 | hg clone --uncompressed http://server/repo -u 1.5 |
|
1536 | hg clone --uncompressed http://server/repo -u 1.5 | |
1537 |
|
1537 | |||
1538 | - create a repository without changesets after a particular revision:: |
|
1538 | - create a repository without changesets after a particular revision:: | |
1539 |
|
1539 | |||
1540 | hg clone -r 04e544 experimental/ good/ |
|
1540 | hg clone -r 04e544 experimental/ good/ | |
1541 |
|
1541 | |||
1542 | - clone (and track) a particular named branch:: |
|
1542 | - clone (and track) a particular named branch:: | |
1543 |
|
1543 | |||
1544 | hg clone https://www.mercurial-scm.org/repo/hg/#stable |
|
1544 | hg clone https://www.mercurial-scm.org/repo/hg/#stable | |
1545 |
|
1545 | |||
1546 | See :hg:`help urls` for details on specifying URLs. |
|
1546 | See :hg:`help urls` for details on specifying URLs. | |
1547 |
|
1547 | |||
1548 | Returns 0 on success. |
|
1548 | Returns 0 on success. | |
1549 | """ |
|
1549 | """ | |
1550 | if opts.get('noupdate') and opts.get('updaterev'): |
|
1550 | if opts.get('noupdate') and opts.get('updaterev'): | |
1551 | raise error.Abort(_("cannot specify both --noupdate and --updaterev")) |
|
1551 | raise error.Abort(_("cannot specify both --noupdate and --updaterev")) | |
1552 |
|
1552 | |||
1553 | r = hg.clone(ui, opts, source, dest, |
|
1553 | r = hg.clone(ui, opts, source, dest, | |
1554 | pull=opts.get('pull'), |
|
1554 | pull=opts.get('pull'), | |
1555 | stream=opts.get('uncompressed'), |
|
1555 | stream=opts.get('uncompressed'), | |
1556 | rev=opts.get('rev'), |
|
1556 | rev=opts.get('rev'), | |
1557 | update=opts.get('updaterev') or not opts.get('noupdate'), |
|
1557 | update=opts.get('updaterev') or not opts.get('noupdate'), | |
1558 | branch=opts.get('branch'), |
|
1558 | branch=opts.get('branch'), | |
1559 | shareopts=opts.get('shareopts')) |
|
1559 | shareopts=opts.get('shareopts')) | |
1560 |
|
1560 | |||
1561 | return r is None |
|
1561 | return r is None | |
1562 |
|
1562 | |||
1563 | @command('^commit|ci', |
|
1563 | @command('^commit|ci', | |
1564 | [('A', 'addremove', None, |
|
1564 | [('A', 'addremove', None, | |
1565 | _('mark new/missing files as added/removed before committing')), |
|
1565 | _('mark new/missing files as added/removed before committing')), | |
1566 | ('', 'close-branch', None, |
|
1566 | ('', 'close-branch', None, | |
1567 | _('mark a branch head as closed')), |
|
1567 | _('mark a branch head as closed')), | |
1568 | ('', 'amend', None, _('amend the parent of the working directory')), |
|
1568 | ('', 'amend', None, _('amend the parent of the working directory')), | |
1569 | ('s', 'secret', None, _('use the secret phase for committing')), |
|
1569 | ('s', 'secret', None, _('use the secret phase for committing')), | |
1570 | ('e', 'edit', None, _('invoke editor on commit messages')), |
|
1570 | ('e', 'edit', None, _('invoke editor on commit messages')), | |
1571 | ('i', 'interactive', None, _('use interactive mode')), |
|
1571 | ('i', 'interactive', None, _('use interactive mode')), | |
1572 | ] + walkopts + commitopts + commitopts2 + subrepoopts, |
|
1572 | ] + walkopts + commitopts + commitopts2 + subrepoopts, | |
1573 | _('[OPTION]... [FILE]...'), |
|
1573 | _('[OPTION]... [FILE]...'), | |
1574 | inferrepo=True) |
|
1574 | inferrepo=True) | |
1575 | def commit(ui, repo, *pats, **opts): |
|
1575 | def commit(ui, repo, *pats, **opts): | |
1576 | """commit the specified files or all outstanding changes |
|
1576 | """commit the specified files or all outstanding changes | |
1577 |
|
1577 | |||
1578 | Commit changes to the given files into the repository. Unlike a |
|
1578 | Commit changes to the given files into the repository. Unlike a | |
1579 | centralized SCM, this operation is a local operation. See |
|
1579 | centralized SCM, this operation is a local operation. See | |
1580 | :hg:`push` for a way to actively distribute your changes. |
|
1580 | :hg:`push` for a way to actively distribute your changes. | |
1581 |
|
1581 | |||
1582 | If a list of files is omitted, all changes reported by :hg:`status` |
|
1582 | If a list of files is omitted, all changes reported by :hg:`status` | |
1583 | will be committed. |
|
1583 | will be committed. | |
1584 |
|
1584 | |||
1585 | If you are committing the result of a merge, do not provide any |
|
1585 | If you are committing the result of a merge, do not provide any | |
1586 | filenames or -I/-X filters. |
|
1586 | filenames or -I/-X filters. | |
1587 |
|
1587 | |||
1588 | If no commit message is specified, Mercurial starts your |
|
1588 | If no commit message is specified, Mercurial starts your | |
1589 | configured editor where you can enter a message. In case your |
|
1589 | configured editor where you can enter a message. In case your | |
1590 | commit fails, you will find a backup of your message in |
|
1590 | commit fails, you will find a backup of your message in | |
1591 | ``.hg/last-message.txt``. |
|
1591 | ``.hg/last-message.txt``. | |
1592 |
|
1592 | |||
1593 | The --close-branch flag can be used to mark the current branch |
|
1593 | The --close-branch flag can be used to mark the current branch | |
1594 | head closed. When all heads of a branch are closed, the branch |
|
1594 | head closed. When all heads of a branch are closed, the branch | |
1595 | will be considered closed and no longer listed. |
|
1595 | will be considered closed and no longer listed. | |
1596 |
|
1596 | |||
1597 | The --amend flag can be used to amend the parent of the |
|
1597 | The --amend flag can be used to amend the parent of the | |
1598 | working directory with a new commit that contains the changes |
|
1598 | working directory with a new commit that contains the changes | |
1599 | in the parent in addition to those currently reported by :hg:`status`, |
|
1599 | in the parent in addition to those currently reported by :hg:`status`, | |
1600 | if there are any. The old commit is stored in a backup bundle in |
|
1600 | if there are any. The old commit is stored in a backup bundle in | |
1601 | ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle` |
|
1601 | ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle` | |
1602 | on how to restore it). |
|
1602 | on how to restore it). | |
1603 |
|
1603 | |||
1604 | Message, user and date are taken from the amended commit unless |
|
1604 | Message, user and date are taken from the amended commit unless | |
1605 | specified. When a message isn't specified on the command line, |
|
1605 | specified. When a message isn't specified on the command line, | |
1606 | the editor will open with the message of the amended commit. |
|
1606 | the editor will open with the message of the amended commit. | |
1607 |
|
1607 | |||
1608 | It is not possible to amend public changesets (see :hg:`help phases`) |
|
1608 | It is not possible to amend public changesets (see :hg:`help phases`) | |
1609 | or changesets that have children. |
|
1609 | or changesets that have children. | |
1610 |
|
1610 | |||
1611 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
1611 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
1612 |
|
1612 | |||
1613 | Returns 0 on success, 1 if nothing changed. |
|
1613 | Returns 0 on success, 1 if nothing changed. | |
1614 |
|
1614 | |||
1615 | .. container:: verbose |
|
1615 | .. container:: verbose | |
1616 |
|
1616 | |||
1617 | Examples: |
|
1617 | Examples: | |
1618 |
|
1618 | |||
1619 | - commit all files ending in .py:: |
|
1619 | - commit all files ending in .py:: | |
1620 |
|
1620 | |||
1621 | hg commit --include "set:**.py" |
|
1621 | hg commit --include "set:**.py" | |
1622 |
|
1622 | |||
1623 | - commit all non-binary files:: |
|
1623 | - commit all non-binary files:: | |
1624 |
|
1624 | |||
1625 | hg commit --exclude "set:binary()" |
|
1625 | hg commit --exclude "set:binary()" | |
1626 |
|
1626 | |||
1627 | - amend the current commit and set the date to now:: |
|
1627 | - amend the current commit and set the date to now:: | |
1628 |
|
1628 | |||
1629 | hg commit --amend --date now |
|
1629 | hg commit --amend --date now | |
1630 | """ |
|
1630 | """ | |
1631 | wlock = lock = None |
|
1631 | wlock = lock = None | |
1632 | try: |
|
1632 | try: | |
1633 | wlock = repo.wlock() |
|
1633 | wlock = repo.wlock() | |
1634 | lock = repo.lock() |
|
1634 | lock = repo.lock() | |
1635 | return _docommit(ui, repo, *pats, **opts) |
|
1635 | return _docommit(ui, repo, *pats, **opts) | |
1636 | finally: |
|
1636 | finally: | |
1637 | release(lock, wlock) |
|
1637 | release(lock, wlock) | |
1638 |
|
1638 | |||
1639 | def _docommit(ui, repo, *pats, **opts): |
|
1639 | def _docommit(ui, repo, *pats, **opts): | |
1640 | if opts.get('interactive'): |
|
1640 | if opts.get('interactive'): | |
1641 | opts.pop('interactive') |
|
1641 | opts.pop('interactive') | |
1642 | ret = cmdutil.dorecord(ui, repo, commit, None, False, |
|
1642 | ret = cmdutil.dorecord(ui, repo, commit, None, False, | |
1643 | cmdutil.recordfilter, *pats, **opts) |
|
1643 | cmdutil.recordfilter, *pats, **opts) | |
1644 | # ret can be 0 (no changes to record) or the value returned by |
|
1644 | # ret can be 0 (no changes to record) or the value returned by | |
1645 | # commit(), 1 if nothing changed or None on success. |
|
1645 | # commit(), 1 if nothing changed or None on success. | |
1646 | return 1 if ret == 0 else ret |
|
1646 | return 1 if ret == 0 else ret | |
1647 |
|
1647 | |||
1648 | if opts.get('subrepos'): |
|
1648 | if opts.get('subrepos'): | |
1649 | if opts.get('amend'): |
|
1649 | if opts.get('amend'): | |
1650 | raise error.Abort(_('cannot amend with --subrepos')) |
|
1650 | raise error.Abort(_('cannot amend with --subrepos')) | |
1651 | # Let --subrepos on the command line override config setting. |
|
1651 | # Let --subrepos on the command line override config setting. | |
1652 | ui.setconfig('ui', 'commitsubrepos', True, 'commit') |
|
1652 | ui.setconfig('ui', 'commitsubrepos', True, 'commit') | |
1653 |
|
1653 | |||
1654 | cmdutil.checkunfinished(repo, commit=True) |
|
1654 | cmdutil.checkunfinished(repo, commit=True) | |
1655 |
|
1655 | |||
1656 | branch = repo[None].branch() |
|
1656 | branch = repo[None].branch() | |
1657 | bheads = repo.branchheads(branch) |
|
1657 | bheads = repo.branchheads(branch) | |
1658 |
|
1658 | |||
1659 | extra = {} |
|
1659 | extra = {} | |
1660 | if opts.get('close_branch'): |
|
1660 | if opts.get('close_branch'): | |
1661 | extra['close'] = 1 |
|
1661 | extra['close'] = 1 | |
1662 |
|
1662 | |||
1663 | if not bheads: |
|
1663 | if not bheads: | |
1664 | raise error.Abort(_('can only close branch heads')) |
|
1664 | raise error.Abort(_('can only close branch heads')) | |
1665 | elif opts.get('amend'): |
|
1665 | elif opts.get('amend'): | |
1666 | if repo[None].parents()[0].p1().branch() != branch and \ |
|
1666 | if repo[None].parents()[0].p1().branch() != branch and \ | |
1667 | repo[None].parents()[0].p2().branch() != branch: |
|
1667 | repo[None].parents()[0].p2().branch() != branch: | |
1668 | raise error.Abort(_('can only close branch heads')) |
|
1668 | raise error.Abort(_('can only close branch heads')) | |
1669 |
|
1669 | |||
1670 | if opts.get('amend'): |
|
1670 | if opts.get('amend'): | |
1671 | if ui.configbool('ui', 'commitsubrepos'): |
|
1671 | if ui.configbool('ui', 'commitsubrepos'): | |
1672 | raise error.Abort(_('cannot amend with ui.commitsubrepos enabled')) |
|
1672 | raise error.Abort(_('cannot amend with ui.commitsubrepos enabled')) | |
1673 |
|
1673 | |||
1674 | old = repo['.'] |
|
1674 | old = repo['.'] | |
1675 | if not old.mutable(): |
|
1675 | if not old.mutable(): | |
1676 | raise error.Abort(_('cannot amend public changesets')) |
|
1676 | raise error.Abort(_('cannot amend public changesets')) | |
1677 | if len(repo[None].parents()) > 1: |
|
1677 | if len(repo[None].parents()) > 1: | |
1678 | raise error.Abort(_('cannot amend while merging')) |
|
1678 | raise error.Abort(_('cannot amend while merging')) | |
1679 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
|
1679 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) | |
1680 | if not allowunstable and old.children(): |
|
1680 | if not allowunstable and old.children(): | |
1681 | raise error.Abort(_('cannot amend changeset with children')) |
|
1681 | raise error.Abort(_('cannot amend changeset with children')) | |
1682 |
|
1682 | |||
1683 | # Currently histedit gets confused if an amend happens while histedit |
|
1683 | # Currently histedit gets confused if an amend happens while histedit | |
1684 | # is in progress. Since we have a checkunfinished command, we are |
|
1684 | # is in progress. Since we have a checkunfinished command, we are | |
1685 | # temporarily honoring it. |
|
1685 | # temporarily honoring it. | |
1686 | # |
|
1686 | # | |
1687 | # Note: eventually this guard will be removed. Please do not expect |
|
1687 | # Note: eventually this guard will be removed. Please do not expect | |
1688 | # this behavior to remain. |
|
1688 | # this behavior to remain. | |
1689 | if not obsolete.isenabled(repo, obsolete.createmarkersopt): |
|
1689 | if not obsolete.isenabled(repo, obsolete.createmarkersopt): | |
1690 | cmdutil.checkunfinished(repo) |
|
1690 | cmdutil.checkunfinished(repo) | |
1691 |
|
1691 | |||
1692 | # commitfunc is used only for temporary amend commit by cmdutil.amend |
|
1692 | # commitfunc is used only for temporary amend commit by cmdutil.amend | |
1693 | def commitfunc(ui, repo, message, match, opts): |
|
1693 | def commitfunc(ui, repo, message, match, opts): | |
1694 | return repo.commit(message, |
|
1694 | return repo.commit(message, | |
1695 | opts.get('user') or old.user(), |
|
1695 | opts.get('user') or old.user(), | |
1696 | opts.get('date') or old.date(), |
|
1696 | opts.get('date') or old.date(), | |
1697 | match, |
|
1697 | match, | |
1698 | extra=extra) |
|
1698 | extra=extra) | |
1699 |
|
1699 | |||
1700 | node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts) |
|
1700 | node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts) | |
1701 | if node == old.node(): |
|
1701 | if node == old.node(): | |
1702 | ui.status(_("nothing changed\n")) |
|
1702 | ui.status(_("nothing changed\n")) | |
1703 | return 1 |
|
1703 | return 1 | |
1704 | else: |
|
1704 | else: | |
1705 | def commitfunc(ui, repo, message, match, opts): |
|
1705 | def commitfunc(ui, repo, message, match, opts): | |
1706 | backup = ui.backupconfig('phases', 'new-commit') |
|
1706 | backup = ui.backupconfig('phases', 'new-commit') | |
1707 | baseui = repo.baseui |
|
1707 | baseui = repo.baseui | |
1708 | basebackup = baseui.backupconfig('phases', 'new-commit') |
|
1708 | basebackup = baseui.backupconfig('phases', 'new-commit') | |
1709 | try: |
|
1709 | try: | |
1710 | if opts.get('secret'): |
|
1710 | if opts.get('secret'): | |
1711 | ui.setconfig('phases', 'new-commit', 'secret', 'commit') |
|
1711 | ui.setconfig('phases', 'new-commit', 'secret', 'commit') | |
1712 | # Propagate to subrepos |
|
1712 | # Propagate to subrepos | |
1713 | baseui.setconfig('phases', 'new-commit', 'secret', 'commit') |
|
1713 | baseui.setconfig('phases', 'new-commit', 'secret', 'commit') | |
1714 |
|
1714 | |||
1715 | editform = cmdutil.mergeeditform(repo[None], 'commit.normal') |
|
1715 | editform = cmdutil.mergeeditform(repo[None], 'commit.normal') | |
1716 | editor = cmdutil.getcommiteditor(editform=editform, **opts) |
|
1716 | editor = cmdutil.getcommiteditor(editform=editform, **opts) | |
1717 | return repo.commit(message, opts.get('user'), opts.get('date'), |
|
1717 | return repo.commit(message, opts.get('user'), opts.get('date'), | |
1718 | match, |
|
1718 | match, | |
1719 | editor=editor, |
|
1719 | editor=editor, | |
1720 | extra=extra) |
|
1720 | extra=extra) | |
1721 | finally: |
|
1721 | finally: | |
1722 | ui.restoreconfig(backup) |
|
1722 | ui.restoreconfig(backup) | |
1723 | repo.baseui.restoreconfig(basebackup) |
|
1723 | repo.baseui.restoreconfig(basebackup) | |
1724 |
|
1724 | |||
1725 |
|
1725 | |||
1726 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
1726 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) | |
1727 |
|
1727 | |||
1728 | if not node: |
|
1728 | if not node: | |
1729 | stat = cmdutil.postcommitstatus(repo, pats, opts) |
|
1729 | stat = cmdutil.postcommitstatus(repo, pats, opts) | |
1730 | if stat[3]: |
|
1730 | if stat[3]: | |
1731 | ui.status(_("nothing changed (%d missing files, see " |
|
1731 | ui.status(_("nothing changed (%d missing files, see " | |
1732 | "'hg status')\n") % len(stat[3])) |
|
1732 | "'hg status')\n") % len(stat[3])) | |
1733 | else: |
|
1733 | else: | |
1734 | ui.status(_("nothing changed\n")) |
|
1734 | ui.status(_("nothing changed\n")) | |
1735 | return 1 |
|
1735 | return 1 | |
1736 |
|
1736 | |||
1737 | cmdutil.commitstatus(repo, node, branch, bheads, opts) |
|
1737 | cmdutil.commitstatus(repo, node, branch, bheads, opts) | |
1738 |
|
1738 | |||
1739 | @command('config|showconfig|debugconfig', |
|
1739 | @command('config|showconfig|debugconfig', | |
1740 | [('u', 'untrusted', None, _('show untrusted configuration options')), |
|
1740 | [('u', 'untrusted', None, _('show untrusted configuration options')), | |
1741 | ('e', 'edit', None, _('edit user config')), |
|
1741 | ('e', 'edit', None, _('edit user config')), | |
1742 | ('l', 'local', None, _('edit repository config')), |
|
1742 | ('l', 'local', None, _('edit repository config')), | |
1743 | ('g', 'global', None, _('edit global config'))] + formatteropts, |
|
1743 | ('g', 'global', None, _('edit global config'))] + formatteropts, | |
1744 | _('[-u] [NAME]...'), |
|
1744 | _('[-u] [NAME]...'), | |
1745 | optionalrepo=True) |
|
1745 | optionalrepo=True) | |
1746 | def config(ui, repo, *values, **opts): |
|
1746 | def config(ui, repo, *values, **opts): | |
1747 | """show combined config settings from all hgrc files |
|
1747 | """show combined config settings from all hgrc files | |
1748 |
|
1748 | |||
1749 | With no arguments, print names and values of all config items. |
|
1749 | With no arguments, print names and values of all config items. | |
1750 |
|
1750 | |||
1751 | With one argument of the form section.name, print just the value |
|
1751 | With one argument of the form section.name, print just the value | |
1752 | of that config item. |
|
1752 | of that config item. | |
1753 |
|
1753 | |||
1754 | With multiple arguments, print names and values of all config |
|
1754 | With multiple arguments, print names and values of all config | |
1755 | items with matching section names. |
|
1755 | items with matching section names. | |
1756 |
|
1756 | |||
1757 | With --edit, start an editor on the user-level config file. With |
|
1757 | With --edit, start an editor on the user-level config file. With | |
1758 | --global, edit the system-wide config file. With --local, edit the |
|
1758 | --global, edit the system-wide config file. With --local, edit the | |
1759 | repository-level config file. |
|
1759 | repository-level config file. | |
1760 |
|
1760 | |||
1761 | With --debug, the source (filename and line number) is printed |
|
1761 | With --debug, the source (filename and line number) is printed | |
1762 | for each config item. |
|
1762 | for each config item. | |
1763 |
|
1763 | |||
1764 | See :hg:`help config` for more information about config files. |
|
1764 | See :hg:`help config` for more information about config files. | |
1765 |
|
1765 | |||
1766 | Returns 0 on success, 1 if NAME does not exist. |
|
1766 | Returns 0 on success, 1 if NAME does not exist. | |
1767 |
|
1767 | |||
1768 | """ |
|
1768 | """ | |
1769 |
|
1769 | |||
1770 | if opts.get('edit') or opts.get('local') or opts.get('global'): |
|
1770 | if opts.get('edit') or opts.get('local') or opts.get('global'): | |
1771 | if opts.get('local') and opts.get('global'): |
|
1771 | if opts.get('local') and opts.get('global'): | |
1772 | raise error.Abort(_("can't use --local and --global together")) |
|
1772 | raise error.Abort(_("can't use --local and --global together")) | |
1773 |
|
1773 | |||
1774 | if opts.get('local'): |
|
1774 | if opts.get('local'): | |
1775 | if not repo: |
|
1775 | if not repo: | |
1776 | raise error.Abort(_("can't use --local outside a repository")) |
|
1776 | raise error.Abort(_("can't use --local outside a repository")) | |
1777 | paths = [repo.join('hgrc')] |
|
1777 | paths = [repo.join('hgrc')] | |
1778 | elif opts.get('global'): |
|
1778 | elif opts.get('global'): | |
1779 | paths = scmutil.systemrcpath() |
|
1779 | paths = scmutil.systemrcpath() | |
1780 | else: |
|
1780 | else: | |
1781 | paths = scmutil.userrcpath() |
|
1781 | paths = scmutil.userrcpath() | |
1782 |
|
1782 | |||
1783 | for f in paths: |
|
1783 | for f in paths: | |
1784 | if os.path.exists(f): |
|
1784 | if os.path.exists(f): | |
1785 | break |
|
1785 | break | |
1786 | else: |
|
1786 | else: | |
1787 | if opts.get('global'): |
|
1787 | if opts.get('global'): | |
1788 | samplehgrc = uimod.samplehgrcs['global'] |
|
1788 | samplehgrc = uimod.samplehgrcs['global'] | |
1789 | elif opts.get('local'): |
|
1789 | elif opts.get('local'): | |
1790 | samplehgrc = uimod.samplehgrcs['local'] |
|
1790 | samplehgrc = uimod.samplehgrcs['local'] | |
1791 | else: |
|
1791 | else: | |
1792 | samplehgrc = uimod.samplehgrcs['user'] |
|
1792 | samplehgrc = uimod.samplehgrcs['user'] | |
1793 |
|
1793 | |||
1794 | f = paths[0] |
|
1794 | f = paths[0] | |
1795 | fp = open(f, "w") |
|
1795 | fp = open(f, "w") | |
1796 | fp.write(samplehgrc) |
|
1796 | fp.write(samplehgrc) | |
1797 | fp.close() |
|
1797 | fp.close() | |
1798 |
|
1798 | |||
1799 | editor = ui.geteditor() |
|
1799 | editor = ui.geteditor() | |
1800 | ui.system("%s \"%s\"" % (editor, f), |
|
1800 | ui.system("%s \"%s\"" % (editor, f), | |
1801 | onerr=error.Abort, errprefix=_("edit failed")) |
|
1801 | onerr=error.Abort, errprefix=_("edit failed")) | |
1802 | return |
|
1802 | return | |
1803 |
|
1803 | |||
1804 | fm = ui.formatter('config', opts) |
|
1804 | fm = ui.formatter('config', opts) | |
1805 | for f in scmutil.rcpath(): |
|
1805 | for f in scmutil.rcpath(): | |
1806 | ui.debug('read config from: %s\n' % f) |
|
1806 | ui.debug('read config from: %s\n' % f) | |
1807 | untrusted = bool(opts.get('untrusted')) |
|
1807 | untrusted = bool(opts.get('untrusted')) | |
1808 | if values: |
|
1808 | if values: | |
1809 | sections = [v for v in values if '.' not in v] |
|
1809 | sections = [v for v in values if '.' not in v] | |
1810 | items = [v for v in values if '.' in v] |
|
1810 | items = [v for v in values if '.' in v] | |
1811 | if len(items) > 1 or items and sections: |
|
1811 | if len(items) > 1 or items and sections: | |
1812 | raise error.Abort(_('only one config item permitted')) |
|
1812 | raise error.Abort(_('only one config item permitted')) | |
1813 | matched = False |
|
1813 | matched = False | |
1814 | for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
1814 | for section, name, value in ui.walkconfig(untrusted=untrusted): | |
1815 | value = str(value) |
|
1815 | value = str(value) | |
1816 | if fm.isplain(): |
|
1816 | if fm.isplain(): | |
1817 | value = value.replace('\n', '\\n') |
|
1817 | value = value.replace('\n', '\\n') | |
1818 | entryname = section + '.' + name |
|
1818 | entryname = section + '.' + name | |
1819 | if values: |
|
1819 | if values: | |
1820 | for v in values: |
|
1820 | for v in values: | |
1821 | if v == section: |
|
1821 | if v == section: | |
1822 | fm.startitem() |
|
1822 | fm.startitem() | |
1823 | fm.condwrite(ui.debugflag, 'source', '%s: ', |
|
1823 | fm.condwrite(ui.debugflag, 'source', '%s: ', | |
1824 | ui.configsource(section, name, untrusted)) |
|
1824 | ui.configsource(section, name, untrusted)) | |
1825 | fm.write('name value', '%s=%s\n', entryname, value) |
|
1825 | fm.write('name value', '%s=%s\n', entryname, value) | |
1826 | matched = True |
|
1826 | matched = True | |
1827 | elif v == entryname: |
|
1827 | elif v == entryname: | |
1828 | fm.startitem() |
|
1828 | fm.startitem() | |
1829 | fm.condwrite(ui.debugflag, 'source', '%s: ', |
|
1829 | fm.condwrite(ui.debugflag, 'source', '%s: ', | |
1830 | ui.configsource(section, name, untrusted)) |
|
1830 | ui.configsource(section, name, untrusted)) | |
1831 | fm.write('value', '%s\n', value) |
|
1831 | fm.write('value', '%s\n', value) | |
1832 | fm.data(name=entryname) |
|
1832 | fm.data(name=entryname) | |
1833 | matched = True |
|
1833 | matched = True | |
1834 | else: |
|
1834 | else: | |
1835 | fm.startitem() |
|
1835 | fm.startitem() | |
1836 | fm.condwrite(ui.debugflag, 'source', '%s: ', |
|
1836 | fm.condwrite(ui.debugflag, 'source', '%s: ', | |
1837 | ui.configsource(section, name, untrusted)) |
|
1837 | ui.configsource(section, name, untrusted)) | |
1838 | fm.write('name value', '%s=%s\n', entryname, value) |
|
1838 | fm.write('name value', '%s=%s\n', entryname, value) | |
1839 | matched = True |
|
1839 | matched = True | |
1840 | fm.end() |
|
1840 | fm.end() | |
1841 | if matched: |
|
1841 | if matched: | |
1842 | return 0 |
|
1842 | return 0 | |
1843 | return 1 |
|
1843 | return 1 | |
1844 |
|
1844 | |||
1845 | @command('copy|cp', |
|
1845 | @command('copy|cp', | |
1846 | [('A', 'after', None, _('record a copy that has already occurred')), |
|
1846 | [('A', 'after', None, _('record a copy that has already occurred')), | |
1847 | ('f', 'force', None, _('forcibly copy over an existing managed file')), |
|
1847 | ('f', 'force', None, _('forcibly copy over an existing managed file')), | |
1848 | ] + walkopts + dryrunopts, |
|
1848 | ] + walkopts + dryrunopts, | |
1849 | _('[OPTION]... [SOURCE]... DEST')) |
|
1849 | _('[OPTION]... [SOURCE]... DEST')) | |
1850 | def copy(ui, repo, *pats, **opts): |
|
1850 | def copy(ui, repo, *pats, **opts): | |
1851 | """mark files as copied for the next commit |
|
1851 | """mark files as copied for the next commit | |
1852 |
|
1852 | |||
1853 | Mark dest as having copies of source files. If dest is a |
|
1853 | Mark dest as having copies of source files. If dest is a | |
1854 | directory, copies are put in that directory. If dest is a file, |
|
1854 | directory, copies are put in that directory. If dest is a file, | |
1855 | the source must be a single file. |
|
1855 | the source must be a single file. | |
1856 |
|
1856 | |||
1857 | By default, this command copies the contents of files as they |
|
1857 | By default, this command copies the contents of files as they | |
1858 | exist in the working directory. If invoked with -A/--after, the |
|
1858 | exist in the working directory. If invoked with -A/--after, the | |
1859 | operation is recorded, but no copying is performed. |
|
1859 | operation is recorded, but no copying is performed. | |
1860 |
|
1860 | |||
1861 | This command takes effect with the next commit. To undo a copy |
|
1861 | This command takes effect with the next commit. To undo a copy | |
1862 | before that, see :hg:`revert`. |
|
1862 | before that, see :hg:`revert`. | |
1863 |
|
1863 | |||
1864 | Returns 0 on success, 1 if errors are encountered. |
|
1864 | Returns 0 on success, 1 if errors are encountered. | |
1865 | """ |
|
1865 | """ | |
1866 | with repo.wlock(False): |
|
1866 | with repo.wlock(False): | |
1867 | return cmdutil.copy(ui, repo, pats, opts) |
|
1867 | return cmdutil.copy(ui, repo, pats, opts) | |
1868 |
|
1868 | |||
1869 | @command('debugbundle', |
|
1869 | @command('debugbundle', | |
1870 | [('a', 'all', None, _('show all details')), |
|
1870 | [('a', 'all', None, _('show all details')), | |
1871 | ('', 'spec', None, _('print the bundlespec of the bundle'))], |
|
1871 | ('', 'spec', None, _('print the bundlespec of the bundle'))], | |
1872 | _('FILE'), |
|
1872 | _('FILE'), | |
1873 | norepo=True) |
|
1873 | norepo=True) | |
1874 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
|
1874 | def debugbundle(ui, bundlepath, all=None, spec=None, **opts): | |
1875 | """lists the contents of a bundle""" |
|
1875 | """lists the contents of a bundle""" | |
1876 | with hg.openpath(ui, bundlepath) as f: |
|
1876 | with hg.openpath(ui, bundlepath) as f: | |
1877 | if spec: |
|
1877 | if spec: | |
1878 | spec = exchange.getbundlespec(ui, f) |
|
1878 | spec = exchange.getbundlespec(ui, f) | |
1879 | ui.write('%s\n' % spec) |
|
1879 | ui.write('%s\n' % spec) | |
1880 | return |
|
1880 | return | |
1881 |
|
1881 | |||
1882 | gen = exchange.readbundle(ui, f, bundlepath) |
|
1882 | gen = exchange.readbundle(ui, f, bundlepath) | |
1883 | if isinstance(gen, bundle2.unbundle20): |
|
1883 | if isinstance(gen, bundle2.unbundle20): | |
1884 | return _debugbundle2(ui, gen, all=all, **opts) |
|
1884 | return _debugbundle2(ui, gen, all=all, **opts) | |
1885 | _debugchangegroup(ui, gen, all=all, **opts) |
|
1885 | _debugchangegroup(ui, gen, all=all, **opts) | |
1886 |
|
1886 | |||
1887 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
|
1887 | def _debugchangegroup(ui, gen, all=None, indent=0, **opts): | |
1888 | indent_string = ' ' * indent |
|
1888 | indent_string = ' ' * indent | |
1889 | if all: |
|
1889 | if all: | |
1890 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
|
1890 | ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") | |
1891 | % indent_string) |
|
1891 | % indent_string) | |
1892 |
|
1892 | |||
1893 | def showchunks(named): |
|
1893 | def showchunks(named): | |
1894 | ui.write("\n%s%s\n" % (indent_string, named)) |
|
1894 | ui.write("\n%s%s\n" % (indent_string, named)) | |
1895 | chain = None |
|
1895 | chain = None | |
1896 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
|
1896 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): | |
1897 | node = chunkdata['node'] |
|
1897 | node = chunkdata['node'] | |
1898 | p1 = chunkdata['p1'] |
|
1898 | p1 = chunkdata['p1'] | |
1899 | p2 = chunkdata['p2'] |
|
1899 | p2 = chunkdata['p2'] | |
1900 | cs = chunkdata['cs'] |
|
1900 | cs = chunkdata['cs'] | |
1901 | deltabase = chunkdata['deltabase'] |
|
1901 | deltabase = chunkdata['deltabase'] | |
1902 | delta = chunkdata['delta'] |
|
1902 | delta = chunkdata['delta'] | |
1903 | ui.write("%s%s %s %s %s %s %s\n" % |
|
1903 | ui.write("%s%s %s %s %s %s %s\n" % | |
1904 | (indent_string, hex(node), hex(p1), hex(p2), |
|
1904 | (indent_string, hex(node), hex(p1), hex(p2), | |
1905 | hex(cs), hex(deltabase), len(delta))) |
|
1905 | hex(cs), hex(deltabase), len(delta))) | |
1906 | chain = node |
|
1906 | chain = node | |
1907 |
|
1907 | |||
1908 | chunkdata = gen.changelogheader() |
|
1908 | chunkdata = gen.changelogheader() | |
1909 | showchunks("changelog") |
|
1909 | showchunks("changelog") | |
1910 | chunkdata = gen.manifestheader() |
|
1910 | chunkdata = gen.manifestheader() | |
1911 | showchunks("manifest") |
|
1911 | showchunks("manifest") | |
1912 | for chunkdata in iter(gen.filelogheader, {}): |
|
1912 | for chunkdata in iter(gen.filelogheader, {}): | |
1913 | fname = chunkdata['filename'] |
|
1913 | fname = chunkdata['filename'] | |
1914 | showchunks(fname) |
|
1914 | showchunks(fname) | |
1915 | else: |
|
1915 | else: | |
1916 | if isinstance(gen, bundle2.unbundle20): |
|
1916 | if isinstance(gen, bundle2.unbundle20): | |
1917 | raise error.Abort(_('use debugbundle2 for this file')) |
|
1917 | raise error.Abort(_('use debugbundle2 for this file')) | |
1918 | chunkdata = gen.changelogheader() |
|
1918 | chunkdata = gen.changelogheader() | |
1919 | chain = None |
|
1919 | chain = None | |
1920 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
|
1920 | for chunkdata in iter(lambda: gen.deltachunk(chain), {}): | |
1921 | node = chunkdata['node'] |
|
1921 | node = chunkdata['node'] | |
1922 | ui.write("%s%s\n" % (indent_string, hex(node))) |
|
1922 | ui.write("%s%s\n" % (indent_string, hex(node))) | |
1923 | chain = node |
|
1923 | chain = node | |
1924 |
|
1924 | |||
1925 | def _debugbundle2(ui, gen, all=None, **opts): |
|
1925 | def _debugbundle2(ui, gen, all=None, **opts): | |
1926 | """lists the contents of a bundle2""" |
|
1926 | """lists the contents of a bundle2""" | |
1927 | if not isinstance(gen, bundle2.unbundle20): |
|
1927 | if not isinstance(gen, bundle2.unbundle20): | |
1928 | raise error.Abort(_('not a bundle2 file')) |
|
1928 | raise error.Abort(_('not a bundle2 file')) | |
1929 | ui.write(('Stream params: %s\n' % repr(gen.params))) |
|
1929 | ui.write(('Stream params: %s\n' % repr(gen.params))) | |
1930 | for part in gen.iterparts(): |
|
1930 | for part in gen.iterparts(): | |
1931 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
|
1931 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) | |
1932 | if part.type == 'changegroup': |
|
1932 | if part.type == 'changegroup': | |
1933 | version = part.params.get('version', '01') |
|
1933 | version = part.params.get('version', '01') | |
1934 | cg = changegroup.getunbundler(version, part, 'UN') |
|
1934 | cg = changegroup.getunbundler(version, part, 'UN') | |
1935 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
|
1935 | _debugchangegroup(ui, cg, all=all, indent=4, **opts) | |
1936 |
|
1936 | |||
1937 | @command('debugcreatestreamclonebundle', [], 'FILE') |
|
1937 | @command('debugcreatestreamclonebundle', [], 'FILE') | |
1938 | def debugcreatestreamclonebundle(ui, repo, fname): |
|
1938 | def debugcreatestreamclonebundle(ui, repo, fname): | |
1939 | """create a stream clone bundle file |
|
1939 | """create a stream clone bundle file | |
1940 |
|
1940 | |||
1941 | Stream bundles are special bundles that are essentially archives of |
|
1941 | Stream bundles are special bundles that are essentially archives of | |
1942 | revlog files. They are commonly used for cloning very quickly. |
|
1942 | revlog files. They are commonly used for cloning very quickly. | |
1943 | """ |
|
1943 | """ | |
1944 | requirements, gen = streamclone.generatebundlev1(repo) |
|
1944 | requirements, gen = streamclone.generatebundlev1(repo) | |
1945 | changegroup.writechunks(ui, gen, fname) |
|
1945 | changegroup.writechunks(ui, gen, fname) | |
1946 |
|
1946 | |||
1947 | ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
|
1947 | ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) | |
1948 |
|
1948 | |||
1949 | @command('debugapplystreamclonebundle', [], 'FILE') |
|
1949 | @command('debugapplystreamclonebundle', [], 'FILE') | |
1950 | def debugapplystreamclonebundle(ui, repo, fname): |
|
1950 | def debugapplystreamclonebundle(ui, repo, fname): | |
1951 | """apply a stream clone bundle file""" |
|
1951 | """apply a stream clone bundle file""" | |
1952 | f = hg.openpath(ui, fname) |
|
1952 | f = hg.openpath(ui, fname) | |
1953 | gen = exchange.readbundle(ui, f, fname) |
|
1953 | gen = exchange.readbundle(ui, f, fname) | |
1954 | gen.apply(repo) |
|
1954 | gen.apply(repo) | |
1955 |
|
1955 | |||
1956 | @command('debugcheckstate', [], '') |
|
1956 | @command('debugcheckstate', [], '') | |
1957 | def debugcheckstate(ui, repo): |
|
1957 | def debugcheckstate(ui, repo): | |
1958 | """validate the correctness of the current dirstate""" |
|
1958 | """validate the correctness of the current dirstate""" | |
1959 | parent1, parent2 = repo.dirstate.parents() |
|
1959 | parent1, parent2 = repo.dirstate.parents() | |
1960 | m1 = repo[parent1].manifest() |
|
1960 | m1 = repo[parent1].manifest() | |
1961 | m2 = repo[parent2].manifest() |
|
1961 | m2 = repo[parent2].manifest() | |
1962 | errors = 0 |
|
1962 | errors = 0 | |
1963 | for f in repo.dirstate: |
|
1963 | for f in repo.dirstate: | |
1964 | state = repo.dirstate[f] |
|
1964 | state = repo.dirstate[f] | |
1965 | if state in "nr" and f not in m1: |
|
1965 | if state in "nr" and f not in m1: | |
1966 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
1966 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | |
1967 | errors += 1 |
|
1967 | errors += 1 | |
1968 | if state in "a" and f in m1: |
|
1968 | if state in "a" and f in m1: | |
1969 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
|
1969 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) | |
1970 | errors += 1 |
|
1970 | errors += 1 | |
1971 | if state in "m" and f not in m1 and f not in m2: |
|
1971 | if state in "m" and f not in m1 and f not in m2: | |
1972 | ui.warn(_("%s in state %s, but not in either manifest\n") % |
|
1972 | ui.warn(_("%s in state %s, but not in either manifest\n") % | |
1973 | (f, state)) |
|
1973 | (f, state)) | |
1974 | errors += 1 |
|
1974 | errors += 1 | |
1975 | for f in m1: |
|
1975 | for f in m1: | |
1976 | state = repo.dirstate[f] |
|
1976 | state = repo.dirstate[f] | |
1977 | if state not in "nrm": |
|
1977 | if state not in "nrm": | |
1978 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
1978 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | |
1979 | errors += 1 |
|
1979 | errors += 1 | |
1980 | if errors: |
|
1980 | if errors: | |
1981 | error = _(".hg/dirstate inconsistent with current parent's manifest") |
|
1981 | error = _(".hg/dirstate inconsistent with current parent's manifest") | |
1982 | raise error.Abort(error) |
|
1982 | raise error.Abort(error) | |
1983 |
|
1983 | |||
1984 | @command('debugcommands', [], _('[COMMAND]'), norepo=True) |
|
1984 | @command('debugcommands', [], _('[COMMAND]'), norepo=True) | |
1985 | def debugcommands(ui, cmd='', *args): |
|
1985 | def debugcommands(ui, cmd='', *args): | |
1986 | """list all available commands and options""" |
|
1986 | """list all available commands and options""" | |
1987 | for cmd, vals in sorted(table.iteritems()): |
|
1987 | for cmd, vals in sorted(table.iteritems()): | |
1988 | cmd = cmd.split('|')[0].strip('^') |
|
1988 | cmd = cmd.split('|')[0].strip('^') | |
1989 | opts = ', '.join([i[1] for i in vals[1]]) |
|
1989 | opts = ', '.join([i[1] for i in vals[1]]) | |
1990 | ui.write('%s: %s\n' % (cmd, opts)) |
|
1990 | ui.write('%s: %s\n' % (cmd, opts)) | |
1991 |
|
1991 | |||
1992 | @command('debugcomplete', |
|
1992 | @command('debugcomplete', | |
1993 | [('o', 'options', None, _('show the command options'))], |
|
1993 | [('o', 'options', None, _('show the command options'))], | |
1994 | _('[-o] CMD'), |
|
1994 | _('[-o] CMD'), | |
1995 | norepo=True) |
|
1995 | norepo=True) | |
1996 | def debugcomplete(ui, cmd='', **opts): |
|
1996 | def debugcomplete(ui, cmd='', **opts): | |
1997 | """returns the completion list associated with the given command""" |
|
1997 | """returns the completion list associated with the given command""" | |
1998 |
|
1998 | |||
1999 | if opts.get('options'): |
|
1999 | if opts.get('options'): | |
2000 | options = [] |
|
2000 | options = [] | |
2001 | otables = [globalopts] |
|
2001 | otables = [globalopts] | |
2002 | if cmd: |
|
2002 | if cmd: | |
2003 | aliases, entry = cmdutil.findcmd(cmd, table, False) |
|
2003 | aliases, entry = cmdutil.findcmd(cmd, table, False) | |
2004 | otables.append(entry[1]) |
|
2004 | otables.append(entry[1]) | |
2005 | for t in otables: |
|
2005 | for t in otables: | |
2006 | for o in t: |
|
2006 | for o in t: | |
2007 | if "(DEPRECATED)" in o[3]: |
|
2007 | if "(DEPRECATED)" in o[3]: | |
2008 | continue |
|
2008 | continue | |
2009 | if o[0]: |
|
2009 | if o[0]: | |
2010 | options.append('-%s' % o[0]) |
|
2010 | options.append('-%s' % o[0]) | |
2011 | options.append('--%s' % o[1]) |
|
2011 | options.append('--%s' % o[1]) | |
2012 | ui.write("%s\n" % "\n".join(options)) |
|
2012 | ui.write("%s\n" % "\n".join(options)) | |
2013 | return |
|
2013 | return | |
2014 |
|
2014 | |||
2015 | cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table) |
|
2015 | cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table) | |
2016 | if ui.verbose: |
|
2016 | if ui.verbose: | |
2017 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
|
2017 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | |
2018 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
|
2018 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) | |
2019 |
|
2019 | |||
2020 | @command('debugdag', |
|
2020 | @command('debugdag', | |
2021 | [('t', 'tags', None, _('use tags as labels')), |
|
2021 | [('t', 'tags', None, _('use tags as labels')), | |
2022 | ('b', 'branches', None, _('annotate with branch names')), |
|
2022 | ('b', 'branches', None, _('annotate with branch names')), | |
2023 | ('', 'dots', None, _('use dots for runs')), |
|
2023 | ('', 'dots', None, _('use dots for runs')), | |
2024 | ('s', 'spaces', None, _('separate elements by spaces'))], |
|
2024 | ('s', 'spaces', None, _('separate elements by spaces'))], | |
2025 | _('[OPTION]... [FILE [REV]...]'), |
|
2025 | _('[OPTION]... [FILE [REV]...]'), | |
2026 | optionalrepo=True) |
|
2026 | optionalrepo=True) | |
2027 | def debugdag(ui, repo, file_=None, *revs, **opts): |
|
2027 | def debugdag(ui, repo, file_=None, *revs, **opts): | |
2028 | """format the changelog or an index DAG as a concise textual description |
|
2028 | """format the changelog or an index DAG as a concise textual description | |
2029 |
|
2029 | |||
2030 | If you pass a revlog index, the revlog's DAG is emitted. If you list |
|
2030 | If you pass a revlog index, the revlog's DAG is emitted. If you list | |
2031 | revision numbers, they get labeled in the output as rN. |
|
2031 | revision numbers, they get labeled in the output as rN. | |
2032 |
|
2032 | |||
2033 | Otherwise, the changelog DAG of the current repo is emitted. |
|
2033 | Otherwise, the changelog DAG of the current repo is emitted. | |
2034 | """ |
|
2034 | """ | |
2035 | spaces = opts.get('spaces') |
|
2035 | spaces = opts.get('spaces') | |
2036 | dots = opts.get('dots') |
|
2036 | dots = opts.get('dots') | |
2037 | if file_: |
|
2037 | if file_: | |
2038 | rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) |
|
2038 | rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) | |
2039 | revs = set((int(r) for r in revs)) |
|
2039 | revs = set((int(r) for r in revs)) | |
2040 | def events(): |
|
2040 | def events(): | |
2041 | for r in rlog: |
|
2041 | for r in rlog: | |
2042 | yield 'n', (r, list(p for p in rlog.parentrevs(r) |
|
2042 | yield 'n', (r, list(p for p in rlog.parentrevs(r) | |
2043 | if p != -1)) |
|
2043 | if p != -1)) | |
2044 | if r in revs: |
|
2044 | if r in revs: | |
2045 | yield 'l', (r, "r%i" % r) |
|
2045 | yield 'l', (r, "r%i" % r) | |
2046 | elif repo: |
|
2046 | elif repo: | |
2047 | cl = repo.changelog |
|
2047 | cl = repo.changelog | |
2048 | tags = opts.get('tags') |
|
2048 | tags = opts.get('tags') | |
2049 | branches = opts.get('branches') |
|
2049 | branches = opts.get('branches') | |
2050 | if tags: |
|
2050 | if tags: | |
2051 | labels = {} |
|
2051 | labels = {} | |
2052 | for l, n in repo.tags().items(): |
|
2052 | for l, n in repo.tags().items(): | |
2053 | labels.setdefault(cl.rev(n), []).append(l) |
|
2053 | labels.setdefault(cl.rev(n), []).append(l) | |
2054 | def events(): |
|
2054 | def events(): | |
2055 | b = "default" |
|
2055 | b = "default" | |
2056 | for r in cl: |
|
2056 | for r in cl: | |
2057 | if branches: |
|
2057 | if branches: | |
2058 | newb = cl.read(cl.node(r))[5]['branch'] |
|
2058 | newb = cl.read(cl.node(r))[5]['branch'] | |
2059 | if newb != b: |
|
2059 | if newb != b: | |
2060 | yield 'a', newb |
|
2060 | yield 'a', newb | |
2061 | b = newb |
|
2061 | b = newb | |
2062 | yield 'n', (r, list(p for p in cl.parentrevs(r) |
|
2062 | yield 'n', (r, list(p for p in cl.parentrevs(r) | |
2063 | if p != -1)) |
|
2063 | if p != -1)) | |
2064 | if tags: |
|
2064 | if tags: | |
2065 | ls = labels.get(r) |
|
2065 | ls = labels.get(r) | |
2066 | if ls: |
|
2066 | if ls: | |
2067 | for l in ls: |
|
2067 | for l in ls: | |
2068 | yield 'l', (r, l) |
|
2068 | yield 'l', (r, l) | |
2069 | else: |
|
2069 | else: | |
2070 | raise error.Abort(_('need repo for changelog dag')) |
|
2070 | raise error.Abort(_('need repo for changelog dag')) | |
2071 |
|
2071 | |||
2072 | for line in dagparser.dagtextlines(events(), |
|
2072 | for line in dagparser.dagtextlines(events(), | |
2073 | addspaces=spaces, |
|
2073 | addspaces=spaces, | |
2074 | wraplabels=True, |
|
2074 | wraplabels=True, | |
2075 | wrapannotations=True, |
|
2075 | wrapannotations=True, | |
2076 | wrapnonlinear=dots, |
|
2076 | wrapnonlinear=dots, | |
2077 | usedots=dots, |
|
2077 | usedots=dots, | |
2078 | maxlinewidth=70): |
|
2078 | maxlinewidth=70): | |
2079 | ui.write(line) |
|
2079 | ui.write(line) | |
2080 | ui.write("\n") |
|
2080 | ui.write("\n") | |
2081 |
|
2081 | |||
2082 | @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV')) |
|
2082 | @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV')) | |
2083 | def debugdata(ui, repo, file_, rev=None, **opts): |
|
2083 | def debugdata(ui, repo, file_, rev=None, **opts): | |
2084 | """dump the contents of a data file revision""" |
|
2084 | """dump the contents of a data file revision""" | |
2085 | if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
|
2085 | if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): | |
2086 | if rev is not None: |
|
2086 | if rev is not None: | |
2087 | raise error.CommandError('debugdata', _('invalid arguments')) |
|
2087 | raise error.CommandError('debugdata', _('invalid arguments')) | |
2088 | file_, rev = None, file_ |
|
2088 | file_, rev = None, file_ | |
2089 | elif rev is None: |
|
2089 | elif rev is None: | |
2090 | raise error.CommandError('debugdata', _('invalid arguments')) |
|
2090 | raise error.CommandError('debugdata', _('invalid arguments')) | |
2091 | r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) |
|
2091 | r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) | |
2092 | try: |
|
2092 | try: | |
2093 | ui.write(r.revision(r.lookup(rev))) |
|
2093 | ui.write(r.revision(r.lookup(rev))) | |
2094 | except KeyError: |
|
2094 | except KeyError: | |
2095 | raise error.Abort(_('invalid revision identifier %s') % rev) |
|
2095 | raise error.Abort(_('invalid revision identifier %s') % rev) | |
2096 |
|
2096 | |||
2097 | @command('debugdate', |
|
2097 | @command('debugdate', | |
2098 | [('e', 'extended', None, _('try extended date formats'))], |
|
2098 | [('e', 'extended', None, _('try extended date formats'))], | |
2099 | _('[-e] DATE [RANGE]'), |
|
2099 | _('[-e] DATE [RANGE]'), | |
2100 | norepo=True, optionalrepo=True) |
|
2100 | norepo=True, optionalrepo=True) | |
2101 | def debugdate(ui, date, range=None, **opts): |
|
2101 | def debugdate(ui, date, range=None, **opts): | |
2102 | """parse and display a date""" |
|
2102 | """parse and display a date""" | |
2103 | if opts["extended"]: |
|
2103 | if opts["extended"]: | |
2104 | d = util.parsedate(date, util.extendeddateformats) |
|
2104 | d = util.parsedate(date, util.extendeddateformats) | |
2105 | else: |
|
2105 | else: | |
2106 | d = util.parsedate(date) |
|
2106 | d = util.parsedate(date) | |
2107 | ui.write(("internal: %s %s\n") % d) |
|
2107 | ui.write(("internal: %s %s\n") % d) | |
2108 | ui.write(("standard: %s\n") % util.datestr(d)) |
|
2108 | ui.write(("standard: %s\n") % util.datestr(d)) | |
2109 | if range: |
|
2109 | if range: | |
2110 | m = util.matchdate(range) |
|
2110 | m = util.matchdate(range) | |
2111 | ui.write(("match: %s\n") % m(d[0])) |
|
2111 | ui.write(("match: %s\n") % m(d[0])) | |
2112 |
|
2112 | |||
2113 | @command('debugdiscovery', |
|
2113 | @command('debugdiscovery', | |
2114 | [('', 'old', None, _('use old-style discovery')), |
|
2114 | [('', 'old', None, _('use old-style discovery')), | |
2115 | ('', 'nonheads', None, |
|
2115 | ('', 'nonheads', None, | |
2116 | _('use old-style discovery with non-heads included')), |
|
2116 | _('use old-style discovery with non-heads included')), | |
2117 | ] + remoteopts, |
|
2117 | ] + remoteopts, | |
2118 | _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
|
2118 | _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) | |
2119 | def debugdiscovery(ui, repo, remoteurl="default", **opts): |
|
2119 | def debugdiscovery(ui, repo, remoteurl="default", **opts): | |
2120 | """runs the changeset discovery protocol in isolation""" |
|
2120 | """runs the changeset discovery protocol in isolation""" | |
2121 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), |
|
2121 | remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), | |
2122 | opts.get('branch')) |
|
2122 | opts.get('branch')) | |
2123 | remote = hg.peer(repo, opts, remoteurl) |
|
2123 | remote = hg.peer(repo, opts, remoteurl) | |
2124 | ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
|
2124 | ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | |
2125 |
|
2125 | |||
2126 | # make sure tests are repeatable |
|
2126 | # make sure tests are repeatable | |
2127 | random.seed(12323) |
|
2127 | random.seed(12323) | |
2128 |
|
2128 | |||
2129 | def doit(localheads, remoteheads, remote=remote): |
|
2129 | def doit(localheads, remoteheads, remote=remote): | |
2130 | if opts.get('old'): |
|
2130 | if opts.get('old'): | |
2131 | if localheads: |
|
2131 | if localheads: | |
2132 | raise error.Abort('cannot use localheads with old style ' |
|
2132 | raise error.Abort('cannot use localheads with old style ' | |
2133 | 'discovery') |
|
2133 | 'discovery') | |
2134 | if not util.safehasattr(remote, 'branches'): |
|
2134 | if not util.safehasattr(remote, 'branches'): | |
2135 | # enable in-client legacy support |
|
2135 | # enable in-client legacy support | |
2136 | remote = localrepo.locallegacypeer(remote.local()) |
|
2136 | remote = localrepo.locallegacypeer(remote.local()) | |
2137 | common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
|
2137 | common, _in, hds = treediscovery.findcommonincoming(repo, remote, | |
2138 | force=True) |
|
2138 | force=True) | |
2139 | common = set(common) |
|
2139 | common = set(common) | |
2140 | if not opts.get('nonheads'): |
|
2140 | if not opts.get('nonheads'): | |
2141 | ui.write(("unpruned common: %s\n") % |
|
2141 | ui.write(("unpruned common: %s\n") % | |
2142 | " ".join(sorted(short(n) for n in common))) |
|
2142 | " ".join(sorted(short(n) for n in common))) | |
2143 | dag = dagutil.revlogdag(repo.changelog) |
|
2143 | dag = dagutil.revlogdag(repo.changelog) | |
2144 | all = dag.ancestorset(dag.internalizeall(common)) |
|
2144 | all = dag.ancestorset(dag.internalizeall(common)) | |
2145 | common = dag.externalizeall(dag.headsetofconnecteds(all)) |
|
2145 | common = dag.externalizeall(dag.headsetofconnecteds(all)) | |
2146 | else: |
|
2146 | else: | |
2147 | common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) |
|
2147 | common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) | |
2148 | common = set(common) |
|
2148 | common = set(common) | |
2149 | rheads = set(hds) |
|
2149 | rheads = set(hds) | |
2150 | lheads = set(repo.heads()) |
|
2150 | lheads = set(repo.heads()) | |
2151 | ui.write(("common heads: %s\n") % |
|
2151 | ui.write(("common heads: %s\n") % | |
2152 | " ".join(sorted(short(n) for n in common))) |
|
2152 | " ".join(sorted(short(n) for n in common))) | |
2153 | if lheads <= common: |
|
2153 | if lheads <= common: | |
2154 | ui.write(("local is subset\n")) |
|
2154 | ui.write(("local is subset\n")) | |
2155 | elif rheads <= common: |
|
2155 | elif rheads <= common: | |
2156 | ui.write(("remote is subset\n")) |
|
2156 | ui.write(("remote is subset\n")) | |
2157 |
|
2157 | |||
2158 | serverlogs = opts.get('serverlog') |
|
2158 | serverlogs = opts.get('serverlog') | |
2159 | if serverlogs: |
|
2159 | if serverlogs: | |
2160 | for filename in serverlogs: |
|
2160 | for filename in serverlogs: | |
2161 | with open(filename, 'r') as logfile: |
|
2161 | with open(filename, 'r') as logfile: | |
2162 | line = logfile.readline() |
|
2162 | line = logfile.readline() | |
2163 | while line: |
|
2163 | while line: | |
2164 | parts = line.strip().split(';') |
|
2164 | parts = line.strip().split(';') | |
2165 | op = parts[1] |
|
2165 | op = parts[1] | |
2166 | if op == 'cg': |
|
2166 | if op == 'cg': | |
2167 | pass |
|
2167 | pass | |
2168 | elif op == 'cgss': |
|
2168 | elif op == 'cgss': | |
2169 | doit(parts[2].split(' '), parts[3].split(' ')) |
|
2169 | doit(parts[2].split(' '), parts[3].split(' ')) | |
2170 | elif op == 'unb': |
|
2170 | elif op == 'unb': | |
2171 | doit(parts[3].split(' '), parts[2].split(' ')) |
|
2171 | doit(parts[3].split(' '), parts[2].split(' ')) | |
2172 | line = logfile.readline() |
|
2172 | line = logfile.readline() | |
2173 | else: |
|
2173 | else: | |
2174 | remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
|
2174 | remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, | |
2175 | opts.get('remote_head')) |
|
2175 | opts.get('remote_head')) | |
2176 | localrevs = opts.get('local_head') |
|
2176 | localrevs = opts.get('local_head') | |
2177 | doit(localrevs, remoterevs) |
|
2177 | doit(localrevs, remoterevs) | |
2178 |
|
2178 | |||
2179 | @command('debugextensions', formatteropts, [], norepo=True) |
|
2179 | @command('debugextensions', formatteropts, [], norepo=True) | |
2180 | def debugextensions(ui, **opts): |
|
2180 | def debugextensions(ui, **opts): | |
2181 | '''show information about active extensions''' |
|
2181 | '''show information about active extensions''' | |
2182 | exts = extensions.extensions(ui) |
|
2182 | exts = extensions.extensions(ui) | |
2183 | hgver = util.version() |
|
2183 | hgver = util.version() | |
2184 | fm = ui.formatter('debugextensions', opts) |
|
2184 | fm = ui.formatter('debugextensions', opts) | |
2185 | for extname, extmod in sorted(exts, key=operator.itemgetter(0)): |
|
2185 | for extname, extmod in sorted(exts, key=operator.itemgetter(0)): | |
2186 | isinternal = extensions.ismoduleinternal(extmod) |
|
2186 | isinternal = extensions.ismoduleinternal(extmod) | |
2187 | extsource = extmod.__file__ |
|
2187 | extsource = extmod.__file__ | |
2188 | if isinternal: |
|
2188 | if isinternal: | |
2189 | exttestedwith = [] # never expose magic string to users |
|
2189 | exttestedwith = [] # never expose magic string to users | |
2190 | else: |
|
2190 | else: | |
2191 | exttestedwith = getattr(extmod, 'testedwith', '').split() |
|
2191 | exttestedwith = getattr(extmod, 'testedwith', '').split() | |
2192 | extbuglink = getattr(extmod, 'buglink', None) |
|
2192 | extbuglink = getattr(extmod, 'buglink', None) | |
2193 |
|
2193 | |||
2194 | fm.startitem() |
|
2194 | fm.startitem() | |
2195 |
|
2195 | |||
2196 | if ui.quiet or ui.verbose: |
|
2196 | if ui.quiet or ui.verbose: | |
2197 | fm.write('name', '%s\n', extname) |
|
2197 | fm.write('name', '%s\n', extname) | |
2198 | else: |
|
2198 | else: | |
2199 | fm.write('name', '%s', extname) |
|
2199 | fm.write('name', '%s', extname) | |
2200 | if isinternal or hgver in exttestedwith: |
|
2200 | if isinternal or hgver in exttestedwith: | |
2201 | fm.plain('\n') |
|
2201 | fm.plain('\n') | |
2202 | elif not exttestedwith: |
|
2202 | elif not exttestedwith: | |
2203 | fm.plain(_(' (untested!)\n')) |
|
2203 | fm.plain(_(' (untested!)\n')) | |
2204 | else: |
|
2204 | else: | |
2205 | lasttestedversion = exttestedwith[-1] |
|
2205 | lasttestedversion = exttestedwith[-1] | |
2206 | fm.plain(' (%s!)\n' % lasttestedversion) |
|
2206 | fm.plain(' (%s!)\n' % lasttestedversion) | |
2207 |
|
2207 | |||
2208 | fm.condwrite(ui.verbose and extsource, 'source', |
|
2208 | fm.condwrite(ui.verbose and extsource, 'source', | |
2209 | _(' location: %s\n'), extsource or "") |
|
2209 | _(' location: %s\n'), extsource or "") | |
2210 |
|
2210 | |||
2211 | if ui.verbose: |
|
2211 | if ui.verbose: | |
2212 | fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) |
|
2212 | fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) | |
2213 | fm.data(bundled=isinternal) |
|
2213 | fm.data(bundled=isinternal) | |
2214 |
|
2214 | |||
2215 | fm.condwrite(ui.verbose and exttestedwith, 'testedwith', |
|
2215 | fm.condwrite(ui.verbose and exttestedwith, 'testedwith', | |
2216 | _(' tested with: %s\n'), |
|
2216 | _(' tested with: %s\n'), | |
2217 | fm.formatlist(exttestedwith, name='ver')) |
|
2217 | fm.formatlist(exttestedwith, name='ver')) | |
2218 |
|
2218 | |||
2219 | fm.condwrite(ui.verbose and extbuglink, 'buglink', |
|
2219 | fm.condwrite(ui.verbose and extbuglink, 'buglink', | |
2220 | _(' bug reporting: %s\n'), extbuglink or "") |
|
2220 | _(' bug reporting: %s\n'), extbuglink or "") | |
2221 |
|
2221 | |||
2222 | fm.end() |
|
2222 | fm.end() | |
2223 |
|
2223 | |||
2224 | @command('debugfileset', |
|
2224 | @command('debugfileset', | |
2225 | [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], |
|
2225 | [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], | |
2226 | _('[-r REV] FILESPEC')) |
|
2226 | _('[-r REV] FILESPEC')) | |
2227 | def debugfileset(ui, repo, expr, **opts): |
|
2227 | def debugfileset(ui, repo, expr, **opts): | |
2228 | '''parse and apply a fileset specification''' |
|
2228 | '''parse and apply a fileset specification''' | |
2229 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
2229 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) | |
2230 | if ui.verbose: |
|
2230 | if ui.verbose: | |
2231 | tree = fileset.parse(expr) |
|
2231 | tree = fileset.parse(expr) | |
2232 | ui.note(fileset.prettyformat(tree), "\n") |
|
2232 | ui.note(fileset.prettyformat(tree), "\n") | |
2233 |
|
2233 | |||
2234 | for f in ctx.getfileset(expr): |
|
2234 | for f in ctx.getfileset(expr): | |
2235 | ui.write("%s\n" % f) |
|
2235 | ui.write("%s\n" % f) | |
2236 |
|
2236 | |||
2237 | @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
|
2237 | @command('debugfsinfo', [], _('[PATH]'), norepo=True) | |
2238 | def debugfsinfo(ui, path="."): |
|
2238 | def debugfsinfo(ui, path="."): | |
2239 | """show information detected about current filesystem""" |
|
2239 | """show information detected about current filesystem""" | |
2240 | util.writefile('.debugfsinfo', '') |
|
2240 | util.writefile('.debugfsinfo', '') | |
2241 | ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
|
2241 | ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) | |
2242 | ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
|
2242 | ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) | |
2243 | ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
|
2243 | ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) | |
2244 | ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo') |
|
2244 | ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo') | |
2245 | and 'yes' or 'no')) |
|
2245 | and 'yes' or 'no')) | |
2246 | os.unlink('.debugfsinfo') |
|
2246 | os.unlink('.debugfsinfo') | |
2247 |
|
2247 | |||
2248 | @command('debuggetbundle', |
|
2248 | @command('debuggetbundle', | |
2249 | [('H', 'head', [], _('id of head node'), _('ID')), |
|
2249 | [('H', 'head', [], _('id of head node'), _('ID')), | |
2250 | ('C', 'common', [], _('id of common node'), _('ID')), |
|
2250 | ('C', 'common', [], _('id of common node'), _('ID')), | |
2251 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
|
2251 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], | |
2252 | _('REPO FILE [-H|-C ID]...'), |
|
2252 | _('REPO FILE [-H|-C ID]...'), | |
2253 | norepo=True) |
|
2253 | norepo=True) | |
2254 | def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
|
2254 | def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): | |
2255 | """retrieves a bundle from a repo |
|
2255 | """retrieves a bundle from a repo | |
2256 |
|
2256 | |||
2257 | Every ID must be a full-length hex node id string. Saves the bundle to the |
|
2257 | Every ID must be a full-length hex node id string. Saves the bundle to the | |
2258 | given file. |
|
2258 | given file. | |
2259 | """ |
|
2259 | """ | |
2260 | repo = hg.peer(ui, opts, repopath) |
|
2260 | repo = hg.peer(ui, opts, repopath) | |
2261 | if not repo.capable('getbundle'): |
|
2261 | if not repo.capable('getbundle'): | |
2262 | raise error.Abort("getbundle() not supported by target repository") |
|
2262 | raise error.Abort("getbundle() not supported by target repository") | |
2263 | args = {} |
|
2263 | args = {} | |
2264 | if common: |
|
2264 | if common: | |
2265 | args['common'] = [bin(s) for s in common] |
|
2265 | args['common'] = [bin(s) for s in common] | |
2266 | if head: |
|
2266 | if head: | |
2267 | args['heads'] = [bin(s) for s in head] |
|
2267 | args['heads'] = [bin(s) for s in head] | |
2268 | # TODO: get desired bundlecaps from command line. |
|
2268 | # TODO: get desired bundlecaps from command line. | |
2269 | args['bundlecaps'] = None |
|
2269 | args['bundlecaps'] = None | |
2270 | bundle = repo.getbundle('debug', **args) |
|
2270 | bundle = repo.getbundle('debug', **args) | |
2271 |
|
2271 | |||
2272 | bundletype = opts.get('type', 'bzip2').lower() |
|
2272 | bundletype = opts.get('type', 'bzip2').lower() | |
2273 | btypes = {'none': 'HG10UN', |
|
2273 | btypes = {'none': 'HG10UN', | |
2274 | 'bzip2': 'HG10BZ', |
|
2274 | 'bzip2': 'HG10BZ', | |
2275 | 'gzip': 'HG10GZ', |
|
2275 | 'gzip': 'HG10GZ', | |
2276 | 'bundle2': 'HG20'} |
|
2276 | 'bundle2': 'HG20'} | |
2277 | bundletype = btypes.get(bundletype) |
|
2277 | bundletype = btypes.get(bundletype) | |
2278 | if bundletype not in bundle2.bundletypes: |
|
2278 | if bundletype not in bundle2.bundletypes: | |
2279 | raise error.Abort(_('unknown bundle type specified with --type')) |
|
2279 | raise error.Abort(_('unknown bundle type specified with --type')) | |
2280 | bundle2.writebundle(ui, bundle, bundlepath, bundletype) |
|
2280 | bundle2.writebundle(ui, bundle, bundlepath, bundletype) | |
2281 |
|
2281 | |||
2282 | @command('debugignore', [], '[FILE]') |
|
2282 | @command('debugignore', [], '[FILE]') | |
2283 | def debugignore(ui, repo, *files, **opts): |
|
2283 | def debugignore(ui, repo, *files, **opts): | |
2284 | """display the combined ignore pattern and information about ignored files |
|
2284 | """display the combined ignore pattern and information about ignored files | |
2285 |
|
2285 | |||
2286 | With no argument display the combined ignore pattern. |
|
2286 | With no argument display the combined ignore pattern. | |
2287 |
|
2287 | |||
2288 | Given space separated file names, shows if the given file is ignored and |
|
2288 | Given space separated file names, shows if the given file is ignored and | |
2289 | if so, show the ignore rule (file and line number) that matched it. |
|
2289 | if so, show the ignore rule (file and line number) that matched it. | |
2290 | """ |
|
2290 | """ | |
2291 | ignore = repo.dirstate._ignore |
|
2291 | ignore = repo.dirstate._ignore | |
2292 | if not files: |
|
2292 | if not files: | |
2293 | # Show all the patterns |
|
2293 | # Show all the patterns | |
2294 | includepat = getattr(ignore, 'includepat', None) |
|
2294 | includepat = getattr(ignore, 'includepat', None) | |
2295 | if includepat is not None: |
|
2295 | if includepat is not None: | |
2296 | ui.write("%s\n" % includepat) |
|
2296 | ui.write("%s\n" % includepat) | |
2297 | else: |
|
2297 | else: | |
2298 | raise error.Abort(_("no ignore patterns found")) |
|
2298 | raise error.Abort(_("no ignore patterns found")) | |
2299 | else: |
|
2299 | else: | |
2300 | for f in files: |
|
2300 | for f in files: | |
2301 | nf = util.normpath(f) |
|
2301 | nf = util.normpath(f) | |
2302 | ignored = None |
|
2302 | ignored = None | |
2303 | ignoredata = None |
|
2303 | ignoredata = None | |
2304 | if nf != '.': |
|
2304 | if nf != '.': | |
2305 | if ignore(nf): |
|
2305 | if ignore(nf): | |
2306 | ignored = nf |
|
2306 | ignored = nf | |
2307 | ignoredata = repo.dirstate._ignorefileandline(nf) |
|
2307 | ignoredata = repo.dirstate._ignorefileandline(nf) | |
2308 | else: |
|
2308 | else: | |
2309 | for p in util.finddirs(nf): |
|
2309 | for p in util.finddirs(nf): | |
2310 | if ignore(p): |
|
2310 | if ignore(p): | |
2311 | ignored = p |
|
2311 | ignored = p | |
2312 | ignoredata = repo.dirstate._ignorefileandline(p) |
|
2312 | ignoredata = repo.dirstate._ignorefileandline(p) | |
2313 | break |
|
2313 | break | |
2314 | if ignored: |
|
2314 | if ignored: | |
2315 | if ignored == nf: |
|
2315 | if ignored == nf: | |
2316 | ui.write(_("%s is ignored\n") % f) |
|
2316 | ui.write(_("%s is ignored\n") % f) | |
2317 | else: |
|
2317 | else: | |
2318 | ui.write(_("%s is ignored because of " |
|
2318 | ui.write(_("%s is ignored because of " | |
2319 | "containing folder %s\n") |
|
2319 | "containing folder %s\n") | |
2320 | % (f, ignored)) |
|
2320 | % (f, ignored)) | |
2321 | ignorefile, lineno, line = ignoredata |
|
2321 | ignorefile, lineno, line = ignoredata | |
2322 | ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
|
2322 | ui.write(_("(ignore rule in %s, line %d: '%s')\n") | |
2323 | % (ignorefile, lineno, line)) |
|
2323 | % (ignorefile, lineno, line)) | |
2324 | else: |
|
2324 | else: | |
2325 | ui.write(_("%s is not ignored\n") % f) |
|
2325 | ui.write(_("%s is not ignored\n") % f) | |
2326 |
|
2326 | |||
2327 | @command('debugindex', debugrevlogopts + |
|
2327 | @command('debugindex', debugrevlogopts + | |
2328 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
|
2328 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | |
2329 | _('[-f FORMAT] -c|-m|FILE'), |
|
2329 | _('[-f FORMAT] -c|-m|FILE'), | |
2330 | optionalrepo=True) |
|
2330 | optionalrepo=True) | |
2331 | def debugindex(ui, repo, file_=None, **opts): |
|
2331 | def debugindex(ui, repo, file_=None, **opts): | |
2332 | """dump the contents of an index file""" |
|
2332 | """dump the contents of an index file""" | |
2333 | r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) |
|
2333 | r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) | |
2334 | format = opts.get('format', 0) |
|
2334 | format = opts.get('format', 0) | |
2335 | if format not in (0, 1): |
|
2335 | if format not in (0, 1): | |
2336 | raise error.Abort(_("unknown format %d") % format) |
|
2336 | raise error.Abort(_("unknown format %d") % format) | |
2337 |
|
2337 | |||
2338 | generaldelta = r.version & revlog.REVLOGGENERALDELTA |
|
2338 | generaldelta = r.version & revlog.REVLOGGENERALDELTA | |
2339 | if generaldelta: |
|
2339 | if generaldelta: | |
2340 | basehdr = ' delta' |
|
2340 | basehdr = ' delta' | |
2341 | else: |
|
2341 | else: | |
2342 | basehdr = ' base' |
|
2342 | basehdr = ' base' | |
2343 |
|
2343 | |||
2344 | if ui.debugflag: |
|
2344 | if ui.debugflag: | |
2345 | shortfn = hex |
|
2345 | shortfn = hex | |
2346 | else: |
|
2346 | else: | |
2347 | shortfn = short |
|
2347 | shortfn = short | |
2348 |
|
2348 | |||
2349 | # There might not be anything in r, so have a sane default |
|
2349 | # There might not be anything in r, so have a sane default | |
2350 | idlen = 12 |
|
2350 | idlen = 12 | |
2351 | for i in r: |
|
2351 | for i in r: | |
2352 | idlen = len(shortfn(r.node(i))) |
|
2352 | idlen = len(shortfn(r.node(i))) | |
2353 | break |
|
2353 | break | |
2354 |
|
2354 | |||
2355 | if format == 0: |
|
2355 | if format == 0: | |
2356 | ui.write((" rev offset length " + basehdr + " linkrev" |
|
2356 | ui.write((" rev offset length " + basehdr + " linkrev" | |
2357 | " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) |
|
2357 | " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) | |
2358 | elif format == 1: |
|
2358 | elif format == 1: | |
2359 | ui.write((" rev flag offset length" |
|
2359 | ui.write((" rev flag offset length" | |
2360 | " size " + basehdr + " link p1 p2" |
|
2360 | " size " + basehdr + " link p1 p2" | |
2361 | " %s\n") % "nodeid".rjust(idlen)) |
|
2361 | " %s\n") % "nodeid".rjust(idlen)) | |
2362 |
|
2362 | |||
2363 | for i in r: |
|
2363 | for i in r: | |
2364 | node = r.node(i) |
|
2364 | node = r.node(i) | |
2365 | if generaldelta: |
|
2365 | if generaldelta: | |
2366 | base = r.deltaparent(i) |
|
2366 | base = r.deltaparent(i) | |
2367 | else: |
|
2367 | else: | |
2368 | base = r.chainbase(i) |
|
2368 | base = r.chainbase(i) | |
2369 | if format == 0: |
|
2369 | if format == 0: | |
2370 | try: |
|
2370 | try: | |
2371 | pp = r.parents(node) |
|
2371 | pp = r.parents(node) | |
2372 | except Exception: |
|
2372 | except Exception: | |
2373 | pp = [nullid, nullid] |
|
2373 | pp = [nullid, nullid] | |
2374 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
|
2374 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | |
2375 | i, r.start(i), r.length(i), base, r.linkrev(i), |
|
2375 | i, r.start(i), r.length(i), base, r.linkrev(i), | |
2376 | shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
|
2376 | shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) | |
2377 | elif format == 1: |
|
2377 | elif format == 1: | |
2378 | pr = r.parentrevs(i) |
|
2378 | pr = r.parentrevs(i) | |
2379 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
|
2379 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( | |
2380 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
|
2380 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), | |
2381 | base, r.linkrev(i), pr[0], pr[1], shortfn(node))) |
|
2381 | base, r.linkrev(i), pr[0], pr[1], shortfn(node))) | |
2382 |
|
2382 | |||
2383 | @command('debugindexdot', debugrevlogopts, |
|
2383 | @command('debugindexdot', debugrevlogopts, | |
2384 | _('-c|-m|FILE'), optionalrepo=True) |
|
2384 | _('-c|-m|FILE'), optionalrepo=True) | |
2385 | def debugindexdot(ui, repo, file_=None, **opts): |
|
2385 | def debugindexdot(ui, repo, file_=None, **opts): | |
2386 | """dump an index DAG as a graphviz dot file""" |
|
2386 | """dump an index DAG as a graphviz dot file""" | |
2387 | r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) |
|
2387 | r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) | |
2388 | ui.write(("digraph G {\n")) |
|
2388 | ui.write(("digraph G {\n")) | |
2389 | for i in r: |
|
2389 | for i in r: | |
2390 | node = r.node(i) |
|
2390 | node = r.node(i) | |
2391 | pp = r.parents(node) |
|
2391 | pp = r.parents(node) | |
2392 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
|
2392 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | |
2393 | if pp[1] != nullid: |
|
2393 | if pp[1] != nullid: | |
2394 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
|
2394 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | |
2395 | ui.write("}\n") |
|
2395 | ui.write("}\n") | |
2396 |
|
2396 | |||
2397 | @command('debugdeltachain', |
|
2397 | @command('debugdeltachain', | |
2398 | debugrevlogopts + formatteropts, |
|
2398 | debugrevlogopts + formatteropts, | |
2399 | _('-c|-m|FILE'), |
|
2399 | _('-c|-m|FILE'), | |
2400 | optionalrepo=True) |
|
2400 | optionalrepo=True) | |
2401 | def debugdeltachain(ui, repo, file_=None, **opts): |
|
2401 | def debugdeltachain(ui, repo, file_=None, **opts): | |
2402 | """dump information about delta chains in a revlog |
|
2402 | """dump information about delta chains in a revlog | |
2403 |
|
2403 | |||
2404 | Output can be templatized. Available template keywords are: |
|
2404 | Output can be templatized. Available template keywords are: | |
2405 |
|
2405 | |||
2406 | :``rev``: revision number |
|
2406 | :``rev``: revision number | |
2407 | :``chainid``: delta chain identifier (numbered by unique base) |
|
2407 | :``chainid``: delta chain identifier (numbered by unique base) | |
2408 | :``chainlen``: delta chain length to this revision |
|
2408 | :``chainlen``: delta chain length to this revision | |
2409 | :``prevrev``: previous revision in delta chain |
|
2409 | :``prevrev``: previous revision in delta chain | |
2410 | :``deltatype``: role of delta / how it was computed |
|
2410 | :``deltatype``: role of delta / how it was computed | |
2411 | :``compsize``: compressed size of revision |
|
2411 | :``compsize``: compressed size of revision | |
2412 | :``uncompsize``: uncompressed size of revision |
|
2412 | :``uncompsize``: uncompressed size of revision | |
2413 | :``chainsize``: total size of compressed revisions in chain |
|
2413 | :``chainsize``: total size of compressed revisions in chain | |
2414 | :``chainratio``: total chain size divided by uncompressed revision size |
|
2414 | :``chainratio``: total chain size divided by uncompressed revision size | |
2415 | (new delta chains typically start at ratio 2.00) |
|
2415 | (new delta chains typically start at ratio 2.00) | |
2416 | :``lindist``: linear distance from base revision in delta chain to end |
|
2416 | :``lindist``: linear distance from base revision in delta chain to end | |
2417 | of this revision |
|
2417 | of this revision | |
2418 | :``extradist``: total size of revisions not part of this delta chain from |
|
2418 | :``extradist``: total size of revisions not part of this delta chain from | |
2419 | base of delta chain to end of this revision; a measurement |
|
2419 | base of delta chain to end of this revision; a measurement | |
2420 | of how much extra data we need to read/seek across to read |
|
2420 | of how much extra data we need to read/seek across to read | |
2421 | the delta chain for this revision |
|
2421 | the delta chain for this revision | |
2422 | :``extraratio``: extradist divided by chainsize; another representation of |
|
2422 | :``extraratio``: extradist divided by chainsize; another representation of | |
2423 | how much unrelated data is needed to load this delta chain |
|
2423 | how much unrelated data is needed to load this delta chain | |
2424 | """ |
|
2424 | """ | |
2425 | r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
|
2425 | r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) | |
2426 | index = r.index |
|
2426 | index = r.index | |
2427 | generaldelta = r.version & revlog.REVLOGGENERALDELTA |
|
2427 | generaldelta = r.version & revlog.REVLOGGENERALDELTA | |
2428 |
|
2428 | |||
2429 | def revinfo(rev): |
|
2429 | def revinfo(rev): | |
2430 | e = index[rev] |
|
2430 | e = index[rev] | |
2431 | compsize = e[1] |
|
2431 | compsize = e[1] | |
2432 | uncompsize = e[2] |
|
2432 | uncompsize = e[2] | |
2433 | chainsize = 0 |
|
2433 | chainsize = 0 | |
2434 |
|
2434 | |||
2435 | if generaldelta: |
|
2435 | if generaldelta: | |
2436 | if e[3] == e[5]: |
|
2436 | if e[3] == e[5]: | |
2437 | deltatype = 'p1' |
|
2437 | deltatype = 'p1' | |
2438 | elif e[3] == e[6]: |
|
2438 | elif e[3] == e[6]: | |
2439 | deltatype = 'p2' |
|
2439 | deltatype = 'p2' | |
2440 | elif e[3] == rev - 1: |
|
2440 | elif e[3] == rev - 1: | |
2441 | deltatype = 'prev' |
|
2441 | deltatype = 'prev' | |
2442 | elif e[3] == rev: |
|
2442 | elif e[3] == rev: | |
2443 | deltatype = 'base' |
|
2443 | deltatype = 'base' | |
2444 | else: |
|
2444 | else: | |
2445 | deltatype = 'other' |
|
2445 | deltatype = 'other' | |
2446 | else: |
|
2446 | else: | |
2447 | if e[3] == rev: |
|
2447 | if e[3] == rev: | |
2448 | deltatype = 'base' |
|
2448 | deltatype = 'base' | |
2449 | else: |
|
2449 | else: | |
2450 | deltatype = 'prev' |
|
2450 | deltatype = 'prev' | |
2451 |
|
2451 | |||
2452 | chain = r._deltachain(rev)[0] |
|
2452 | chain = r._deltachain(rev)[0] | |
2453 | for iterrev in chain: |
|
2453 | for iterrev in chain: | |
2454 | e = index[iterrev] |
|
2454 | e = index[iterrev] | |
2455 | chainsize += e[1] |
|
2455 | chainsize += e[1] | |
2456 |
|
2456 | |||
2457 | return compsize, uncompsize, deltatype, chain, chainsize |
|
2457 | return compsize, uncompsize, deltatype, chain, chainsize | |
2458 |
|
2458 | |||
2459 | fm = ui.formatter('debugdeltachain', opts) |
|
2459 | fm = ui.formatter('debugdeltachain', opts) | |
2460 |
|
2460 | |||
2461 | fm.plain(' rev chain# chainlen prev delta ' |
|
2461 | fm.plain(' rev chain# chainlen prev delta ' | |
2462 | 'size rawsize chainsize ratio lindist extradist ' |
|
2462 | 'size rawsize chainsize ratio lindist extradist ' | |
2463 | 'extraratio\n') |
|
2463 | 'extraratio\n') | |
2464 |
|
2464 | |||
2465 | chainbases = {} |
|
2465 | chainbases = {} | |
2466 | for rev in r: |
|
2466 | for rev in r: | |
2467 | comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
|
2467 | comp, uncomp, deltatype, chain, chainsize = revinfo(rev) | |
2468 | chainbase = chain[0] |
|
2468 | chainbase = chain[0] | |
2469 | chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) |
|
2469 | chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) | |
2470 | basestart = r.start(chainbase) |
|
2470 | basestart = r.start(chainbase) | |
2471 | revstart = r.start(rev) |
|
2471 | revstart = r.start(rev) | |
2472 | lineardist = revstart + comp - basestart |
|
2472 | lineardist = revstart + comp - basestart | |
2473 | extradist = lineardist - chainsize |
|
2473 | extradist = lineardist - chainsize | |
2474 | try: |
|
2474 | try: | |
2475 | prevrev = chain[-2] |
|
2475 | prevrev = chain[-2] | |
2476 | except IndexError: |
|
2476 | except IndexError: | |
2477 | prevrev = -1 |
|
2477 | prevrev = -1 | |
2478 |
|
2478 | |||
2479 | chainratio = float(chainsize) / float(uncomp) |
|
2479 | chainratio = float(chainsize) / float(uncomp) | |
2480 | extraratio = float(extradist) / float(chainsize) |
|
2480 | extraratio = float(extradist) / float(chainsize) | |
2481 |
|
2481 | |||
2482 | fm.startitem() |
|
2482 | fm.startitem() | |
2483 | fm.write('rev chainid chainlen prevrev deltatype compsize ' |
|
2483 | fm.write('rev chainid chainlen prevrev deltatype compsize ' | |
2484 | 'uncompsize chainsize chainratio lindist extradist ' |
|
2484 | 'uncompsize chainsize chainratio lindist extradist ' | |
2485 | 'extraratio', |
|
2485 | 'extraratio', | |
2486 | '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n', |
|
2486 | '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n', | |
2487 | rev, chainid, len(chain), prevrev, deltatype, comp, |
|
2487 | rev, chainid, len(chain), prevrev, deltatype, comp, | |
2488 | uncomp, chainsize, chainratio, lineardist, extradist, |
|
2488 | uncomp, chainsize, chainratio, lineardist, extradist, | |
2489 | extraratio, |
|
2489 | extraratio, | |
2490 | rev=rev, chainid=chainid, chainlen=len(chain), |
|
2490 | rev=rev, chainid=chainid, chainlen=len(chain), | |
2491 | prevrev=prevrev, deltatype=deltatype, compsize=comp, |
|
2491 | prevrev=prevrev, deltatype=deltatype, compsize=comp, | |
2492 | uncompsize=uncomp, chainsize=chainsize, |
|
2492 | uncompsize=uncomp, chainsize=chainsize, | |
2493 | chainratio=chainratio, lindist=lineardist, |
|
2493 | chainratio=chainratio, lindist=lineardist, | |
2494 | extradist=extradist, extraratio=extraratio) |
|
2494 | extradist=extradist, extraratio=extraratio) | |
2495 |
|
2495 | |||
2496 | fm.end() |
|
2496 | fm.end() | |
2497 |
|
2497 | |||
2498 | @command('debuginstall', [] + formatteropts, '', norepo=True) |
|
2498 | @command('debuginstall', [] + formatteropts, '', norepo=True) | |
2499 | def debuginstall(ui, **opts): |
|
2499 | def debuginstall(ui, **opts): | |
2500 | '''test Mercurial installation |
|
2500 | '''test Mercurial installation | |
2501 |
|
2501 | |||
2502 | Returns 0 on success. |
|
2502 | Returns 0 on success. | |
2503 | ''' |
|
2503 | ''' | |
2504 |
|
2504 | |||
2505 | def writetemp(contents): |
|
2505 | def writetemp(contents): | |
2506 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
|
2506 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") | |
2507 | f = os.fdopen(fd, "wb") |
|
2507 | f = os.fdopen(fd, "wb") | |
2508 | f.write(contents) |
|
2508 | f.write(contents) | |
2509 | f.close() |
|
2509 | f.close() | |
2510 | return name |
|
2510 | return name | |
2511 |
|
2511 | |||
2512 | problems = 0 |
|
2512 | problems = 0 | |
2513 |
|
2513 | |||
2514 | fm = ui.formatter('debuginstall', opts) |
|
2514 | fm = ui.formatter('debuginstall', opts) | |
2515 | fm.startitem() |
|
2515 | fm.startitem() | |
2516 |
|
2516 | |||
2517 | # encoding |
|
2517 | # encoding | |
2518 | fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
|
2518 | fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) | |
2519 | err = None |
|
2519 | err = None | |
2520 | try: |
|
2520 | try: | |
2521 | encoding.fromlocal("test") |
|
2521 | encoding.fromlocal("test") | |
2522 | except error.Abort as inst: |
|
2522 | except error.Abort as inst: | |
2523 | err = inst |
|
2523 | err = inst | |
2524 | problems += 1 |
|
2524 | problems += 1 | |
2525 | fm.condwrite(err, 'encodingerror', _(" %s\n" |
|
2525 | fm.condwrite(err, 'encodingerror', _(" %s\n" | |
2526 | " (check that your locale is properly set)\n"), err) |
|
2526 | " (check that your locale is properly set)\n"), err) | |
2527 |
|
2527 | |||
2528 | # Python |
|
2528 | # Python | |
2529 | fm.write('pythonexe', _("checking Python executable (%s)\n"), |
|
2529 | fm.write('pythonexe', _("checking Python executable (%s)\n"), | |
2530 | sys.executable) |
|
2530 | sys.executable) | |
2531 | fm.write('pythonver', _("checking Python version (%s)\n"), |
|
2531 | fm.write('pythonver', _("checking Python version (%s)\n"), | |
2532 | ("%s.%s.%s" % sys.version_info[:3])) |
|
2532 | ("%s.%s.%s" % sys.version_info[:3])) | |
2533 | fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
|
2533 | fm.write('pythonlib', _("checking Python lib (%s)...\n"), | |
2534 | os.path.dirname(os.__file__)) |
|
2534 | os.path.dirname(os.__file__)) | |
2535 |
|
2535 | |||
2536 | security = set(sslutil.supportedprotocols) |
|
2536 | security = set(sslutil.supportedprotocols) | |
2537 | if sslutil.hassni: |
|
2537 | if sslutil.hassni: | |
2538 | security.add('sni') |
|
2538 | security.add('sni') | |
2539 |
|
2539 | |||
2540 | fm.write('pythonsecurity', _("checking Python security support (%s)\n"), |
|
2540 | fm.write('pythonsecurity', _("checking Python security support (%s)\n"), | |
2541 | fm.formatlist(sorted(security), name='protocol', |
|
2541 | fm.formatlist(sorted(security), name='protocol', | |
2542 | fmt='%s', sep=',')) |
|
2542 | fmt='%s', sep=',')) | |
2543 |
|
2543 | |||
2544 | # These are warnings, not errors. So don't increment problem count. This |
|
2544 | # These are warnings, not errors. So don't increment problem count. This | |
2545 | # may change in the future. |
|
2545 | # may change in the future. | |
2546 | if 'tls1.2' not in security: |
|
2546 | if 'tls1.2' not in security: | |
2547 | fm.plain(_(' TLS 1.2 not supported by Python install; ' |
|
2547 | fm.plain(_(' TLS 1.2 not supported by Python install; ' | |
2548 | 'network connections lack modern security\n')) |
|
2548 | 'network connections lack modern security\n')) | |
2549 | if 'sni' not in security: |
|
2549 | if 'sni' not in security: | |
2550 | fm.plain(_(' SNI not supported by Python install; may have ' |
|
2550 | fm.plain(_(' SNI not supported by Python install; may have ' | |
2551 | 'connectivity issues with some servers\n')) |
|
2551 | 'connectivity issues with some servers\n')) | |
2552 |
|
2552 | |||
2553 | # TODO print CA cert info |
|
2553 | # TODO print CA cert info | |
2554 |
|
2554 | |||
2555 | # hg version |
|
2555 | # hg version | |
2556 | hgver = util.version() |
|
2556 | hgver = util.version() | |
2557 | fm.write('hgver', _("checking Mercurial version (%s)\n"), |
|
2557 | fm.write('hgver', _("checking Mercurial version (%s)\n"), | |
2558 | hgver.split('+')[0]) |
|
2558 | hgver.split('+')[0]) | |
2559 | fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), |
|
2559 | fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), | |
2560 | '+'.join(hgver.split('+')[1:])) |
|
2560 | '+'.join(hgver.split('+')[1:])) | |
2561 |
|
2561 | |||
2562 | # compiled modules |
|
2562 | # compiled modules | |
2563 | fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), |
|
2563 | fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), | |
2564 | policy.policy) |
|
2564 | policy.policy) | |
2565 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
|
2565 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), | |
2566 | os.path.dirname(__file__)) |
|
2566 | os.path.dirname(__file__)) | |
2567 |
|
2567 | |||
2568 | err = None |
|
2568 | err = None | |
2569 | try: |
|
2569 | try: | |
2570 | from . import ( |
|
2570 | from . import ( | |
2571 | base85, |
|
2571 | base85, | |
2572 | bdiff, |
|
2572 | bdiff, | |
2573 | mpatch, |
|
2573 | mpatch, | |
2574 | osutil, |
|
2574 | osutil, | |
2575 | ) |
|
2575 | ) | |
2576 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
|
2576 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes | |
2577 | except Exception as inst: |
|
2577 | except Exception as inst: | |
2578 | err = inst |
|
2578 | err = inst | |
2579 | problems += 1 |
|
2579 | problems += 1 | |
2580 | fm.condwrite(err, 'extensionserror', " %s\n", err) |
|
2580 | fm.condwrite(err, 'extensionserror', " %s\n", err) | |
2581 |
|
2581 | |||
|
2582 | compengines = util.compengines._engines.values() | |||
|
2583 | fm.write('compengines', _('checking registered compression engines (%s)\n'), | |||
|
2584 | fm.formatlist(sorted(e.name() for e in compengines), | |||
|
2585 | name='compengine', fmt='%s', sep=', ')) | |||
|
2586 | fm.write('compenginesavail', _('checking available compression engines ' | |||
|
2587 | '(%s)\n'), | |||
|
2588 | fm.formatlist(sorted(e.name() for e in compengines | |||
|
2589 | if e.available()), | |||
|
2590 | name='compengine', fmt='%s', sep=', ')) | |||
|
2591 | ||||
2582 | # templates |
|
2592 | # templates | |
2583 | p = templater.templatepaths() |
|
2593 | p = templater.templatepaths() | |
2584 | fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
|
2594 | fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) | |
2585 | fm.condwrite(not p, '', _(" no template directories found\n")) |
|
2595 | fm.condwrite(not p, '', _(" no template directories found\n")) | |
2586 | if p: |
|
2596 | if p: | |
2587 | m = templater.templatepath("map-cmdline.default") |
|
2597 | m = templater.templatepath("map-cmdline.default") | |
2588 | if m: |
|
2598 | if m: | |
2589 | # template found, check if it is working |
|
2599 | # template found, check if it is working | |
2590 | err = None |
|
2600 | err = None | |
2591 | try: |
|
2601 | try: | |
2592 | templater.templater.frommapfile(m) |
|
2602 | templater.templater.frommapfile(m) | |
2593 | except Exception as inst: |
|
2603 | except Exception as inst: | |
2594 | err = inst |
|
2604 | err = inst | |
2595 | p = None |
|
2605 | p = None | |
2596 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
|
2606 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) | |
2597 | else: |
|
2607 | else: | |
2598 | p = None |
|
2608 | p = None | |
2599 | fm.condwrite(p, 'defaulttemplate', |
|
2609 | fm.condwrite(p, 'defaulttemplate', | |
2600 | _("checking default template (%s)\n"), m) |
|
2610 | _("checking default template (%s)\n"), m) | |
2601 | fm.condwrite(not m, 'defaulttemplatenotfound', |
|
2611 | fm.condwrite(not m, 'defaulttemplatenotfound', | |
2602 | _(" template '%s' not found\n"), "default") |
|
2612 | _(" template '%s' not found\n"), "default") | |
2603 | if not p: |
|
2613 | if not p: | |
2604 | problems += 1 |
|
2614 | problems += 1 | |
2605 | fm.condwrite(not p, '', |
|
2615 | fm.condwrite(not p, '', | |
2606 | _(" (templates seem to have been installed incorrectly)\n")) |
|
2616 | _(" (templates seem to have been installed incorrectly)\n")) | |
2607 |
|
2617 | |||
2608 | # editor |
|
2618 | # editor | |
2609 | editor = ui.geteditor() |
|
2619 | editor = ui.geteditor() | |
2610 | editor = util.expandpath(editor) |
|
2620 | editor = util.expandpath(editor) | |
2611 | fm.write('editor', _("checking commit editor... (%s)\n"), editor) |
|
2621 | fm.write('editor', _("checking commit editor... (%s)\n"), editor) | |
2612 | cmdpath = util.findexe(shlex.split(editor)[0]) |
|
2622 | cmdpath = util.findexe(shlex.split(editor)[0]) | |
2613 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
|
2623 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', | |
2614 | _(" No commit editor set and can't find %s in PATH\n" |
|
2624 | _(" No commit editor set and can't find %s in PATH\n" | |
2615 | " (specify a commit editor in your configuration" |
|
2625 | " (specify a commit editor in your configuration" | |
2616 | " file)\n"), not cmdpath and editor == 'vi' and editor) |
|
2626 | " file)\n"), not cmdpath and editor == 'vi' and editor) | |
2617 | fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
|
2627 | fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', | |
2618 | _(" Can't find editor '%s' in PATH\n" |
|
2628 | _(" Can't find editor '%s' in PATH\n" | |
2619 | " (specify a commit editor in your configuration" |
|
2629 | " (specify a commit editor in your configuration" | |
2620 | " file)\n"), not cmdpath and editor) |
|
2630 | " file)\n"), not cmdpath and editor) | |
2621 | if not cmdpath and editor != 'vi': |
|
2631 | if not cmdpath and editor != 'vi': | |
2622 | problems += 1 |
|
2632 | problems += 1 | |
2623 |
|
2633 | |||
2624 | # check username |
|
2634 | # check username | |
2625 | username = None |
|
2635 | username = None | |
2626 | err = None |
|
2636 | err = None | |
2627 | try: |
|
2637 | try: | |
2628 | username = ui.username() |
|
2638 | username = ui.username() | |
2629 | except error.Abort as e: |
|
2639 | except error.Abort as e: | |
2630 | err = e |
|
2640 | err = e | |
2631 | problems += 1 |
|
2641 | problems += 1 | |
2632 |
|
2642 | |||
2633 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
|
2643 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) | |
2634 | fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
|
2644 | fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" | |
2635 | " (specify a username in your configuration file)\n"), err) |
|
2645 | " (specify a username in your configuration file)\n"), err) | |
2636 |
|
2646 | |||
2637 | fm.condwrite(not problems, '', |
|
2647 | fm.condwrite(not problems, '', | |
2638 | _("no problems detected\n")) |
|
2648 | _("no problems detected\n")) | |
2639 | if not problems: |
|
2649 | if not problems: | |
2640 | fm.data(problems=problems) |
|
2650 | fm.data(problems=problems) | |
2641 | fm.condwrite(problems, 'problems', |
|
2651 | fm.condwrite(problems, 'problems', | |
2642 | _("%d problems detected," |
|
2652 | _("%d problems detected," | |
2643 | " please check your install!\n"), problems) |
|
2653 | " please check your install!\n"), problems) | |
2644 | fm.end() |
|
2654 | fm.end() | |
2645 |
|
2655 | |||
2646 | return problems |
|
2656 | return problems | |
2647 |
|
2657 | |||
2648 | @command('debugknown', [], _('REPO ID...'), norepo=True) |
|
2658 | @command('debugknown', [], _('REPO ID...'), norepo=True) | |
2649 | def debugknown(ui, repopath, *ids, **opts): |
|
2659 | def debugknown(ui, repopath, *ids, **opts): | |
2650 | """test whether node ids are known to a repo |
|
2660 | """test whether node ids are known to a repo | |
2651 |
|
2661 | |||
2652 | Every ID must be a full-length hex node id string. Returns a list of 0s |
|
2662 | Every ID must be a full-length hex node id string. Returns a list of 0s | |
2653 | and 1s indicating unknown/known. |
|
2663 | and 1s indicating unknown/known. | |
2654 | """ |
|
2664 | """ | |
2655 | repo = hg.peer(ui, opts, repopath) |
|
2665 | repo = hg.peer(ui, opts, repopath) | |
2656 | if not repo.capable('known'): |
|
2666 | if not repo.capable('known'): | |
2657 | raise error.Abort("known() not supported by target repository") |
|
2667 | raise error.Abort("known() not supported by target repository") | |
2658 | flags = repo.known([bin(s) for s in ids]) |
|
2668 | flags = repo.known([bin(s) for s in ids]) | |
2659 | ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
|
2669 | ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) | |
2660 |
|
2670 | |||
2661 | @command('debuglabelcomplete', [], _('LABEL...')) |
|
2671 | @command('debuglabelcomplete', [], _('LABEL...')) | |
2662 | def debuglabelcomplete(ui, repo, *args): |
|
2672 | def debuglabelcomplete(ui, repo, *args): | |
2663 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' |
|
2673 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' | |
2664 | debugnamecomplete(ui, repo, *args) |
|
2674 | debugnamecomplete(ui, repo, *args) | |
2665 |
|
2675 | |||
2666 | @command('debugmergestate', [], '') |
|
2676 | @command('debugmergestate', [], '') | |
2667 | def debugmergestate(ui, repo, *args): |
|
2677 | def debugmergestate(ui, repo, *args): | |
2668 | """print merge state |
|
2678 | """print merge state | |
2669 |
|
2679 | |||
2670 | Use --verbose to print out information about whether v1 or v2 merge state |
|
2680 | Use --verbose to print out information about whether v1 or v2 merge state | |
2671 | was chosen.""" |
|
2681 | was chosen.""" | |
2672 | def _hashornull(h): |
|
2682 | def _hashornull(h): | |
2673 | if h == nullhex: |
|
2683 | if h == nullhex: | |
2674 | return 'null' |
|
2684 | return 'null' | |
2675 | else: |
|
2685 | else: | |
2676 | return h |
|
2686 | return h | |
2677 |
|
2687 | |||
2678 | def printrecords(version): |
|
2688 | def printrecords(version): | |
2679 | ui.write(('* version %s records\n') % version) |
|
2689 | ui.write(('* version %s records\n') % version) | |
2680 | if version == 1: |
|
2690 | if version == 1: | |
2681 | records = v1records |
|
2691 | records = v1records | |
2682 | else: |
|
2692 | else: | |
2683 | records = v2records |
|
2693 | records = v2records | |
2684 |
|
2694 | |||
2685 | for rtype, record in records: |
|
2695 | for rtype, record in records: | |
2686 | # pretty print some record types |
|
2696 | # pretty print some record types | |
2687 | if rtype == 'L': |
|
2697 | if rtype == 'L': | |
2688 | ui.write(('local: %s\n') % record) |
|
2698 | ui.write(('local: %s\n') % record) | |
2689 | elif rtype == 'O': |
|
2699 | elif rtype == 'O': | |
2690 | ui.write(('other: %s\n') % record) |
|
2700 | ui.write(('other: %s\n') % record) | |
2691 | elif rtype == 'm': |
|
2701 | elif rtype == 'm': | |
2692 | driver, mdstate = record.split('\0', 1) |
|
2702 | driver, mdstate = record.split('\0', 1) | |
2693 | ui.write(('merge driver: %s (state "%s")\n') |
|
2703 | ui.write(('merge driver: %s (state "%s")\n') | |
2694 | % (driver, mdstate)) |
|
2704 | % (driver, mdstate)) | |
2695 | elif rtype in 'FDC': |
|
2705 | elif rtype in 'FDC': | |
2696 | r = record.split('\0') |
|
2706 | r = record.split('\0') | |
2697 | f, state, hash, lfile, afile, anode, ofile = r[0:7] |
|
2707 | f, state, hash, lfile, afile, anode, ofile = r[0:7] | |
2698 | if version == 1: |
|
2708 | if version == 1: | |
2699 | onode = 'not stored in v1 format' |
|
2709 | onode = 'not stored in v1 format' | |
2700 | flags = r[7] |
|
2710 | flags = r[7] | |
2701 | else: |
|
2711 | else: | |
2702 | onode, flags = r[7:9] |
|
2712 | onode, flags = r[7:9] | |
2703 | ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') |
|
2713 | ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') | |
2704 | % (f, rtype, state, _hashornull(hash))) |
|
2714 | % (f, rtype, state, _hashornull(hash))) | |
2705 | ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) |
|
2715 | ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) | |
2706 | ui.write((' ancestor path: %s (node %s)\n') |
|
2716 | ui.write((' ancestor path: %s (node %s)\n') | |
2707 | % (afile, _hashornull(anode))) |
|
2717 | % (afile, _hashornull(anode))) | |
2708 | ui.write((' other path: %s (node %s)\n') |
|
2718 | ui.write((' other path: %s (node %s)\n') | |
2709 | % (ofile, _hashornull(onode))) |
|
2719 | % (ofile, _hashornull(onode))) | |
2710 | elif rtype == 'f': |
|
2720 | elif rtype == 'f': | |
2711 | filename, rawextras = record.split('\0', 1) |
|
2721 | filename, rawextras = record.split('\0', 1) | |
2712 | extras = rawextras.split('\0') |
|
2722 | extras = rawextras.split('\0') | |
2713 | i = 0 |
|
2723 | i = 0 | |
2714 | extrastrings = [] |
|
2724 | extrastrings = [] | |
2715 | while i < len(extras): |
|
2725 | while i < len(extras): | |
2716 | extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) |
|
2726 | extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) | |
2717 | i += 2 |
|
2727 | i += 2 | |
2718 |
|
2728 | |||
2719 | ui.write(('file extras: %s (%s)\n') |
|
2729 | ui.write(('file extras: %s (%s)\n') | |
2720 | % (filename, ', '.join(extrastrings))) |
|
2730 | % (filename, ', '.join(extrastrings))) | |
2721 | elif rtype == 'l': |
|
2731 | elif rtype == 'l': | |
2722 | labels = record.split('\0', 2) |
|
2732 | labels = record.split('\0', 2) | |
2723 | labels = [l for l in labels if len(l) > 0] |
|
2733 | labels = [l for l in labels if len(l) > 0] | |
2724 | ui.write(('labels:\n')) |
|
2734 | ui.write(('labels:\n')) | |
2725 | ui.write((' local: %s\n' % labels[0])) |
|
2735 | ui.write((' local: %s\n' % labels[0])) | |
2726 | ui.write((' other: %s\n' % labels[1])) |
|
2736 | ui.write((' other: %s\n' % labels[1])) | |
2727 | if len(labels) > 2: |
|
2737 | if len(labels) > 2: | |
2728 | ui.write((' base: %s\n' % labels[2])) |
|
2738 | ui.write((' base: %s\n' % labels[2])) | |
2729 | else: |
|
2739 | else: | |
2730 | ui.write(('unrecognized entry: %s\t%s\n') |
|
2740 | ui.write(('unrecognized entry: %s\t%s\n') | |
2731 | % (rtype, record.replace('\0', '\t'))) |
|
2741 | % (rtype, record.replace('\0', '\t'))) | |
2732 |
|
2742 | |||
2733 | # Avoid mergestate.read() since it may raise an exception for unsupported |
|
2743 | # Avoid mergestate.read() since it may raise an exception for unsupported | |
2734 | # merge state records. We shouldn't be doing this, but this is OK since this |
|
2744 | # merge state records. We shouldn't be doing this, but this is OK since this | |
2735 | # command is pretty low-level. |
|
2745 | # command is pretty low-level. | |
2736 | ms = mergemod.mergestate(repo) |
|
2746 | ms = mergemod.mergestate(repo) | |
2737 |
|
2747 | |||
2738 | # sort so that reasonable information is on top |
|
2748 | # sort so that reasonable information is on top | |
2739 | v1records = ms._readrecordsv1() |
|
2749 | v1records = ms._readrecordsv1() | |
2740 | v2records = ms._readrecordsv2() |
|
2750 | v2records = ms._readrecordsv2() | |
2741 | order = 'LOml' |
|
2751 | order = 'LOml' | |
2742 | def key(r): |
|
2752 | def key(r): | |
2743 | idx = order.find(r[0]) |
|
2753 | idx = order.find(r[0]) | |
2744 | if idx == -1: |
|
2754 | if idx == -1: | |
2745 | return (1, r[1]) |
|
2755 | return (1, r[1]) | |
2746 | else: |
|
2756 | else: | |
2747 | return (0, idx) |
|
2757 | return (0, idx) | |
2748 | v1records.sort(key=key) |
|
2758 | v1records.sort(key=key) | |
2749 | v2records.sort(key=key) |
|
2759 | v2records.sort(key=key) | |
2750 |
|
2760 | |||
2751 | if not v1records and not v2records: |
|
2761 | if not v1records and not v2records: | |
2752 | ui.write(('no merge state found\n')) |
|
2762 | ui.write(('no merge state found\n')) | |
2753 | elif not v2records: |
|
2763 | elif not v2records: | |
2754 | ui.note(('no version 2 merge state\n')) |
|
2764 | ui.note(('no version 2 merge state\n')) | |
2755 | printrecords(1) |
|
2765 | printrecords(1) | |
2756 | elif ms._v1v2match(v1records, v2records): |
|
2766 | elif ms._v1v2match(v1records, v2records): | |
2757 | ui.note(('v1 and v2 states match: using v2\n')) |
|
2767 | ui.note(('v1 and v2 states match: using v2\n')) | |
2758 | printrecords(2) |
|
2768 | printrecords(2) | |
2759 | else: |
|
2769 | else: | |
2760 | ui.note(('v1 and v2 states mismatch: using v1\n')) |
|
2770 | ui.note(('v1 and v2 states mismatch: using v1\n')) | |
2761 | printrecords(1) |
|
2771 | printrecords(1) | |
2762 | if ui.verbose: |
|
2772 | if ui.verbose: | |
2763 | printrecords(2) |
|
2773 | printrecords(2) | |
2764 |
|
2774 | |||
2765 | @command('debugnamecomplete', [], _('NAME...')) |
|
2775 | @command('debugnamecomplete', [], _('NAME...')) | |
2766 | def debugnamecomplete(ui, repo, *args): |
|
2776 | def debugnamecomplete(ui, repo, *args): | |
2767 | '''complete "names" - tags, open branch names, bookmark names''' |
|
2777 | '''complete "names" - tags, open branch names, bookmark names''' | |
2768 |
|
2778 | |||
2769 | names = set() |
|
2779 | names = set() | |
2770 | # since we previously only listed open branches, we will handle that |
|
2780 | # since we previously only listed open branches, we will handle that | |
2771 | # specially (after this for loop) |
|
2781 | # specially (after this for loop) | |
2772 | for name, ns in repo.names.iteritems(): |
|
2782 | for name, ns in repo.names.iteritems(): | |
2773 | if name != 'branches': |
|
2783 | if name != 'branches': | |
2774 | names.update(ns.listnames(repo)) |
|
2784 | names.update(ns.listnames(repo)) | |
2775 | names.update(tag for (tag, heads, tip, closed) |
|
2785 | names.update(tag for (tag, heads, tip, closed) | |
2776 | in repo.branchmap().iterbranches() if not closed) |
|
2786 | in repo.branchmap().iterbranches() if not closed) | |
2777 | completions = set() |
|
2787 | completions = set() | |
2778 | if not args: |
|
2788 | if not args: | |
2779 | args = [''] |
|
2789 | args = [''] | |
2780 | for a in args: |
|
2790 | for a in args: | |
2781 | completions.update(n for n in names if n.startswith(a)) |
|
2791 | completions.update(n for n in names if n.startswith(a)) | |
2782 | ui.write('\n'.join(sorted(completions))) |
|
2792 | ui.write('\n'.join(sorted(completions))) | |
2783 | ui.write('\n') |
|
2793 | ui.write('\n') | |
2784 |
|
2794 | |||
2785 | @command('debuglocks', |
|
2795 | @command('debuglocks', | |
2786 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
|
2796 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), | |
2787 | ('W', 'force-wlock', None, |
|
2797 | ('W', 'force-wlock', None, | |
2788 | _('free the working state lock (DANGEROUS)'))], |
|
2798 | _('free the working state lock (DANGEROUS)'))], | |
2789 | _('[OPTION]...')) |
|
2799 | _('[OPTION]...')) | |
2790 | def debuglocks(ui, repo, **opts): |
|
2800 | def debuglocks(ui, repo, **opts): | |
2791 | """show or modify state of locks |
|
2801 | """show or modify state of locks | |
2792 |
|
2802 | |||
2793 | By default, this command will show which locks are held. This |
|
2803 | By default, this command will show which locks are held. This | |
2794 | includes the user and process holding the lock, the amount of time |
|
2804 | includes the user and process holding the lock, the amount of time | |
2795 | the lock has been held, and the machine name where the process is |
|
2805 | the lock has been held, and the machine name where the process is | |
2796 | running if it's not local. |
|
2806 | running if it's not local. | |
2797 |
|
2807 | |||
2798 | Locks protect the integrity of Mercurial's data, so should be |
|
2808 | Locks protect the integrity of Mercurial's data, so should be | |
2799 | treated with care. System crashes or other interruptions may cause |
|
2809 | treated with care. System crashes or other interruptions may cause | |
2800 | locks to not be properly released, though Mercurial will usually |
|
2810 | locks to not be properly released, though Mercurial will usually | |
2801 | detect and remove such stale locks automatically. |
|
2811 | detect and remove such stale locks automatically. | |
2802 |
|
2812 | |||
2803 | However, detecting stale locks may not always be possible (for |
|
2813 | However, detecting stale locks may not always be possible (for | |
2804 | instance, on a shared filesystem). Removing locks may also be |
|
2814 | instance, on a shared filesystem). Removing locks may also be | |
2805 | blocked by filesystem permissions. |
|
2815 | blocked by filesystem permissions. | |
2806 |
|
2816 | |||
2807 | Returns 0 if no locks are held. |
|
2817 | Returns 0 if no locks are held. | |
2808 |
|
2818 | |||
2809 | """ |
|
2819 | """ | |
2810 |
|
2820 | |||
2811 | if opts.get('force_lock'): |
|
2821 | if opts.get('force_lock'): | |
2812 | repo.svfs.unlink('lock') |
|
2822 | repo.svfs.unlink('lock') | |
2813 | if opts.get('force_wlock'): |
|
2823 | if opts.get('force_wlock'): | |
2814 | repo.vfs.unlink('wlock') |
|
2824 | repo.vfs.unlink('wlock') | |
2815 | if opts.get('force_lock') or opts.get('force_lock'): |
|
2825 | if opts.get('force_lock') or opts.get('force_lock'): | |
2816 | return 0 |
|
2826 | return 0 | |
2817 |
|
2827 | |||
2818 | now = time.time() |
|
2828 | now = time.time() | |
2819 | held = 0 |
|
2829 | held = 0 | |
2820 |
|
2830 | |||
2821 | def report(vfs, name, method): |
|
2831 | def report(vfs, name, method): | |
2822 | # this causes stale locks to get reaped for more accurate reporting |
|
2832 | # this causes stale locks to get reaped for more accurate reporting | |
2823 | try: |
|
2833 | try: | |
2824 | l = method(False) |
|
2834 | l = method(False) | |
2825 | except error.LockHeld: |
|
2835 | except error.LockHeld: | |
2826 | l = None |
|
2836 | l = None | |
2827 |
|
2837 | |||
2828 | if l: |
|
2838 | if l: | |
2829 | l.release() |
|
2839 | l.release() | |
2830 | else: |
|
2840 | else: | |
2831 | try: |
|
2841 | try: | |
2832 | stat = vfs.lstat(name) |
|
2842 | stat = vfs.lstat(name) | |
2833 | age = now - stat.st_mtime |
|
2843 | age = now - stat.st_mtime | |
2834 | user = util.username(stat.st_uid) |
|
2844 | user = util.username(stat.st_uid) | |
2835 | locker = vfs.readlock(name) |
|
2845 | locker = vfs.readlock(name) | |
2836 | if ":" in locker: |
|
2846 | if ":" in locker: | |
2837 | host, pid = locker.split(':') |
|
2847 | host, pid = locker.split(':') | |
2838 | if host == socket.gethostname(): |
|
2848 | if host == socket.gethostname(): | |
2839 | locker = 'user %s, process %s' % (user, pid) |
|
2849 | locker = 'user %s, process %s' % (user, pid) | |
2840 | else: |
|
2850 | else: | |
2841 | locker = 'user %s, process %s, host %s' \ |
|
2851 | locker = 'user %s, process %s, host %s' \ | |
2842 | % (user, pid, host) |
|
2852 | % (user, pid, host) | |
2843 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
|
2853 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) | |
2844 | return 1 |
|
2854 | return 1 | |
2845 | except OSError as e: |
|
2855 | except OSError as e: | |
2846 | if e.errno != errno.ENOENT: |
|
2856 | if e.errno != errno.ENOENT: | |
2847 | raise |
|
2857 | raise | |
2848 |
|
2858 | |||
2849 | ui.write(("%-6s free\n") % (name + ":")) |
|
2859 | ui.write(("%-6s free\n") % (name + ":")) | |
2850 | return 0 |
|
2860 | return 0 | |
2851 |
|
2861 | |||
2852 | held += report(repo.svfs, "lock", repo.lock) |
|
2862 | held += report(repo.svfs, "lock", repo.lock) | |
2853 | held += report(repo.vfs, "wlock", repo.wlock) |
|
2863 | held += report(repo.vfs, "wlock", repo.wlock) | |
2854 |
|
2864 | |||
2855 | return held |
|
2865 | return held | |
2856 |
|
2866 | |||
2857 | @command('debugobsolete', |
|
2867 | @command('debugobsolete', | |
2858 | [('', 'flags', 0, _('markers flag')), |
|
2868 | [('', 'flags', 0, _('markers flag')), | |
2859 | ('', 'record-parents', False, |
|
2869 | ('', 'record-parents', False, | |
2860 | _('record parent information for the precursor')), |
|
2870 | _('record parent information for the precursor')), | |
2861 | ('r', 'rev', [], _('display markers relevant to REV')), |
|
2871 | ('r', 'rev', [], _('display markers relevant to REV')), | |
2862 | ('', 'index', False, _('display index of the marker')), |
|
2872 | ('', 'index', False, _('display index of the marker')), | |
2863 | ('', 'delete', [], _('delete markers specified by indices')), |
|
2873 | ('', 'delete', [], _('delete markers specified by indices')), | |
2864 | ] + commitopts2 + formatteropts, |
|
2874 | ] + commitopts2 + formatteropts, | |
2865 | _('[OBSOLETED [REPLACEMENT ...]]')) |
|
2875 | _('[OBSOLETED [REPLACEMENT ...]]')) | |
2866 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
|
2876 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): | |
2867 | """create arbitrary obsolete marker |
|
2877 | """create arbitrary obsolete marker | |
2868 |
|
2878 | |||
2869 | With no arguments, displays the list of obsolescence markers.""" |
|
2879 | With no arguments, displays the list of obsolescence markers.""" | |
2870 |
|
2880 | |||
2871 | def parsenodeid(s): |
|
2881 | def parsenodeid(s): | |
2872 | try: |
|
2882 | try: | |
2873 | # We do not use revsingle/revrange functions here to accept |
|
2883 | # We do not use revsingle/revrange functions here to accept | |
2874 | # arbitrary node identifiers, possibly not present in the |
|
2884 | # arbitrary node identifiers, possibly not present in the | |
2875 | # local repository. |
|
2885 | # local repository. | |
2876 | n = bin(s) |
|
2886 | n = bin(s) | |
2877 | if len(n) != len(nullid): |
|
2887 | if len(n) != len(nullid): | |
2878 | raise TypeError() |
|
2888 | raise TypeError() | |
2879 | return n |
|
2889 | return n | |
2880 | except TypeError: |
|
2890 | except TypeError: | |
2881 | raise error.Abort('changeset references must be full hexadecimal ' |
|
2891 | raise error.Abort('changeset references must be full hexadecimal ' | |
2882 | 'node identifiers') |
|
2892 | 'node identifiers') | |
2883 |
|
2893 | |||
2884 | if opts.get('delete'): |
|
2894 | if opts.get('delete'): | |
2885 | indices = [] |
|
2895 | indices = [] | |
2886 | for v in opts.get('delete'): |
|
2896 | for v in opts.get('delete'): | |
2887 | try: |
|
2897 | try: | |
2888 | indices.append(int(v)) |
|
2898 | indices.append(int(v)) | |
2889 | except ValueError: |
|
2899 | except ValueError: | |
2890 | raise error.Abort(_('invalid index value: %r') % v, |
|
2900 | raise error.Abort(_('invalid index value: %r') % v, | |
2891 | hint=_('use integers for indices')) |
|
2901 | hint=_('use integers for indices')) | |
2892 |
|
2902 | |||
2893 | if repo.currenttransaction(): |
|
2903 | if repo.currenttransaction(): | |
2894 | raise error.Abort(_('cannot delete obsmarkers in the middle ' |
|
2904 | raise error.Abort(_('cannot delete obsmarkers in the middle ' | |
2895 | 'of transaction.')) |
|
2905 | 'of transaction.')) | |
2896 |
|
2906 | |||
2897 | with repo.lock(): |
|
2907 | with repo.lock(): | |
2898 | n = repair.deleteobsmarkers(repo.obsstore, indices) |
|
2908 | n = repair.deleteobsmarkers(repo.obsstore, indices) | |
2899 | ui.write(_('deleted %i obsolescence markers\n') % n) |
|
2909 | ui.write(_('deleted %i obsolescence markers\n') % n) | |
2900 |
|
2910 | |||
2901 | return |
|
2911 | return | |
2902 |
|
2912 | |||
2903 | if precursor is not None: |
|
2913 | if precursor is not None: | |
2904 | if opts['rev']: |
|
2914 | if opts['rev']: | |
2905 | raise error.Abort('cannot select revision when creating marker') |
|
2915 | raise error.Abort('cannot select revision when creating marker') | |
2906 | metadata = {} |
|
2916 | metadata = {} | |
2907 | metadata['user'] = opts['user'] or ui.username() |
|
2917 | metadata['user'] = opts['user'] or ui.username() | |
2908 | succs = tuple(parsenodeid(succ) for succ in successors) |
|
2918 | succs = tuple(parsenodeid(succ) for succ in successors) | |
2909 | l = repo.lock() |
|
2919 | l = repo.lock() | |
2910 | try: |
|
2920 | try: | |
2911 | tr = repo.transaction('debugobsolete') |
|
2921 | tr = repo.transaction('debugobsolete') | |
2912 | try: |
|
2922 | try: | |
2913 | date = opts.get('date') |
|
2923 | date = opts.get('date') | |
2914 | if date: |
|
2924 | if date: | |
2915 | date = util.parsedate(date) |
|
2925 | date = util.parsedate(date) | |
2916 | else: |
|
2926 | else: | |
2917 | date = None |
|
2927 | date = None | |
2918 | prec = parsenodeid(precursor) |
|
2928 | prec = parsenodeid(precursor) | |
2919 | parents = None |
|
2929 | parents = None | |
2920 | if opts['record_parents']: |
|
2930 | if opts['record_parents']: | |
2921 | if prec not in repo.unfiltered(): |
|
2931 | if prec not in repo.unfiltered(): | |
2922 | raise error.Abort('cannot used --record-parents on ' |
|
2932 | raise error.Abort('cannot used --record-parents on ' | |
2923 | 'unknown changesets') |
|
2933 | 'unknown changesets') | |
2924 | parents = repo.unfiltered()[prec].parents() |
|
2934 | parents = repo.unfiltered()[prec].parents() | |
2925 | parents = tuple(p.node() for p in parents) |
|
2935 | parents = tuple(p.node() for p in parents) | |
2926 | repo.obsstore.create(tr, prec, succs, opts['flags'], |
|
2936 | repo.obsstore.create(tr, prec, succs, opts['flags'], | |
2927 | parents=parents, date=date, |
|
2937 | parents=parents, date=date, | |
2928 | metadata=metadata) |
|
2938 | metadata=metadata) | |
2929 | tr.close() |
|
2939 | tr.close() | |
2930 | except ValueError as exc: |
|
2940 | except ValueError as exc: | |
2931 | raise error.Abort(_('bad obsmarker input: %s') % exc) |
|
2941 | raise error.Abort(_('bad obsmarker input: %s') % exc) | |
2932 | finally: |
|
2942 | finally: | |
2933 | tr.release() |
|
2943 | tr.release() | |
2934 | finally: |
|
2944 | finally: | |
2935 | l.release() |
|
2945 | l.release() | |
2936 | else: |
|
2946 | else: | |
2937 | if opts['rev']: |
|
2947 | if opts['rev']: | |
2938 | revs = scmutil.revrange(repo, opts['rev']) |
|
2948 | revs = scmutil.revrange(repo, opts['rev']) | |
2939 | nodes = [repo[r].node() for r in revs] |
|
2949 | nodes = [repo[r].node() for r in revs] | |
2940 | markers = list(obsolete.getmarkers(repo, nodes=nodes)) |
|
2950 | markers = list(obsolete.getmarkers(repo, nodes=nodes)) | |
2941 | markers.sort(key=lambda x: x._data) |
|
2951 | markers.sort(key=lambda x: x._data) | |
2942 | else: |
|
2952 | else: | |
2943 | markers = obsolete.getmarkers(repo) |
|
2953 | markers = obsolete.getmarkers(repo) | |
2944 |
|
2954 | |||
2945 | markerstoiter = markers |
|
2955 | markerstoiter = markers | |
2946 | isrelevant = lambda m: True |
|
2956 | isrelevant = lambda m: True | |
2947 | if opts.get('rev') and opts.get('index'): |
|
2957 | if opts.get('rev') and opts.get('index'): | |
2948 | markerstoiter = obsolete.getmarkers(repo) |
|
2958 | markerstoiter = obsolete.getmarkers(repo) | |
2949 | markerset = set(markers) |
|
2959 | markerset = set(markers) | |
2950 | isrelevant = lambda m: m in markerset |
|
2960 | isrelevant = lambda m: m in markerset | |
2951 |
|
2961 | |||
2952 | fm = ui.formatter('debugobsolete', opts) |
|
2962 | fm = ui.formatter('debugobsolete', opts) | |
2953 | for i, m in enumerate(markerstoiter): |
|
2963 | for i, m in enumerate(markerstoiter): | |
2954 | if not isrelevant(m): |
|
2964 | if not isrelevant(m): | |
2955 | # marker can be irrelevant when we're iterating over a set |
|
2965 | # marker can be irrelevant when we're iterating over a set | |
2956 | # of markers (markerstoiter) which is bigger than the set |
|
2966 | # of markers (markerstoiter) which is bigger than the set | |
2957 | # of markers we want to display (markers) |
|
2967 | # of markers we want to display (markers) | |
2958 | # this can happen if both --index and --rev options are |
|
2968 | # this can happen if both --index and --rev options are | |
2959 | # provided and thus we need to iterate over all of the markers |
|
2969 | # provided and thus we need to iterate over all of the markers | |
2960 | # to get the correct indices, but only display the ones that |
|
2970 | # to get the correct indices, but only display the ones that | |
2961 | # are relevant to --rev value |
|
2971 | # are relevant to --rev value | |
2962 | continue |
|
2972 | continue | |
2963 | fm.startitem() |
|
2973 | fm.startitem() | |
2964 | ind = i if opts.get('index') else None |
|
2974 | ind = i if opts.get('index') else None | |
2965 | cmdutil.showmarker(fm, m, index=ind) |
|
2975 | cmdutil.showmarker(fm, m, index=ind) | |
2966 | fm.end() |
|
2976 | fm.end() | |
2967 |
|
2977 | |||
2968 | @command('debugpathcomplete', |
|
2978 | @command('debugpathcomplete', | |
2969 | [('f', 'full', None, _('complete an entire path')), |
|
2979 | [('f', 'full', None, _('complete an entire path')), | |
2970 | ('n', 'normal', None, _('show only normal files')), |
|
2980 | ('n', 'normal', None, _('show only normal files')), | |
2971 | ('a', 'added', None, _('show only added files')), |
|
2981 | ('a', 'added', None, _('show only added files')), | |
2972 | ('r', 'removed', None, _('show only removed files'))], |
|
2982 | ('r', 'removed', None, _('show only removed files'))], | |
2973 | _('FILESPEC...')) |
|
2983 | _('FILESPEC...')) | |
2974 | def debugpathcomplete(ui, repo, *specs, **opts): |
|
2984 | def debugpathcomplete(ui, repo, *specs, **opts): | |
2975 | '''complete part or all of a tracked path |
|
2985 | '''complete part or all of a tracked path | |
2976 |
|
2986 | |||
2977 | This command supports shells that offer path name completion. It |
|
2987 | This command supports shells that offer path name completion. It | |
2978 | currently completes only files already known to the dirstate. |
|
2988 | currently completes only files already known to the dirstate. | |
2979 |
|
2989 | |||
2980 | Completion extends only to the next path segment unless |
|
2990 | Completion extends only to the next path segment unless | |
2981 | --full is specified, in which case entire paths are used.''' |
|
2991 | --full is specified, in which case entire paths are used.''' | |
2982 |
|
2992 | |||
2983 | def complete(path, acceptable): |
|
2993 | def complete(path, acceptable): | |
2984 | dirstate = repo.dirstate |
|
2994 | dirstate = repo.dirstate | |
2985 | spec = os.path.normpath(os.path.join(os.getcwd(), path)) |
|
2995 | spec = os.path.normpath(os.path.join(os.getcwd(), path)) | |
2986 | rootdir = repo.root + os.sep |
|
2996 | rootdir = repo.root + os.sep | |
2987 | if spec != repo.root and not spec.startswith(rootdir): |
|
2997 | if spec != repo.root and not spec.startswith(rootdir): | |
2988 | return [], [] |
|
2998 | return [], [] | |
2989 | if os.path.isdir(spec): |
|
2999 | if os.path.isdir(spec): | |
2990 | spec += '/' |
|
3000 | spec += '/' | |
2991 | spec = spec[len(rootdir):] |
|
3001 | spec = spec[len(rootdir):] | |
2992 | fixpaths = pycompat.ossep != '/' |
|
3002 | fixpaths = pycompat.ossep != '/' | |
2993 | if fixpaths: |
|
3003 | if fixpaths: | |
2994 | spec = spec.replace(os.sep, '/') |
|
3004 | spec = spec.replace(os.sep, '/') | |
2995 | speclen = len(spec) |
|
3005 | speclen = len(spec) | |
2996 | fullpaths = opts['full'] |
|
3006 | fullpaths = opts['full'] | |
2997 | files, dirs = set(), set() |
|
3007 | files, dirs = set(), set() | |
2998 | adddir, addfile = dirs.add, files.add |
|
3008 | adddir, addfile = dirs.add, files.add | |
2999 | for f, st in dirstate.iteritems(): |
|
3009 | for f, st in dirstate.iteritems(): | |
3000 | if f.startswith(spec) and st[0] in acceptable: |
|
3010 | if f.startswith(spec) and st[0] in acceptable: | |
3001 | if fixpaths: |
|
3011 | if fixpaths: | |
3002 | f = f.replace('/', os.sep) |
|
3012 | f = f.replace('/', os.sep) | |
3003 | if fullpaths: |
|
3013 | if fullpaths: | |
3004 | addfile(f) |
|
3014 | addfile(f) | |
3005 | continue |
|
3015 | continue | |
3006 | s = f.find(os.sep, speclen) |
|
3016 | s = f.find(os.sep, speclen) | |
3007 | if s >= 0: |
|
3017 | if s >= 0: | |
3008 | adddir(f[:s]) |
|
3018 | adddir(f[:s]) | |
3009 | else: |
|
3019 | else: | |
3010 | addfile(f) |
|
3020 | addfile(f) | |
3011 | return files, dirs |
|
3021 | return files, dirs | |
3012 |
|
3022 | |||
3013 | acceptable = '' |
|
3023 | acceptable = '' | |
3014 | if opts['normal']: |
|
3024 | if opts['normal']: | |
3015 | acceptable += 'nm' |
|
3025 | acceptable += 'nm' | |
3016 | if opts['added']: |
|
3026 | if opts['added']: | |
3017 | acceptable += 'a' |
|
3027 | acceptable += 'a' | |
3018 | if opts['removed']: |
|
3028 | if opts['removed']: | |
3019 | acceptable += 'r' |
|
3029 | acceptable += 'r' | |
3020 | cwd = repo.getcwd() |
|
3030 | cwd = repo.getcwd() | |
3021 | if not specs: |
|
3031 | if not specs: | |
3022 | specs = ['.'] |
|
3032 | specs = ['.'] | |
3023 |
|
3033 | |||
3024 | files, dirs = set(), set() |
|
3034 | files, dirs = set(), set() | |
3025 | for spec in specs: |
|
3035 | for spec in specs: | |
3026 | f, d = complete(spec, acceptable or 'nmar') |
|
3036 | f, d = complete(spec, acceptable or 'nmar') | |
3027 | files.update(f) |
|
3037 | files.update(f) | |
3028 | dirs.update(d) |
|
3038 | dirs.update(d) | |
3029 | files.update(dirs) |
|
3039 | files.update(dirs) | |
3030 | ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
|
3040 | ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) | |
3031 | ui.write('\n') |
|
3041 | ui.write('\n') | |
3032 |
|
3042 | |||
3033 | @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
|
3043 | @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) | |
3034 | def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
|
3044 | def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): | |
3035 | '''access the pushkey key/value protocol |
|
3045 | '''access the pushkey key/value protocol | |
3036 |
|
3046 | |||
3037 | With two args, list the keys in the given namespace. |
|
3047 | With two args, list the keys in the given namespace. | |
3038 |
|
3048 | |||
3039 | With five args, set a key to new if it currently is set to old. |
|
3049 | With five args, set a key to new if it currently is set to old. | |
3040 | Reports success or failure. |
|
3050 | Reports success or failure. | |
3041 | ''' |
|
3051 | ''' | |
3042 |
|
3052 | |||
3043 | target = hg.peer(ui, {}, repopath) |
|
3053 | target = hg.peer(ui, {}, repopath) | |
3044 | if keyinfo: |
|
3054 | if keyinfo: | |
3045 | key, old, new = keyinfo |
|
3055 | key, old, new = keyinfo | |
3046 | r = target.pushkey(namespace, key, old, new) |
|
3056 | r = target.pushkey(namespace, key, old, new) | |
3047 | ui.status(str(r) + '\n') |
|
3057 | ui.status(str(r) + '\n') | |
3048 | return not r |
|
3058 | return not r | |
3049 | else: |
|
3059 | else: | |
3050 | for k, v in sorted(target.listkeys(namespace).iteritems()): |
|
3060 | for k, v in sorted(target.listkeys(namespace).iteritems()): | |
3051 | ui.write("%s\t%s\n" % (k.encode('string-escape'), |
|
3061 | ui.write("%s\t%s\n" % (k.encode('string-escape'), | |
3052 | v.encode('string-escape'))) |
|
3062 | v.encode('string-escape'))) | |
3053 |
|
3063 | |||
3054 | @command('debugpvec', [], _('A B')) |
|
3064 | @command('debugpvec', [], _('A B')) | |
3055 | def debugpvec(ui, repo, a, b=None): |
|
3065 | def debugpvec(ui, repo, a, b=None): | |
3056 | ca = scmutil.revsingle(repo, a) |
|
3066 | ca = scmutil.revsingle(repo, a) | |
3057 | cb = scmutil.revsingle(repo, b) |
|
3067 | cb = scmutil.revsingle(repo, b) | |
3058 | pa = pvec.ctxpvec(ca) |
|
3068 | pa = pvec.ctxpvec(ca) | |
3059 | pb = pvec.ctxpvec(cb) |
|
3069 | pb = pvec.ctxpvec(cb) | |
3060 | if pa == pb: |
|
3070 | if pa == pb: | |
3061 | rel = "=" |
|
3071 | rel = "=" | |
3062 | elif pa > pb: |
|
3072 | elif pa > pb: | |
3063 | rel = ">" |
|
3073 | rel = ">" | |
3064 | elif pa < pb: |
|
3074 | elif pa < pb: | |
3065 | rel = "<" |
|
3075 | rel = "<" | |
3066 | elif pa | pb: |
|
3076 | elif pa | pb: | |
3067 | rel = "|" |
|
3077 | rel = "|" | |
3068 | ui.write(_("a: %s\n") % pa) |
|
3078 | ui.write(_("a: %s\n") % pa) | |
3069 | ui.write(_("b: %s\n") % pb) |
|
3079 | ui.write(_("b: %s\n") % pb) | |
3070 | ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
|
3080 | ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) | |
3071 | ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % |
|
3081 | ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % | |
3072 | (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), |
|
3082 | (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), | |
3073 | pa.distance(pb), rel)) |
|
3083 | pa.distance(pb), rel)) | |
3074 |
|
3084 | |||
3075 | @command('debugrebuilddirstate|debugrebuildstate', |
|
3085 | @command('debugrebuilddirstate|debugrebuildstate', | |
3076 | [('r', 'rev', '', _('revision to rebuild to'), _('REV')), |
|
3086 | [('r', 'rev', '', _('revision to rebuild to'), _('REV')), | |
3077 | ('', 'minimal', None, _('only rebuild files that are inconsistent with ' |
|
3087 | ('', 'minimal', None, _('only rebuild files that are inconsistent with ' | |
3078 | 'the working copy parent')), |
|
3088 | 'the working copy parent')), | |
3079 | ], |
|
3089 | ], | |
3080 | _('[-r REV]')) |
|
3090 | _('[-r REV]')) | |
3081 | def debugrebuilddirstate(ui, repo, rev, **opts): |
|
3091 | def debugrebuilddirstate(ui, repo, rev, **opts): | |
3082 | """rebuild the dirstate as it would look like for the given revision |
|
3092 | """rebuild the dirstate as it would look like for the given revision | |
3083 |
|
3093 | |||
3084 | If no revision is specified the first current parent will be used. |
|
3094 | If no revision is specified the first current parent will be used. | |
3085 |
|
3095 | |||
3086 | The dirstate will be set to the files of the given revision. |
|
3096 | The dirstate will be set to the files of the given revision. | |
3087 | The actual working directory content or existing dirstate |
|
3097 | The actual working directory content or existing dirstate | |
3088 | information such as adds or removes is not considered. |
|
3098 | information such as adds or removes is not considered. | |
3089 |
|
3099 | |||
3090 | ``minimal`` will only rebuild the dirstate status for files that claim to be |
|
3100 | ``minimal`` will only rebuild the dirstate status for files that claim to be | |
3091 | tracked but are not in the parent manifest, or that exist in the parent |
|
3101 | tracked but are not in the parent manifest, or that exist in the parent | |
3092 | manifest but are not in the dirstate. It will not change adds, removes, or |
|
3102 | manifest but are not in the dirstate. It will not change adds, removes, or | |
3093 | modified files that are in the working copy parent. |
|
3103 | modified files that are in the working copy parent. | |
3094 |
|
3104 | |||
3095 | One use of this command is to make the next :hg:`status` invocation |
|
3105 | One use of this command is to make the next :hg:`status` invocation | |
3096 | check the actual file content. |
|
3106 | check the actual file content. | |
3097 | """ |
|
3107 | """ | |
3098 | ctx = scmutil.revsingle(repo, rev) |
|
3108 | ctx = scmutil.revsingle(repo, rev) | |
3099 | with repo.wlock(): |
|
3109 | with repo.wlock(): | |
3100 | dirstate = repo.dirstate |
|
3110 | dirstate = repo.dirstate | |
3101 | changedfiles = None |
|
3111 | changedfiles = None | |
3102 | # See command doc for what minimal does. |
|
3112 | # See command doc for what minimal does. | |
3103 | if opts.get('minimal'): |
|
3113 | if opts.get('minimal'): | |
3104 | manifestfiles = set(ctx.manifest().keys()) |
|
3114 | manifestfiles = set(ctx.manifest().keys()) | |
3105 | dirstatefiles = set(dirstate) |
|
3115 | dirstatefiles = set(dirstate) | |
3106 | manifestonly = manifestfiles - dirstatefiles |
|
3116 | manifestonly = manifestfiles - dirstatefiles | |
3107 | dsonly = dirstatefiles - manifestfiles |
|
3117 | dsonly = dirstatefiles - manifestfiles | |
3108 | dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
|
3118 | dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') | |
3109 | changedfiles = manifestonly | dsnotadded |
|
3119 | changedfiles = manifestonly | dsnotadded | |
3110 |
|
3120 | |||
3111 | dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) |
|
3121 | dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) | |
3112 |
|
3122 | |||
3113 | @command('debugrebuildfncache', [], '') |
|
3123 | @command('debugrebuildfncache', [], '') | |
3114 | def debugrebuildfncache(ui, repo): |
|
3124 | def debugrebuildfncache(ui, repo): | |
3115 | """rebuild the fncache file""" |
|
3125 | """rebuild the fncache file""" | |
3116 | repair.rebuildfncache(ui, repo) |
|
3126 | repair.rebuildfncache(ui, repo) | |
3117 |
|
3127 | |||
3118 | @command('debugrename', |
|
3128 | @command('debugrename', | |
3119 | [('r', 'rev', '', _('revision to debug'), _('REV'))], |
|
3129 | [('r', 'rev', '', _('revision to debug'), _('REV'))], | |
3120 | _('[-r REV] FILE')) |
|
3130 | _('[-r REV] FILE')) | |
3121 | def debugrename(ui, repo, file1, *pats, **opts): |
|
3131 | def debugrename(ui, repo, file1, *pats, **opts): | |
3122 | """dump rename information""" |
|
3132 | """dump rename information""" | |
3123 |
|
3133 | |||
3124 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
3134 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
3125 | m = scmutil.match(ctx, (file1,) + pats, opts) |
|
3135 | m = scmutil.match(ctx, (file1,) + pats, opts) | |
3126 | for abs in ctx.walk(m): |
|
3136 | for abs in ctx.walk(m): | |
3127 | fctx = ctx[abs] |
|
3137 | fctx = ctx[abs] | |
3128 | o = fctx.filelog().renamed(fctx.filenode()) |
|
3138 | o = fctx.filelog().renamed(fctx.filenode()) | |
3129 | rel = m.rel(abs) |
|
3139 | rel = m.rel(abs) | |
3130 | if o: |
|
3140 | if o: | |
3131 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
|
3141 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | |
3132 | else: |
|
3142 | else: | |
3133 | ui.write(_("%s not renamed\n") % rel) |
|
3143 | ui.write(_("%s not renamed\n") % rel) | |
3134 |
|
3144 | |||
3135 | @command('debugrevlog', debugrevlogopts + |
|
3145 | @command('debugrevlog', debugrevlogopts + | |
3136 | [('d', 'dump', False, _('dump index data'))], |
|
3146 | [('d', 'dump', False, _('dump index data'))], | |
3137 | _('-c|-m|FILE'), |
|
3147 | _('-c|-m|FILE'), | |
3138 | optionalrepo=True) |
|
3148 | optionalrepo=True) | |
3139 | def debugrevlog(ui, repo, file_=None, **opts): |
|
3149 | def debugrevlog(ui, repo, file_=None, **opts): | |
3140 | """show data and statistics about a revlog""" |
|
3150 | """show data and statistics about a revlog""" | |
3141 | r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
|
3151 | r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) | |
3142 |
|
3152 | |||
3143 | if opts.get("dump"): |
|
3153 | if opts.get("dump"): | |
3144 | numrevs = len(r) |
|
3154 | numrevs = len(r) | |
3145 | ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
|
3155 | ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" | |
3146 | " rawsize totalsize compression heads chainlen\n")) |
|
3156 | " rawsize totalsize compression heads chainlen\n")) | |
3147 | ts = 0 |
|
3157 | ts = 0 | |
3148 | heads = set() |
|
3158 | heads = set() | |
3149 |
|
3159 | |||
3150 | for rev in xrange(numrevs): |
|
3160 | for rev in xrange(numrevs): | |
3151 | dbase = r.deltaparent(rev) |
|
3161 | dbase = r.deltaparent(rev) | |
3152 | if dbase == -1: |
|
3162 | if dbase == -1: | |
3153 | dbase = rev |
|
3163 | dbase = rev | |
3154 | cbase = r.chainbase(rev) |
|
3164 | cbase = r.chainbase(rev) | |
3155 | clen = r.chainlen(rev) |
|
3165 | clen = r.chainlen(rev) | |
3156 | p1, p2 = r.parentrevs(rev) |
|
3166 | p1, p2 = r.parentrevs(rev) | |
3157 | rs = r.rawsize(rev) |
|
3167 | rs = r.rawsize(rev) | |
3158 | ts = ts + rs |
|
3168 | ts = ts + rs | |
3159 | heads -= set(r.parentrevs(rev)) |
|
3169 | heads -= set(r.parentrevs(rev)) | |
3160 | heads.add(rev) |
|
3170 | heads.add(rev) | |
3161 | try: |
|
3171 | try: | |
3162 | compression = ts / r.end(rev) |
|
3172 | compression = ts / r.end(rev) | |
3163 | except ZeroDivisionError: |
|
3173 | except ZeroDivisionError: | |
3164 | compression = 0 |
|
3174 | compression = 0 | |
3165 | ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
|
3175 | ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " | |
3166 | "%11d %5d %8d\n" % |
|
3176 | "%11d %5d %8d\n" % | |
3167 | (rev, p1, p2, r.start(rev), r.end(rev), |
|
3177 | (rev, p1, p2, r.start(rev), r.end(rev), | |
3168 | r.start(dbase), r.start(cbase), |
|
3178 | r.start(dbase), r.start(cbase), | |
3169 | r.start(p1), r.start(p2), |
|
3179 | r.start(p1), r.start(p2), | |
3170 | rs, ts, compression, len(heads), clen)) |
|
3180 | rs, ts, compression, len(heads), clen)) | |
3171 | return 0 |
|
3181 | return 0 | |
3172 |
|
3182 | |||
3173 | v = r.version |
|
3183 | v = r.version | |
3174 | format = v & 0xFFFF |
|
3184 | format = v & 0xFFFF | |
3175 | flags = [] |
|
3185 | flags = [] | |
3176 | gdelta = False |
|
3186 | gdelta = False | |
3177 | if v & revlog.REVLOGNGINLINEDATA: |
|
3187 | if v & revlog.REVLOGNGINLINEDATA: | |
3178 | flags.append('inline') |
|
3188 | flags.append('inline') | |
3179 | if v & revlog.REVLOGGENERALDELTA: |
|
3189 | if v & revlog.REVLOGGENERALDELTA: | |
3180 | gdelta = True |
|
3190 | gdelta = True | |
3181 | flags.append('generaldelta') |
|
3191 | flags.append('generaldelta') | |
3182 | if not flags: |
|
3192 | if not flags: | |
3183 | flags = ['(none)'] |
|
3193 | flags = ['(none)'] | |
3184 |
|
3194 | |||
3185 | nummerges = 0 |
|
3195 | nummerges = 0 | |
3186 | numfull = 0 |
|
3196 | numfull = 0 | |
3187 | numprev = 0 |
|
3197 | numprev = 0 | |
3188 | nump1 = 0 |
|
3198 | nump1 = 0 | |
3189 | nump2 = 0 |
|
3199 | nump2 = 0 | |
3190 | numother = 0 |
|
3200 | numother = 0 | |
3191 | nump1prev = 0 |
|
3201 | nump1prev = 0 | |
3192 | nump2prev = 0 |
|
3202 | nump2prev = 0 | |
3193 | chainlengths = [] |
|
3203 | chainlengths = [] | |
3194 |
|
3204 | |||
3195 | datasize = [None, 0, 0] |
|
3205 | datasize = [None, 0, 0] | |
3196 | fullsize = [None, 0, 0] |
|
3206 | fullsize = [None, 0, 0] | |
3197 | deltasize = [None, 0, 0] |
|
3207 | deltasize = [None, 0, 0] | |
3198 | chunktypecounts = {} |
|
3208 | chunktypecounts = {} | |
3199 | chunktypesizes = {} |
|
3209 | chunktypesizes = {} | |
3200 |
|
3210 | |||
3201 | def addsize(size, l): |
|
3211 | def addsize(size, l): | |
3202 | if l[0] is None or size < l[0]: |
|
3212 | if l[0] is None or size < l[0]: | |
3203 | l[0] = size |
|
3213 | l[0] = size | |
3204 | if size > l[1]: |
|
3214 | if size > l[1]: | |
3205 | l[1] = size |
|
3215 | l[1] = size | |
3206 | l[2] += size |
|
3216 | l[2] += size | |
3207 |
|
3217 | |||
3208 | numrevs = len(r) |
|
3218 | numrevs = len(r) | |
3209 | for rev in xrange(numrevs): |
|
3219 | for rev in xrange(numrevs): | |
3210 | p1, p2 = r.parentrevs(rev) |
|
3220 | p1, p2 = r.parentrevs(rev) | |
3211 | delta = r.deltaparent(rev) |
|
3221 | delta = r.deltaparent(rev) | |
3212 | if format > 0: |
|
3222 | if format > 0: | |
3213 | addsize(r.rawsize(rev), datasize) |
|
3223 | addsize(r.rawsize(rev), datasize) | |
3214 | if p2 != nullrev: |
|
3224 | if p2 != nullrev: | |
3215 | nummerges += 1 |
|
3225 | nummerges += 1 | |
3216 | size = r.length(rev) |
|
3226 | size = r.length(rev) | |
3217 | if delta == nullrev: |
|
3227 | if delta == nullrev: | |
3218 | chainlengths.append(0) |
|
3228 | chainlengths.append(0) | |
3219 | numfull += 1 |
|
3229 | numfull += 1 | |
3220 | addsize(size, fullsize) |
|
3230 | addsize(size, fullsize) | |
3221 | else: |
|
3231 | else: | |
3222 | chainlengths.append(chainlengths[delta] + 1) |
|
3232 | chainlengths.append(chainlengths[delta] + 1) | |
3223 | addsize(size, deltasize) |
|
3233 | addsize(size, deltasize) | |
3224 | if delta == rev - 1: |
|
3234 | if delta == rev - 1: | |
3225 | numprev += 1 |
|
3235 | numprev += 1 | |
3226 | if delta == p1: |
|
3236 | if delta == p1: | |
3227 | nump1prev += 1 |
|
3237 | nump1prev += 1 | |
3228 | elif delta == p2: |
|
3238 | elif delta == p2: | |
3229 | nump2prev += 1 |
|
3239 | nump2prev += 1 | |
3230 | elif delta == p1: |
|
3240 | elif delta == p1: | |
3231 | nump1 += 1 |
|
3241 | nump1 += 1 | |
3232 | elif delta == p2: |
|
3242 | elif delta == p2: | |
3233 | nump2 += 1 |
|
3243 | nump2 += 1 | |
3234 | elif delta != nullrev: |
|
3244 | elif delta != nullrev: | |
3235 | numother += 1 |
|
3245 | numother += 1 | |
3236 |
|
3246 | |||
3237 | # Obtain data on the raw chunks in the revlog. |
|
3247 | # Obtain data on the raw chunks in the revlog. | |
3238 | chunk = r._chunkraw(rev, rev)[1] |
|
3248 | chunk = r._chunkraw(rev, rev)[1] | |
3239 | if chunk: |
|
3249 | if chunk: | |
3240 | chunktype = chunk[0] |
|
3250 | chunktype = chunk[0] | |
3241 | else: |
|
3251 | else: | |
3242 | chunktype = 'empty' |
|
3252 | chunktype = 'empty' | |
3243 |
|
3253 | |||
3244 | if chunktype not in chunktypecounts: |
|
3254 | if chunktype not in chunktypecounts: | |
3245 | chunktypecounts[chunktype] = 0 |
|
3255 | chunktypecounts[chunktype] = 0 | |
3246 | chunktypesizes[chunktype] = 0 |
|
3256 | chunktypesizes[chunktype] = 0 | |
3247 |
|
3257 | |||
3248 | chunktypecounts[chunktype] += 1 |
|
3258 | chunktypecounts[chunktype] += 1 | |
3249 | chunktypesizes[chunktype] += size |
|
3259 | chunktypesizes[chunktype] += size | |
3250 |
|
3260 | |||
3251 | # Adjust size min value for empty cases |
|
3261 | # Adjust size min value for empty cases | |
3252 | for size in (datasize, fullsize, deltasize): |
|
3262 | for size in (datasize, fullsize, deltasize): | |
3253 | if size[0] is None: |
|
3263 | if size[0] is None: | |
3254 | size[0] = 0 |
|
3264 | size[0] = 0 | |
3255 |
|
3265 | |||
3256 | numdeltas = numrevs - numfull |
|
3266 | numdeltas = numrevs - numfull | |
3257 | numoprev = numprev - nump1prev - nump2prev |
|
3267 | numoprev = numprev - nump1prev - nump2prev | |
3258 | totalrawsize = datasize[2] |
|
3268 | totalrawsize = datasize[2] | |
3259 | datasize[2] /= numrevs |
|
3269 | datasize[2] /= numrevs | |
3260 | fulltotal = fullsize[2] |
|
3270 | fulltotal = fullsize[2] | |
3261 | fullsize[2] /= numfull |
|
3271 | fullsize[2] /= numfull | |
3262 | deltatotal = deltasize[2] |
|
3272 | deltatotal = deltasize[2] | |
3263 | if numrevs - numfull > 0: |
|
3273 | if numrevs - numfull > 0: | |
3264 | deltasize[2] /= numrevs - numfull |
|
3274 | deltasize[2] /= numrevs - numfull | |
3265 | totalsize = fulltotal + deltatotal |
|
3275 | totalsize = fulltotal + deltatotal | |
3266 | avgchainlen = sum(chainlengths) / numrevs |
|
3276 | avgchainlen = sum(chainlengths) / numrevs | |
3267 | maxchainlen = max(chainlengths) |
|
3277 | maxchainlen = max(chainlengths) | |
3268 | compratio = 1 |
|
3278 | compratio = 1 | |
3269 | if totalsize: |
|
3279 | if totalsize: | |
3270 | compratio = totalrawsize / totalsize |
|
3280 | compratio = totalrawsize / totalsize | |
3271 |
|
3281 | |||
3272 | basedfmtstr = '%%%dd\n' |
|
3282 | basedfmtstr = '%%%dd\n' | |
3273 | basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
|
3283 | basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' | |
3274 |
|
3284 | |||
3275 | def dfmtstr(max): |
|
3285 | def dfmtstr(max): | |
3276 | return basedfmtstr % len(str(max)) |
|
3286 | return basedfmtstr % len(str(max)) | |
3277 | def pcfmtstr(max, padding=0): |
|
3287 | def pcfmtstr(max, padding=0): | |
3278 | return basepcfmtstr % (len(str(max)), ' ' * padding) |
|
3288 | return basepcfmtstr % (len(str(max)), ' ' * padding) | |
3279 |
|
3289 | |||
3280 | def pcfmt(value, total): |
|
3290 | def pcfmt(value, total): | |
3281 | if total: |
|
3291 | if total: | |
3282 | return (value, 100 * float(value) / total) |
|
3292 | return (value, 100 * float(value) / total) | |
3283 | else: |
|
3293 | else: | |
3284 | return value, 100.0 |
|
3294 | return value, 100.0 | |
3285 |
|
3295 | |||
3286 | ui.write(('format : %d\n') % format) |
|
3296 | ui.write(('format : %d\n') % format) | |
3287 | ui.write(('flags : %s\n') % ', '.join(flags)) |
|
3297 | ui.write(('flags : %s\n') % ', '.join(flags)) | |
3288 |
|
3298 | |||
3289 | ui.write('\n') |
|
3299 | ui.write('\n') | |
3290 | fmt = pcfmtstr(totalsize) |
|
3300 | fmt = pcfmtstr(totalsize) | |
3291 | fmt2 = dfmtstr(totalsize) |
|
3301 | fmt2 = dfmtstr(totalsize) | |
3292 | ui.write(('revisions : ') + fmt2 % numrevs) |
|
3302 | ui.write(('revisions : ') + fmt2 % numrevs) | |
3293 | ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) |
|
3303 | ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) | |
3294 | ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) |
|
3304 | ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) | |
3295 | ui.write(('revisions : ') + fmt2 % numrevs) |
|
3305 | ui.write(('revisions : ') + fmt2 % numrevs) | |
3296 | ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) |
|
3306 | ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) | |
3297 | ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
|
3307 | ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) | |
3298 | ui.write(('revision size : ') + fmt2 % totalsize) |
|
3308 | ui.write(('revision size : ') + fmt2 % totalsize) | |
3299 | ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) |
|
3309 | ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) | |
3300 | ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
|
3310 | ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) | |
3301 |
|
3311 | |||
3302 | def fmtchunktype(chunktype): |
|
3312 | def fmtchunktype(chunktype): | |
3303 | if chunktype == 'empty': |
|
3313 | if chunktype == 'empty': | |
3304 | return ' %s : ' % chunktype |
|
3314 | return ' %s : ' % chunktype | |
3305 | elif chunktype in string.ascii_letters: |
|
3315 | elif chunktype in string.ascii_letters: | |
3306 | return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) |
|
3316 | return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) | |
3307 | else: |
|
3317 | else: | |
3308 | return ' 0x%s : ' % hex(chunktype) |
|
3318 | return ' 0x%s : ' % hex(chunktype) | |
3309 |
|
3319 | |||
3310 | ui.write('\n') |
|
3320 | ui.write('\n') | |
3311 | ui.write(('chunks : ') + fmt2 % numrevs) |
|
3321 | ui.write(('chunks : ') + fmt2 % numrevs) | |
3312 | for chunktype in sorted(chunktypecounts): |
|
3322 | for chunktype in sorted(chunktypecounts): | |
3313 | ui.write(fmtchunktype(chunktype)) |
|
3323 | ui.write(fmtchunktype(chunktype)) | |
3314 | ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
|
3324 | ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) | |
3315 | ui.write(('chunks size : ') + fmt2 % totalsize) |
|
3325 | ui.write(('chunks size : ') + fmt2 % totalsize) | |
3316 | for chunktype in sorted(chunktypecounts): |
|
3326 | for chunktype in sorted(chunktypecounts): | |
3317 | ui.write(fmtchunktype(chunktype)) |
|
3327 | ui.write(fmtchunktype(chunktype)) | |
3318 | ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) |
|
3328 | ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) | |
3319 |
|
3329 | |||
3320 | ui.write('\n') |
|
3330 | ui.write('\n') | |
3321 | fmt = dfmtstr(max(avgchainlen, compratio)) |
|
3331 | fmt = dfmtstr(max(avgchainlen, compratio)) | |
3322 | ui.write(('avg chain length : ') + fmt % avgchainlen) |
|
3332 | ui.write(('avg chain length : ') + fmt % avgchainlen) | |
3323 | ui.write(('max chain length : ') + fmt % maxchainlen) |
|
3333 | ui.write(('max chain length : ') + fmt % maxchainlen) | |
3324 | ui.write(('compression ratio : ') + fmt % compratio) |
|
3334 | ui.write(('compression ratio : ') + fmt % compratio) | |
3325 |
|
3335 | |||
3326 | if format > 0: |
|
3336 | if format > 0: | |
3327 | ui.write('\n') |
|
3337 | ui.write('\n') | |
3328 | ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
|
3338 | ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') | |
3329 | % tuple(datasize)) |
|
3339 | % tuple(datasize)) | |
3330 | ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') |
|
3340 | ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') | |
3331 | % tuple(fullsize)) |
|
3341 | % tuple(fullsize)) | |
3332 | ui.write(('delta size (min/max/avg) : %d / %d / %d\n') |
|
3342 | ui.write(('delta size (min/max/avg) : %d / %d / %d\n') | |
3333 | % tuple(deltasize)) |
|
3343 | % tuple(deltasize)) | |
3334 |
|
3344 | |||
3335 | if numdeltas > 0: |
|
3345 | if numdeltas > 0: | |
3336 | ui.write('\n') |
|
3346 | ui.write('\n') | |
3337 | fmt = pcfmtstr(numdeltas) |
|
3347 | fmt = pcfmtstr(numdeltas) | |
3338 | fmt2 = pcfmtstr(numdeltas, 4) |
|
3348 | fmt2 = pcfmtstr(numdeltas, 4) | |
3339 | ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) |
|
3349 | ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) | |
3340 | if numprev > 0: |
|
3350 | if numprev > 0: | |
3341 | ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, |
|
3351 | ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, | |
3342 | numprev)) |
|
3352 | numprev)) | |
3343 | ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, |
|
3353 | ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, | |
3344 | numprev)) |
|
3354 | numprev)) | |
3345 | ui.write((' other : ') + fmt2 % pcfmt(numoprev, |
|
3355 | ui.write((' other : ') + fmt2 % pcfmt(numoprev, | |
3346 | numprev)) |
|
3356 | numprev)) | |
3347 | if gdelta: |
|
3357 | if gdelta: | |
3348 | ui.write(('deltas against p1 : ') |
|
3358 | ui.write(('deltas against p1 : ') | |
3349 | + fmt % pcfmt(nump1, numdeltas)) |
|
3359 | + fmt % pcfmt(nump1, numdeltas)) | |
3350 | ui.write(('deltas against p2 : ') |
|
3360 | ui.write(('deltas against p2 : ') | |
3351 | + fmt % pcfmt(nump2, numdeltas)) |
|
3361 | + fmt % pcfmt(nump2, numdeltas)) | |
3352 | ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
|
3362 | ui.write(('deltas against other : ') + fmt % pcfmt(numother, | |
3353 | numdeltas)) |
|
3363 | numdeltas)) | |
3354 |
|
3364 | |||
3355 | @command('debugrevspec', |
|
3365 | @command('debugrevspec', | |
3356 | [('', 'optimize', None, |
|
3366 | [('', 'optimize', None, | |
3357 | _('print parsed tree after optimizing (DEPRECATED)')), |
|
3367 | _('print parsed tree after optimizing (DEPRECATED)')), | |
3358 | ('p', 'show-stage', [], |
|
3368 | ('p', 'show-stage', [], | |
3359 | _('print parsed tree at the given stage'), _('NAME')), |
|
3369 | _('print parsed tree at the given stage'), _('NAME')), | |
3360 | ('', 'no-optimized', False, _('evaluate tree without optimization')), |
|
3370 | ('', 'no-optimized', False, _('evaluate tree without optimization')), | |
3361 | ('', 'verify-optimized', False, _('verify optimized result')), |
|
3371 | ('', 'verify-optimized', False, _('verify optimized result')), | |
3362 | ], |
|
3372 | ], | |
3363 | ('REVSPEC')) |
|
3373 | ('REVSPEC')) | |
3364 | def debugrevspec(ui, repo, expr, **opts): |
|
3374 | def debugrevspec(ui, repo, expr, **opts): | |
3365 | """parse and apply a revision specification |
|
3375 | """parse and apply a revision specification | |
3366 |
|
3376 | |||
3367 | Use -p/--show-stage option to print the parsed tree at the given stages. |
|
3377 | Use -p/--show-stage option to print the parsed tree at the given stages. | |
3368 | Use -p all to print tree at every stage. |
|
3378 | Use -p all to print tree at every stage. | |
3369 |
|
3379 | |||
3370 | Use --verify-optimized to compare the optimized result with the unoptimized |
|
3380 | Use --verify-optimized to compare the optimized result with the unoptimized | |
3371 | one. Returns 1 if the optimized result differs. |
|
3381 | one. Returns 1 if the optimized result differs. | |
3372 | """ |
|
3382 | """ | |
3373 | stages = [ |
|
3383 | stages = [ | |
3374 | ('parsed', lambda tree: tree), |
|
3384 | ('parsed', lambda tree: tree), | |
3375 | ('expanded', lambda tree: revset.expandaliases(ui, tree)), |
|
3385 | ('expanded', lambda tree: revset.expandaliases(ui, tree)), | |
3376 | ('concatenated', revset.foldconcat), |
|
3386 | ('concatenated', revset.foldconcat), | |
3377 | ('analyzed', revset.analyze), |
|
3387 | ('analyzed', revset.analyze), | |
3378 | ('optimized', revset.optimize), |
|
3388 | ('optimized', revset.optimize), | |
3379 | ] |
|
3389 | ] | |
3380 | if opts['no_optimized']: |
|
3390 | if opts['no_optimized']: | |
3381 | stages = stages[:-1] |
|
3391 | stages = stages[:-1] | |
3382 | if opts['verify_optimized'] and opts['no_optimized']: |
|
3392 | if opts['verify_optimized'] and opts['no_optimized']: | |
3383 | raise error.Abort(_('cannot use --verify-optimized with ' |
|
3393 | raise error.Abort(_('cannot use --verify-optimized with ' | |
3384 | '--no-optimized')) |
|
3394 | '--no-optimized')) | |
3385 | stagenames = set(n for n, f in stages) |
|
3395 | stagenames = set(n for n, f in stages) | |
3386 |
|
3396 | |||
3387 | showalways = set() |
|
3397 | showalways = set() | |
3388 | showchanged = set() |
|
3398 | showchanged = set() | |
3389 | if ui.verbose and not opts['show_stage']: |
|
3399 | if ui.verbose and not opts['show_stage']: | |
3390 | # show parsed tree by --verbose (deprecated) |
|
3400 | # show parsed tree by --verbose (deprecated) | |
3391 | showalways.add('parsed') |
|
3401 | showalways.add('parsed') | |
3392 | showchanged.update(['expanded', 'concatenated']) |
|
3402 | showchanged.update(['expanded', 'concatenated']) | |
3393 | if opts['optimize']: |
|
3403 | if opts['optimize']: | |
3394 | showalways.add('optimized') |
|
3404 | showalways.add('optimized') | |
3395 | if opts['show_stage'] and opts['optimize']: |
|
3405 | if opts['show_stage'] and opts['optimize']: | |
3396 | raise error.Abort(_('cannot use --optimize with --show-stage')) |
|
3406 | raise error.Abort(_('cannot use --optimize with --show-stage')) | |
3397 | if opts['show_stage'] == ['all']: |
|
3407 | if opts['show_stage'] == ['all']: | |
3398 | showalways.update(stagenames) |
|
3408 | showalways.update(stagenames) | |
3399 | else: |
|
3409 | else: | |
3400 | for n in opts['show_stage']: |
|
3410 | for n in opts['show_stage']: | |
3401 | if n not in stagenames: |
|
3411 | if n not in stagenames: | |
3402 | raise error.Abort(_('invalid stage name: %s') % n) |
|
3412 | raise error.Abort(_('invalid stage name: %s') % n) | |
3403 | showalways.update(opts['show_stage']) |
|
3413 | showalways.update(opts['show_stage']) | |
3404 |
|
3414 | |||
3405 | treebystage = {} |
|
3415 | treebystage = {} | |
3406 | printedtree = None |
|
3416 | printedtree = None | |
3407 | tree = revset.parse(expr, lookup=repo.__contains__) |
|
3417 | tree = revset.parse(expr, lookup=repo.__contains__) | |
3408 | for n, f in stages: |
|
3418 | for n, f in stages: | |
3409 | treebystage[n] = tree = f(tree) |
|
3419 | treebystage[n] = tree = f(tree) | |
3410 | if n in showalways or (n in showchanged and tree != printedtree): |
|
3420 | if n in showalways or (n in showchanged and tree != printedtree): | |
3411 | if opts['show_stage'] or n != 'parsed': |
|
3421 | if opts['show_stage'] or n != 'parsed': | |
3412 | ui.write(("* %s:\n") % n) |
|
3422 | ui.write(("* %s:\n") % n) | |
3413 | ui.write(revset.prettyformat(tree), "\n") |
|
3423 | ui.write(revset.prettyformat(tree), "\n") | |
3414 | printedtree = tree |
|
3424 | printedtree = tree | |
3415 |
|
3425 | |||
3416 | if opts['verify_optimized']: |
|
3426 | if opts['verify_optimized']: | |
3417 | arevs = revset.makematcher(treebystage['analyzed'])(repo) |
|
3427 | arevs = revset.makematcher(treebystage['analyzed'])(repo) | |
3418 | brevs = revset.makematcher(treebystage['optimized'])(repo) |
|
3428 | brevs = revset.makematcher(treebystage['optimized'])(repo) | |
3419 | if ui.verbose: |
|
3429 | if ui.verbose: | |
3420 | ui.note(("* analyzed set:\n"), revset.prettyformatset(arevs), "\n") |
|
3430 | ui.note(("* analyzed set:\n"), revset.prettyformatset(arevs), "\n") | |
3421 | ui.note(("* optimized set:\n"), revset.prettyformatset(brevs), "\n") |
|
3431 | ui.note(("* optimized set:\n"), revset.prettyformatset(brevs), "\n") | |
3422 | arevs = list(arevs) |
|
3432 | arevs = list(arevs) | |
3423 | brevs = list(brevs) |
|
3433 | brevs = list(brevs) | |
3424 | if arevs == brevs: |
|
3434 | if arevs == brevs: | |
3425 | return 0 |
|
3435 | return 0 | |
3426 | ui.write(('--- analyzed\n'), label='diff.file_a') |
|
3436 | ui.write(('--- analyzed\n'), label='diff.file_a') | |
3427 | ui.write(('+++ optimized\n'), label='diff.file_b') |
|
3437 | ui.write(('+++ optimized\n'), label='diff.file_b') | |
3428 | sm = difflib.SequenceMatcher(None, arevs, brevs) |
|
3438 | sm = difflib.SequenceMatcher(None, arevs, brevs) | |
3429 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
3439 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | |
3430 | if tag in ('delete', 'replace'): |
|
3440 | if tag in ('delete', 'replace'): | |
3431 | for c in arevs[alo:ahi]: |
|
3441 | for c in arevs[alo:ahi]: | |
3432 | ui.write('-%s\n' % c, label='diff.deleted') |
|
3442 | ui.write('-%s\n' % c, label='diff.deleted') | |
3433 | if tag in ('insert', 'replace'): |
|
3443 | if tag in ('insert', 'replace'): | |
3434 | for c in brevs[blo:bhi]: |
|
3444 | for c in brevs[blo:bhi]: | |
3435 | ui.write('+%s\n' % c, label='diff.inserted') |
|
3445 | ui.write('+%s\n' % c, label='diff.inserted') | |
3436 | if tag == 'equal': |
|
3446 | if tag == 'equal': | |
3437 | for c in arevs[alo:ahi]: |
|
3447 | for c in arevs[alo:ahi]: | |
3438 | ui.write(' %s\n' % c) |
|
3448 | ui.write(' %s\n' % c) | |
3439 | return 1 |
|
3449 | return 1 | |
3440 |
|
3450 | |||
3441 | func = revset.makematcher(tree) |
|
3451 | func = revset.makematcher(tree) | |
3442 | revs = func(repo) |
|
3452 | revs = func(repo) | |
3443 | if ui.verbose: |
|
3453 | if ui.verbose: | |
3444 | ui.note(("* set:\n"), revset.prettyformatset(revs), "\n") |
|
3454 | ui.note(("* set:\n"), revset.prettyformatset(revs), "\n") | |
3445 | for c in revs: |
|
3455 | for c in revs: | |
3446 | ui.write("%s\n" % c) |
|
3456 | ui.write("%s\n" % c) | |
3447 |
|
3457 | |||
3448 | @command('debugsetparents', [], _('REV1 [REV2]')) |
|
3458 | @command('debugsetparents', [], _('REV1 [REV2]')) | |
3449 | def debugsetparents(ui, repo, rev1, rev2=None): |
|
3459 | def debugsetparents(ui, repo, rev1, rev2=None): | |
3450 | """manually set the parents of the current working directory |
|
3460 | """manually set the parents of the current working directory | |
3451 |
|
3461 | |||
3452 | This is useful for writing repository conversion tools, but should |
|
3462 | This is useful for writing repository conversion tools, but should | |
3453 | be used with care. For example, neither the working directory nor the |
|
3463 | be used with care. For example, neither the working directory nor the | |
3454 | dirstate is updated, so file status may be incorrect after running this |
|
3464 | dirstate is updated, so file status may be incorrect after running this | |
3455 | command. |
|
3465 | command. | |
3456 |
|
3466 | |||
3457 | Returns 0 on success. |
|
3467 | Returns 0 on success. | |
3458 | """ |
|
3468 | """ | |
3459 |
|
3469 | |||
3460 | r1 = scmutil.revsingle(repo, rev1).node() |
|
3470 | r1 = scmutil.revsingle(repo, rev1).node() | |
3461 | r2 = scmutil.revsingle(repo, rev2, 'null').node() |
|
3471 | r2 = scmutil.revsingle(repo, rev2, 'null').node() | |
3462 |
|
3472 | |||
3463 | with repo.wlock(): |
|
3473 | with repo.wlock(): | |
3464 | repo.setparents(r1, r2) |
|
3474 | repo.setparents(r1, r2) | |
3465 |
|
3475 | |||
3466 | @command('debugdirstate|debugstate', |
|
3476 | @command('debugdirstate|debugstate', | |
3467 | [('', 'nodates', None, _('do not display the saved mtime')), |
|
3477 | [('', 'nodates', None, _('do not display the saved mtime')), | |
3468 | ('', 'datesort', None, _('sort by saved mtime'))], |
|
3478 | ('', 'datesort', None, _('sort by saved mtime'))], | |
3469 | _('[OPTION]...')) |
|
3479 | _('[OPTION]...')) | |
3470 | def debugstate(ui, repo, **opts): |
|
3480 | def debugstate(ui, repo, **opts): | |
3471 | """show the contents of the current dirstate""" |
|
3481 | """show the contents of the current dirstate""" | |
3472 |
|
3482 | |||
3473 | nodates = opts.get('nodates') |
|
3483 | nodates = opts.get('nodates') | |
3474 | datesort = opts.get('datesort') |
|
3484 | datesort = opts.get('datesort') | |
3475 |
|
3485 | |||
3476 | timestr = "" |
|
3486 | timestr = "" | |
3477 | if datesort: |
|
3487 | if datesort: | |
3478 | keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
|
3488 | keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename | |
3479 | else: |
|
3489 | else: | |
3480 | keyfunc = None # sort by filename |
|
3490 | keyfunc = None # sort by filename | |
3481 | for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
|
3491 | for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): | |
3482 | if ent[3] == -1: |
|
3492 | if ent[3] == -1: | |
3483 | timestr = 'unset ' |
|
3493 | timestr = 'unset ' | |
3484 | elif nodates: |
|
3494 | elif nodates: | |
3485 | timestr = 'set ' |
|
3495 | timestr = 'set ' | |
3486 | else: |
|
3496 | else: | |
3487 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
3497 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", | |
3488 | time.localtime(ent[3])) |
|
3498 | time.localtime(ent[3])) | |
3489 | if ent[1] & 0o20000: |
|
3499 | if ent[1] & 0o20000: | |
3490 | mode = 'lnk' |
|
3500 | mode = 'lnk' | |
3491 | else: |
|
3501 | else: | |
3492 | mode = '%3o' % (ent[1] & 0o777 & ~util.umask) |
|
3502 | mode = '%3o' % (ent[1] & 0o777 & ~util.umask) | |
3493 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
3503 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | |
3494 | for f in repo.dirstate.copies(): |
|
3504 | for f in repo.dirstate.copies(): | |
3495 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
3505 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | |
3496 |
|
3506 | |||
3497 | @command('debugsub', |
|
3507 | @command('debugsub', | |
3498 | [('r', 'rev', '', |
|
3508 | [('r', 'rev', '', | |
3499 | _('revision to check'), _('REV'))], |
|
3509 | _('revision to check'), _('REV'))], | |
3500 | _('[-r REV] [REV]')) |
|
3510 | _('[-r REV] [REV]')) | |
3501 | def debugsub(ui, repo, rev=None): |
|
3511 | def debugsub(ui, repo, rev=None): | |
3502 | ctx = scmutil.revsingle(repo, rev, None) |
|
3512 | ctx = scmutil.revsingle(repo, rev, None) | |
3503 | for k, v in sorted(ctx.substate.items()): |
|
3513 | for k, v in sorted(ctx.substate.items()): | |
3504 | ui.write(('path %s\n') % k) |
|
3514 | ui.write(('path %s\n') % k) | |
3505 | ui.write((' source %s\n') % v[0]) |
|
3515 | ui.write((' source %s\n') % v[0]) | |
3506 | ui.write((' revision %s\n') % v[1]) |
|
3516 | ui.write((' revision %s\n') % v[1]) | |
3507 |
|
3517 | |||
3508 | @command('debugsuccessorssets', |
|
3518 | @command('debugsuccessorssets', | |
3509 | [], |
|
3519 | [], | |
3510 | _('[REV]')) |
|
3520 | _('[REV]')) | |
3511 | def debugsuccessorssets(ui, repo, *revs): |
|
3521 | def debugsuccessorssets(ui, repo, *revs): | |
3512 | """show set of successors for revision |
|
3522 | """show set of successors for revision | |
3513 |
|
3523 | |||
3514 | A successors set of changeset A is a consistent group of revisions that |
|
3524 | A successors set of changeset A is a consistent group of revisions that | |
3515 | succeed A. It contains non-obsolete changesets only. |
|
3525 | succeed A. It contains non-obsolete changesets only. | |
3516 |
|
3526 | |||
3517 | In most cases a changeset A has a single successors set containing a single |
|
3527 | In most cases a changeset A has a single successors set containing a single | |
3518 | successor (changeset A replaced by A'). |
|
3528 | successor (changeset A replaced by A'). | |
3519 |
|
3529 | |||
3520 | A changeset that is made obsolete with no successors are called "pruned". |
|
3530 | A changeset that is made obsolete with no successors are called "pruned". | |
3521 | Such changesets have no successors sets at all. |
|
3531 | Such changesets have no successors sets at all. | |
3522 |
|
3532 | |||
3523 | A changeset that has been "split" will have a successors set containing |
|
3533 | A changeset that has been "split" will have a successors set containing | |
3524 | more than one successor. |
|
3534 | more than one successor. | |
3525 |
|
3535 | |||
3526 | A changeset that has been rewritten in multiple different ways is called |
|
3536 | A changeset that has been rewritten in multiple different ways is called | |
3527 | "divergent". Such changesets have multiple successor sets (each of which |
|
3537 | "divergent". Such changesets have multiple successor sets (each of which | |
3528 | may also be split, i.e. have multiple successors). |
|
3538 | may also be split, i.e. have multiple successors). | |
3529 |
|
3539 | |||
3530 | Results are displayed as follows:: |
|
3540 | Results are displayed as follows:: | |
3531 |
|
3541 | |||
3532 | <rev1> |
|
3542 | <rev1> | |
3533 | <successors-1A> |
|
3543 | <successors-1A> | |
3534 | <rev2> |
|
3544 | <rev2> | |
3535 | <successors-2A> |
|
3545 | <successors-2A> | |
3536 | <successors-2B1> <successors-2B2> <successors-2B3> |
|
3546 | <successors-2B1> <successors-2B2> <successors-2B3> | |
3537 |
|
3547 | |||
3538 | Here rev2 has two possible (i.e. divergent) successors sets. The first |
|
3548 | Here rev2 has two possible (i.e. divergent) successors sets. The first | |
3539 | holds one element, whereas the second holds three (i.e. the changeset has |
|
3549 | holds one element, whereas the second holds three (i.e. the changeset has | |
3540 | been split). |
|
3550 | been split). | |
3541 | """ |
|
3551 | """ | |
3542 | # passed to successorssets caching computation from one call to another |
|
3552 | # passed to successorssets caching computation from one call to another | |
3543 | cache = {} |
|
3553 | cache = {} | |
3544 | ctx2str = str |
|
3554 | ctx2str = str | |
3545 | node2str = short |
|
3555 | node2str = short | |
3546 | if ui.debug(): |
|
3556 | if ui.debug(): | |
3547 | def ctx2str(ctx): |
|
3557 | def ctx2str(ctx): | |
3548 | return ctx.hex() |
|
3558 | return ctx.hex() | |
3549 | node2str = hex |
|
3559 | node2str = hex | |
3550 | for rev in scmutil.revrange(repo, revs): |
|
3560 | for rev in scmutil.revrange(repo, revs): | |
3551 | ctx = repo[rev] |
|
3561 | ctx = repo[rev] | |
3552 | ui.write('%s\n'% ctx2str(ctx)) |
|
3562 | ui.write('%s\n'% ctx2str(ctx)) | |
3553 | for succsset in obsolete.successorssets(repo, ctx.node(), cache): |
|
3563 | for succsset in obsolete.successorssets(repo, ctx.node(), cache): | |
3554 | if succsset: |
|
3564 | if succsset: | |
3555 | ui.write(' ') |
|
3565 | ui.write(' ') | |
3556 | ui.write(node2str(succsset[0])) |
|
3566 | ui.write(node2str(succsset[0])) | |
3557 | for node in succsset[1:]: |
|
3567 | for node in succsset[1:]: | |
3558 | ui.write(' ') |
|
3568 | ui.write(' ') | |
3559 | ui.write(node2str(node)) |
|
3569 | ui.write(node2str(node)) | |
3560 | ui.write('\n') |
|
3570 | ui.write('\n') | |
3561 |
|
3571 | |||
3562 | @command('debugtemplate', |
|
3572 | @command('debugtemplate', | |
3563 | [('r', 'rev', [], _('apply template on changesets'), _('REV')), |
|
3573 | [('r', 'rev', [], _('apply template on changesets'), _('REV')), | |
3564 | ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], |
|
3574 | ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], | |
3565 | _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
|
3575 | _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), | |
3566 | optionalrepo=True) |
|
3576 | optionalrepo=True) | |
3567 | def debugtemplate(ui, repo, tmpl, **opts): |
|
3577 | def debugtemplate(ui, repo, tmpl, **opts): | |
3568 | """parse and apply a template |
|
3578 | """parse and apply a template | |
3569 |
|
3579 | |||
3570 | If -r/--rev is given, the template is processed as a log template and |
|
3580 | If -r/--rev is given, the template is processed as a log template and | |
3571 | applied to the given changesets. Otherwise, it is processed as a generic |
|
3581 | applied to the given changesets. Otherwise, it is processed as a generic | |
3572 | template. |
|
3582 | template. | |
3573 |
|
3583 | |||
3574 | Use --verbose to print the parsed tree. |
|
3584 | Use --verbose to print the parsed tree. | |
3575 | """ |
|
3585 | """ | |
3576 | revs = None |
|
3586 | revs = None | |
3577 | if opts['rev']: |
|
3587 | if opts['rev']: | |
3578 | if repo is None: |
|
3588 | if repo is None: | |
3579 | raise error.RepoError(_('there is no Mercurial repository here ' |
|
3589 | raise error.RepoError(_('there is no Mercurial repository here ' | |
3580 | '(.hg not found)')) |
|
3590 | '(.hg not found)')) | |
3581 | revs = scmutil.revrange(repo, opts['rev']) |
|
3591 | revs = scmutil.revrange(repo, opts['rev']) | |
3582 |
|
3592 | |||
3583 | props = {} |
|
3593 | props = {} | |
3584 | for d in opts['define']: |
|
3594 | for d in opts['define']: | |
3585 | try: |
|
3595 | try: | |
3586 | k, v = (e.strip() for e in d.split('=', 1)) |
|
3596 | k, v = (e.strip() for e in d.split('=', 1)) | |
3587 | if not k: |
|
3597 | if not k: | |
3588 | raise ValueError |
|
3598 | raise ValueError | |
3589 | props[k] = v |
|
3599 | props[k] = v | |
3590 | except ValueError: |
|
3600 | except ValueError: | |
3591 | raise error.Abort(_('malformed keyword definition: %s') % d) |
|
3601 | raise error.Abort(_('malformed keyword definition: %s') % d) | |
3592 |
|
3602 | |||
3593 | if ui.verbose: |
|
3603 | if ui.verbose: | |
3594 | aliases = ui.configitems('templatealias') |
|
3604 | aliases = ui.configitems('templatealias') | |
3595 | tree = templater.parse(tmpl) |
|
3605 | tree = templater.parse(tmpl) | |
3596 | ui.note(templater.prettyformat(tree), '\n') |
|
3606 | ui.note(templater.prettyformat(tree), '\n') | |
3597 | newtree = templater.expandaliases(tree, aliases) |
|
3607 | newtree = templater.expandaliases(tree, aliases) | |
3598 | if newtree != tree: |
|
3608 | if newtree != tree: | |
3599 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
|
3609 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') | |
3600 |
|
3610 | |||
3601 | mapfile = None |
|
3611 | mapfile = None | |
3602 | if revs is None: |
|
3612 | if revs is None: | |
3603 | k = 'debugtemplate' |
|
3613 | k = 'debugtemplate' | |
3604 | t = formatter.maketemplater(ui, k, tmpl) |
|
3614 | t = formatter.maketemplater(ui, k, tmpl) | |
3605 | ui.write(templater.stringify(t(k, **props))) |
|
3615 | ui.write(templater.stringify(t(k, **props))) | |
3606 | else: |
|
3616 | else: | |
3607 | displayer = cmdutil.changeset_templater(ui, repo, None, opts, tmpl, |
|
3617 | displayer = cmdutil.changeset_templater(ui, repo, None, opts, tmpl, | |
3608 | mapfile, buffered=False) |
|
3618 | mapfile, buffered=False) | |
3609 | for r in revs: |
|
3619 | for r in revs: | |
3610 | displayer.show(repo[r], **props) |
|
3620 | displayer.show(repo[r], **props) | |
3611 | displayer.close() |
|
3621 | displayer.close() | |
3612 |
|
3622 | |||
3613 | @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True) |
|
3623 | @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True) | |
3614 | def debugwalk(ui, repo, *pats, **opts): |
|
3624 | def debugwalk(ui, repo, *pats, **opts): | |
3615 | """show how files match on given patterns""" |
|
3625 | """show how files match on given patterns""" | |
3616 | m = scmutil.match(repo[None], pats, opts) |
|
3626 | m = scmutil.match(repo[None], pats, opts) | |
3617 | items = list(repo.walk(m)) |
|
3627 | items = list(repo.walk(m)) | |
3618 | if not items: |
|
3628 | if not items: | |
3619 | return |
|
3629 | return | |
3620 | f = lambda fn: fn |
|
3630 | f = lambda fn: fn | |
3621 | if ui.configbool('ui', 'slash') and pycompat.ossep != '/': |
|
3631 | if ui.configbool('ui', 'slash') and pycompat.ossep != '/': | |
3622 | f = lambda fn: util.normpath(fn) |
|
3632 | f = lambda fn: util.normpath(fn) | |
3623 | fmt = 'f %%-%ds %%-%ds %%s' % ( |
|
3633 | fmt = 'f %%-%ds %%-%ds %%s' % ( | |
3624 | max([len(abs) for abs in items]), |
|
3634 | max([len(abs) for abs in items]), | |
3625 | max([len(m.rel(abs)) for abs in items])) |
|
3635 | max([len(m.rel(abs)) for abs in items])) | |
3626 | for abs in items: |
|
3636 | for abs in items: | |
3627 | line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '') |
|
3637 | line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '') | |
3628 | ui.write("%s\n" % line.rstrip()) |
|
3638 | ui.write("%s\n" % line.rstrip()) | |
3629 |
|
3639 | |||
3630 | @command('debugwireargs', |
|
3640 | @command('debugwireargs', | |
3631 | [('', 'three', '', 'three'), |
|
3641 | [('', 'three', '', 'three'), | |
3632 | ('', 'four', '', 'four'), |
|
3642 | ('', 'four', '', 'four'), | |
3633 | ('', 'five', '', 'five'), |
|
3643 | ('', 'five', '', 'five'), | |
3634 | ] + remoteopts, |
|
3644 | ] + remoteopts, | |
3635 | _('REPO [OPTIONS]... [ONE [TWO]]'), |
|
3645 | _('REPO [OPTIONS]... [ONE [TWO]]'), | |
3636 | norepo=True) |
|
3646 | norepo=True) | |
3637 | def debugwireargs(ui, repopath, *vals, **opts): |
|
3647 | def debugwireargs(ui, repopath, *vals, **opts): | |
3638 | repo = hg.peer(ui, opts, repopath) |
|
3648 | repo = hg.peer(ui, opts, repopath) | |
3639 | for opt in remoteopts: |
|
3649 | for opt in remoteopts: | |
3640 | del opts[opt[1]] |
|
3650 | del opts[opt[1]] | |
3641 | args = {} |
|
3651 | args = {} | |
3642 | for k, v in opts.iteritems(): |
|
3652 | for k, v in opts.iteritems(): | |
3643 | if v: |
|
3653 | if v: | |
3644 | args[k] = v |
|
3654 | args[k] = v | |
3645 | # run twice to check that we don't mess up the stream for the next command |
|
3655 | # run twice to check that we don't mess up the stream for the next command | |
3646 | res1 = repo.debugwireargs(*vals, **args) |
|
3656 | res1 = repo.debugwireargs(*vals, **args) | |
3647 | res2 = repo.debugwireargs(*vals, **args) |
|
3657 | res2 = repo.debugwireargs(*vals, **args) | |
3648 | ui.write("%s\n" % res1) |
|
3658 | ui.write("%s\n" % res1) | |
3649 | if res1 != res2: |
|
3659 | if res1 != res2: | |
3650 | ui.warn("%s\n" % res2) |
|
3660 | ui.warn("%s\n" % res2) | |
3651 |
|
3661 | |||
3652 | @command('^diff', |
|
3662 | @command('^diff', | |
3653 | [('r', 'rev', [], _('revision'), _('REV')), |
|
3663 | [('r', 'rev', [], _('revision'), _('REV')), | |
3654 | ('c', 'change', '', _('change made by revision'), _('REV')) |
|
3664 | ('c', 'change', '', _('change made by revision'), _('REV')) | |
3655 | ] + diffopts + diffopts2 + walkopts + subrepoopts, |
|
3665 | ] + diffopts + diffopts2 + walkopts + subrepoopts, | |
3656 | _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'), |
|
3666 | _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'), | |
3657 | inferrepo=True) |
|
3667 | inferrepo=True) | |
3658 | def diff(ui, repo, *pats, **opts): |
|
3668 | def diff(ui, repo, *pats, **opts): | |
3659 | """diff repository (or selected files) |
|
3669 | """diff repository (or selected files) | |
3660 |
|
3670 | |||
3661 | Show differences between revisions for the specified files. |
|
3671 | Show differences between revisions for the specified files. | |
3662 |
|
3672 | |||
3663 | Differences between files are shown using the unified diff format. |
|
3673 | Differences between files are shown using the unified diff format. | |
3664 |
|
3674 | |||
3665 | .. note:: |
|
3675 | .. note:: | |
3666 |
|
3676 | |||
3667 | :hg:`diff` may generate unexpected results for merges, as it will |
|
3677 | :hg:`diff` may generate unexpected results for merges, as it will | |
3668 | default to comparing against the working directory's first |
|
3678 | default to comparing against the working directory's first | |
3669 | parent changeset if no revisions are specified. |
|
3679 | parent changeset if no revisions are specified. | |
3670 |
|
3680 | |||
3671 | When two revision arguments are given, then changes are shown |
|
3681 | When two revision arguments are given, then changes are shown | |
3672 | between those revisions. If only one revision is specified then |
|
3682 | between those revisions. If only one revision is specified then | |
3673 | that revision is compared to the working directory, and, when no |
|
3683 | that revision is compared to the working directory, and, when no | |
3674 | revisions are specified, the working directory files are compared |
|
3684 | revisions are specified, the working directory files are compared | |
3675 | to its first parent. |
|
3685 | to its first parent. | |
3676 |
|
3686 | |||
3677 | Alternatively you can specify -c/--change with a revision to see |
|
3687 | Alternatively you can specify -c/--change with a revision to see | |
3678 | the changes in that changeset relative to its first parent. |
|
3688 | the changes in that changeset relative to its first parent. | |
3679 |
|
3689 | |||
3680 | Without the -a/--text option, diff will avoid generating diffs of |
|
3690 | Without the -a/--text option, diff will avoid generating diffs of | |
3681 | files it detects as binary. With -a, diff will generate a diff |
|
3691 | files it detects as binary. With -a, diff will generate a diff | |
3682 | anyway, probably with undesirable results. |
|
3692 | anyway, probably with undesirable results. | |
3683 |
|
3693 | |||
3684 | Use the -g/--git option to generate diffs in the git extended diff |
|
3694 | Use the -g/--git option to generate diffs in the git extended diff | |
3685 | format. For more information, read :hg:`help diffs`. |
|
3695 | format. For more information, read :hg:`help diffs`. | |
3686 |
|
3696 | |||
3687 | .. container:: verbose |
|
3697 | .. container:: verbose | |
3688 |
|
3698 | |||
3689 | Examples: |
|
3699 | Examples: | |
3690 |
|
3700 | |||
3691 | - compare a file in the current working directory to its parent:: |
|
3701 | - compare a file in the current working directory to its parent:: | |
3692 |
|
3702 | |||
3693 | hg diff foo.c |
|
3703 | hg diff foo.c | |
3694 |
|
3704 | |||
3695 | - compare two historical versions of a directory, with rename info:: |
|
3705 | - compare two historical versions of a directory, with rename info:: | |
3696 |
|
3706 | |||
3697 | hg diff --git -r 1.0:1.2 lib/ |
|
3707 | hg diff --git -r 1.0:1.2 lib/ | |
3698 |
|
3708 | |||
3699 | - get change stats relative to the last change on some date:: |
|
3709 | - get change stats relative to the last change on some date:: | |
3700 |
|
3710 | |||
3701 | hg diff --stat -r "date('may 2')" |
|
3711 | hg diff --stat -r "date('may 2')" | |
3702 |
|
3712 | |||
3703 | - diff all newly-added files that contain a keyword:: |
|
3713 | - diff all newly-added files that contain a keyword:: | |
3704 |
|
3714 | |||
3705 | hg diff "set:added() and grep(GNU)" |
|
3715 | hg diff "set:added() and grep(GNU)" | |
3706 |
|
3716 | |||
3707 | - compare a revision and its parents:: |
|
3717 | - compare a revision and its parents:: | |
3708 |
|
3718 | |||
3709 | hg diff -c 9353 # compare against first parent |
|
3719 | hg diff -c 9353 # compare against first parent | |
3710 | hg diff -r 9353^:9353 # same using revset syntax |
|
3720 | hg diff -r 9353^:9353 # same using revset syntax | |
3711 | hg diff -r 9353^2:9353 # compare against the second parent |
|
3721 | hg diff -r 9353^2:9353 # compare against the second parent | |
3712 |
|
3722 | |||
3713 | Returns 0 on success. |
|
3723 | Returns 0 on success. | |
3714 | """ |
|
3724 | """ | |
3715 |
|
3725 | |||
3716 | revs = opts.get('rev') |
|
3726 | revs = opts.get('rev') | |
3717 | change = opts.get('change') |
|
3727 | change = opts.get('change') | |
3718 | stat = opts.get('stat') |
|
3728 | stat = opts.get('stat') | |
3719 | reverse = opts.get('reverse') |
|
3729 | reverse = opts.get('reverse') | |
3720 |
|
3730 | |||
3721 | if revs and change: |
|
3731 | if revs and change: | |
3722 | msg = _('cannot specify --rev and --change at the same time') |
|
3732 | msg = _('cannot specify --rev and --change at the same time') | |
3723 | raise error.Abort(msg) |
|
3733 | raise error.Abort(msg) | |
3724 | elif change: |
|
3734 | elif change: | |
3725 | node2 = scmutil.revsingle(repo, change, None).node() |
|
3735 | node2 = scmutil.revsingle(repo, change, None).node() | |
3726 | node1 = repo[node2].p1().node() |
|
3736 | node1 = repo[node2].p1().node() | |
3727 | else: |
|
3737 | else: | |
3728 | node1, node2 = scmutil.revpair(repo, revs) |
|
3738 | node1, node2 = scmutil.revpair(repo, revs) | |
3729 |
|
3739 | |||
3730 | if reverse: |
|
3740 | if reverse: | |
3731 | node1, node2 = node2, node1 |
|
3741 | node1, node2 = node2, node1 | |
3732 |
|
3742 | |||
3733 | diffopts = patch.diffallopts(ui, opts) |
|
3743 | diffopts = patch.diffallopts(ui, opts) | |
3734 | m = scmutil.match(repo[node2], pats, opts) |
|
3744 | m = scmutil.match(repo[node2], pats, opts) | |
3735 | cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, |
|
3745 | cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, | |
3736 | listsubrepos=opts.get('subrepos'), |
|
3746 | listsubrepos=opts.get('subrepos'), | |
3737 | root=opts.get('root')) |
|
3747 | root=opts.get('root')) | |
3738 |
|
3748 | |||
3739 | @command('^export', |
|
3749 | @command('^export', | |
3740 | [('o', 'output', '', |
|
3750 | [('o', 'output', '', | |
3741 | _('print output to file with formatted name'), _('FORMAT')), |
|
3751 | _('print output to file with formatted name'), _('FORMAT')), | |
3742 | ('', 'switch-parent', None, _('diff against the second parent')), |
|
3752 | ('', 'switch-parent', None, _('diff against the second parent')), | |
3743 | ('r', 'rev', [], _('revisions to export'), _('REV')), |
|
3753 | ('r', 'rev', [], _('revisions to export'), _('REV')), | |
3744 | ] + diffopts, |
|
3754 | ] + diffopts, | |
3745 | _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...')) |
|
3755 | _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...')) | |
3746 | def export(ui, repo, *changesets, **opts): |
|
3756 | def export(ui, repo, *changesets, **opts): | |
3747 | """dump the header and diffs for one or more changesets |
|
3757 | """dump the header and diffs for one or more changesets | |
3748 |
|
3758 | |||
3749 | Print the changeset header and diffs for one or more revisions. |
|
3759 | Print the changeset header and diffs for one or more revisions. | |
3750 | If no revision is given, the parent of the working directory is used. |
|
3760 | If no revision is given, the parent of the working directory is used. | |
3751 |
|
3761 | |||
3752 | The information shown in the changeset header is: author, date, |
|
3762 | The information shown in the changeset header is: author, date, | |
3753 | branch name (if non-default), changeset hash, parent(s) and commit |
|
3763 | branch name (if non-default), changeset hash, parent(s) and commit | |
3754 | comment. |
|
3764 | comment. | |
3755 |
|
3765 | |||
3756 | .. note:: |
|
3766 | .. note:: | |
3757 |
|
3767 | |||
3758 | :hg:`export` may generate unexpected diff output for merge |
|
3768 | :hg:`export` may generate unexpected diff output for merge | |
3759 | changesets, as it will compare the merge changeset against its |
|
3769 | changesets, as it will compare the merge changeset against its | |
3760 | first parent only. |
|
3770 | first parent only. | |
3761 |
|
3771 | |||
3762 | Output may be to a file, in which case the name of the file is |
|
3772 | Output may be to a file, in which case the name of the file is | |
3763 | given using a format string. The formatting rules are as follows: |
|
3773 | given using a format string. The formatting rules are as follows: | |
3764 |
|
3774 | |||
3765 | :``%%``: literal "%" character |
|
3775 | :``%%``: literal "%" character | |
3766 | :``%H``: changeset hash (40 hexadecimal digits) |
|
3776 | :``%H``: changeset hash (40 hexadecimal digits) | |
3767 | :``%N``: number of patches being generated |
|
3777 | :``%N``: number of patches being generated | |
3768 | :``%R``: changeset revision number |
|
3778 | :``%R``: changeset revision number | |
3769 | :``%b``: basename of the exporting repository |
|
3779 | :``%b``: basename of the exporting repository | |
3770 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
3780 | :``%h``: short-form changeset hash (12 hexadecimal digits) | |
3771 | :``%m``: first line of the commit message (only alphanumeric characters) |
|
3781 | :``%m``: first line of the commit message (only alphanumeric characters) | |
3772 | :``%n``: zero-padded sequence number, starting at 1 |
|
3782 | :``%n``: zero-padded sequence number, starting at 1 | |
3773 | :``%r``: zero-padded changeset revision number |
|
3783 | :``%r``: zero-padded changeset revision number | |
3774 |
|
3784 | |||
3775 | Without the -a/--text option, export will avoid generating diffs |
|
3785 | Without the -a/--text option, export will avoid generating diffs | |
3776 | of files it detects as binary. With -a, export will generate a |
|
3786 | of files it detects as binary. With -a, export will generate a | |
3777 | diff anyway, probably with undesirable results. |
|
3787 | diff anyway, probably with undesirable results. | |
3778 |
|
3788 | |||
3779 | Use the -g/--git option to generate diffs in the git extended diff |
|
3789 | Use the -g/--git option to generate diffs in the git extended diff | |
3780 | format. See :hg:`help diffs` for more information. |
|
3790 | format. See :hg:`help diffs` for more information. | |
3781 |
|
3791 | |||
3782 | With the --switch-parent option, the diff will be against the |
|
3792 | With the --switch-parent option, the diff will be against the | |
3783 | second parent. It can be useful to review a merge. |
|
3793 | second parent. It can be useful to review a merge. | |
3784 |
|
3794 | |||
3785 | .. container:: verbose |
|
3795 | .. container:: verbose | |
3786 |
|
3796 | |||
3787 | Examples: |
|
3797 | Examples: | |
3788 |
|
3798 | |||
3789 | - use export and import to transplant a bugfix to the current |
|
3799 | - use export and import to transplant a bugfix to the current | |
3790 | branch:: |
|
3800 | branch:: | |
3791 |
|
3801 | |||
3792 | hg export -r 9353 | hg import - |
|
3802 | hg export -r 9353 | hg import - | |
3793 |
|
3803 | |||
3794 | - export all the changesets between two revisions to a file with |
|
3804 | - export all the changesets between two revisions to a file with | |
3795 | rename information:: |
|
3805 | rename information:: | |
3796 |
|
3806 | |||
3797 | hg export --git -r 123:150 > changes.txt |
|
3807 | hg export --git -r 123:150 > changes.txt | |
3798 |
|
3808 | |||
3799 | - split outgoing changes into a series of patches with |
|
3809 | - split outgoing changes into a series of patches with | |
3800 | descriptive names:: |
|
3810 | descriptive names:: | |
3801 |
|
3811 | |||
3802 | hg export -r "outgoing()" -o "%n-%m.patch" |
|
3812 | hg export -r "outgoing()" -o "%n-%m.patch" | |
3803 |
|
3813 | |||
3804 | Returns 0 on success. |
|
3814 | Returns 0 on success. | |
3805 | """ |
|
3815 | """ | |
3806 | changesets += tuple(opts.get('rev', [])) |
|
3816 | changesets += tuple(opts.get('rev', [])) | |
3807 | if not changesets: |
|
3817 | if not changesets: | |
3808 | changesets = ['.'] |
|
3818 | changesets = ['.'] | |
3809 | revs = scmutil.revrange(repo, changesets) |
|
3819 | revs = scmutil.revrange(repo, changesets) | |
3810 | if not revs: |
|
3820 | if not revs: | |
3811 | raise error.Abort(_("export requires at least one changeset")) |
|
3821 | raise error.Abort(_("export requires at least one changeset")) | |
3812 | if len(revs) > 1: |
|
3822 | if len(revs) > 1: | |
3813 | ui.note(_('exporting patches:\n')) |
|
3823 | ui.note(_('exporting patches:\n')) | |
3814 | else: |
|
3824 | else: | |
3815 | ui.note(_('exporting patch:\n')) |
|
3825 | ui.note(_('exporting patch:\n')) | |
3816 | cmdutil.export(repo, revs, template=opts.get('output'), |
|
3826 | cmdutil.export(repo, revs, template=opts.get('output'), | |
3817 | switch_parent=opts.get('switch_parent'), |
|
3827 | switch_parent=opts.get('switch_parent'), | |
3818 | opts=patch.diffallopts(ui, opts)) |
|
3828 | opts=patch.diffallopts(ui, opts)) | |
3819 |
|
3829 | |||
3820 | @command('files', |
|
3830 | @command('files', | |
3821 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
|
3831 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), | |
3822 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
3832 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), | |
3823 | ] + walkopts + formatteropts + subrepoopts, |
|
3833 | ] + walkopts + formatteropts + subrepoopts, | |
3824 | _('[OPTION]... [FILE]...')) |
|
3834 | _('[OPTION]... [FILE]...')) | |
3825 | def files(ui, repo, *pats, **opts): |
|
3835 | def files(ui, repo, *pats, **opts): | |
3826 | """list tracked files |
|
3836 | """list tracked files | |
3827 |
|
3837 | |||
3828 | Print files under Mercurial control in the working directory or |
|
3838 | Print files under Mercurial control in the working directory or | |
3829 | specified revision for given files (excluding removed files). |
|
3839 | specified revision for given files (excluding removed files). | |
3830 | Files can be specified as filenames or filesets. |
|
3840 | Files can be specified as filenames or filesets. | |
3831 |
|
3841 | |||
3832 | If no files are given to match, this command prints the names |
|
3842 | If no files are given to match, this command prints the names | |
3833 | of all files under Mercurial control. |
|
3843 | of all files under Mercurial control. | |
3834 |
|
3844 | |||
3835 | .. container:: verbose |
|
3845 | .. container:: verbose | |
3836 |
|
3846 | |||
3837 | Examples: |
|
3847 | Examples: | |
3838 |
|
3848 | |||
3839 | - list all files under the current directory:: |
|
3849 | - list all files under the current directory:: | |
3840 |
|
3850 | |||
3841 | hg files . |
|
3851 | hg files . | |
3842 |
|
3852 | |||
3843 | - shows sizes and flags for current revision:: |
|
3853 | - shows sizes and flags for current revision:: | |
3844 |
|
3854 | |||
3845 | hg files -vr . |
|
3855 | hg files -vr . | |
3846 |
|
3856 | |||
3847 | - list all files named README:: |
|
3857 | - list all files named README:: | |
3848 |
|
3858 | |||
3849 | hg files -I "**/README" |
|
3859 | hg files -I "**/README" | |
3850 |
|
3860 | |||
3851 | - list all binary files:: |
|
3861 | - list all binary files:: | |
3852 |
|
3862 | |||
3853 | hg files "set:binary()" |
|
3863 | hg files "set:binary()" | |
3854 |
|
3864 | |||
3855 | - find files containing a regular expression:: |
|
3865 | - find files containing a regular expression:: | |
3856 |
|
3866 | |||
3857 | hg files "set:grep('bob')" |
|
3867 | hg files "set:grep('bob')" | |
3858 |
|
3868 | |||
3859 | - search tracked file contents with xargs and grep:: |
|
3869 | - search tracked file contents with xargs and grep:: | |
3860 |
|
3870 | |||
3861 | hg files -0 | xargs -0 grep foo |
|
3871 | hg files -0 | xargs -0 grep foo | |
3862 |
|
3872 | |||
3863 | See :hg:`help patterns` and :hg:`help filesets` for more information |
|
3873 | See :hg:`help patterns` and :hg:`help filesets` for more information | |
3864 | on specifying file patterns. |
|
3874 | on specifying file patterns. | |
3865 |
|
3875 | |||
3866 | Returns 0 if a match is found, 1 otherwise. |
|
3876 | Returns 0 if a match is found, 1 otherwise. | |
3867 |
|
3877 | |||
3868 | """ |
|
3878 | """ | |
3869 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
3879 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) | |
3870 |
|
3880 | |||
3871 | end = '\n' |
|
3881 | end = '\n' | |
3872 | if opts.get('print0'): |
|
3882 | if opts.get('print0'): | |
3873 | end = '\0' |
|
3883 | end = '\0' | |
3874 | fmt = '%s' + end |
|
3884 | fmt = '%s' + end | |
3875 |
|
3885 | |||
3876 | m = scmutil.match(ctx, pats, opts) |
|
3886 | m = scmutil.match(ctx, pats, opts) | |
3877 | with ui.formatter('files', opts) as fm: |
|
3887 | with ui.formatter('files', opts) as fm: | |
3878 | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) |
|
3888 | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) | |
3879 |
|
3889 | |||
3880 | @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) |
|
3890 | @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) | |
3881 | def forget(ui, repo, *pats, **opts): |
|
3891 | def forget(ui, repo, *pats, **opts): | |
3882 | """forget the specified files on the next commit |
|
3892 | """forget the specified files on the next commit | |
3883 |
|
3893 | |||
3884 | Mark the specified files so they will no longer be tracked |
|
3894 | Mark the specified files so they will no longer be tracked | |
3885 | after the next commit. |
|
3895 | after the next commit. | |
3886 |
|
3896 | |||
3887 | This only removes files from the current branch, not from the |
|
3897 | This only removes files from the current branch, not from the | |
3888 | entire project history, and it does not delete them from the |
|
3898 | entire project history, and it does not delete them from the | |
3889 | working directory. |
|
3899 | working directory. | |
3890 |
|
3900 | |||
3891 | To delete the file from the working directory, see :hg:`remove`. |
|
3901 | To delete the file from the working directory, see :hg:`remove`. | |
3892 |
|
3902 | |||
3893 | To undo a forget before the next commit, see :hg:`add`. |
|
3903 | To undo a forget before the next commit, see :hg:`add`. | |
3894 |
|
3904 | |||
3895 | .. container:: verbose |
|
3905 | .. container:: verbose | |
3896 |
|
3906 | |||
3897 | Examples: |
|
3907 | Examples: | |
3898 |
|
3908 | |||
3899 | - forget newly-added binary files:: |
|
3909 | - forget newly-added binary files:: | |
3900 |
|
3910 | |||
3901 | hg forget "set:added() and binary()" |
|
3911 | hg forget "set:added() and binary()" | |
3902 |
|
3912 | |||
3903 | - forget files that would be excluded by .hgignore:: |
|
3913 | - forget files that would be excluded by .hgignore:: | |
3904 |
|
3914 | |||
3905 | hg forget "set:hgignore()" |
|
3915 | hg forget "set:hgignore()" | |
3906 |
|
3916 | |||
3907 | Returns 0 on success. |
|
3917 | Returns 0 on success. | |
3908 | """ |
|
3918 | """ | |
3909 |
|
3919 | |||
3910 | if not pats: |
|
3920 | if not pats: | |
3911 | raise error.Abort(_('no files specified')) |
|
3921 | raise error.Abort(_('no files specified')) | |
3912 |
|
3922 | |||
3913 | m = scmutil.match(repo[None], pats, opts) |
|
3923 | m = scmutil.match(repo[None], pats, opts) | |
3914 | rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0] |
|
3924 | rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0] | |
3915 | return rejected and 1 or 0 |
|
3925 | return rejected and 1 or 0 | |
3916 |
|
3926 | |||
3917 | @command( |
|
3927 | @command( | |
3918 | 'graft', |
|
3928 | 'graft', | |
3919 | [('r', 'rev', [], _('revisions to graft'), _('REV')), |
|
3929 | [('r', 'rev', [], _('revisions to graft'), _('REV')), | |
3920 | ('c', 'continue', False, _('resume interrupted graft')), |
|
3930 | ('c', 'continue', False, _('resume interrupted graft')), | |
3921 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
3931 | ('e', 'edit', False, _('invoke editor on commit messages')), | |
3922 | ('', 'log', None, _('append graft info to log message')), |
|
3932 | ('', 'log', None, _('append graft info to log message')), | |
3923 | ('f', 'force', False, _('force graft')), |
|
3933 | ('f', 'force', False, _('force graft')), | |
3924 | ('D', 'currentdate', False, |
|
3934 | ('D', 'currentdate', False, | |
3925 | _('record the current date as commit date')), |
|
3935 | _('record the current date as commit date')), | |
3926 | ('U', 'currentuser', False, |
|
3936 | ('U', 'currentuser', False, | |
3927 | _('record the current user as committer'), _('DATE'))] |
|
3937 | _('record the current user as committer'), _('DATE'))] | |
3928 | + commitopts2 + mergetoolopts + dryrunopts, |
|
3938 | + commitopts2 + mergetoolopts + dryrunopts, | |
3929 | _('[OPTION]... [-r REV]... REV...')) |
|
3939 | _('[OPTION]... [-r REV]... REV...')) | |
3930 | def graft(ui, repo, *revs, **opts): |
|
3940 | def graft(ui, repo, *revs, **opts): | |
3931 | '''copy changes from other branches onto the current branch |
|
3941 | '''copy changes from other branches onto the current branch | |
3932 |
|
3942 | |||
3933 | This command uses Mercurial's merge logic to copy individual |
|
3943 | This command uses Mercurial's merge logic to copy individual | |
3934 | changes from other branches without merging branches in the |
|
3944 | changes from other branches without merging branches in the | |
3935 | history graph. This is sometimes known as 'backporting' or |
|
3945 | history graph. This is sometimes known as 'backporting' or | |
3936 | 'cherry-picking'. By default, graft will copy user, date, and |
|
3946 | 'cherry-picking'. By default, graft will copy user, date, and | |
3937 | description from the source changesets. |
|
3947 | description from the source changesets. | |
3938 |
|
3948 | |||
3939 | Changesets that are ancestors of the current revision, that have |
|
3949 | Changesets that are ancestors of the current revision, that have | |
3940 | already been grafted, or that are merges will be skipped. |
|
3950 | already been grafted, or that are merges will be skipped. | |
3941 |
|
3951 | |||
3942 | If --log is specified, log messages will have a comment appended |
|
3952 | If --log is specified, log messages will have a comment appended | |
3943 | of the form:: |
|
3953 | of the form:: | |
3944 |
|
3954 | |||
3945 | (grafted from CHANGESETHASH) |
|
3955 | (grafted from CHANGESETHASH) | |
3946 |
|
3956 | |||
3947 | If --force is specified, revisions will be grafted even if they |
|
3957 | If --force is specified, revisions will be grafted even if they | |
3948 | are already ancestors of or have been grafted to the destination. |
|
3958 | are already ancestors of or have been grafted to the destination. | |
3949 | This is useful when the revisions have since been backed out. |
|
3959 | This is useful when the revisions have since been backed out. | |
3950 |
|
3960 | |||
3951 | If a graft merge results in conflicts, the graft process is |
|
3961 | If a graft merge results in conflicts, the graft process is | |
3952 | interrupted so that the current merge can be manually resolved. |
|
3962 | interrupted so that the current merge can be manually resolved. | |
3953 | Once all conflicts are addressed, the graft process can be |
|
3963 | Once all conflicts are addressed, the graft process can be | |
3954 | continued with the -c/--continue option. |
|
3964 | continued with the -c/--continue option. | |
3955 |
|
3965 | |||
3956 | .. note:: |
|
3966 | .. note:: | |
3957 |
|
3967 | |||
3958 | The -c/--continue option does not reapply earlier options, except |
|
3968 | The -c/--continue option does not reapply earlier options, except | |
3959 | for --force. |
|
3969 | for --force. | |
3960 |
|
3970 | |||
3961 | .. container:: verbose |
|
3971 | .. container:: verbose | |
3962 |
|
3972 | |||
3963 | Examples: |
|
3973 | Examples: | |
3964 |
|
3974 | |||
3965 | - copy a single change to the stable branch and edit its description:: |
|
3975 | - copy a single change to the stable branch and edit its description:: | |
3966 |
|
3976 | |||
3967 | hg update stable |
|
3977 | hg update stable | |
3968 | hg graft --edit 9393 |
|
3978 | hg graft --edit 9393 | |
3969 |
|
3979 | |||
3970 | - graft a range of changesets with one exception, updating dates:: |
|
3980 | - graft a range of changesets with one exception, updating dates:: | |
3971 |
|
3981 | |||
3972 | hg graft -D "2085::2093 and not 2091" |
|
3982 | hg graft -D "2085::2093 and not 2091" | |
3973 |
|
3983 | |||
3974 | - continue a graft after resolving conflicts:: |
|
3984 | - continue a graft after resolving conflicts:: | |
3975 |
|
3985 | |||
3976 | hg graft -c |
|
3986 | hg graft -c | |
3977 |
|
3987 | |||
3978 | - show the source of a grafted changeset:: |
|
3988 | - show the source of a grafted changeset:: | |
3979 |
|
3989 | |||
3980 | hg log --debug -r . |
|
3990 | hg log --debug -r . | |
3981 |
|
3991 | |||
3982 | - show revisions sorted by date:: |
|
3992 | - show revisions sorted by date:: | |
3983 |
|
3993 | |||
3984 | hg log -r "sort(all(), date)" |
|
3994 | hg log -r "sort(all(), date)" | |
3985 |
|
3995 | |||
3986 | See :hg:`help revisions` and :hg:`help revsets` for more about |
|
3996 | See :hg:`help revisions` and :hg:`help revsets` for more about | |
3987 | specifying revisions. |
|
3997 | specifying revisions. | |
3988 |
|
3998 | |||
3989 | Returns 0 on successful completion. |
|
3999 | Returns 0 on successful completion. | |
3990 | ''' |
|
4000 | ''' | |
3991 | with repo.wlock(): |
|
4001 | with repo.wlock(): | |
3992 | return _dograft(ui, repo, *revs, **opts) |
|
4002 | return _dograft(ui, repo, *revs, **opts) | |
3993 |
|
4003 | |||
3994 | def _dograft(ui, repo, *revs, **opts): |
|
4004 | def _dograft(ui, repo, *revs, **opts): | |
3995 | if revs and opts.get('rev'): |
|
4005 | if revs and opts.get('rev'): | |
3996 | ui.warn(_('warning: inconsistent use of --rev might give unexpected ' |
|
4006 | ui.warn(_('warning: inconsistent use of --rev might give unexpected ' | |
3997 | 'revision ordering!\n')) |
|
4007 | 'revision ordering!\n')) | |
3998 |
|
4008 | |||
3999 | revs = list(revs) |
|
4009 | revs = list(revs) | |
4000 | revs.extend(opts.get('rev')) |
|
4010 | revs.extend(opts.get('rev')) | |
4001 |
|
4011 | |||
4002 | if not opts.get('user') and opts.get('currentuser'): |
|
4012 | if not opts.get('user') and opts.get('currentuser'): | |
4003 | opts['user'] = ui.username() |
|
4013 | opts['user'] = ui.username() | |
4004 | if not opts.get('date') and opts.get('currentdate'): |
|
4014 | if not opts.get('date') and opts.get('currentdate'): | |
4005 | opts['date'] = "%d %d" % util.makedate() |
|
4015 | opts['date'] = "%d %d" % util.makedate() | |
4006 |
|
4016 | |||
4007 | editor = cmdutil.getcommiteditor(editform='graft', **opts) |
|
4017 | editor = cmdutil.getcommiteditor(editform='graft', **opts) | |
4008 |
|
4018 | |||
4009 | cont = False |
|
4019 | cont = False | |
4010 | if opts.get('continue'): |
|
4020 | if opts.get('continue'): | |
4011 | cont = True |
|
4021 | cont = True | |
4012 | if revs: |
|
4022 | if revs: | |
4013 | raise error.Abort(_("can't specify --continue and revisions")) |
|
4023 | raise error.Abort(_("can't specify --continue and revisions")) | |
4014 | # read in unfinished revisions |
|
4024 | # read in unfinished revisions | |
4015 | try: |
|
4025 | try: | |
4016 | nodes = repo.vfs.read('graftstate').splitlines() |
|
4026 | nodes = repo.vfs.read('graftstate').splitlines() | |
4017 | revs = [repo[node].rev() for node in nodes] |
|
4027 | revs = [repo[node].rev() for node in nodes] | |
4018 | except IOError as inst: |
|
4028 | except IOError as inst: | |
4019 | if inst.errno != errno.ENOENT: |
|
4029 | if inst.errno != errno.ENOENT: | |
4020 | raise |
|
4030 | raise | |
4021 | cmdutil.wrongtooltocontinue(repo, _('graft')) |
|
4031 | cmdutil.wrongtooltocontinue(repo, _('graft')) | |
4022 | else: |
|
4032 | else: | |
4023 | cmdutil.checkunfinished(repo) |
|
4033 | cmdutil.checkunfinished(repo) | |
4024 | cmdutil.bailifchanged(repo) |
|
4034 | cmdutil.bailifchanged(repo) | |
4025 | if not revs: |
|
4035 | if not revs: | |
4026 | raise error.Abort(_('no revisions specified')) |
|
4036 | raise error.Abort(_('no revisions specified')) | |
4027 | revs = scmutil.revrange(repo, revs) |
|
4037 | revs = scmutil.revrange(repo, revs) | |
4028 |
|
4038 | |||
4029 | skipped = set() |
|
4039 | skipped = set() | |
4030 | # check for merges |
|
4040 | # check for merges | |
4031 | for rev in repo.revs('%ld and merge()', revs): |
|
4041 | for rev in repo.revs('%ld and merge()', revs): | |
4032 | ui.warn(_('skipping ungraftable merge revision %s\n') % rev) |
|
4042 | ui.warn(_('skipping ungraftable merge revision %s\n') % rev) | |
4033 | skipped.add(rev) |
|
4043 | skipped.add(rev) | |
4034 | revs = [r for r in revs if r not in skipped] |
|
4044 | revs = [r for r in revs if r not in skipped] | |
4035 | if not revs: |
|
4045 | if not revs: | |
4036 | return -1 |
|
4046 | return -1 | |
4037 |
|
4047 | |||
4038 | # Don't check in the --continue case, in effect retaining --force across |
|
4048 | # Don't check in the --continue case, in effect retaining --force across | |
4039 | # --continues. That's because without --force, any revisions we decided to |
|
4049 | # --continues. That's because without --force, any revisions we decided to | |
4040 | # skip would have been filtered out here, so they wouldn't have made their |
|
4050 | # skip would have been filtered out here, so they wouldn't have made their | |
4041 | # way to the graftstate. With --force, any revisions we would have otherwise |
|
4051 | # way to the graftstate. With --force, any revisions we would have otherwise | |
4042 | # skipped would not have been filtered out, and if they hadn't been applied |
|
4052 | # skipped would not have been filtered out, and if they hadn't been applied | |
4043 | # already, they'd have been in the graftstate. |
|
4053 | # already, they'd have been in the graftstate. | |
4044 | if not (cont or opts.get('force')): |
|
4054 | if not (cont or opts.get('force')): | |
4045 | # check for ancestors of dest branch |
|
4055 | # check for ancestors of dest branch | |
4046 | crev = repo['.'].rev() |
|
4056 | crev = repo['.'].rev() | |
4047 | ancestors = repo.changelog.ancestors([crev], inclusive=True) |
|
4057 | ancestors = repo.changelog.ancestors([crev], inclusive=True) | |
4048 | # XXX make this lazy in the future |
|
4058 | # XXX make this lazy in the future | |
4049 | # don't mutate while iterating, create a copy |
|
4059 | # don't mutate while iterating, create a copy | |
4050 | for rev in list(revs): |
|
4060 | for rev in list(revs): | |
4051 | if rev in ancestors: |
|
4061 | if rev in ancestors: | |
4052 | ui.warn(_('skipping ancestor revision %d:%s\n') % |
|
4062 | ui.warn(_('skipping ancestor revision %d:%s\n') % | |
4053 | (rev, repo[rev])) |
|
4063 | (rev, repo[rev])) | |
4054 | # XXX remove on list is slow |
|
4064 | # XXX remove on list is slow | |
4055 | revs.remove(rev) |
|
4065 | revs.remove(rev) | |
4056 | if not revs: |
|
4066 | if not revs: | |
4057 | return -1 |
|
4067 | return -1 | |
4058 |
|
4068 | |||
4059 | # analyze revs for earlier grafts |
|
4069 | # analyze revs for earlier grafts | |
4060 | ids = {} |
|
4070 | ids = {} | |
4061 | for ctx in repo.set("%ld", revs): |
|
4071 | for ctx in repo.set("%ld", revs): | |
4062 | ids[ctx.hex()] = ctx.rev() |
|
4072 | ids[ctx.hex()] = ctx.rev() | |
4063 | n = ctx.extra().get('source') |
|
4073 | n = ctx.extra().get('source') | |
4064 | if n: |
|
4074 | if n: | |
4065 | ids[n] = ctx.rev() |
|
4075 | ids[n] = ctx.rev() | |
4066 |
|
4076 | |||
4067 | # check ancestors for earlier grafts |
|
4077 | # check ancestors for earlier grafts | |
4068 | ui.debug('scanning for duplicate grafts\n') |
|
4078 | ui.debug('scanning for duplicate grafts\n') | |
4069 |
|
4079 | |||
4070 | for rev in repo.changelog.findmissingrevs(revs, [crev]): |
|
4080 | for rev in repo.changelog.findmissingrevs(revs, [crev]): | |
4071 | ctx = repo[rev] |
|
4081 | ctx = repo[rev] | |
4072 | n = ctx.extra().get('source') |
|
4082 | n = ctx.extra().get('source') | |
4073 | if n in ids: |
|
4083 | if n in ids: | |
4074 | try: |
|
4084 | try: | |
4075 | r = repo[n].rev() |
|
4085 | r = repo[n].rev() | |
4076 | except error.RepoLookupError: |
|
4086 | except error.RepoLookupError: | |
4077 | r = None |
|
4087 | r = None | |
4078 | if r in revs: |
|
4088 | if r in revs: | |
4079 | ui.warn(_('skipping revision %d:%s ' |
|
4089 | ui.warn(_('skipping revision %d:%s ' | |
4080 | '(already grafted to %d:%s)\n') |
|
4090 | '(already grafted to %d:%s)\n') | |
4081 | % (r, repo[r], rev, ctx)) |
|
4091 | % (r, repo[r], rev, ctx)) | |
4082 | revs.remove(r) |
|
4092 | revs.remove(r) | |
4083 | elif ids[n] in revs: |
|
4093 | elif ids[n] in revs: | |
4084 | if r is None: |
|
4094 | if r is None: | |
4085 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
4095 | ui.warn(_('skipping already grafted revision %d:%s ' | |
4086 | '(%d:%s also has unknown origin %s)\n') |
|
4096 | '(%d:%s also has unknown origin %s)\n') | |
4087 | % (ids[n], repo[ids[n]], rev, ctx, n[:12])) |
|
4097 | % (ids[n], repo[ids[n]], rev, ctx, n[:12])) | |
4088 | else: |
|
4098 | else: | |
4089 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
4099 | ui.warn(_('skipping already grafted revision %d:%s ' | |
4090 | '(%d:%s also has origin %d:%s)\n') |
|
4100 | '(%d:%s also has origin %d:%s)\n') | |
4091 | % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])) |
|
4101 | % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])) | |
4092 | revs.remove(ids[n]) |
|
4102 | revs.remove(ids[n]) | |
4093 | elif ctx.hex() in ids: |
|
4103 | elif ctx.hex() in ids: | |
4094 | r = ids[ctx.hex()] |
|
4104 | r = ids[ctx.hex()] | |
4095 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
4105 | ui.warn(_('skipping already grafted revision %d:%s ' | |
4096 | '(was grafted from %d:%s)\n') % |
|
4106 | '(was grafted from %d:%s)\n') % | |
4097 | (r, repo[r], rev, ctx)) |
|
4107 | (r, repo[r], rev, ctx)) | |
4098 | revs.remove(r) |
|
4108 | revs.remove(r) | |
4099 | if not revs: |
|
4109 | if not revs: | |
4100 | return -1 |
|
4110 | return -1 | |
4101 |
|
4111 | |||
4102 | for pos, ctx in enumerate(repo.set("%ld", revs)): |
|
4112 | for pos, ctx in enumerate(repo.set("%ld", revs)): | |
4103 | desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
|
4113 | desc = '%d:%s "%s"' % (ctx.rev(), ctx, | |
4104 | ctx.description().split('\n', 1)[0]) |
|
4114 | ctx.description().split('\n', 1)[0]) | |
4105 | names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
|
4115 | names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) | |
4106 | if names: |
|
4116 | if names: | |
4107 | desc += ' (%s)' % ' '.join(names) |
|
4117 | desc += ' (%s)' % ' '.join(names) | |
4108 | ui.status(_('grafting %s\n') % desc) |
|
4118 | ui.status(_('grafting %s\n') % desc) | |
4109 | if opts.get('dry_run'): |
|
4119 | if opts.get('dry_run'): | |
4110 | continue |
|
4120 | continue | |
4111 |
|
4121 | |||
4112 | source = ctx.extra().get('source') |
|
4122 | source = ctx.extra().get('source') | |
4113 | extra = {} |
|
4123 | extra = {} | |
4114 | if source: |
|
4124 | if source: | |
4115 | extra['source'] = source |
|
4125 | extra['source'] = source | |
4116 | extra['intermediate-source'] = ctx.hex() |
|
4126 | extra['intermediate-source'] = ctx.hex() | |
4117 | else: |
|
4127 | else: | |
4118 | extra['source'] = ctx.hex() |
|
4128 | extra['source'] = ctx.hex() | |
4119 | user = ctx.user() |
|
4129 | user = ctx.user() | |
4120 | if opts.get('user'): |
|
4130 | if opts.get('user'): | |
4121 | user = opts['user'] |
|
4131 | user = opts['user'] | |
4122 | date = ctx.date() |
|
4132 | date = ctx.date() | |
4123 | if opts.get('date'): |
|
4133 | if opts.get('date'): | |
4124 | date = opts['date'] |
|
4134 | date = opts['date'] | |
4125 | message = ctx.description() |
|
4135 | message = ctx.description() | |
4126 | if opts.get('log'): |
|
4136 | if opts.get('log'): | |
4127 | message += '\n(grafted from %s)' % ctx.hex() |
|
4137 | message += '\n(grafted from %s)' % ctx.hex() | |
4128 |
|
4138 | |||
4129 | # we don't merge the first commit when continuing |
|
4139 | # we don't merge the first commit when continuing | |
4130 | if not cont: |
|
4140 | if not cont: | |
4131 | # perform the graft merge with p1(rev) as 'ancestor' |
|
4141 | # perform the graft merge with p1(rev) as 'ancestor' | |
4132 | try: |
|
4142 | try: | |
4133 | # ui.forcemerge is an internal variable, do not document |
|
4143 | # ui.forcemerge is an internal variable, do not document | |
4134 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
4144 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | |
4135 | 'graft') |
|
4145 | 'graft') | |
4136 | stats = mergemod.graft(repo, ctx, ctx.p1(), |
|
4146 | stats = mergemod.graft(repo, ctx, ctx.p1(), | |
4137 | ['local', 'graft']) |
|
4147 | ['local', 'graft']) | |
4138 | finally: |
|
4148 | finally: | |
4139 | repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
|
4149 | repo.ui.setconfig('ui', 'forcemerge', '', 'graft') | |
4140 | # report any conflicts |
|
4150 | # report any conflicts | |
4141 | if stats and stats[3] > 0: |
|
4151 | if stats and stats[3] > 0: | |
4142 | # write out state for --continue |
|
4152 | # write out state for --continue | |
4143 | nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
|
4153 | nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] | |
4144 | repo.vfs.write('graftstate', ''.join(nodelines)) |
|
4154 | repo.vfs.write('graftstate', ''.join(nodelines)) | |
4145 | extra = '' |
|
4155 | extra = '' | |
4146 | if opts.get('user'): |
|
4156 | if opts.get('user'): | |
4147 | extra += ' --user %s' % util.shellquote(opts['user']) |
|
4157 | extra += ' --user %s' % util.shellquote(opts['user']) | |
4148 | if opts.get('date'): |
|
4158 | if opts.get('date'): | |
4149 | extra += ' --date %s' % util.shellquote(opts['date']) |
|
4159 | extra += ' --date %s' % util.shellquote(opts['date']) | |
4150 | if opts.get('log'): |
|
4160 | if opts.get('log'): | |
4151 | extra += ' --log' |
|
4161 | extra += ' --log' | |
4152 | hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra |
|
4162 | hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra | |
4153 | raise error.Abort( |
|
4163 | raise error.Abort( | |
4154 | _("unresolved conflicts, can't continue"), |
|
4164 | _("unresolved conflicts, can't continue"), | |
4155 | hint=hint) |
|
4165 | hint=hint) | |
4156 | else: |
|
4166 | else: | |
4157 | cont = False |
|
4167 | cont = False | |
4158 |
|
4168 | |||
4159 | # commit |
|
4169 | # commit | |
4160 | node = repo.commit(text=message, user=user, |
|
4170 | node = repo.commit(text=message, user=user, | |
4161 | date=date, extra=extra, editor=editor) |
|
4171 | date=date, extra=extra, editor=editor) | |
4162 | if node is None: |
|
4172 | if node is None: | |
4163 | ui.warn( |
|
4173 | ui.warn( | |
4164 | _('note: graft of %d:%s created no changes to commit\n') % |
|
4174 | _('note: graft of %d:%s created no changes to commit\n') % | |
4165 | (ctx.rev(), ctx)) |
|
4175 | (ctx.rev(), ctx)) | |
4166 |
|
4176 | |||
4167 | # remove state when we complete successfully |
|
4177 | # remove state when we complete successfully | |
4168 | if not opts.get('dry_run'): |
|
4178 | if not opts.get('dry_run'): | |
4169 | util.unlinkpath(repo.join('graftstate'), ignoremissing=True) |
|
4179 | util.unlinkpath(repo.join('graftstate'), ignoremissing=True) | |
4170 |
|
4180 | |||
4171 | return 0 |
|
4181 | return 0 | |
4172 |
|
4182 | |||
4173 | @command('grep', |
|
4183 | @command('grep', | |
4174 | [('0', 'print0', None, _('end fields with NUL')), |
|
4184 | [('0', 'print0', None, _('end fields with NUL')), | |
4175 | ('', 'all', None, _('print all revisions that match')), |
|
4185 | ('', 'all', None, _('print all revisions that match')), | |
4176 | ('a', 'text', None, _('treat all files as text')), |
|
4186 | ('a', 'text', None, _('treat all files as text')), | |
4177 | ('f', 'follow', None, |
|
4187 | ('f', 'follow', None, | |
4178 | _('follow changeset history,' |
|
4188 | _('follow changeset history,' | |
4179 | ' or file history across copies and renames')), |
|
4189 | ' or file history across copies and renames')), | |
4180 | ('i', 'ignore-case', None, _('ignore case when matching')), |
|
4190 | ('i', 'ignore-case', None, _('ignore case when matching')), | |
4181 | ('l', 'files-with-matches', None, |
|
4191 | ('l', 'files-with-matches', None, | |
4182 | _('print only filenames and revisions that match')), |
|
4192 | _('print only filenames and revisions that match')), | |
4183 | ('n', 'line-number', None, _('print matching line numbers')), |
|
4193 | ('n', 'line-number', None, _('print matching line numbers')), | |
4184 | ('r', 'rev', [], |
|
4194 | ('r', 'rev', [], | |
4185 | _('only search files changed within revision range'), _('REV')), |
|
4195 | _('only search files changed within revision range'), _('REV')), | |
4186 | ('u', 'user', None, _('list the author (long with -v)')), |
|
4196 | ('u', 'user', None, _('list the author (long with -v)')), | |
4187 | ('d', 'date', None, _('list the date (short with -q)')), |
|
4197 | ('d', 'date', None, _('list the date (short with -q)')), | |
4188 | ] + formatteropts + walkopts, |
|
4198 | ] + formatteropts + walkopts, | |
4189 | _('[OPTION]... PATTERN [FILE]...'), |
|
4199 | _('[OPTION]... PATTERN [FILE]...'), | |
4190 | inferrepo=True) |
|
4200 | inferrepo=True) | |
4191 | def grep(ui, repo, pattern, *pats, **opts): |
|
4201 | def grep(ui, repo, pattern, *pats, **opts): | |
4192 | """search revision history for a pattern in specified files |
|
4202 | """search revision history for a pattern in specified files | |
4193 |
|
4203 | |||
4194 | Search revision history for a regular expression in the specified |
|
4204 | Search revision history for a regular expression in the specified | |
4195 | files or the entire project. |
|
4205 | files or the entire project. | |
4196 |
|
4206 | |||
4197 | By default, grep prints the most recent revision number for each |
|
4207 | By default, grep prints the most recent revision number for each | |
4198 | file in which it finds a match. To get it to print every revision |
|
4208 | file in which it finds a match. To get it to print every revision | |
4199 | that contains a change in match status ("-" for a match that becomes |
|
4209 | that contains a change in match status ("-" for a match that becomes | |
4200 | a non-match, or "+" for a non-match that becomes a match), use the |
|
4210 | a non-match, or "+" for a non-match that becomes a match), use the | |
4201 | --all flag. |
|
4211 | --all flag. | |
4202 |
|
4212 | |||
4203 | PATTERN can be any Python (roughly Perl-compatible) regular |
|
4213 | PATTERN can be any Python (roughly Perl-compatible) regular | |
4204 | expression. |
|
4214 | expression. | |
4205 |
|
4215 | |||
4206 | If no FILEs are specified (and -f/--follow isn't set), all files in |
|
4216 | If no FILEs are specified (and -f/--follow isn't set), all files in | |
4207 | the repository are searched, including those that don't exist in the |
|
4217 | the repository are searched, including those that don't exist in the | |
4208 | current branch or have been deleted in a prior changeset. |
|
4218 | current branch or have been deleted in a prior changeset. | |
4209 |
|
4219 | |||
4210 | Returns 0 if a match is found, 1 otherwise. |
|
4220 | Returns 0 if a match is found, 1 otherwise. | |
4211 | """ |
|
4221 | """ | |
4212 | reflags = re.M |
|
4222 | reflags = re.M | |
4213 | if opts.get('ignore_case'): |
|
4223 | if opts.get('ignore_case'): | |
4214 | reflags |= re.I |
|
4224 | reflags |= re.I | |
4215 | try: |
|
4225 | try: | |
4216 | regexp = util.re.compile(pattern, reflags) |
|
4226 | regexp = util.re.compile(pattern, reflags) | |
4217 | except re.error as inst: |
|
4227 | except re.error as inst: | |
4218 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
|
4228 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) | |
4219 | return 1 |
|
4229 | return 1 | |
4220 | sep, eol = ':', '\n' |
|
4230 | sep, eol = ':', '\n' | |
4221 | if opts.get('print0'): |
|
4231 | if opts.get('print0'): | |
4222 | sep = eol = '\0' |
|
4232 | sep = eol = '\0' | |
4223 |
|
4233 | |||
4224 | getfile = util.lrucachefunc(repo.file) |
|
4234 | getfile = util.lrucachefunc(repo.file) | |
4225 |
|
4235 | |||
4226 | def matchlines(body): |
|
4236 | def matchlines(body): | |
4227 | begin = 0 |
|
4237 | begin = 0 | |
4228 | linenum = 0 |
|
4238 | linenum = 0 | |
4229 | while begin < len(body): |
|
4239 | while begin < len(body): | |
4230 | match = regexp.search(body, begin) |
|
4240 | match = regexp.search(body, begin) | |
4231 | if not match: |
|
4241 | if not match: | |
4232 | break |
|
4242 | break | |
4233 | mstart, mend = match.span() |
|
4243 | mstart, mend = match.span() | |
4234 | linenum += body.count('\n', begin, mstart) + 1 |
|
4244 | linenum += body.count('\n', begin, mstart) + 1 | |
4235 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
4245 | lstart = body.rfind('\n', begin, mstart) + 1 or begin | |
4236 | begin = body.find('\n', mend) + 1 or len(body) + 1 |
|
4246 | begin = body.find('\n', mend) + 1 or len(body) + 1 | |
4237 | lend = begin - 1 |
|
4247 | lend = begin - 1 | |
4238 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
4248 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] | |
4239 |
|
4249 | |||
4240 | class linestate(object): |
|
4250 | class linestate(object): | |
4241 | def __init__(self, line, linenum, colstart, colend): |
|
4251 | def __init__(self, line, linenum, colstart, colend): | |
4242 | self.line = line |
|
4252 | self.line = line | |
4243 | self.linenum = linenum |
|
4253 | self.linenum = linenum | |
4244 | self.colstart = colstart |
|
4254 | self.colstart = colstart | |
4245 | self.colend = colend |
|
4255 | self.colend = colend | |
4246 |
|
4256 | |||
4247 | def __hash__(self): |
|
4257 | def __hash__(self): | |
4248 | return hash((self.linenum, self.line)) |
|
4258 | return hash((self.linenum, self.line)) | |
4249 |
|
4259 | |||
4250 | def __eq__(self, other): |
|
4260 | def __eq__(self, other): | |
4251 | return self.line == other.line |
|
4261 | return self.line == other.line | |
4252 |
|
4262 | |||
4253 | def findpos(self): |
|
4263 | def findpos(self): | |
4254 | """Iterate all (start, end) indices of matches""" |
|
4264 | """Iterate all (start, end) indices of matches""" | |
4255 | yield self.colstart, self.colend |
|
4265 | yield self.colstart, self.colend | |
4256 | p = self.colend |
|
4266 | p = self.colend | |
4257 | while p < len(self.line): |
|
4267 | while p < len(self.line): | |
4258 | m = regexp.search(self.line, p) |
|
4268 | m = regexp.search(self.line, p) | |
4259 | if not m: |
|
4269 | if not m: | |
4260 | break |
|
4270 | break | |
4261 | yield m.span() |
|
4271 | yield m.span() | |
4262 | p = m.end() |
|
4272 | p = m.end() | |
4263 |
|
4273 | |||
4264 | matches = {} |
|
4274 | matches = {} | |
4265 | copies = {} |
|
4275 | copies = {} | |
4266 | def grepbody(fn, rev, body): |
|
4276 | def grepbody(fn, rev, body): | |
4267 | matches[rev].setdefault(fn, []) |
|
4277 | matches[rev].setdefault(fn, []) | |
4268 | m = matches[rev][fn] |
|
4278 | m = matches[rev][fn] | |
4269 | for lnum, cstart, cend, line in matchlines(body): |
|
4279 | for lnum, cstart, cend, line in matchlines(body): | |
4270 | s = linestate(line, lnum, cstart, cend) |
|
4280 | s = linestate(line, lnum, cstart, cend) | |
4271 | m.append(s) |
|
4281 | m.append(s) | |
4272 |
|
4282 | |||
4273 | def difflinestates(a, b): |
|
4283 | def difflinestates(a, b): | |
4274 | sm = difflib.SequenceMatcher(None, a, b) |
|
4284 | sm = difflib.SequenceMatcher(None, a, b) | |
4275 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
4285 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | |
4276 | if tag == 'insert': |
|
4286 | if tag == 'insert': | |
4277 | for i in xrange(blo, bhi): |
|
4287 | for i in xrange(blo, bhi): | |
4278 | yield ('+', b[i]) |
|
4288 | yield ('+', b[i]) | |
4279 | elif tag == 'delete': |
|
4289 | elif tag == 'delete': | |
4280 | for i in xrange(alo, ahi): |
|
4290 | for i in xrange(alo, ahi): | |
4281 | yield ('-', a[i]) |
|
4291 | yield ('-', a[i]) | |
4282 | elif tag == 'replace': |
|
4292 | elif tag == 'replace': | |
4283 | for i in xrange(alo, ahi): |
|
4293 | for i in xrange(alo, ahi): | |
4284 | yield ('-', a[i]) |
|
4294 | yield ('-', a[i]) | |
4285 | for i in xrange(blo, bhi): |
|
4295 | for i in xrange(blo, bhi): | |
4286 | yield ('+', b[i]) |
|
4296 | yield ('+', b[i]) | |
4287 |
|
4297 | |||
4288 | def display(fm, fn, ctx, pstates, states): |
|
4298 | def display(fm, fn, ctx, pstates, states): | |
4289 | rev = ctx.rev() |
|
4299 | rev = ctx.rev() | |
4290 | if fm.isplain(): |
|
4300 | if fm.isplain(): | |
4291 | formatuser = ui.shortuser |
|
4301 | formatuser = ui.shortuser | |
4292 | else: |
|
4302 | else: | |
4293 | formatuser = str |
|
4303 | formatuser = str | |
4294 | if ui.quiet: |
|
4304 | if ui.quiet: | |
4295 | datefmt = '%Y-%m-%d' |
|
4305 | datefmt = '%Y-%m-%d' | |
4296 | else: |
|
4306 | else: | |
4297 | datefmt = '%a %b %d %H:%M:%S %Y %1%2' |
|
4307 | datefmt = '%a %b %d %H:%M:%S %Y %1%2' | |
4298 | found = False |
|
4308 | found = False | |
4299 | @util.cachefunc |
|
4309 | @util.cachefunc | |
4300 | def binary(): |
|
4310 | def binary(): | |
4301 | flog = getfile(fn) |
|
4311 | flog = getfile(fn) | |
4302 | return util.binary(flog.read(ctx.filenode(fn))) |
|
4312 | return util.binary(flog.read(ctx.filenode(fn))) | |
4303 |
|
4313 | |||
4304 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
4314 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} | |
4305 | if opts.get('all'): |
|
4315 | if opts.get('all'): | |
4306 | iter = difflinestates(pstates, states) |
|
4316 | iter = difflinestates(pstates, states) | |
4307 | else: |
|
4317 | else: | |
4308 | iter = [('', l) for l in states] |
|
4318 | iter = [('', l) for l in states] | |
4309 | for change, l in iter: |
|
4319 | for change, l in iter: | |
4310 | fm.startitem() |
|
4320 | fm.startitem() | |
4311 | fm.data(node=fm.hexfunc(ctx.node())) |
|
4321 | fm.data(node=fm.hexfunc(ctx.node())) | |
4312 | cols = [ |
|
4322 | cols = [ | |
4313 | ('filename', fn, True), |
|
4323 | ('filename', fn, True), | |
4314 | ('rev', rev, True), |
|
4324 | ('rev', rev, True), | |
4315 | ('linenumber', l.linenum, opts.get('line_number')), |
|
4325 | ('linenumber', l.linenum, opts.get('line_number')), | |
4316 | ] |
|
4326 | ] | |
4317 | if opts.get('all'): |
|
4327 | if opts.get('all'): | |
4318 | cols.append(('change', change, True)) |
|
4328 | cols.append(('change', change, True)) | |
4319 | cols.extend([ |
|
4329 | cols.extend([ | |
4320 | ('user', formatuser(ctx.user()), opts.get('user')), |
|
4330 | ('user', formatuser(ctx.user()), opts.get('user')), | |
4321 | ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')), |
|
4331 | ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')), | |
4322 | ]) |
|
4332 | ]) | |
4323 | lastcol = next(name for name, data, cond in reversed(cols) if cond) |
|
4333 | lastcol = next(name for name, data, cond in reversed(cols) if cond) | |
4324 | for name, data, cond in cols: |
|
4334 | for name, data, cond in cols: | |
4325 | field = fieldnamemap.get(name, name) |
|
4335 | field = fieldnamemap.get(name, name) | |
4326 | fm.condwrite(cond, field, '%s', data, label='grep.%s' % name) |
|
4336 | fm.condwrite(cond, field, '%s', data, label='grep.%s' % name) | |
4327 | if cond and name != lastcol: |
|
4337 | if cond and name != lastcol: | |
4328 | fm.plain(sep, label='grep.sep') |
|
4338 | fm.plain(sep, label='grep.sep') | |
4329 | if not opts.get('files_with_matches'): |
|
4339 | if not opts.get('files_with_matches'): | |
4330 | fm.plain(sep, label='grep.sep') |
|
4340 | fm.plain(sep, label='grep.sep') | |
4331 | if not opts.get('text') and binary(): |
|
4341 | if not opts.get('text') and binary(): | |
4332 | fm.plain(_(" Binary file matches")) |
|
4342 | fm.plain(_(" Binary file matches")) | |
4333 | else: |
|
4343 | else: | |
4334 | displaymatches(fm.nested('texts'), l) |
|
4344 | displaymatches(fm.nested('texts'), l) | |
4335 | fm.plain(eol) |
|
4345 | fm.plain(eol) | |
4336 | found = True |
|
4346 | found = True | |
4337 | if opts.get('files_with_matches'): |
|
4347 | if opts.get('files_with_matches'): | |
4338 | break |
|
4348 | break | |
4339 | return found |
|
4349 | return found | |
4340 |
|
4350 | |||
4341 | def displaymatches(fm, l): |
|
4351 | def displaymatches(fm, l): | |
4342 | p = 0 |
|
4352 | p = 0 | |
4343 | for s, e in l.findpos(): |
|
4353 | for s, e in l.findpos(): | |
4344 | if p < s: |
|
4354 | if p < s: | |
4345 | fm.startitem() |
|
4355 | fm.startitem() | |
4346 | fm.write('text', '%s', l.line[p:s]) |
|
4356 | fm.write('text', '%s', l.line[p:s]) | |
4347 | fm.data(matched=False) |
|
4357 | fm.data(matched=False) | |
4348 | fm.startitem() |
|
4358 | fm.startitem() | |
4349 | fm.write('text', '%s', l.line[s:e], label='grep.match') |
|
4359 | fm.write('text', '%s', l.line[s:e], label='grep.match') | |
4350 | fm.data(matched=True) |
|
4360 | fm.data(matched=True) | |
4351 | p = e |
|
4361 | p = e | |
4352 | if p < len(l.line): |
|
4362 | if p < len(l.line): | |
4353 | fm.startitem() |
|
4363 | fm.startitem() | |
4354 | fm.write('text', '%s', l.line[p:]) |
|
4364 | fm.write('text', '%s', l.line[p:]) | |
4355 | fm.data(matched=False) |
|
4365 | fm.data(matched=False) | |
4356 | fm.end() |
|
4366 | fm.end() | |
4357 |
|
4367 | |||
4358 | skip = {} |
|
4368 | skip = {} | |
4359 | revfiles = {} |
|
4369 | revfiles = {} | |
4360 | matchfn = scmutil.match(repo[None], pats, opts) |
|
4370 | matchfn = scmutil.match(repo[None], pats, opts) | |
4361 | found = False |
|
4371 | found = False | |
4362 | follow = opts.get('follow') |
|
4372 | follow = opts.get('follow') | |
4363 |
|
4373 | |||
4364 | def prep(ctx, fns): |
|
4374 | def prep(ctx, fns): | |
4365 | rev = ctx.rev() |
|
4375 | rev = ctx.rev() | |
4366 | pctx = ctx.p1() |
|
4376 | pctx = ctx.p1() | |
4367 | parent = pctx.rev() |
|
4377 | parent = pctx.rev() | |
4368 | matches.setdefault(rev, {}) |
|
4378 | matches.setdefault(rev, {}) | |
4369 | matches.setdefault(parent, {}) |
|
4379 | matches.setdefault(parent, {}) | |
4370 | files = revfiles.setdefault(rev, []) |
|
4380 | files = revfiles.setdefault(rev, []) | |
4371 | for fn in fns: |
|
4381 | for fn in fns: | |
4372 | flog = getfile(fn) |
|
4382 | flog = getfile(fn) | |
4373 | try: |
|
4383 | try: | |
4374 | fnode = ctx.filenode(fn) |
|
4384 | fnode = ctx.filenode(fn) | |
4375 | except error.LookupError: |
|
4385 | except error.LookupError: | |
4376 | continue |
|
4386 | continue | |
4377 |
|
4387 | |||
4378 | copied = flog.renamed(fnode) |
|
4388 | copied = flog.renamed(fnode) | |
4379 | copy = follow and copied and copied[0] |
|
4389 | copy = follow and copied and copied[0] | |
4380 | if copy: |
|
4390 | if copy: | |
4381 | copies.setdefault(rev, {})[fn] = copy |
|
4391 | copies.setdefault(rev, {})[fn] = copy | |
4382 | if fn in skip: |
|
4392 | if fn in skip: | |
4383 | if copy: |
|
4393 | if copy: | |
4384 | skip[copy] = True |
|
4394 | skip[copy] = True | |
4385 | continue |
|
4395 | continue | |
4386 | files.append(fn) |
|
4396 | files.append(fn) | |
4387 |
|
4397 | |||
4388 | if fn not in matches[rev]: |
|
4398 | if fn not in matches[rev]: | |
4389 | grepbody(fn, rev, flog.read(fnode)) |
|
4399 | grepbody(fn, rev, flog.read(fnode)) | |
4390 |
|
4400 | |||
4391 | pfn = copy or fn |
|
4401 | pfn = copy or fn | |
4392 | if pfn not in matches[parent]: |
|
4402 | if pfn not in matches[parent]: | |
4393 | try: |
|
4403 | try: | |
4394 | fnode = pctx.filenode(pfn) |
|
4404 | fnode = pctx.filenode(pfn) | |
4395 | grepbody(pfn, parent, flog.read(fnode)) |
|
4405 | grepbody(pfn, parent, flog.read(fnode)) | |
4396 | except error.LookupError: |
|
4406 | except error.LookupError: | |
4397 | pass |
|
4407 | pass | |
4398 |
|
4408 | |||
4399 | fm = ui.formatter('grep', opts) |
|
4409 | fm = ui.formatter('grep', opts) | |
4400 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): |
|
4410 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): | |
4401 | rev = ctx.rev() |
|
4411 | rev = ctx.rev() | |
4402 | parent = ctx.p1().rev() |
|
4412 | parent = ctx.p1().rev() | |
4403 | for fn in sorted(revfiles.get(rev, [])): |
|
4413 | for fn in sorted(revfiles.get(rev, [])): | |
4404 | states = matches[rev][fn] |
|
4414 | states = matches[rev][fn] | |
4405 | copy = copies.get(rev, {}).get(fn) |
|
4415 | copy = copies.get(rev, {}).get(fn) | |
4406 | if fn in skip: |
|
4416 | if fn in skip: | |
4407 | if copy: |
|
4417 | if copy: | |
4408 | skip[copy] = True |
|
4418 | skip[copy] = True | |
4409 | continue |
|
4419 | continue | |
4410 | pstates = matches.get(parent, {}).get(copy or fn, []) |
|
4420 | pstates = matches.get(parent, {}).get(copy or fn, []) | |
4411 | if pstates or states: |
|
4421 | if pstates or states: | |
4412 | r = display(fm, fn, ctx, pstates, states) |
|
4422 | r = display(fm, fn, ctx, pstates, states) | |
4413 | found = found or r |
|
4423 | found = found or r | |
4414 | if r and not opts.get('all'): |
|
4424 | if r and not opts.get('all'): | |
4415 | skip[fn] = True |
|
4425 | skip[fn] = True | |
4416 | if copy: |
|
4426 | if copy: | |
4417 | skip[copy] = True |
|
4427 | skip[copy] = True | |
4418 | del matches[rev] |
|
4428 | del matches[rev] | |
4419 | del revfiles[rev] |
|
4429 | del revfiles[rev] | |
4420 | fm.end() |
|
4430 | fm.end() | |
4421 |
|
4431 | |||
4422 | return not found |
|
4432 | return not found | |
4423 |
|
4433 | |||
4424 | @command('heads', |
|
4434 | @command('heads', | |
4425 | [('r', 'rev', '', |
|
4435 | [('r', 'rev', '', | |
4426 | _('show only heads which are descendants of STARTREV'), _('STARTREV')), |
|
4436 | _('show only heads which are descendants of STARTREV'), _('STARTREV')), | |
4427 | ('t', 'topo', False, _('show topological heads only')), |
|
4437 | ('t', 'topo', False, _('show topological heads only')), | |
4428 | ('a', 'active', False, _('show active branchheads only (DEPRECATED)')), |
|
4438 | ('a', 'active', False, _('show active branchheads only (DEPRECATED)')), | |
4429 | ('c', 'closed', False, _('show normal and closed branch heads')), |
|
4439 | ('c', 'closed', False, _('show normal and closed branch heads')), | |
4430 | ] + templateopts, |
|
4440 | ] + templateopts, | |
4431 | _('[-ct] [-r STARTREV] [REV]...')) |
|
4441 | _('[-ct] [-r STARTREV] [REV]...')) | |
4432 | def heads(ui, repo, *branchrevs, **opts): |
|
4442 | def heads(ui, repo, *branchrevs, **opts): | |
4433 | """show branch heads |
|
4443 | """show branch heads | |
4434 |
|
4444 | |||
4435 | With no arguments, show all open branch heads in the repository. |
|
4445 | With no arguments, show all open branch heads in the repository. | |
4436 | Branch heads are changesets that have no descendants on the |
|
4446 | Branch heads are changesets that have no descendants on the | |
4437 | same branch. They are where development generally takes place and |
|
4447 | same branch. They are where development generally takes place and | |
4438 | are the usual targets for update and merge operations. |
|
4448 | are the usual targets for update and merge operations. | |
4439 |
|
4449 | |||
4440 | If one or more REVs are given, only open branch heads on the |
|
4450 | If one or more REVs are given, only open branch heads on the | |
4441 | branches associated with the specified changesets are shown. This |
|
4451 | branches associated with the specified changesets are shown. This | |
4442 | means that you can use :hg:`heads .` to see the heads on the |
|
4452 | means that you can use :hg:`heads .` to see the heads on the | |
4443 | currently checked-out branch. |
|
4453 | currently checked-out branch. | |
4444 |
|
4454 | |||
4445 | If -c/--closed is specified, also show branch heads marked closed |
|
4455 | If -c/--closed is specified, also show branch heads marked closed | |
4446 | (see :hg:`commit --close-branch`). |
|
4456 | (see :hg:`commit --close-branch`). | |
4447 |
|
4457 | |||
4448 | If STARTREV is specified, only those heads that are descendants of |
|
4458 | If STARTREV is specified, only those heads that are descendants of | |
4449 | STARTREV will be displayed. |
|
4459 | STARTREV will be displayed. | |
4450 |
|
4460 | |||
4451 | If -t/--topo is specified, named branch mechanics will be ignored and only |
|
4461 | If -t/--topo is specified, named branch mechanics will be ignored and only | |
4452 | topological heads (changesets with no children) will be shown. |
|
4462 | topological heads (changesets with no children) will be shown. | |
4453 |
|
4463 | |||
4454 | Returns 0 if matching heads are found, 1 if not. |
|
4464 | Returns 0 if matching heads are found, 1 if not. | |
4455 | """ |
|
4465 | """ | |
4456 |
|
4466 | |||
4457 | start = None |
|
4467 | start = None | |
4458 | if 'rev' in opts: |
|
4468 | if 'rev' in opts: | |
4459 | start = scmutil.revsingle(repo, opts['rev'], None).node() |
|
4469 | start = scmutil.revsingle(repo, opts['rev'], None).node() | |
4460 |
|
4470 | |||
4461 | if opts.get('topo'): |
|
4471 | if opts.get('topo'): | |
4462 | heads = [repo[h] for h in repo.heads(start)] |
|
4472 | heads = [repo[h] for h in repo.heads(start)] | |
4463 | else: |
|
4473 | else: | |
4464 | heads = [] |
|
4474 | heads = [] | |
4465 | for branch in repo.branchmap(): |
|
4475 | for branch in repo.branchmap(): | |
4466 | heads += repo.branchheads(branch, start, opts.get('closed')) |
|
4476 | heads += repo.branchheads(branch, start, opts.get('closed')) | |
4467 | heads = [repo[h] for h in heads] |
|
4477 | heads = [repo[h] for h in heads] | |
4468 |
|
4478 | |||
4469 | if branchrevs: |
|
4479 | if branchrevs: | |
4470 | branches = set(repo[br].branch() for br in branchrevs) |
|
4480 | branches = set(repo[br].branch() for br in branchrevs) | |
4471 | heads = [h for h in heads if h.branch() in branches] |
|
4481 | heads = [h for h in heads if h.branch() in branches] | |
4472 |
|
4482 | |||
4473 | if opts.get('active') and branchrevs: |
|
4483 | if opts.get('active') and branchrevs: | |
4474 | dagheads = repo.heads(start) |
|
4484 | dagheads = repo.heads(start) | |
4475 | heads = [h for h in heads if h.node() in dagheads] |
|
4485 | heads = [h for h in heads if h.node() in dagheads] | |
4476 |
|
4486 | |||
4477 | if branchrevs: |
|
4487 | if branchrevs: | |
4478 | haveheads = set(h.branch() for h in heads) |
|
4488 | haveheads = set(h.branch() for h in heads) | |
4479 | if branches - haveheads: |
|
4489 | if branches - haveheads: | |
4480 | headless = ', '.join(b for b in branches - haveheads) |
|
4490 | headless = ', '.join(b for b in branches - haveheads) | |
4481 | msg = _('no open branch heads found on branches %s') |
|
4491 | msg = _('no open branch heads found on branches %s') | |
4482 | if opts.get('rev'): |
|
4492 | if opts.get('rev'): | |
4483 | msg += _(' (started at %s)') % opts['rev'] |
|
4493 | msg += _(' (started at %s)') % opts['rev'] | |
4484 | ui.warn((msg + '\n') % headless) |
|
4494 | ui.warn((msg + '\n') % headless) | |
4485 |
|
4495 | |||
4486 | if not heads: |
|
4496 | if not heads: | |
4487 | return 1 |
|
4497 | return 1 | |
4488 |
|
4498 | |||
4489 | heads = sorted(heads, key=lambda x: -x.rev()) |
|
4499 | heads = sorted(heads, key=lambda x: -x.rev()) | |
4490 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
4500 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
4491 | for ctx in heads: |
|
4501 | for ctx in heads: | |
4492 | displayer.show(ctx) |
|
4502 | displayer.show(ctx) | |
4493 | displayer.close() |
|
4503 | displayer.close() | |
4494 |
|
4504 | |||
4495 | @command('help', |
|
4505 | @command('help', | |
4496 | [('e', 'extension', None, _('show only help for extensions')), |
|
4506 | [('e', 'extension', None, _('show only help for extensions')), | |
4497 | ('c', 'command', None, _('show only help for commands')), |
|
4507 | ('c', 'command', None, _('show only help for commands')), | |
4498 | ('k', 'keyword', None, _('show topics matching keyword')), |
|
4508 | ('k', 'keyword', None, _('show topics matching keyword')), | |
4499 | ('s', 'system', [], _('show help for specific platform(s)')), |
|
4509 | ('s', 'system', [], _('show help for specific platform(s)')), | |
4500 | ], |
|
4510 | ], | |
4501 | _('[-ecks] [TOPIC]'), |
|
4511 | _('[-ecks] [TOPIC]'), | |
4502 | norepo=True) |
|
4512 | norepo=True) | |
4503 | def help_(ui, name=None, **opts): |
|
4513 | def help_(ui, name=None, **opts): | |
4504 | """show help for a given topic or a help overview |
|
4514 | """show help for a given topic or a help overview | |
4505 |
|
4515 | |||
4506 | With no arguments, print a list of commands with short help messages. |
|
4516 | With no arguments, print a list of commands with short help messages. | |
4507 |
|
4517 | |||
4508 | Given a topic, extension, or command name, print help for that |
|
4518 | Given a topic, extension, or command name, print help for that | |
4509 | topic. |
|
4519 | topic. | |
4510 |
|
4520 | |||
4511 | Returns 0 if successful. |
|
4521 | Returns 0 if successful. | |
4512 | """ |
|
4522 | """ | |
4513 |
|
4523 | |||
4514 | textwidth = ui.configint('ui', 'textwidth', 78) |
|
4524 | textwidth = ui.configint('ui', 'textwidth', 78) | |
4515 | termwidth = ui.termwidth() - 2 |
|
4525 | termwidth = ui.termwidth() - 2 | |
4516 | if textwidth <= 0 or termwidth < textwidth: |
|
4526 | if textwidth <= 0 or termwidth < textwidth: | |
4517 | textwidth = termwidth |
|
4527 | textwidth = termwidth | |
4518 |
|
4528 | |||
4519 | keep = opts.get('system') or [] |
|
4529 | keep = opts.get('system') or [] | |
4520 | if len(keep) == 0: |
|
4530 | if len(keep) == 0: | |
4521 | if sys.platform.startswith('win'): |
|
4531 | if sys.platform.startswith('win'): | |
4522 | keep.append('windows') |
|
4532 | keep.append('windows') | |
4523 | elif sys.platform == 'OpenVMS': |
|
4533 | elif sys.platform == 'OpenVMS': | |
4524 | keep.append('vms') |
|
4534 | keep.append('vms') | |
4525 | elif sys.platform == 'plan9': |
|
4535 | elif sys.platform == 'plan9': | |
4526 | keep.append('plan9') |
|
4536 | keep.append('plan9') | |
4527 | else: |
|
4537 | else: | |
4528 | keep.append('unix') |
|
4538 | keep.append('unix') | |
4529 | keep.append(sys.platform.lower()) |
|
4539 | keep.append(sys.platform.lower()) | |
4530 | if ui.verbose: |
|
4540 | if ui.verbose: | |
4531 | keep.append('verbose') |
|
4541 | keep.append('verbose') | |
4532 |
|
4542 | |||
4533 | section = None |
|
4543 | section = None | |
4534 | subtopic = None |
|
4544 | subtopic = None | |
4535 | if name and '.' in name: |
|
4545 | if name and '.' in name: | |
4536 | name, remaining = name.split('.', 1) |
|
4546 | name, remaining = name.split('.', 1) | |
4537 | remaining = encoding.lower(remaining) |
|
4547 | remaining = encoding.lower(remaining) | |
4538 | if '.' in remaining: |
|
4548 | if '.' in remaining: | |
4539 | subtopic, section = remaining.split('.', 1) |
|
4549 | subtopic, section = remaining.split('.', 1) | |
4540 | else: |
|
4550 | else: | |
4541 | if name in help.subtopics: |
|
4551 | if name in help.subtopics: | |
4542 | subtopic = remaining |
|
4552 | subtopic = remaining | |
4543 | else: |
|
4553 | else: | |
4544 | section = remaining |
|
4554 | section = remaining | |
4545 |
|
4555 | |||
4546 | text = help.help_(ui, name, subtopic=subtopic, **opts) |
|
4556 | text = help.help_(ui, name, subtopic=subtopic, **opts) | |
4547 |
|
4557 | |||
4548 | formatted, pruned = minirst.format(text, textwidth, keep=keep, |
|
4558 | formatted, pruned = minirst.format(text, textwidth, keep=keep, | |
4549 | section=section) |
|
4559 | section=section) | |
4550 |
|
4560 | |||
4551 | # We could have been given a weird ".foo" section without a name |
|
4561 | # We could have been given a weird ".foo" section without a name | |
4552 | # to look for, or we could have simply failed to found "foo.bar" |
|
4562 | # to look for, or we could have simply failed to found "foo.bar" | |
4553 | # because bar isn't a section of foo |
|
4563 | # because bar isn't a section of foo | |
4554 | if section and not (formatted and name): |
|
4564 | if section and not (formatted and name): | |
4555 | raise error.Abort(_("help section not found")) |
|
4565 | raise error.Abort(_("help section not found")) | |
4556 |
|
4566 | |||
4557 | if 'verbose' in pruned: |
|
4567 | if 'verbose' in pruned: | |
4558 | keep.append('omitted') |
|
4568 | keep.append('omitted') | |
4559 | else: |
|
4569 | else: | |
4560 | keep.append('notomitted') |
|
4570 | keep.append('notomitted') | |
4561 | formatted, pruned = minirst.format(text, textwidth, keep=keep, |
|
4571 | formatted, pruned = minirst.format(text, textwidth, keep=keep, | |
4562 | section=section) |
|
4572 | section=section) | |
4563 | ui.write(formatted) |
|
4573 | ui.write(formatted) | |
4564 |
|
4574 | |||
4565 |
|
4575 | |||
4566 | @command('identify|id', |
|
4576 | @command('identify|id', | |
4567 | [('r', 'rev', '', |
|
4577 | [('r', 'rev', '', | |
4568 | _('identify the specified revision'), _('REV')), |
|
4578 | _('identify the specified revision'), _('REV')), | |
4569 | ('n', 'num', None, _('show local revision number')), |
|
4579 | ('n', 'num', None, _('show local revision number')), | |
4570 | ('i', 'id', None, _('show global revision id')), |
|
4580 | ('i', 'id', None, _('show global revision id')), | |
4571 | ('b', 'branch', None, _('show branch')), |
|
4581 | ('b', 'branch', None, _('show branch')), | |
4572 | ('t', 'tags', None, _('show tags')), |
|
4582 | ('t', 'tags', None, _('show tags')), | |
4573 | ('B', 'bookmarks', None, _('show bookmarks')), |
|
4583 | ('B', 'bookmarks', None, _('show bookmarks')), | |
4574 | ] + remoteopts, |
|
4584 | ] + remoteopts, | |
4575 | _('[-nibtB] [-r REV] [SOURCE]'), |
|
4585 | _('[-nibtB] [-r REV] [SOURCE]'), | |
4576 | optionalrepo=True) |
|
4586 | optionalrepo=True) | |
4577 | def identify(ui, repo, source=None, rev=None, |
|
4587 | def identify(ui, repo, source=None, rev=None, | |
4578 | num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): |
|
4588 | num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): | |
4579 | """identify the working directory or specified revision |
|
4589 | """identify the working directory or specified revision | |
4580 |
|
4590 | |||
4581 | Print a summary identifying the repository state at REV using one or |
|
4591 | Print a summary identifying the repository state at REV using one or | |
4582 | two parent hash identifiers, followed by a "+" if the working |
|
4592 | two parent hash identifiers, followed by a "+" if the working | |
4583 | directory has uncommitted changes, the branch name (if not default), |
|
4593 | directory has uncommitted changes, the branch name (if not default), | |
4584 | a list of tags, and a list of bookmarks. |
|
4594 | a list of tags, and a list of bookmarks. | |
4585 |
|
4595 | |||
4586 | When REV is not given, print a summary of the current state of the |
|
4596 | When REV is not given, print a summary of the current state of the | |
4587 | repository. |
|
4597 | repository. | |
4588 |
|
4598 | |||
4589 | Specifying a path to a repository root or Mercurial bundle will |
|
4599 | Specifying a path to a repository root or Mercurial bundle will | |
4590 | cause lookup to operate on that repository/bundle. |
|
4600 | cause lookup to operate on that repository/bundle. | |
4591 |
|
4601 | |||
4592 | .. container:: verbose |
|
4602 | .. container:: verbose | |
4593 |
|
4603 | |||
4594 | Examples: |
|
4604 | Examples: | |
4595 |
|
4605 | |||
4596 | - generate a build identifier for the working directory:: |
|
4606 | - generate a build identifier for the working directory:: | |
4597 |
|
4607 | |||
4598 | hg id --id > build-id.dat |
|
4608 | hg id --id > build-id.dat | |
4599 |
|
4609 | |||
4600 | - find the revision corresponding to a tag:: |
|
4610 | - find the revision corresponding to a tag:: | |
4601 |
|
4611 | |||
4602 | hg id -n -r 1.3 |
|
4612 | hg id -n -r 1.3 | |
4603 |
|
4613 | |||
4604 | - check the most recent revision of a remote repository:: |
|
4614 | - check the most recent revision of a remote repository:: | |
4605 |
|
4615 | |||
4606 | hg id -r tip https://www.mercurial-scm.org/repo/hg/ |
|
4616 | hg id -r tip https://www.mercurial-scm.org/repo/hg/ | |
4607 |
|
4617 | |||
4608 | See :hg:`log` for generating more information about specific revisions, |
|
4618 | See :hg:`log` for generating more information about specific revisions, | |
4609 | including full hash identifiers. |
|
4619 | including full hash identifiers. | |
4610 |
|
4620 | |||
4611 | Returns 0 if successful. |
|
4621 | Returns 0 if successful. | |
4612 | """ |
|
4622 | """ | |
4613 |
|
4623 | |||
4614 | if not repo and not source: |
|
4624 | if not repo and not source: | |
4615 | raise error.Abort(_("there is no Mercurial repository here " |
|
4625 | raise error.Abort(_("there is no Mercurial repository here " | |
4616 | "(.hg not found)")) |
|
4626 | "(.hg not found)")) | |
4617 |
|
4627 | |||
4618 | if ui.debugflag: |
|
4628 | if ui.debugflag: | |
4619 | hexfunc = hex |
|
4629 | hexfunc = hex | |
4620 | else: |
|
4630 | else: | |
4621 | hexfunc = short |
|
4631 | hexfunc = short | |
4622 | default = not (num or id or branch or tags or bookmarks) |
|
4632 | default = not (num or id or branch or tags or bookmarks) | |
4623 | output = [] |
|
4633 | output = [] | |
4624 | revs = [] |
|
4634 | revs = [] | |
4625 |
|
4635 | |||
4626 | if source: |
|
4636 | if source: | |
4627 | source, branches = hg.parseurl(ui.expandpath(source)) |
|
4637 | source, branches = hg.parseurl(ui.expandpath(source)) | |
4628 | peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo |
|
4638 | peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo | |
4629 | repo = peer.local() |
|
4639 | repo = peer.local() | |
4630 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) |
|
4640 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) | |
4631 |
|
4641 | |||
4632 | if not repo: |
|
4642 | if not repo: | |
4633 | if num or branch or tags: |
|
4643 | if num or branch or tags: | |
4634 | raise error.Abort( |
|
4644 | raise error.Abort( | |
4635 | _("can't query remote revision number, branch, or tags")) |
|
4645 | _("can't query remote revision number, branch, or tags")) | |
4636 | if not rev and revs: |
|
4646 | if not rev and revs: | |
4637 | rev = revs[0] |
|
4647 | rev = revs[0] | |
4638 | if not rev: |
|
4648 | if not rev: | |
4639 | rev = "tip" |
|
4649 | rev = "tip" | |
4640 |
|
4650 | |||
4641 | remoterev = peer.lookup(rev) |
|
4651 | remoterev = peer.lookup(rev) | |
4642 | if default or id: |
|
4652 | if default or id: | |
4643 | output = [hexfunc(remoterev)] |
|
4653 | output = [hexfunc(remoterev)] | |
4644 |
|
4654 | |||
4645 | def getbms(): |
|
4655 | def getbms(): | |
4646 | bms = [] |
|
4656 | bms = [] | |
4647 |
|
4657 | |||
4648 | if 'bookmarks' in peer.listkeys('namespaces'): |
|
4658 | if 'bookmarks' in peer.listkeys('namespaces'): | |
4649 | hexremoterev = hex(remoterev) |
|
4659 | hexremoterev = hex(remoterev) | |
4650 | bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems() |
|
4660 | bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems() | |
4651 | if bmr == hexremoterev] |
|
4661 | if bmr == hexremoterev] | |
4652 |
|
4662 | |||
4653 | return sorted(bms) |
|
4663 | return sorted(bms) | |
4654 |
|
4664 | |||
4655 | if bookmarks: |
|
4665 | if bookmarks: | |
4656 | output.extend(getbms()) |
|
4666 | output.extend(getbms()) | |
4657 | elif default and not ui.quiet: |
|
4667 | elif default and not ui.quiet: | |
4658 | # multiple bookmarks for a single parent separated by '/' |
|
4668 | # multiple bookmarks for a single parent separated by '/' | |
4659 | bm = '/'.join(getbms()) |
|
4669 | bm = '/'.join(getbms()) | |
4660 | if bm: |
|
4670 | if bm: | |
4661 | output.append(bm) |
|
4671 | output.append(bm) | |
4662 | else: |
|
4672 | else: | |
4663 | ctx = scmutil.revsingle(repo, rev, None) |
|
4673 | ctx = scmutil.revsingle(repo, rev, None) | |
4664 |
|
4674 | |||
4665 | if ctx.rev() is None: |
|
4675 | if ctx.rev() is None: | |
4666 | ctx = repo[None] |
|
4676 | ctx = repo[None] | |
4667 | parents = ctx.parents() |
|
4677 | parents = ctx.parents() | |
4668 | taglist = [] |
|
4678 | taglist = [] | |
4669 | for p in parents: |
|
4679 | for p in parents: | |
4670 | taglist.extend(p.tags()) |
|
4680 | taglist.extend(p.tags()) | |
4671 |
|
4681 | |||
4672 | changed = "" |
|
4682 | changed = "" | |
4673 | if default or id or num: |
|
4683 | if default or id or num: | |
4674 | if (any(repo.status()) |
|
4684 | if (any(repo.status()) | |
4675 | or any(ctx.sub(s).dirty() for s in ctx.substate)): |
|
4685 | or any(ctx.sub(s).dirty() for s in ctx.substate)): | |
4676 | changed = '+' |
|
4686 | changed = '+' | |
4677 | if default or id: |
|
4687 | if default or id: | |
4678 | output = ["%s%s" % |
|
4688 | output = ["%s%s" % | |
4679 | ('+'.join([hexfunc(p.node()) for p in parents]), changed)] |
|
4689 | ('+'.join([hexfunc(p.node()) for p in parents]), changed)] | |
4680 | if num: |
|
4690 | if num: | |
4681 | output.append("%s%s" % |
|
4691 | output.append("%s%s" % | |
4682 | ('+'.join([str(p.rev()) for p in parents]), changed)) |
|
4692 | ('+'.join([str(p.rev()) for p in parents]), changed)) | |
4683 | else: |
|
4693 | else: | |
4684 | if default or id: |
|
4694 | if default or id: | |
4685 | output = [hexfunc(ctx.node())] |
|
4695 | output = [hexfunc(ctx.node())] | |
4686 | if num: |
|
4696 | if num: | |
4687 | output.append(str(ctx.rev())) |
|
4697 | output.append(str(ctx.rev())) | |
4688 | taglist = ctx.tags() |
|
4698 | taglist = ctx.tags() | |
4689 |
|
4699 | |||
4690 | if default and not ui.quiet: |
|
4700 | if default and not ui.quiet: | |
4691 | b = ctx.branch() |
|
4701 | b = ctx.branch() | |
4692 | if b != 'default': |
|
4702 | if b != 'default': | |
4693 | output.append("(%s)" % b) |
|
4703 | output.append("(%s)" % b) | |
4694 |
|
4704 | |||
4695 | # multiple tags for a single parent separated by '/' |
|
4705 | # multiple tags for a single parent separated by '/' | |
4696 | t = '/'.join(taglist) |
|
4706 | t = '/'.join(taglist) | |
4697 | if t: |
|
4707 | if t: | |
4698 | output.append(t) |
|
4708 | output.append(t) | |
4699 |
|
4709 | |||
4700 | # multiple bookmarks for a single parent separated by '/' |
|
4710 | # multiple bookmarks for a single parent separated by '/' | |
4701 | bm = '/'.join(ctx.bookmarks()) |
|
4711 | bm = '/'.join(ctx.bookmarks()) | |
4702 | if bm: |
|
4712 | if bm: | |
4703 | output.append(bm) |
|
4713 | output.append(bm) | |
4704 | else: |
|
4714 | else: | |
4705 | if branch: |
|
4715 | if branch: | |
4706 | output.append(ctx.branch()) |
|
4716 | output.append(ctx.branch()) | |
4707 |
|
4717 | |||
4708 | if tags: |
|
4718 | if tags: | |
4709 | output.extend(taglist) |
|
4719 | output.extend(taglist) | |
4710 |
|
4720 | |||
4711 | if bookmarks: |
|
4721 | if bookmarks: | |
4712 | output.extend(ctx.bookmarks()) |
|
4722 | output.extend(ctx.bookmarks()) | |
4713 |
|
4723 | |||
4714 | ui.write("%s\n" % ' '.join(output)) |
|
4724 | ui.write("%s\n" % ' '.join(output)) | |
4715 |
|
4725 | |||
4716 | @command('import|patch', |
|
4726 | @command('import|patch', | |
4717 | [('p', 'strip', 1, |
|
4727 | [('p', 'strip', 1, | |
4718 | _('directory strip option for patch. This has the same ' |
|
4728 | _('directory strip option for patch. This has the same ' | |
4719 | 'meaning as the corresponding patch option'), _('NUM')), |
|
4729 | 'meaning as the corresponding patch option'), _('NUM')), | |
4720 | ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')), |
|
4730 | ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')), | |
4721 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
4731 | ('e', 'edit', False, _('invoke editor on commit messages')), | |
4722 | ('f', 'force', None, |
|
4732 | ('f', 'force', None, | |
4723 | _('skip check for outstanding uncommitted changes (DEPRECATED)')), |
|
4733 | _('skip check for outstanding uncommitted changes (DEPRECATED)')), | |
4724 | ('', 'no-commit', None, |
|
4734 | ('', 'no-commit', None, | |
4725 | _("don't commit, just update the working directory")), |
|
4735 | _("don't commit, just update the working directory")), | |
4726 | ('', 'bypass', None, |
|
4736 | ('', 'bypass', None, | |
4727 | _("apply patch without touching the working directory")), |
|
4737 | _("apply patch without touching the working directory")), | |
4728 | ('', 'partial', None, |
|
4738 | ('', 'partial', None, | |
4729 | _('commit even if some hunks fail')), |
|
4739 | _('commit even if some hunks fail')), | |
4730 | ('', 'exact', None, |
|
4740 | ('', 'exact', None, | |
4731 | _('abort if patch would apply lossily')), |
|
4741 | _('abort if patch would apply lossily')), | |
4732 | ('', 'prefix', '', |
|
4742 | ('', 'prefix', '', | |
4733 | _('apply patch to subdirectory'), _('DIR')), |
|
4743 | _('apply patch to subdirectory'), _('DIR')), | |
4734 | ('', 'import-branch', None, |
|
4744 | ('', 'import-branch', None, | |
4735 | _('use any branch information in patch (implied by --exact)'))] + |
|
4745 | _('use any branch information in patch (implied by --exact)'))] + | |
4736 | commitopts + commitopts2 + similarityopts, |
|
4746 | commitopts + commitopts2 + similarityopts, | |
4737 | _('[OPTION]... PATCH...')) |
|
4747 | _('[OPTION]... PATCH...')) | |
4738 | def import_(ui, repo, patch1=None, *patches, **opts): |
|
4748 | def import_(ui, repo, patch1=None, *patches, **opts): | |
4739 | """import an ordered set of patches |
|
4749 | """import an ordered set of patches | |
4740 |
|
4750 | |||
4741 | Import a list of patches and commit them individually (unless |
|
4751 | Import a list of patches and commit them individually (unless | |
4742 | --no-commit is specified). |
|
4752 | --no-commit is specified). | |
4743 |
|
4753 | |||
4744 | To read a patch from standard input, use "-" as the patch name. If |
|
4754 | To read a patch from standard input, use "-" as the patch name. If | |
4745 | a URL is specified, the patch will be downloaded from there. |
|
4755 | a URL is specified, the patch will be downloaded from there. | |
4746 |
|
4756 | |||
4747 | Import first applies changes to the working directory (unless |
|
4757 | Import first applies changes to the working directory (unless | |
4748 | --bypass is specified), import will abort if there are outstanding |
|
4758 | --bypass is specified), import will abort if there are outstanding | |
4749 | changes. |
|
4759 | changes. | |
4750 |
|
4760 | |||
4751 | Use --bypass to apply and commit patches directly to the |
|
4761 | Use --bypass to apply and commit patches directly to the | |
4752 | repository, without affecting the working directory. Without |
|
4762 | repository, without affecting the working directory. Without | |
4753 | --exact, patches will be applied on top of the working directory |
|
4763 | --exact, patches will be applied on top of the working directory | |
4754 | parent revision. |
|
4764 | parent revision. | |
4755 |
|
4765 | |||
4756 | You can import a patch straight from a mail message. Even patches |
|
4766 | You can import a patch straight from a mail message. Even patches | |
4757 | as attachments work (to use the body part, it must have type |
|
4767 | as attachments work (to use the body part, it must have type | |
4758 | text/plain or text/x-patch). From and Subject headers of email |
|
4768 | text/plain or text/x-patch). From and Subject headers of email | |
4759 | message are used as default committer and commit message. All |
|
4769 | message are used as default committer and commit message. All | |
4760 | text/plain body parts before first diff are added to the commit |
|
4770 | text/plain body parts before first diff are added to the commit | |
4761 | message. |
|
4771 | message. | |
4762 |
|
4772 | |||
4763 | If the imported patch was generated by :hg:`export`, user and |
|
4773 | If the imported patch was generated by :hg:`export`, user and | |
4764 | description from patch override values from message headers and |
|
4774 | description from patch override values from message headers and | |
4765 | body. Values given on command line with -m/--message and -u/--user |
|
4775 | body. Values given on command line with -m/--message and -u/--user | |
4766 | override these. |
|
4776 | override these. | |
4767 |
|
4777 | |||
4768 | If --exact is specified, import will set the working directory to |
|
4778 | If --exact is specified, import will set the working directory to | |
4769 | the parent of each patch before applying it, and will abort if the |
|
4779 | the parent of each patch before applying it, and will abort if the | |
4770 | resulting changeset has a different ID than the one recorded in |
|
4780 | resulting changeset has a different ID than the one recorded in | |
4771 | the patch. This will guard against various ways that portable |
|
4781 | the patch. This will guard against various ways that portable | |
4772 | patch formats and mail systems might fail to transfer Mercurial |
|
4782 | patch formats and mail systems might fail to transfer Mercurial | |
4773 | data or metadata. See :hg:`bundle` for lossless transmission. |
|
4783 | data or metadata. See :hg:`bundle` for lossless transmission. | |
4774 |
|
4784 | |||
4775 | Use --partial to ensure a changeset will be created from the patch |
|
4785 | Use --partial to ensure a changeset will be created from the patch | |
4776 | even if some hunks fail to apply. Hunks that fail to apply will be |
|
4786 | even if some hunks fail to apply. Hunks that fail to apply will be | |
4777 | written to a <target-file>.rej file. Conflicts can then be resolved |
|
4787 | written to a <target-file>.rej file. Conflicts can then be resolved | |
4778 | by hand before :hg:`commit --amend` is run to update the created |
|
4788 | by hand before :hg:`commit --amend` is run to update the created | |
4779 | changeset. This flag exists to let people import patches that |
|
4789 | changeset. This flag exists to let people import patches that | |
4780 | partially apply without losing the associated metadata (author, |
|
4790 | partially apply without losing the associated metadata (author, | |
4781 | date, description, ...). |
|
4791 | date, description, ...). | |
4782 |
|
4792 | |||
4783 | .. note:: |
|
4793 | .. note:: | |
4784 |
|
4794 | |||
4785 | When no hunks apply cleanly, :hg:`import --partial` will create |
|
4795 | When no hunks apply cleanly, :hg:`import --partial` will create | |
4786 | an empty changeset, importing only the patch metadata. |
|
4796 | an empty changeset, importing only the patch metadata. | |
4787 |
|
4797 | |||
4788 | With -s/--similarity, hg will attempt to discover renames and |
|
4798 | With -s/--similarity, hg will attempt to discover renames and | |
4789 | copies in the patch in the same way as :hg:`addremove`. |
|
4799 | copies in the patch in the same way as :hg:`addremove`. | |
4790 |
|
4800 | |||
4791 | It is possible to use external patch programs to perform the patch |
|
4801 | It is possible to use external patch programs to perform the patch | |
4792 | by setting the ``ui.patch`` configuration option. For the default |
|
4802 | by setting the ``ui.patch`` configuration option. For the default | |
4793 | internal tool, the fuzz can also be configured via ``patch.fuzz``. |
|
4803 | internal tool, the fuzz can also be configured via ``patch.fuzz``. | |
4794 | See :hg:`help config` for more information about configuration |
|
4804 | See :hg:`help config` for more information about configuration | |
4795 | files and how to use these options. |
|
4805 | files and how to use these options. | |
4796 |
|
4806 | |||
4797 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
4807 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
4798 |
|
4808 | |||
4799 | .. container:: verbose |
|
4809 | .. container:: verbose | |
4800 |
|
4810 | |||
4801 | Examples: |
|
4811 | Examples: | |
4802 |
|
4812 | |||
4803 | - import a traditional patch from a website and detect renames:: |
|
4813 | - import a traditional patch from a website and detect renames:: | |
4804 |
|
4814 | |||
4805 | hg import -s 80 http://example.com/bugfix.patch |
|
4815 | hg import -s 80 http://example.com/bugfix.patch | |
4806 |
|
4816 | |||
4807 | - import a changeset from an hgweb server:: |
|
4817 | - import a changeset from an hgweb server:: | |
4808 |
|
4818 | |||
4809 | hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa |
|
4819 | hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa | |
4810 |
|
4820 | |||
4811 | - import all the patches in an Unix-style mbox:: |
|
4821 | - import all the patches in an Unix-style mbox:: | |
4812 |
|
4822 | |||
4813 | hg import incoming-patches.mbox |
|
4823 | hg import incoming-patches.mbox | |
4814 |
|
4824 | |||
4815 | - attempt to exactly restore an exported changeset (not always |
|
4825 | - attempt to exactly restore an exported changeset (not always | |
4816 | possible):: |
|
4826 | possible):: | |
4817 |
|
4827 | |||
4818 | hg import --exact proposed-fix.patch |
|
4828 | hg import --exact proposed-fix.patch | |
4819 |
|
4829 | |||
4820 | - use an external tool to apply a patch which is too fuzzy for |
|
4830 | - use an external tool to apply a patch which is too fuzzy for | |
4821 | the default internal tool. |
|
4831 | the default internal tool. | |
4822 |
|
4832 | |||
4823 | hg import --config ui.patch="patch --merge" fuzzy.patch |
|
4833 | hg import --config ui.patch="patch --merge" fuzzy.patch | |
4824 |
|
4834 | |||
4825 | - change the default fuzzing from 2 to a less strict 7 |
|
4835 | - change the default fuzzing from 2 to a less strict 7 | |
4826 |
|
4836 | |||
4827 | hg import --config ui.fuzz=7 fuzz.patch |
|
4837 | hg import --config ui.fuzz=7 fuzz.patch | |
4828 |
|
4838 | |||
4829 | Returns 0 on success, 1 on partial success (see --partial). |
|
4839 | Returns 0 on success, 1 on partial success (see --partial). | |
4830 | """ |
|
4840 | """ | |
4831 |
|
4841 | |||
4832 | if not patch1: |
|
4842 | if not patch1: | |
4833 | raise error.Abort(_('need at least one patch to import')) |
|
4843 | raise error.Abort(_('need at least one patch to import')) | |
4834 |
|
4844 | |||
4835 | patches = (patch1,) + patches |
|
4845 | patches = (patch1,) + patches | |
4836 |
|
4846 | |||
4837 | date = opts.get('date') |
|
4847 | date = opts.get('date') | |
4838 | if date: |
|
4848 | if date: | |
4839 | opts['date'] = util.parsedate(date) |
|
4849 | opts['date'] = util.parsedate(date) | |
4840 |
|
4850 | |||
4841 | exact = opts.get('exact') |
|
4851 | exact = opts.get('exact') | |
4842 | update = not opts.get('bypass') |
|
4852 | update = not opts.get('bypass') | |
4843 | if not update and opts.get('no_commit'): |
|
4853 | if not update and opts.get('no_commit'): | |
4844 | raise error.Abort(_('cannot use --no-commit with --bypass')) |
|
4854 | raise error.Abort(_('cannot use --no-commit with --bypass')) | |
4845 | try: |
|
4855 | try: | |
4846 | sim = float(opts.get('similarity') or 0) |
|
4856 | sim = float(opts.get('similarity') or 0) | |
4847 | except ValueError: |
|
4857 | except ValueError: | |
4848 | raise error.Abort(_('similarity must be a number')) |
|
4858 | raise error.Abort(_('similarity must be a number')) | |
4849 | if sim < 0 or sim > 100: |
|
4859 | if sim < 0 or sim > 100: | |
4850 | raise error.Abort(_('similarity must be between 0 and 100')) |
|
4860 | raise error.Abort(_('similarity must be between 0 and 100')) | |
4851 | if sim and not update: |
|
4861 | if sim and not update: | |
4852 | raise error.Abort(_('cannot use --similarity with --bypass')) |
|
4862 | raise error.Abort(_('cannot use --similarity with --bypass')) | |
4853 | if exact: |
|
4863 | if exact: | |
4854 | if opts.get('edit'): |
|
4864 | if opts.get('edit'): | |
4855 | raise error.Abort(_('cannot use --exact with --edit')) |
|
4865 | raise error.Abort(_('cannot use --exact with --edit')) | |
4856 | if opts.get('prefix'): |
|
4866 | if opts.get('prefix'): | |
4857 | raise error.Abort(_('cannot use --exact with --prefix')) |
|
4867 | raise error.Abort(_('cannot use --exact with --prefix')) | |
4858 |
|
4868 | |||
4859 | base = opts["base"] |
|
4869 | base = opts["base"] | |
4860 | wlock = dsguard = lock = tr = None |
|
4870 | wlock = dsguard = lock = tr = None | |
4861 | msgs = [] |
|
4871 | msgs = [] | |
4862 | ret = 0 |
|
4872 | ret = 0 | |
4863 |
|
4873 | |||
4864 |
|
4874 | |||
4865 | try: |
|
4875 | try: | |
4866 | wlock = repo.wlock() |
|
4876 | wlock = repo.wlock() | |
4867 |
|
4877 | |||
4868 | if update: |
|
4878 | if update: | |
4869 | cmdutil.checkunfinished(repo) |
|
4879 | cmdutil.checkunfinished(repo) | |
4870 | if (exact or not opts.get('force')): |
|
4880 | if (exact or not opts.get('force')): | |
4871 | cmdutil.bailifchanged(repo) |
|
4881 | cmdutil.bailifchanged(repo) | |
4872 |
|
4882 | |||
4873 | if not opts.get('no_commit'): |
|
4883 | if not opts.get('no_commit'): | |
4874 | lock = repo.lock() |
|
4884 | lock = repo.lock() | |
4875 | tr = repo.transaction('import') |
|
4885 | tr = repo.transaction('import') | |
4876 | else: |
|
4886 | else: | |
4877 | dsguard = cmdutil.dirstateguard(repo, 'import') |
|
4887 | dsguard = cmdutil.dirstateguard(repo, 'import') | |
4878 | parents = repo[None].parents() |
|
4888 | parents = repo[None].parents() | |
4879 | for patchurl in patches: |
|
4889 | for patchurl in patches: | |
4880 | if patchurl == '-': |
|
4890 | if patchurl == '-': | |
4881 | ui.status(_('applying patch from stdin\n')) |
|
4891 | ui.status(_('applying patch from stdin\n')) | |
4882 | patchfile = ui.fin |
|
4892 | patchfile = ui.fin | |
4883 | patchurl = 'stdin' # for error message |
|
4893 | patchurl = 'stdin' # for error message | |
4884 | else: |
|
4894 | else: | |
4885 | patchurl = os.path.join(base, patchurl) |
|
4895 | patchurl = os.path.join(base, patchurl) | |
4886 | ui.status(_('applying %s\n') % patchurl) |
|
4896 | ui.status(_('applying %s\n') % patchurl) | |
4887 | patchfile = hg.openpath(ui, patchurl) |
|
4897 | patchfile = hg.openpath(ui, patchurl) | |
4888 |
|
4898 | |||
4889 | haspatch = False |
|
4899 | haspatch = False | |
4890 | for hunk in patch.split(patchfile): |
|
4900 | for hunk in patch.split(patchfile): | |
4891 | (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, |
|
4901 | (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, | |
4892 | parents, opts, |
|
4902 | parents, opts, | |
4893 | msgs, hg.clean) |
|
4903 | msgs, hg.clean) | |
4894 | if msg: |
|
4904 | if msg: | |
4895 | haspatch = True |
|
4905 | haspatch = True | |
4896 | ui.note(msg + '\n') |
|
4906 | ui.note(msg + '\n') | |
4897 | if update or exact: |
|
4907 | if update or exact: | |
4898 | parents = repo[None].parents() |
|
4908 | parents = repo[None].parents() | |
4899 | else: |
|
4909 | else: | |
4900 | parents = [repo[node]] |
|
4910 | parents = [repo[node]] | |
4901 | if rej: |
|
4911 | if rej: | |
4902 | ui.write_err(_("patch applied partially\n")) |
|
4912 | ui.write_err(_("patch applied partially\n")) | |
4903 | ui.write_err(_("(fix the .rej files and run " |
|
4913 | ui.write_err(_("(fix the .rej files and run " | |
4904 | "`hg commit --amend`)\n")) |
|
4914 | "`hg commit --amend`)\n")) | |
4905 | ret = 1 |
|
4915 | ret = 1 | |
4906 | break |
|
4916 | break | |
4907 |
|
4917 | |||
4908 | if not haspatch: |
|
4918 | if not haspatch: | |
4909 | raise error.Abort(_('%s: no diffs found') % patchurl) |
|
4919 | raise error.Abort(_('%s: no diffs found') % patchurl) | |
4910 |
|
4920 | |||
4911 | if tr: |
|
4921 | if tr: | |
4912 | tr.close() |
|
4922 | tr.close() | |
4913 | if msgs: |
|
4923 | if msgs: | |
4914 | repo.savecommitmessage('\n* * *\n'.join(msgs)) |
|
4924 | repo.savecommitmessage('\n* * *\n'.join(msgs)) | |
4915 | if dsguard: |
|
4925 | if dsguard: | |
4916 | dsguard.close() |
|
4926 | dsguard.close() | |
4917 | return ret |
|
4927 | return ret | |
4918 | finally: |
|
4928 | finally: | |
4919 | if tr: |
|
4929 | if tr: | |
4920 | tr.release() |
|
4930 | tr.release() | |
4921 | release(lock, dsguard, wlock) |
|
4931 | release(lock, dsguard, wlock) | |
4922 |
|
4932 | |||
4923 | @command('incoming|in', |
|
4933 | @command('incoming|in', | |
4924 | [('f', 'force', None, |
|
4934 | [('f', 'force', None, | |
4925 | _('run even if remote repository is unrelated')), |
|
4935 | _('run even if remote repository is unrelated')), | |
4926 | ('n', 'newest-first', None, _('show newest record first')), |
|
4936 | ('n', 'newest-first', None, _('show newest record first')), | |
4927 | ('', 'bundle', '', |
|
4937 | ('', 'bundle', '', | |
4928 | _('file to store the bundles into'), _('FILE')), |
|
4938 | _('file to store the bundles into'), _('FILE')), | |
4929 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
|
4939 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), | |
4930 | ('B', 'bookmarks', False, _("compare bookmarks")), |
|
4940 | ('B', 'bookmarks', False, _("compare bookmarks")), | |
4931 | ('b', 'branch', [], |
|
4941 | ('b', 'branch', [], | |
4932 | _('a specific branch you would like to pull'), _('BRANCH')), |
|
4942 | _('a specific branch you would like to pull'), _('BRANCH')), | |
4933 | ] + logopts + remoteopts + subrepoopts, |
|
4943 | ] + logopts + remoteopts + subrepoopts, | |
4934 | _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]')) |
|
4944 | _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]')) | |
4935 | def incoming(ui, repo, source="default", **opts): |
|
4945 | def incoming(ui, repo, source="default", **opts): | |
4936 | """show new changesets found in source |
|
4946 | """show new changesets found in source | |
4937 |
|
4947 | |||
4938 | Show new changesets found in the specified path/URL or the default |
|
4948 | Show new changesets found in the specified path/URL or the default | |
4939 | pull location. These are the changesets that would have been pulled |
|
4949 | pull location. These are the changesets that would have been pulled | |
4940 | if a pull at the time you issued this command. |
|
4950 | if a pull at the time you issued this command. | |
4941 |
|
4951 | |||
4942 | See pull for valid source format details. |
|
4952 | See pull for valid source format details. | |
4943 |
|
4953 | |||
4944 | .. container:: verbose |
|
4954 | .. container:: verbose | |
4945 |
|
4955 | |||
4946 | With -B/--bookmarks, the result of bookmark comparison between |
|
4956 | With -B/--bookmarks, the result of bookmark comparison between | |
4947 | local and remote repositories is displayed. With -v/--verbose, |
|
4957 | local and remote repositories is displayed. With -v/--verbose, | |
4948 | status is also displayed for each bookmark like below:: |
|
4958 | status is also displayed for each bookmark like below:: | |
4949 |
|
4959 | |||
4950 | BM1 01234567890a added |
|
4960 | BM1 01234567890a added | |
4951 | BM2 1234567890ab advanced |
|
4961 | BM2 1234567890ab advanced | |
4952 | BM3 234567890abc diverged |
|
4962 | BM3 234567890abc diverged | |
4953 | BM4 34567890abcd changed |
|
4963 | BM4 34567890abcd changed | |
4954 |
|
4964 | |||
4955 | The action taken locally when pulling depends on the |
|
4965 | The action taken locally when pulling depends on the | |
4956 | status of each bookmark: |
|
4966 | status of each bookmark: | |
4957 |
|
4967 | |||
4958 | :``added``: pull will create it |
|
4968 | :``added``: pull will create it | |
4959 | :``advanced``: pull will update it |
|
4969 | :``advanced``: pull will update it | |
4960 | :``diverged``: pull will create a divergent bookmark |
|
4970 | :``diverged``: pull will create a divergent bookmark | |
4961 | :``changed``: result depends on remote changesets |
|
4971 | :``changed``: result depends on remote changesets | |
4962 |
|
4972 | |||
4963 | From the point of view of pulling behavior, bookmark |
|
4973 | From the point of view of pulling behavior, bookmark | |
4964 | existing only in the remote repository are treated as ``added``, |
|
4974 | existing only in the remote repository are treated as ``added``, | |
4965 | even if it is in fact locally deleted. |
|
4975 | even if it is in fact locally deleted. | |
4966 |
|
4976 | |||
4967 | .. container:: verbose |
|
4977 | .. container:: verbose | |
4968 |
|
4978 | |||
4969 | For remote repository, using --bundle avoids downloading the |
|
4979 | For remote repository, using --bundle avoids downloading the | |
4970 | changesets twice if the incoming is followed by a pull. |
|
4980 | changesets twice if the incoming is followed by a pull. | |
4971 |
|
4981 | |||
4972 | Examples: |
|
4982 | Examples: | |
4973 |
|
4983 | |||
4974 | - show incoming changes with patches and full description:: |
|
4984 | - show incoming changes with patches and full description:: | |
4975 |
|
4985 | |||
4976 | hg incoming -vp |
|
4986 | hg incoming -vp | |
4977 |
|
4987 | |||
4978 | - show incoming changes excluding merges, store a bundle:: |
|
4988 | - show incoming changes excluding merges, store a bundle:: | |
4979 |
|
4989 | |||
4980 | hg in -vpM --bundle incoming.hg |
|
4990 | hg in -vpM --bundle incoming.hg | |
4981 | hg pull incoming.hg |
|
4991 | hg pull incoming.hg | |
4982 |
|
4992 | |||
4983 | - briefly list changes inside a bundle:: |
|
4993 | - briefly list changes inside a bundle:: | |
4984 |
|
4994 | |||
4985 | hg in changes.hg -T "{desc|firstline}\\n" |
|
4995 | hg in changes.hg -T "{desc|firstline}\\n" | |
4986 |
|
4996 | |||
4987 | Returns 0 if there are incoming changes, 1 otherwise. |
|
4997 | Returns 0 if there are incoming changes, 1 otherwise. | |
4988 | """ |
|
4998 | """ | |
4989 | if opts.get('graph'): |
|
4999 | if opts.get('graph'): | |
4990 | cmdutil.checkunsupportedgraphflags([], opts) |
|
5000 | cmdutil.checkunsupportedgraphflags([], opts) | |
4991 | def display(other, chlist, displayer): |
|
5001 | def display(other, chlist, displayer): | |
4992 | revdag = cmdutil.graphrevs(other, chlist, opts) |
|
5002 | revdag = cmdutil.graphrevs(other, chlist, opts) | |
4993 | cmdutil.displaygraph(ui, repo, revdag, displayer, |
|
5003 | cmdutil.displaygraph(ui, repo, revdag, displayer, | |
4994 | graphmod.asciiedges) |
|
5004 | graphmod.asciiedges) | |
4995 |
|
5005 | |||
4996 | hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True) |
|
5006 | hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True) | |
4997 | return 0 |
|
5007 | return 0 | |
4998 |
|
5008 | |||
4999 | if opts.get('bundle') and opts.get('subrepos'): |
|
5009 | if opts.get('bundle') and opts.get('subrepos'): | |
5000 | raise error.Abort(_('cannot combine --bundle and --subrepos')) |
|
5010 | raise error.Abort(_('cannot combine --bundle and --subrepos')) | |
5001 |
|
5011 | |||
5002 | if opts.get('bookmarks'): |
|
5012 | if opts.get('bookmarks'): | |
5003 | source, branches = hg.parseurl(ui.expandpath(source), |
|
5013 | source, branches = hg.parseurl(ui.expandpath(source), | |
5004 | opts.get('branch')) |
|
5014 | opts.get('branch')) | |
5005 | other = hg.peer(repo, opts, source) |
|
5015 | other = hg.peer(repo, opts, source) | |
5006 | if 'bookmarks' not in other.listkeys('namespaces'): |
|
5016 | if 'bookmarks' not in other.listkeys('namespaces'): | |
5007 | ui.warn(_("remote doesn't support bookmarks\n")) |
|
5017 | ui.warn(_("remote doesn't support bookmarks\n")) | |
5008 | return 0 |
|
5018 | return 0 | |
5009 | ui.status(_('comparing with %s\n') % util.hidepassword(source)) |
|
5019 | ui.status(_('comparing with %s\n') % util.hidepassword(source)) | |
5010 | return bookmarks.incoming(ui, repo, other) |
|
5020 | return bookmarks.incoming(ui, repo, other) | |
5011 |
|
5021 | |||
5012 | repo._subtoppath = ui.expandpath(source) |
|
5022 | repo._subtoppath = ui.expandpath(source) | |
5013 | try: |
|
5023 | try: | |
5014 | return hg.incoming(ui, repo, source, opts) |
|
5024 | return hg.incoming(ui, repo, source, opts) | |
5015 | finally: |
|
5025 | finally: | |
5016 | del repo._subtoppath |
|
5026 | del repo._subtoppath | |
5017 |
|
5027 | |||
5018 |
|
5028 | |||
5019 | @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'), |
|
5029 | @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'), | |
5020 | norepo=True) |
|
5030 | norepo=True) | |
5021 | def init(ui, dest=".", **opts): |
|
5031 | def init(ui, dest=".", **opts): | |
5022 | """create a new repository in the given directory |
|
5032 | """create a new repository in the given directory | |
5023 |
|
5033 | |||
5024 | Initialize a new repository in the given directory. If the given |
|
5034 | Initialize a new repository in the given directory. If the given | |
5025 | directory does not exist, it will be created. |
|
5035 | directory does not exist, it will be created. | |
5026 |
|
5036 | |||
5027 | If no directory is given, the current directory is used. |
|
5037 | If no directory is given, the current directory is used. | |
5028 |
|
5038 | |||
5029 | It is possible to specify an ``ssh://`` URL as the destination. |
|
5039 | It is possible to specify an ``ssh://`` URL as the destination. | |
5030 | See :hg:`help urls` for more information. |
|
5040 | See :hg:`help urls` for more information. | |
5031 |
|
5041 | |||
5032 | Returns 0 on success. |
|
5042 | Returns 0 on success. | |
5033 | """ |
|
5043 | """ | |
5034 | hg.peer(ui, opts, ui.expandpath(dest), create=True) |
|
5044 | hg.peer(ui, opts, ui.expandpath(dest), create=True) | |
5035 |
|
5045 | |||
5036 | @command('locate', |
|
5046 | @command('locate', | |
5037 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
|
5047 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), | |
5038 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
5048 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), | |
5039 | ('f', 'fullpath', None, _('print complete paths from the filesystem root')), |
|
5049 | ('f', 'fullpath', None, _('print complete paths from the filesystem root')), | |
5040 | ] + walkopts, |
|
5050 | ] + walkopts, | |
5041 | _('[OPTION]... [PATTERN]...')) |
|
5051 | _('[OPTION]... [PATTERN]...')) | |
5042 | def locate(ui, repo, *pats, **opts): |
|
5052 | def locate(ui, repo, *pats, **opts): | |
5043 | """locate files matching specific patterns (DEPRECATED) |
|
5053 | """locate files matching specific patterns (DEPRECATED) | |
5044 |
|
5054 | |||
5045 | Print files under Mercurial control in the working directory whose |
|
5055 | Print files under Mercurial control in the working directory whose | |
5046 | names match the given patterns. |
|
5056 | names match the given patterns. | |
5047 |
|
5057 | |||
5048 | By default, this command searches all directories in the working |
|
5058 | By default, this command searches all directories in the working | |
5049 | directory. To search just the current directory and its |
|
5059 | directory. To search just the current directory and its | |
5050 | subdirectories, use "--include .". |
|
5060 | subdirectories, use "--include .". | |
5051 |
|
5061 | |||
5052 | If no patterns are given to match, this command prints the names |
|
5062 | If no patterns are given to match, this command prints the names | |
5053 | of all files under Mercurial control in the working directory. |
|
5063 | of all files under Mercurial control in the working directory. | |
5054 |
|
5064 | |||
5055 | If you want to feed the output of this command into the "xargs" |
|
5065 | If you want to feed the output of this command into the "xargs" | |
5056 | command, use the -0 option to both this command and "xargs". This |
|
5066 | command, use the -0 option to both this command and "xargs". This | |
5057 | will avoid the problem of "xargs" treating single filenames that |
|
5067 | will avoid the problem of "xargs" treating single filenames that | |
5058 | contain whitespace as multiple filenames. |
|
5068 | contain whitespace as multiple filenames. | |
5059 |
|
5069 | |||
5060 | See :hg:`help files` for a more versatile command. |
|
5070 | See :hg:`help files` for a more versatile command. | |
5061 |
|
5071 | |||
5062 | Returns 0 if a match is found, 1 otherwise. |
|
5072 | Returns 0 if a match is found, 1 otherwise. | |
5063 | """ |
|
5073 | """ | |
5064 | if opts.get('print0'): |
|
5074 | if opts.get('print0'): | |
5065 | end = '\0' |
|
5075 | end = '\0' | |
5066 | else: |
|
5076 | else: | |
5067 | end = '\n' |
|
5077 | end = '\n' | |
5068 | rev = scmutil.revsingle(repo, opts.get('rev'), None).node() |
|
5078 | rev = scmutil.revsingle(repo, opts.get('rev'), None).node() | |
5069 |
|
5079 | |||
5070 | ret = 1 |
|
5080 | ret = 1 | |
5071 | ctx = repo[rev] |
|
5081 | ctx = repo[rev] | |
5072 | m = scmutil.match(ctx, pats, opts, default='relglob', |
|
5082 | m = scmutil.match(ctx, pats, opts, default='relglob', | |
5073 | badfn=lambda x, y: False) |
|
5083 | badfn=lambda x, y: False) | |
5074 |
|
5084 | |||
5075 | for abs in ctx.matches(m): |
|
5085 | for abs in ctx.matches(m): | |
5076 | if opts.get('fullpath'): |
|
5086 | if opts.get('fullpath'): | |
5077 | ui.write(repo.wjoin(abs), end) |
|
5087 | ui.write(repo.wjoin(abs), end) | |
5078 | else: |
|
5088 | else: | |
5079 | ui.write(((pats and m.rel(abs)) or abs), end) |
|
5089 | ui.write(((pats and m.rel(abs)) or abs), end) | |
5080 | ret = 0 |
|
5090 | ret = 0 | |
5081 |
|
5091 | |||
5082 | return ret |
|
5092 | return ret | |
5083 |
|
5093 | |||
5084 | @command('^log|history', |
|
5094 | @command('^log|history', | |
5085 | [('f', 'follow', None, |
|
5095 | [('f', 'follow', None, | |
5086 | _('follow changeset history, or file history across copies and renames')), |
|
5096 | _('follow changeset history, or file history across copies and renames')), | |
5087 | ('', 'follow-first', None, |
|
5097 | ('', 'follow-first', None, | |
5088 | _('only follow the first parent of merge changesets (DEPRECATED)')), |
|
5098 | _('only follow the first parent of merge changesets (DEPRECATED)')), | |
5089 | ('d', 'date', '', _('show revisions matching date spec'), _('DATE')), |
|
5099 | ('d', 'date', '', _('show revisions matching date spec'), _('DATE')), | |
5090 | ('C', 'copies', None, _('show copied files')), |
|
5100 | ('C', 'copies', None, _('show copied files')), | |
5091 | ('k', 'keyword', [], |
|
5101 | ('k', 'keyword', [], | |
5092 | _('do case-insensitive search for a given text'), _('TEXT')), |
|
5102 | _('do case-insensitive search for a given text'), _('TEXT')), | |
5093 | ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), |
|
5103 | ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), | |
5094 | ('', 'removed', None, _('include revisions where files were removed')), |
|
5104 | ('', 'removed', None, _('include revisions where files were removed')), | |
5095 | ('m', 'only-merges', None, _('show only merges (DEPRECATED)')), |
|
5105 | ('m', 'only-merges', None, _('show only merges (DEPRECATED)')), | |
5096 | ('u', 'user', [], _('revisions committed by user'), _('USER')), |
|
5106 | ('u', 'user', [], _('revisions committed by user'), _('USER')), | |
5097 | ('', 'only-branch', [], |
|
5107 | ('', 'only-branch', [], | |
5098 | _('show only changesets within the given named branch (DEPRECATED)'), |
|
5108 | _('show only changesets within the given named branch (DEPRECATED)'), | |
5099 | _('BRANCH')), |
|
5109 | _('BRANCH')), | |
5100 | ('b', 'branch', [], |
|
5110 | ('b', 'branch', [], | |
5101 | _('show changesets within the given named branch'), _('BRANCH')), |
|
5111 | _('show changesets within the given named branch'), _('BRANCH')), | |
5102 | ('P', 'prune', [], |
|
5112 | ('P', 'prune', [], | |
5103 | _('do not display revision or any of its ancestors'), _('REV')), |
|
5113 | _('do not display revision or any of its ancestors'), _('REV')), | |
5104 | ] + logopts + walkopts, |
|
5114 | ] + logopts + walkopts, | |
5105 | _('[OPTION]... [FILE]'), |
|
5115 | _('[OPTION]... [FILE]'), | |
5106 | inferrepo=True) |
|
5116 | inferrepo=True) | |
5107 | def log(ui, repo, *pats, **opts): |
|
5117 | def log(ui, repo, *pats, **opts): | |
5108 | """show revision history of entire repository or files |
|
5118 | """show revision history of entire repository or files | |
5109 |
|
5119 | |||
5110 | Print the revision history of the specified files or the entire |
|
5120 | Print the revision history of the specified files or the entire | |
5111 | project. |
|
5121 | project. | |
5112 |
|
5122 | |||
5113 | If no revision range is specified, the default is ``tip:0`` unless |
|
5123 | If no revision range is specified, the default is ``tip:0`` unless | |
5114 | --follow is set, in which case the working directory parent is |
|
5124 | --follow is set, in which case the working directory parent is | |
5115 | used as the starting revision. |
|
5125 | used as the starting revision. | |
5116 |
|
5126 | |||
5117 | File history is shown without following rename or copy history of |
|
5127 | File history is shown without following rename or copy history of | |
5118 | files. Use -f/--follow with a filename to follow history across |
|
5128 | files. Use -f/--follow with a filename to follow history across | |
5119 | renames and copies. --follow without a filename will only show |
|
5129 | renames and copies. --follow without a filename will only show | |
5120 | ancestors or descendants of the starting revision. |
|
5130 | ancestors or descendants of the starting revision. | |
5121 |
|
5131 | |||
5122 | By default this command prints revision number and changeset id, |
|
5132 | By default this command prints revision number and changeset id, | |
5123 | tags, non-trivial parents, user, date and time, and a summary for |
|
5133 | tags, non-trivial parents, user, date and time, and a summary for | |
5124 | each commit. When the -v/--verbose switch is used, the list of |
|
5134 | each commit. When the -v/--verbose switch is used, the list of | |
5125 | changed files and full commit message are shown. |
|
5135 | changed files and full commit message are shown. | |
5126 |
|
5136 | |||
5127 | With --graph the revisions are shown as an ASCII art DAG with the most |
|
5137 | With --graph the revisions are shown as an ASCII art DAG with the most | |
5128 | recent changeset at the top. |
|
5138 | recent changeset at the top. | |
5129 | 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete, |
|
5139 | 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete, | |
5130 | and '+' represents a fork where the changeset from the lines below is a |
|
5140 | and '+' represents a fork where the changeset from the lines below is a | |
5131 | parent of the 'o' merge on the same line. |
|
5141 | parent of the 'o' merge on the same line. | |
5132 |
|
5142 | |||
5133 | .. note:: |
|
5143 | .. note:: | |
5134 |
|
5144 | |||
5135 | :hg:`log --patch` may generate unexpected diff output for merge |
|
5145 | :hg:`log --patch` may generate unexpected diff output for merge | |
5136 | changesets, as it will only compare the merge changeset against |
|
5146 | changesets, as it will only compare the merge changeset against | |
5137 | its first parent. Also, only files different from BOTH parents |
|
5147 | its first parent. Also, only files different from BOTH parents | |
5138 | will appear in files:. |
|
5148 | will appear in files:. | |
5139 |
|
5149 | |||
5140 | .. note:: |
|
5150 | .. note:: | |
5141 |
|
5151 | |||
5142 | For performance reasons, :hg:`log FILE` may omit duplicate changes |
|
5152 | For performance reasons, :hg:`log FILE` may omit duplicate changes | |
5143 | made on branches and will not show removals or mode changes. To |
|
5153 | made on branches and will not show removals or mode changes. To | |
5144 | see all such changes, use the --removed switch. |
|
5154 | see all such changes, use the --removed switch. | |
5145 |
|
5155 | |||
5146 | .. container:: verbose |
|
5156 | .. container:: verbose | |
5147 |
|
5157 | |||
5148 | Some examples: |
|
5158 | Some examples: | |
5149 |
|
5159 | |||
5150 | - changesets with full descriptions and file lists:: |
|
5160 | - changesets with full descriptions and file lists:: | |
5151 |
|
5161 | |||
5152 | hg log -v |
|
5162 | hg log -v | |
5153 |
|
5163 | |||
5154 | - changesets ancestral to the working directory:: |
|
5164 | - changesets ancestral to the working directory:: | |
5155 |
|
5165 | |||
5156 | hg log -f |
|
5166 | hg log -f | |
5157 |
|
5167 | |||
5158 | - last 10 commits on the current branch:: |
|
5168 | - last 10 commits on the current branch:: | |
5159 |
|
5169 | |||
5160 | hg log -l 10 -b . |
|
5170 | hg log -l 10 -b . | |
5161 |
|
5171 | |||
5162 | - changesets showing all modifications of a file, including removals:: |
|
5172 | - changesets showing all modifications of a file, including removals:: | |
5163 |
|
5173 | |||
5164 | hg log --removed file.c |
|
5174 | hg log --removed file.c | |
5165 |
|
5175 | |||
5166 | - all changesets that touch a directory, with diffs, excluding merges:: |
|
5176 | - all changesets that touch a directory, with diffs, excluding merges:: | |
5167 |
|
5177 | |||
5168 | hg log -Mp lib/ |
|
5178 | hg log -Mp lib/ | |
5169 |
|
5179 | |||
5170 | - all revision numbers that match a keyword:: |
|
5180 | - all revision numbers that match a keyword:: | |
5171 |
|
5181 | |||
5172 | hg log -k bug --template "{rev}\\n" |
|
5182 | hg log -k bug --template "{rev}\\n" | |
5173 |
|
5183 | |||
5174 | - the full hash identifier of the working directory parent:: |
|
5184 | - the full hash identifier of the working directory parent:: | |
5175 |
|
5185 | |||
5176 | hg log -r . --template "{node}\\n" |
|
5186 | hg log -r . --template "{node}\\n" | |
5177 |
|
5187 | |||
5178 | - list available log templates:: |
|
5188 | - list available log templates:: | |
5179 |
|
5189 | |||
5180 | hg log -T list |
|
5190 | hg log -T list | |
5181 |
|
5191 | |||
5182 | - check if a given changeset is included in a tagged release:: |
|
5192 | - check if a given changeset is included in a tagged release:: | |
5183 |
|
5193 | |||
5184 | hg log -r "a21ccf and ancestor(1.9)" |
|
5194 | hg log -r "a21ccf and ancestor(1.9)" | |
5185 |
|
5195 | |||
5186 | - find all changesets by some user in a date range:: |
|
5196 | - find all changesets by some user in a date range:: | |
5187 |
|
5197 | |||
5188 | hg log -k alice -d "may 2008 to jul 2008" |
|
5198 | hg log -k alice -d "may 2008 to jul 2008" | |
5189 |
|
5199 | |||
5190 | - summary of all changesets after the last tag:: |
|
5200 | - summary of all changesets after the last tag:: | |
5191 |
|
5201 | |||
5192 | hg log -r "last(tagged())::" --template "{desc|firstline}\\n" |
|
5202 | hg log -r "last(tagged())::" --template "{desc|firstline}\\n" | |
5193 |
|
5203 | |||
5194 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
5204 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
5195 |
|
5205 | |||
5196 | See :hg:`help revisions` and :hg:`help revsets` for more about |
|
5206 | See :hg:`help revisions` and :hg:`help revsets` for more about | |
5197 | specifying and ordering revisions. |
|
5207 | specifying and ordering revisions. | |
5198 |
|
5208 | |||
5199 | See :hg:`help templates` for more about pre-packaged styles and |
|
5209 | See :hg:`help templates` for more about pre-packaged styles and | |
5200 | specifying custom templates. |
|
5210 | specifying custom templates. | |
5201 |
|
5211 | |||
5202 | Returns 0 on success. |
|
5212 | Returns 0 on success. | |
5203 |
|
5213 | |||
5204 | """ |
|
5214 | """ | |
5205 | if opts.get('follow') and opts.get('rev'): |
|
5215 | if opts.get('follow') and opts.get('rev'): | |
5206 | opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))] |
|
5216 | opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))] | |
5207 | del opts['follow'] |
|
5217 | del opts['follow'] | |
5208 |
|
5218 | |||
5209 | if opts.get('graph'): |
|
5219 | if opts.get('graph'): | |
5210 | return cmdutil.graphlog(ui, repo, *pats, **opts) |
|
5220 | return cmdutil.graphlog(ui, repo, *pats, **opts) | |
5211 |
|
5221 | |||
5212 | revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) |
|
5222 | revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) | |
5213 | limit = cmdutil.loglimit(opts) |
|
5223 | limit = cmdutil.loglimit(opts) | |
5214 | count = 0 |
|
5224 | count = 0 | |
5215 |
|
5225 | |||
5216 | getrenamed = None |
|
5226 | getrenamed = None | |
5217 | if opts.get('copies'): |
|
5227 | if opts.get('copies'): | |
5218 | endrev = None |
|
5228 | endrev = None | |
5219 | if opts.get('rev'): |
|
5229 | if opts.get('rev'): | |
5220 | endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1 |
|
5230 | endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1 | |
5221 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) |
|
5231 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) | |
5222 |
|
5232 | |||
5223 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) |
|
5233 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) | |
5224 | for rev in revs: |
|
5234 | for rev in revs: | |
5225 | if count == limit: |
|
5235 | if count == limit: | |
5226 | break |
|
5236 | break | |
5227 | ctx = repo[rev] |
|
5237 | ctx = repo[rev] | |
5228 | copies = None |
|
5238 | copies = None | |
5229 | if getrenamed is not None and rev: |
|
5239 | if getrenamed is not None and rev: | |
5230 | copies = [] |
|
5240 | copies = [] | |
5231 | for fn in ctx.files(): |
|
5241 | for fn in ctx.files(): | |
5232 | rename = getrenamed(fn, rev) |
|
5242 | rename = getrenamed(fn, rev) | |
5233 | if rename: |
|
5243 | if rename: | |
5234 | copies.append((fn, rename[0])) |
|
5244 | copies.append((fn, rename[0])) | |
5235 | if filematcher: |
|
5245 | if filematcher: | |
5236 | revmatchfn = filematcher(ctx.rev()) |
|
5246 | revmatchfn = filematcher(ctx.rev()) | |
5237 | else: |
|
5247 | else: | |
5238 | revmatchfn = None |
|
5248 | revmatchfn = None | |
5239 | displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
|
5249 | displayer.show(ctx, copies=copies, matchfn=revmatchfn) | |
5240 | if displayer.flush(ctx): |
|
5250 | if displayer.flush(ctx): | |
5241 | count += 1 |
|
5251 | count += 1 | |
5242 |
|
5252 | |||
5243 | displayer.close() |
|
5253 | displayer.close() | |
5244 |
|
5254 | |||
5245 | @command('manifest', |
|
5255 | @command('manifest', | |
5246 | [('r', 'rev', '', _('revision to display'), _('REV')), |
|
5256 | [('r', 'rev', '', _('revision to display'), _('REV')), | |
5247 | ('', 'all', False, _("list files from all revisions"))] |
|
5257 | ('', 'all', False, _("list files from all revisions"))] | |
5248 | + formatteropts, |
|
5258 | + formatteropts, | |
5249 | _('[-r REV]')) |
|
5259 | _('[-r REV]')) | |
5250 | def manifest(ui, repo, node=None, rev=None, **opts): |
|
5260 | def manifest(ui, repo, node=None, rev=None, **opts): | |
5251 | """output the current or given revision of the project manifest |
|
5261 | """output the current or given revision of the project manifest | |
5252 |
|
5262 | |||
5253 | Print a list of version controlled files for the given revision. |
|
5263 | Print a list of version controlled files for the given revision. | |
5254 | If no revision is given, the first parent of the working directory |
|
5264 | If no revision is given, the first parent of the working directory | |
5255 | is used, or the null revision if no revision is checked out. |
|
5265 | is used, or the null revision if no revision is checked out. | |
5256 |
|
5266 | |||
5257 | With -v, print file permissions, symlink and executable bits. |
|
5267 | With -v, print file permissions, symlink and executable bits. | |
5258 | With --debug, print file revision hashes. |
|
5268 | With --debug, print file revision hashes. | |
5259 |
|
5269 | |||
5260 | If option --all is specified, the list of all files from all revisions |
|
5270 | If option --all is specified, the list of all files from all revisions | |
5261 | is printed. This includes deleted and renamed files. |
|
5271 | is printed. This includes deleted and renamed files. | |
5262 |
|
5272 | |||
5263 | Returns 0 on success. |
|
5273 | Returns 0 on success. | |
5264 | """ |
|
5274 | """ | |
5265 |
|
5275 | |||
5266 | fm = ui.formatter('manifest', opts) |
|
5276 | fm = ui.formatter('manifest', opts) | |
5267 |
|
5277 | |||
5268 | if opts.get('all'): |
|
5278 | if opts.get('all'): | |
5269 | if rev or node: |
|
5279 | if rev or node: | |
5270 | raise error.Abort(_("can't specify a revision with --all")) |
|
5280 | raise error.Abort(_("can't specify a revision with --all")) | |
5271 |
|
5281 | |||
5272 | res = [] |
|
5282 | res = [] | |
5273 | prefix = "data/" |
|
5283 | prefix = "data/" | |
5274 | suffix = ".i" |
|
5284 | suffix = ".i" | |
5275 | plen = len(prefix) |
|
5285 | plen = len(prefix) | |
5276 | slen = len(suffix) |
|
5286 | slen = len(suffix) | |
5277 | with repo.lock(): |
|
5287 | with repo.lock(): | |
5278 | for fn, b, size in repo.store.datafiles(): |
|
5288 | for fn, b, size in repo.store.datafiles(): | |
5279 | if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix: |
|
5289 | if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix: | |
5280 | res.append(fn[plen:-slen]) |
|
5290 | res.append(fn[plen:-slen]) | |
5281 | for f in res: |
|
5291 | for f in res: | |
5282 | fm.startitem() |
|
5292 | fm.startitem() | |
5283 | fm.write("path", '%s\n', f) |
|
5293 | fm.write("path", '%s\n', f) | |
5284 | fm.end() |
|
5294 | fm.end() | |
5285 | return |
|
5295 | return | |
5286 |
|
5296 | |||
5287 | if rev and node: |
|
5297 | if rev and node: | |
5288 | raise error.Abort(_("please specify just one revision")) |
|
5298 | raise error.Abort(_("please specify just one revision")) | |
5289 |
|
5299 | |||
5290 | if not node: |
|
5300 | if not node: | |
5291 | node = rev |
|
5301 | node = rev | |
5292 |
|
5302 | |||
5293 | char = {'l': '@', 'x': '*', '': ''} |
|
5303 | char = {'l': '@', 'x': '*', '': ''} | |
5294 | mode = {'l': '644', 'x': '755', '': '644'} |
|
5304 | mode = {'l': '644', 'x': '755', '': '644'} | |
5295 | ctx = scmutil.revsingle(repo, node) |
|
5305 | ctx = scmutil.revsingle(repo, node) | |
5296 | mf = ctx.manifest() |
|
5306 | mf = ctx.manifest() | |
5297 | for f in ctx: |
|
5307 | for f in ctx: | |
5298 | fm.startitem() |
|
5308 | fm.startitem() | |
5299 | fl = ctx[f].flags() |
|
5309 | fl = ctx[f].flags() | |
5300 | fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f])) |
|
5310 | fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f])) | |
5301 | fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl]) |
|
5311 | fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl]) | |
5302 | fm.write('path', '%s\n', f) |
|
5312 | fm.write('path', '%s\n', f) | |
5303 | fm.end() |
|
5313 | fm.end() | |
5304 |
|
5314 | |||
5305 | @command('^merge', |
|
5315 | @command('^merge', | |
5306 | [('f', 'force', None, |
|
5316 | [('f', 'force', None, | |
5307 | _('force a merge including outstanding changes (DEPRECATED)')), |
|
5317 | _('force a merge including outstanding changes (DEPRECATED)')), | |
5308 | ('r', 'rev', '', _('revision to merge'), _('REV')), |
|
5318 | ('r', 'rev', '', _('revision to merge'), _('REV')), | |
5309 | ('P', 'preview', None, |
|
5319 | ('P', 'preview', None, | |
5310 | _('review revisions to merge (no merge is performed)')) |
|
5320 | _('review revisions to merge (no merge is performed)')) | |
5311 | ] + mergetoolopts, |
|
5321 | ] + mergetoolopts, | |
5312 | _('[-P] [[-r] REV]')) |
|
5322 | _('[-P] [[-r] REV]')) | |
5313 | def merge(ui, repo, node=None, **opts): |
|
5323 | def merge(ui, repo, node=None, **opts): | |
5314 | """merge another revision into working directory |
|
5324 | """merge another revision into working directory | |
5315 |
|
5325 | |||
5316 | The current working directory is updated with all changes made in |
|
5326 | The current working directory is updated with all changes made in | |
5317 | the requested revision since the last common predecessor revision. |
|
5327 | the requested revision since the last common predecessor revision. | |
5318 |
|
5328 | |||
5319 | Files that changed between either parent are marked as changed for |
|
5329 | Files that changed between either parent are marked as changed for | |
5320 | the next commit and a commit must be performed before any further |
|
5330 | the next commit and a commit must be performed before any further | |
5321 | updates to the repository are allowed. The next commit will have |
|
5331 | updates to the repository are allowed. The next commit will have | |
5322 | two parents. |
|
5332 | two parents. | |
5323 |
|
5333 | |||
5324 | ``--tool`` can be used to specify the merge tool used for file |
|
5334 | ``--tool`` can be used to specify the merge tool used for file | |
5325 | merges. It overrides the HGMERGE environment variable and your |
|
5335 | merges. It overrides the HGMERGE environment variable and your | |
5326 | configuration files. See :hg:`help merge-tools` for options. |
|
5336 | configuration files. See :hg:`help merge-tools` for options. | |
5327 |
|
5337 | |||
5328 | If no revision is specified, the working directory's parent is a |
|
5338 | If no revision is specified, the working directory's parent is a | |
5329 | head revision, and the current branch contains exactly one other |
|
5339 | head revision, and the current branch contains exactly one other | |
5330 | head, the other head is merged with by default. Otherwise, an |
|
5340 | head, the other head is merged with by default. Otherwise, an | |
5331 | explicit revision with which to merge with must be provided. |
|
5341 | explicit revision with which to merge with must be provided. | |
5332 |
|
5342 | |||
5333 | See :hg:`help resolve` for information on handling file conflicts. |
|
5343 | See :hg:`help resolve` for information on handling file conflicts. | |
5334 |
|
5344 | |||
5335 | To undo an uncommitted merge, use :hg:`update --clean .` which |
|
5345 | To undo an uncommitted merge, use :hg:`update --clean .` which | |
5336 | will check out a clean copy of the original merge parent, losing |
|
5346 | will check out a clean copy of the original merge parent, losing | |
5337 | all changes. |
|
5347 | all changes. | |
5338 |
|
5348 | |||
5339 | Returns 0 on success, 1 if there are unresolved files. |
|
5349 | Returns 0 on success, 1 if there are unresolved files. | |
5340 | """ |
|
5350 | """ | |
5341 |
|
5351 | |||
5342 | if opts.get('rev') and node: |
|
5352 | if opts.get('rev') and node: | |
5343 | raise error.Abort(_("please specify just one revision")) |
|
5353 | raise error.Abort(_("please specify just one revision")) | |
5344 | if not node: |
|
5354 | if not node: | |
5345 | node = opts.get('rev') |
|
5355 | node = opts.get('rev') | |
5346 |
|
5356 | |||
5347 | if node: |
|
5357 | if node: | |
5348 | node = scmutil.revsingle(repo, node).node() |
|
5358 | node = scmutil.revsingle(repo, node).node() | |
5349 |
|
5359 | |||
5350 | if not node: |
|
5360 | if not node: | |
5351 | node = repo[destutil.destmerge(repo)].node() |
|
5361 | node = repo[destutil.destmerge(repo)].node() | |
5352 |
|
5362 | |||
5353 | if opts.get('preview'): |
|
5363 | if opts.get('preview'): | |
5354 | # find nodes that are ancestors of p2 but not of p1 |
|
5364 | # find nodes that are ancestors of p2 but not of p1 | |
5355 | p1 = repo.lookup('.') |
|
5365 | p1 = repo.lookup('.') | |
5356 | p2 = repo.lookup(node) |
|
5366 | p2 = repo.lookup(node) | |
5357 | nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) |
|
5367 | nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) | |
5358 |
|
5368 | |||
5359 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
5369 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
5360 | for node in nodes: |
|
5370 | for node in nodes: | |
5361 | displayer.show(repo[node]) |
|
5371 | displayer.show(repo[node]) | |
5362 | displayer.close() |
|
5372 | displayer.close() | |
5363 | return 0 |
|
5373 | return 0 | |
5364 |
|
5374 | |||
5365 | try: |
|
5375 | try: | |
5366 | # ui.forcemerge is an internal variable, do not document |
|
5376 | # ui.forcemerge is an internal variable, do not document | |
5367 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge') |
|
5377 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge') | |
5368 | force = opts.get('force') |
|
5378 | force = opts.get('force') | |
5369 | labels = ['working copy', 'merge rev'] |
|
5379 | labels = ['working copy', 'merge rev'] | |
5370 | return hg.merge(repo, node, force=force, mergeforce=force, |
|
5380 | return hg.merge(repo, node, force=force, mergeforce=force, | |
5371 | labels=labels) |
|
5381 | labels=labels) | |
5372 | finally: |
|
5382 | finally: | |
5373 | ui.setconfig('ui', 'forcemerge', '', 'merge') |
|
5383 | ui.setconfig('ui', 'forcemerge', '', 'merge') | |
5374 |
|
5384 | |||
5375 | @command('outgoing|out', |
|
5385 | @command('outgoing|out', | |
5376 | [('f', 'force', None, _('run even when the destination is unrelated')), |
|
5386 | [('f', 'force', None, _('run even when the destination is unrelated')), | |
5377 | ('r', 'rev', [], |
|
5387 | ('r', 'rev', [], | |
5378 | _('a changeset intended to be included in the destination'), _('REV')), |
|
5388 | _('a changeset intended to be included in the destination'), _('REV')), | |
5379 | ('n', 'newest-first', None, _('show newest record first')), |
|
5389 | ('n', 'newest-first', None, _('show newest record first')), | |
5380 | ('B', 'bookmarks', False, _('compare bookmarks')), |
|
5390 | ('B', 'bookmarks', False, _('compare bookmarks')), | |
5381 | ('b', 'branch', [], _('a specific branch you would like to push'), |
|
5391 | ('b', 'branch', [], _('a specific branch you would like to push'), | |
5382 | _('BRANCH')), |
|
5392 | _('BRANCH')), | |
5383 | ] + logopts + remoteopts + subrepoopts, |
|
5393 | ] + logopts + remoteopts + subrepoopts, | |
5384 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')) |
|
5394 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')) | |
5385 | def outgoing(ui, repo, dest=None, **opts): |
|
5395 | def outgoing(ui, repo, dest=None, **opts): | |
5386 | """show changesets not found in the destination |
|
5396 | """show changesets not found in the destination | |
5387 |
|
5397 | |||
5388 | Show changesets not found in the specified destination repository |
|
5398 | Show changesets not found in the specified destination repository | |
5389 | or the default push location. These are the changesets that would |
|
5399 | or the default push location. These are the changesets that would | |
5390 | be pushed if a push was requested. |
|
5400 | be pushed if a push was requested. | |
5391 |
|
5401 | |||
5392 | See pull for details of valid destination formats. |
|
5402 | See pull for details of valid destination formats. | |
5393 |
|
5403 | |||
5394 | .. container:: verbose |
|
5404 | .. container:: verbose | |
5395 |
|
5405 | |||
5396 | With -B/--bookmarks, the result of bookmark comparison between |
|
5406 | With -B/--bookmarks, the result of bookmark comparison between | |
5397 | local and remote repositories is displayed. With -v/--verbose, |
|
5407 | local and remote repositories is displayed. With -v/--verbose, | |
5398 | status is also displayed for each bookmark like below:: |
|
5408 | status is also displayed for each bookmark like below:: | |
5399 |
|
5409 | |||
5400 | BM1 01234567890a added |
|
5410 | BM1 01234567890a added | |
5401 | BM2 deleted |
|
5411 | BM2 deleted | |
5402 | BM3 234567890abc advanced |
|
5412 | BM3 234567890abc advanced | |
5403 | BM4 34567890abcd diverged |
|
5413 | BM4 34567890abcd diverged | |
5404 | BM5 4567890abcde changed |
|
5414 | BM5 4567890abcde changed | |
5405 |
|
5415 | |||
5406 | The action taken when pushing depends on the |
|
5416 | The action taken when pushing depends on the | |
5407 | status of each bookmark: |
|
5417 | status of each bookmark: | |
5408 |
|
5418 | |||
5409 | :``added``: push with ``-B`` will create it |
|
5419 | :``added``: push with ``-B`` will create it | |
5410 | :``deleted``: push with ``-B`` will delete it |
|
5420 | :``deleted``: push with ``-B`` will delete it | |
5411 | :``advanced``: push will update it |
|
5421 | :``advanced``: push will update it | |
5412 | :``diverged``: push with ``-B`` will update it |
|
5422 | :``diverged``: push with ``-B`` will update it | |
5413 | :``changed``: push with ``-B`` will update it |
|
5423 | :``changed``: push with ``-B`` will update it | |
5414 |
|
5424 | |||
5415 | From the point of view of pushing behavior, bookmarks |
|
5425 | From the point of view of pushing behavior, bookmarks | |
5416 | existing only in the remote repository are treated as |
|
5426 | existing only in the remote repository are treated as | |
5417 | ``deleted``, even if it is in fact added remotely. |
|
5427 | ``deleted``, even if it is in fact added remotely. | |
5418 |
|
5428 | |||
5419 | Returns 0 if there are outgoing changes, 1 otherwise. |
|
5429 | Returns 0 if there are outgoing changes, 1 otherwise. | |
5420 | """ |
|
5430 | """ | |
5421 | if opts.get('graph'): |
|
5431 | if opts.get('graph'): | |
5422 | cmdutil.checkunsupportedgraphflags([], opts) |
|
5432 | cmdutil.checkunsupportedgraphflags([], opts) | |
5423 | o, other = hg._outgoing(ui, repo, dest, opts) |
|
5433 | o, other = hg._outgoing(ui, repo, dest, opts) | |
5424 | if not o: |
|
5434 | if not o: | |
5425 | cmdutil.outgoinghooks(ui, repo, other, opts, o) |
|
5435 | cmdutil.outgoinghooks(ui, repo, other, opts, o) | |
5426 | return |
|
5436 | return | |
5427 |
|
5437 | |||
5428 | revdag = cmdutil.graphrevs(repo, o, opts) |
|
5438 | revdag = cmdutil.graphrevs(repo, o, opts) | |
5429 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) |
|
5439 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) | |
5430 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) |
|
5440 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) | |
5431 | cmdutil.outgoinghooks(ui, repo, other, opts, o) |
|
5441 | cmdutil.outgoinghooks(ui, repo, other, opts, o) | |
5432 | return 0 |
|
5442 | return 0 | |
5433 |
|
5443 | |||
5434 | if opts.get('bookmarks'): |
|
5444 | if opts.get('bookmarks'): | |
5435 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
5445 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
5436 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
5446 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
5437 | other = hg.peer(repo, opts, dest) |
|
5447 | other = hg.peer(repo, opts, dest) | |
5438 | if 'bookmarks' not in other.listkeys('namespaces'): |
|
5448 | if 'bookmarks' not in other.listkeys('namespaces'): | |
5439 | ui.warn(_("remote doesn't support bookmarks\n")) |
|
5449 | ui.warn(_("remote doesn't support bookmarks\n")) | |
5440 | return 0 |
|
5450 | return 0 | |
5441 | ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
|
5451 | ui.status(_('comparing with %s\n') % util.hidepassword(dest)) | |
5442 | return bookmarks.outgoing(ui, repo, other) |
|
5452 | return bookmarks.outgoing(ui, repo, other) | |
5443 |
|
5453 | |||
5444 | repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') |
|
5454 | repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') | |
5445 | try: |
|
5455 | try: | |
5446 | return hg.outgoing(ui, repo, dest, opts) |
|
5456 | return hg.outgoing(ui, repo, dest, opts) | |
5447 | finally: |
|
5457 | finally: | |
5448 | del repo._subtoppath |
|
5458 | del repo._subtoppath | |
5449 |
|
5459 | |||
5450 | @command('parents', |
|
5460 | @command('parents', | |
5451 | [('r', 'rev', '', _('show parents of the specified revision'), _('REV')), |
|
5461 | [('r', 'rev', '', _('show parents of the specified revision'), _('REV')), | |
5452 | ] + templateopts, |
|
5462 | ] + templateopts, | |
5453 | _('[-r REV] [FILE]'), |
|
5463 | _('[-r REV] [FILE]'), | |
5454 | inferrepo=True) |
|
5464 | inferrepo=True) | |
5455 | def parents(ui, repo, file_=None, **opts): |
|
5465 | def parents(ui, repo, file_=None, **opts): | |
5456 | """show the parents of the working directory or revision (DEPRECATED) |
|
5466 | """show the parents of the working directory or revision (DEPRECATED) | |
5457 |
|
5467 | |||
5458 | Print the working directory's parent revisions. If a revision is |
|
5468 | Print the working directory's parent revisions. If a revision is | |
5459 | given via -r/--rev, the parent of that revision will be printed. |
|
5469 | given via -r/--rev, the parent of that revision will be printed. | |
5460 | If a file argument is given, the revision in which the file was |
|
5470 | If a file argument is given, the revision in which the file was | |
5461 | last changed (before the working directory revision or the |
|
5471 | last changed (before the working directory revision or the | |
5462 | argument to --rev if given) is printed. |
|
5472 | argument to --rev if given) is printed. | |
5463 |
|
5473 | |||
5464 | This command is equivalent to:: |
|
5474 | This command is equivalent to:: | |
5465 |
|
5475 | |||
5466 | hg log -r "p1()+p2()" or |
|
5476 | hg log -r "p1()+p2()" or | |
5467 | hg log -r "p1(REV)+p2(REV)" or |
|
5477 | hg log -r "p1(REV)+p2(REV)" or | |
5468 | hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or |
|
5478 | hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or | |
5469 | hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))" |
|
5479 | hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))" | |
5470 |
|
5480 | |||
5471 | See :hg:`summary` and :hg:`help revsets` for related information. |
|
5481 | See :hg:`summary` and :hg:`help revsets` for related information. | |
5472 |
|
5482 | |||
5473 | Returns 0 on success. |
|
5483 | Returns 0 on success. | |
5474 | """ |
|
5484 | """ | |
5475 |
|
5485 | |||
5476 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
5486 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) | |
5477 |
|
5487 | |||
5478 | if file_: |
|
5488 | if file_: | |
5479 | m = scmutil.match(ctx, (file_,), opts) |
|
5489 | m = scmutil.match(ctx, (file_,), opts) | |
5480 | if m.anypats() or len(m.files()) != 1: |
|
5490 | if m.anypats() or len(m.files()) != 1: | |
5481 | raise error.Abort(_('can only specify an explicit filename')) |
|
5491 | raise error.Abort(_('can only specify an explicit filename')) | |
5482 | file_ = m.files()[0] |
|
5492 | file_ = m.files()[0] | |
5483 | filenodes = [] |
|
5493 | filenodes = [] | |
5484 | for cp in ctx.parents(): |
|
5494 | for cp in ctx.parents(): | |
5485 | if not cp: |
|
5495 | if not cp: | |
5486 | continue |
|
5496 | continue | |
5487 | try: |
|
5497 | try: | |
5488 | filenodes.append(cp.filenode(file_)) |
|
5498 | filenodes.append(cp.filenode(file_)) | |
5489 | except error.LookupError: |
|
5499 | except error.LookupError: | |
5490 | pass |
|
5500 | pass | |
5491 | if not filenodes: |
|
5501 | if not filenodes: | |
5492 | raise error.Abort(_("'%s' not found in manifest!") % file_) |
|
5502 | raise error.Abort(_("'%s' not found in manifest!") % file_) | |
5493 | p = [] |
|
5503 | p = [] | |
5494 | for fn in filenodes: |
|
5504 | for fn in filenodes: | |
5495 | fctx = repo.filectx(file_, fileid=fn) |
|
5505 | fctx = repo.filectx(file_, fileid=fn) | |
5496 | p.append(fctx.node()) |
|
5506 | p.append(fctx.node()) | |
5497 | else: |
|
5507 | else: | |
5498 | p = [cp.node() for cp in ctx.parents()] |
|
5508 | p = [cp.node() for cp in ctx.parents()] | |
5499 |
|
5509 | |||
5500 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
5510 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
5501 | for n in p: |
|
5511 | for n in p: | |
5502 | if n != nullid: |
|
5512 | if n != nullid: | |
5503 | displayer.show(repo[n]) |
|
5513 | displayer.show(repo[n]) | |
5504 | displayer.close() |
|
5514 | displayer.close() | |
5505 |
|
5515 | |||
5506 | @command('paths', formatteropts, _('[NAME]'), optionalrepo=True) |
|
5516 | @command('paths', formatteropts, _('[NAME]'), optionalrepo=True) | |
5507 | def paths(ui, repo, search=None, **opts): |
|
5517 | def paths(ui, repo, search=None, **opts): | |
5508 | """show aliases for remote repositories |
|
5518 | """show aliases for remote repositories | |
5509 |
|
5519 | |||
5510 | Show definition of symbolic path name NAME. If no name is given, |
|
5520 | Show definition of symbolic path name NAME. If no name is given, | |
5511 | show definition of all available names. |
|
5521 | show definition of all available names. | |
5512 |
|
5522 | |||
5513 | Option -q/--quiet suppresses all output when searching for NAME |
|
5523 | Option -q/--quiet suppresses all output when searching for NAME | |
5514 | and shows only the path names when listing all definitions. |
|
5524 | and shows only the path names when listing all definitions. | |
5515 |
|
5525 | |||
5516 | Path names are defined in the [paths] section of your |
|
5526 | Path names are defined in the [paths] section of your | |
5517 | configuration file and in ``/etc/mercurial/hgrc``. If run inside a |
|
5527 | configuration file and in ``/etc/mercurial/hgrc``. If run inside a | |
5518 | repository, ``.hg/hgrc`` is used, too. |
|
5528 | repository, ``.hg/hgrc`` is used, too. | |
5519 |
|
5529 | |||
5520 | The path names ``default`` and ``default-push`` have a special |
|
5530 | The path names ``default`` and ``default-push`` have a special | |
5521 | meaning. When performing a push or pull operation, they are used |
|
5531 | meaning. When performing a push or pull operation, they are used | |
5522 | as fallbacks if no location is specified on the command-line. |
|
5532 | as fallbacks if no location is specified on the command-line. | |
5523 | When ``default-push`` is set, it will be used for push and |
|
5533 | When ``default-push`` is set, it will be used for push and | |
5524 | ``default`` will be used for pull; otherwise ``default`` is used |
|
5534 | ``default`` will be used for pull; otherwise ``default`` is used | |
5525 | as the fallback for both. When cloning a repository, the clone |
|
5535 | as the fallback for both. When cloning a repository, the clone | |
5526 | source is written as ``default`` in ``.hg/hgrc``. |
|
5536 | source is written as ``default`` in ``.hg/hgrc``. | |
5527 |
|
5537 | |||
5528 | .. note:: |
|
5538 | .. note:: | |
5529 |
|
5539 | |||
5530 | ``default`` and ``default-push`` apply to all inbound (e.g. |
|
5540 | ``default`` and ``default-push`` apply to all inbound (e.g. | |
5531 | :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` |
|
5541 | :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` | |
5532 | and :hg:`bundle`) operations. |
|
5542 | and :hg:`bundle`) operations. | |
5533 |
|
5543 | |||
5534 | See :hg:`help urls` for more information. |
|
5544 | See :hg:`help urls` for more information. | |
5535 |
|
5545 | |||
5536 | Returns 0 on success. |
|
5546 | Returns 0 on success. | |
5537 | """ |
|
5547 | """ | |
5538 | if search: |
|
5548 | if search: | |
5539 | pathitems = [(name, path) for name, path in ui.paths.iteritems() |
|
5549 | pathitems = [(name, path) for name, path in ui.paths.iteritems() | |
5540 | if name == search] |
|
5550 | if name == search] | |
5541 | else: |
|
5551 | else: | |
5542 | pathitems = sorted(ui.paths.iteritems()) |
|
5552 | pathitems = sorted(ui.paths.iteritems()) | |
5543 |
|
5553 | |||
5544 | fm = ui.formatter('paths', opts) |
|
5554 | fm = ui.formatter('paths', opts) | |
5545 | if fm.isplain(): |
|
5555 | if fm.isplain(): | |
5546 | hidepassword = util.hidepassword |
|
5556 | hidepassword = util.hidepassword | |
5547 | else: |
|
5557 | else: | |
5548 | hidepassword = str |
|
5558 | hidepassword = str | |
5549 | if ui.quiet: |
|
5559 | if ui.quiet: | |
5550 | namefmt = '%s\n' |
|
5560 | namefmt = '%s\n' | |
5551 | else: |
|
5561 | else: | |
5552 | namefmt = '%s = ' |
|
5562 | namefmt = '%s = ' | |
5553 | showsubopts = not search and not ui.quiet |
|
5563 | showsubopts = not search and not ui.quiet | |
5554 |
|
5564 | |||
5555 | for name, path in pathitems: |
|
5565 | for name, path in pathitems: | |
5556 | fm.startitem() |
|
5566 | fm.startitem() | |
5557 | fm.condwrite(not search, 'name', namefmt, name) |
|
5567 | fm.condwrite(not search, 'name', namefmt, name) | |
5558 | fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc)) |
|
5568 | fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc)) | |
5559 | for subopt, value in sorted(path.suboptions.items()): |
|
5569 | for subopt, value in sorted(path.suboptions.items()): | |
5560 | assert subopt not in ('name', 'url') |
|
5570 | assert subopt not in ('name', 'url') | |
5561 | if showsubopts: |
|
5571 | if showsubopts: | |
5562 | fm.plain('%s:%s = ' % (name, subopt)) |
|
5572 | fm.plain('%s:%s = ' % (name, subopt)) | |
5563 | fm.condwrite(showsubopts, subopt, '%s\n', value) |
|
5573 | fm.condwrite(showsubopts, subopt, '%s\n', value) | |
5564 |
|
5574 | |||
5565 | fm.end() |
|
5575 | fm.end() | |
5566 |
|
5576 | |||
5567 | if search and not pathitems: |
|
5577 | if search and not pathitems: | |
5568 | if not ui.quiet: |
|
5578 | if not ui.quiet: | |
5569 | ui.warn(_("not found!\n")) |
|
5579 | ui.warn(_("not found!\n")) | |
5570 | return 1 |
|
5580 | return 1 | |
5571 | else: |
|
5581 | else: | |
5572 | return 0 |
|
5582 | return 0 | |
5573 |
|
5583 | |||
5574 | @command('phase', |
|
5584 | @command('phase', | |
5575 | [('p', 'public', False, _('set changeset phase to public')), |
|
5585 | [('p', 'public', False, _('set changeset phase to public')), | |
5576 | ('d', 'draft', False, _('set changeset phase to draft')), |
|
5586 | ('d', 'draft', False, _('set changeset phase to draft')), | |
5577 | ('s', 'secret', False, _('set changeset phase to secret')), |
|
5587 | ('s', 'secret', False, _('set changeset phase to secret')), | |
5578 | ('f', 'force', False, _('allow to move boundary backward')), |
|
5588 | ('f', 'force', False, _('allow to move boundary backward')), | |
5579 | ('r', 'rev', [], _('target revision'), _('REV')), |
|
5589 | ('r', 'rev', [], _('target revision'), _('REV')), | |
5580 | ], |
|
5590 | ], | |
5581 | _('[-p|-d|-s] [-f] [-r] [REV...]')) |
|
5591 | _('[-p|-d|-s] [-f] [-r] [REV...]')) | |
5582 | def phase(ui, repo, *revs, **opts): |
|
5592 | def phase(ui, repo, *revs, **opts): | |
5583 | """set or show the current phase name |
|
5593 | """set or show the current phase name | |
5584 |
|
5594 | |||
5585 | With no argument, show the phase name of the current revision(s). |
|
5595 | With no argument, show the phase name of the current revision(s). | |
5586 |
|
5596 | |||
5587 | With one of -p/--public, -d/--draft or -s/--secret, change the |
|
5597 | With one of -p/--public, -d/--draft or -s/--secret, change the | |
5588 | phase value of the specified revisions. |
|
5598 | phase value of the specified revisions. | |
5589 |
|
5599 | |||
5590 | Unless -f/--force is specified, :hg:`phase` won't move changeset from a |
|
5600 | Unless -f/--force is specified, :hg:`phase` won't move changeset from a | |
5591 | lower phase to an higher phase. Phases are ordered as follows:: |
|
5601 | lower phase to an higher phase. Phases are ordered as follows:: | |
5592 |
|
5602 | |||
5593 | public < draft < secret |
|
5603 | public < draft < secret | |
5594 |
|
5604 | |||
5595 | Returns 0 on success, 1 if some phases could not be changed. |
|
5605 | Returns 0 on success, 1 if some phases could not be changed. | |
5596 |
|
5606 | |||
5597 | (For more information about the phases concept, see :hg:`help phases`.) |
|
5607 | (For more information about the phases concept, see :hg:`help phases`.) | |
5598 | """ |
|
5608 | """ | |
5599 | # search for a unique phase argument |
|
5609 | # search for a unique phase argument | |
5600 | targetphase = None |
|
5610 | targetphase = None | |
5601 | for idx, name in enumerate(phases.phasenames): |
|
5611 | for idx, name in enumerate(phases.phasenames): | |
5602 | if opts[name]: |
|
5612 | if opts[name]: | |
5603 | if targetphase is not None: |
|
5613 | if targetphase is not None: | |
5604 | raise error.Abort(_('only one phase can be specified')) |
|
5614 | raise error.Abort(_('only one phase can be specified')) | |
5605 | targetphase = idx |
|
5615 | targetphase = idx | |
5606 |
|
5616 | |||
5607 | # look for specified revision |
|
5617 | # look for specified revision | |
5608 | revs = list(revs) |
|
5618 | revs = list(revs) | |
5609 | revs.extend(opts['rev']) |
|
5619 | revs.extend(opts['rev']) | |
5610 | if not revs: |
|
5620 | if not revs: | |
5611 | # display both parents as the second parent phase can influence |
|
5621 | # display both parents as the second parent phase can influence | |
5612 | # the phase of a merge commit |
|
5622 | # the phase of a merge commit | |
5613 | revs = [c.rev() for c in repo[None].parents()] |
|
5623 | revs = [c.rev() for c in repo[None].parents()] | |
5614 |
|
5624 | |||
5615 | revs = scmutil.revrange(repo, revs) |
|
5625 | revs = scmutil.revrange(repo, revs) | |
5616 |
|
5626 | |||
5617 | lock = None |
|
5627 | lock = None | |
5618 | ret = 0 |
|
5628 | ret = 0 | |
5619 | if targetphase is None: |
|
5629 | if targetphase is None: | |
5620 | # display |
|
5630 | # display | |
5621 | for r in revs: |
|
5631 | for r in revs: | |
5622 | ctx = repo[r] |
|
5632 | ctx = repo[r] | |
5623 | ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) |
|
5633 | ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) | |
5624 | else: |
|
5634 | else: | |
5625 | tr = None |
|
5635 | tr = None | |
5626 | lock = repo.lock() |
|
5636 | lock = repo.lock() | |
5627 | try: |
|
5637 | try: | |
5628 | tr = repo.transaction("phase") |
|
5638 | tr = repo.transaction("phase") | |
5629 | # set phase |
|
5639 | # set phase | |
5630 | if not revs: |
|
5640 | if not revs: | |
5631 | raise error.Abort(_('empty revision set')) |
|
5641 | raise error.Abort(_('empty revision set')) | |
5632 | nodes = [repo[r].node() for r in revs] |
|
5642 | nodes = [repo[r].node() for r in revs] | |
5633 | # moving revision from public to draft may hide them |
|
5643 | # moving revision from public to draft may hide them | |
5634 | # We have to check result on an unfiltered repository |
|
5644 | # We have to check result on an unfiltered repository | |
5635 | unfi = repo.unfiltered() |
|
5645 | unfi = repo.unfiltered() | |
5636 | getphase = unfi._phasecache.phase |
|
5646 | getphase = unfi._phasecache.phase | |
5637 | olddata = [getphase(unfi, r) for r in unfi] |
|
5647 | olddata = [getphase(unfi, r) for r in unfi] | |
5638 | phases.advanceboundary(repo, tr, targetphase, nodes) |
|
5648 | phases.advanceboundary(repo, tr, targetphase, nodes) | |
5639 | if opts['force']: |
|
5649 | if opts['force']: | |
5640 | phases.retractboundary(repo, tr, targetphase, nodes) |
|
5650 | phases.retractboundary(repo, tr, targetphase, nodes) | |
5641 | tr.close() |
|
5651 | tr.close() | |
5642 | finally: |
|
5652 | finally: | |
5643 | if tr is not None: |
|
5653 | if tr is not None: | |
5644 | tr.release() |
|
5654 | tr.release() | |
5645 | lock.release() |
|
5655 | lock.release() | |
5646 | getphase = unfi._phasecache.phase |
|
5656 | getphase = unfi._phasecache.phase | |
5647 | newdata = [getphase(unfi, r) for r in unfi] |
|
5657 | newdata = [getphase(unfi, r) for r in unfi] | |
5648 | changes = sum(newdata[r] != olddata[r] for r in unfi) |
|
5658 | changes = sum(newdata[r] != olddata[r] for r in unfi) | |
5649 | cl = unfi.changelog |
|
5659 | cl = unfi.changelog | |
5650 | rejected = [n for n in nodes |
|
5660 | rejected = [n for n in nodes | |
5651 | if newdata[cl.rev(n)] < targetphase] |
|
5661 | if newdata[cl.rev(n)] < targetphase] | |
5652 | if rejected: |
|
5662 | if rejected: | |
5653 | ui.warn(_('cannot move %i changesets to a higher ' |
|
5663 | ui.warn(_('cannot move %i changesets to a higher ' | |
5654 | 'phase, use --force\n') % len(rejected)) |
|
5664 | 'phase, use --force\n') % len(rejected)) | |
5655 | ret = 1 |
|
5665 | ret = 1 | |
5656 | if changes: |
|
5666 | if changes: | |
5657 | msg = _('phase changed for %i changesets\n') % changes |
|
5667 | msg = _('phase changed for %i changesets\n') % changes | |
5658 | if ret: |
|
5668 | if ret: | |
5659 | ui.status(msg) |
|
5669 | ui.status(msg) | |
5660 | else: |
|
5670 | else: | |
5661 | ui.note(msg) |
|
5671 | ui.note(msg) | |
5662 | else: |
|
5672 | else: | |
5663 | ui.warn(_('no phases changed\n')) |
|
5673 | ui.warn(_('no phases changed\n')) | |
5664 | return ret |
|
5674 | return ret | |
5665 |
|
5675 | |||
5666 | def postincoming(ui, repo, modheads, optupdate, checkout, brev): |
|
5676 | def postincoming(ui, repo, modheads, optupdate, checkout, brev): | |
5667 | """Run after a changegroup has been added via pull/unbundle |
|
5677 | """Run after a changegroup has been added via pull/unbundle | |
5668 |
|
5678 | |||
5669 | This takes arguments below: |
|
5679 | This takes arguments below: | |
5670 |
|
5680 | |||
5671 | :modheads: change of heads by pull/unbundle |
|
5681 | :modheads: change of heads by pull/unbundle | |
5672 | :optupdate: updating working directory is needed or not |
|
5682 | :optupdate: updating working directory is needed or not | |
5673 | :checkout: update destination revision (or None to default destination) |
|
5683 | :checkout: update destination revision (or None to default destination) | |
5674 | :brev: a name, which might be a bookmark to be activated after updating |
|
5684 | :brev: a name, which might be a bookmark to be activated after updating | |
5675 | """ |
|
5685 | """ | |
5676 | if modheads == 0: |
|
5686 | if modheads == 0: | |
5677 | return |
|
5687 | return | |
5678 | if optupdate: |
|
5688 | if optupdate: | |
5679 | try: |
|
5689 | try: | |
5680 | return hg.updatetotally(ui, repo, checkout, brev) |
|
5690 | return hg.updatetotally(ui, repo, checkout, brev) | |
5681 | except error.UpdateAbort as inst: |
|
5691 | except error.UpdateAbort as inst: | |
5682 | msg = _("not updating: %s") % str(inst) |
|
5692 | msg = _("not updating: %s") % str(inst) | |
5683 | hint = inst.hint |
|
5693 | hint = inst.hint | |
5684 | raise error.UpdateAbort(msg, hint=hint) |
|
5694 | raise error.UpdateAbort(msg, hint=hint) | |
5685 | if modheads > 1: |
|
5695 | if modheads > 1: | |
5686 | currentbranchheads = len(repo.branchheads()) |
|
5696 | currentbranchheads = len(repo.branchheads()) | |
5687 | if currentbranchheads == modheads: |
|
5697 | if currentbranchheads == modheads: | |
5688 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
|
5698 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) | |
5689 | elif currentbranchheads > 1: |
|
5699 | elif currentbranchheads > 1: | |
5690 | ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to " |
|
5700 | ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to " | |
5691 | "merge)\n")) |
|
5701 | "merge)\n")) | |
5692 | else: |
|
5702 | else: | |
5693 | ui.status(_("(run 'hg heads' to see heads)\n")) |
|
5703 | ui.status(_("(run 'hg heads' to see heads)\n")) | |
5694 | else: |
|
5704 | else: | |
5695 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
5705 | ui.status(_("(run 'hg update' to get a working copy)\n")) | |
5696 |
|
5706 | |||
5697 | @command('^pull', |
|
5707 | @command('^pull', | |
5698 | [('u', 'update', None, |
|
5708 | [('u', 'update', None, | |
5699 | _('update to new branch head if changesets were pulled')), |
|
5709 | _('update to new branch head if changesets were pulled')), | |
5700 | ('f', 'force', None, _('run even when remote repository is unrelated')), |
|
5710 | ('f', 'force', None, _('run even when remote repository is unrelated')), | |
5701 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
|
5711 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), | |
5702 | ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')), |
|
5712 | ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')), | |
5703 | ('b', 'branch', [], _('a specific branch you would like to pull'), |
|
5713 | ('b', 'branch', [], _('a specific branch you would like to pull'), | |
5704 | _('BRANCH')), |
|
5714 | _('BRANCH')), | |
5705 | ] + remoteopts, |
|
5715 | ] + remoteopts, | |
5706 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')) |
|
5716 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')) | |
5707 | def pull(ui, repo, source="default", **opts): |
|
5717 | def pull(ui, repo, source="default", **opts): | |
5708 | """pull changes from the specified source |
|
5718 | """pull changes from the specified source | |
5709 |
|
5719 | |||
5710 | Pull changes from a remote repository to a local one. |
|
5720 | Pull changes from a remote repository to a local one. | |
5711 |
|
5721 | |||
5712 | This finds all changes from the repository at the specified path |
|
5722 | This finds all changes from the repository at the specified path | |
5713 | or URL and adds them to a local repository (the current one unless |
|
5723 | or URL and adds them to a local repository (the current one unless | |
5714 | -R is specified). By default, this does not update the copy of the |
|
5724 | -R is specified). By default, this does not update the copy of the | |
5715 | project in the working directory. |
|
5725 | project in the working directory. | |
5716 |
|
5726 | |||
5717 | Use :hg:`incoming` if you want to see what would have been added |
|
5727 | Use :hg:`incoming` if you want to see what would have been added | |
5718 | by a pull at the time you issued this command. If you then decide |
|
5728 | by a pull at the time you issued this command. If you then decide | |
5719 | to add those changes to the repository, you should use :hg:`pull |
|
5729 | to add those changes to the repository, you should use :hg:`pull | |
5720 | -r X` where ``X`` is the last changeset listed by :hg:`incoming`. |
|
5730 | -r X` where ``X`` is the last changeset listed by :hg:`incoming`. | |
5721 |
|
5731 | |||
5722 | If SOURCE is omitted, the 'default' path will be used. |
|
5732 | If SOURCE is omitted, the 'default' path will be used. | |
5723 | See :hg:`help urls` for more information. |
|
5733 | See :hg:`help urls` for more information. | |
5724 |
|
5734 | |||
5725 | Specifying bookmark as ``.`` is equivalent to specifying the active |
|
5735 | Specifying bookmark as ``.`` is equivalent to specifying the active | |
5726 | bookmark's name. |
|
5736 | bookmark's name. | |
5727 |
|
5737 | |||
5728 | Returns 0 on success, 1 if an update had unresolved files. |
|
5738 | Returns 0 on success, 1 if an update had unresolved files. | |
5729 | """ |
|
5739 | """ | |
5730 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
5740 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
5731 | ui.status(_('pulling from %s\n') % util.hidepassword(source)) |
|
5741 | ui.status(_('pulling from %s\n') % util.hidepassword(source)) | |
5732 | other = hg.peer(repo, opts, source) |
|
5742 | other = hg.peer(repo, opts, source) | |
5733 | try: |
|
5743 | try: | |
5734 | revs, checkout = hg.addbranchrevs(repo, other, branches, |
|
5744 | revs, checkout = hg.addbranchrevs(repo, other, branches, | |
5735 | opts.get('rev')) |
|
5745 | opts.get('rev')) | |
5736 |
|
5746 | |||
5737 |
|
5747 | |||
5738 | pullopargs = {} |
|
5748 | pullopargs = {} | |
5739 | if opts.get('bookmark'): |
|
5749 | if opts.get('bookmark'): | |
5740 | if not revs: |
|
5750 | if not revs: | |
5741 | revs = [] |
|
5751 | revs = [] | |
5742 | # The list of bookmark used here is not the one used to actually |
|
5752 | # The list of bookmark used here is not the one used to actually | |
5743 | # update the bookmark name. This can result in the revision pulled |
|
5753 | # update the bookmark name. This can result in the revision pulled | |
5744 | # not ending up with the name of the bookmark because of a race |
|
5754 | # not ending up with the name of the bookmark because of a race | |
5745 | # condition on the server. (See issue 4689 for details) |
|
5755 | # condition on the server. (See issue 4689 for details) | |
5746 | remotebookmarks = other.listkeys('bookmarks') |
|
5756 | remotebookmarks = other.listkeys('bookmarks') | |
5747 | pullopargs['remotebookmarks'] = remotebookmarks |
|
5757 | pullopargs['remotebookmarks'] = remotebookmarks | |
5748 | for b in opts['bookmark']: |
|
5758 | for b in opts['bookmark']: | |
5749 | b = repo._bookmarks.expandname(b) |
|
5759 | b = repo._bookmarks.expandname(b) | |
5750 | if b not in remotebookmarks: |
|
5760 | if b not in remotebookmarks: | |
5751 | raise error.Abort(_('remote bookmark %s not found!') % b) |
|
5761 | raise error.Abort(_('remote bookmark %s not found!') % b) | |
5752 | revs.append(remotebookmarks[b]) |
|
5762 | revs.append(remotebookmarks[b]) | |
5753 |
|
5763 | |||
5754 | if revs: |
|
5764 | if revs: | |
5755 | try: |
|
5765 | try: | |
5756 | # When 'rev' is a bookmark name, we cannot guarantee that it |
|
5766 | # When 'rev' is a bookmark name, we cannot guarantee that it | |
5757 | # will be updated with that name because of a race condition |
|
5767 | # will be updated with that name because of a race condition | |
5758 | # server side. (See issue 4689 for details) |
|
5768 | # server side. (See issue 4689 for details) | |
5759 | oldrevs = revs |
|
5769 | oldrevs = revs | |
5760 | revs = [] # actually, nodes |
|
5770 | revs = [] # actually, nodes | |
5761 | for r in oldrevs: |
|
5771 | for r in oldrevs: | |
5762 | node = other.lookup(r) |
|
5772 | node = other.lookup(r) | |
5763 | revs.append(node) |
|
5773 | revs.append(node) | |
5764 | if r == checkout: |
|
5774 | if r == checkout: | |
5765 | checkout = node |
|
5775 | checkout = node | |
5766 | except error.CapabilityError: |
|
5776 | except error.CapabilityError: | |
5767 | err = _("other repository doesn't support revision lookup, " |
|
5777 | err = _("other repository doesn't support revision lookup, " | |
5768 | "so a rev cannot be specified.") |
|
5778 | "so a rev cannot be specified.") | |
5769 | raise error.Abort(err) |
|
5779 | raise error.Abort(err) | |
5770 |
|
5780 | |||
5771 | pullopargs.update(opts.get('opargs', {})) |
|
5781 | pullopargs.update(opts.get('opargs', {})) | |
5772 | modheads = exchange.pull(repo, other, heads=revs, |
|
5782 | modheads = exchange.pull(repo, other, heads=revs, | |
5773 | force=opts.get('force'), |
|
5783 | force=opts.get('force'), | |
5774 | bookmarks=opts.get('bookmark', ()), |
|
5784 | bookmarks=opts.get('bookmark', ()), | |
5775 | opargs=pullopargs).cgresult |
|
5785 | opargs=pullopargs).cgresult | |
5776 |
|
5786 | |||
5777 | # brev is a name, which might be a bookmark to be activated at |
|
5787 | # brev is a name, which might be a bookmark to be activated at | |
5778 | # the end of the update. In other words, it is an explicit |
|
5788 | # the end of the update. In other words, it is an explicit | |
5779 | # destination of the update |
|
5789 | # destination of the update | |
5780 | brev = None |
|
5790 | brev = None | |
5781 |
|
5791 | |||
5782 | if checkout: |
|
5792 | if checkout: | |
5783 | checkout = str(repo.changelog.rev(checkout)) |
|
5793 | checkout = str(repo.changelog.rev(checkout)) | |
5784 |
|
5794 | |||
5785 | # order below depends on implementation of |
|
5795 | # order below depends on implementation of | |
5786 | # hg.addbranchrevs(). opts['bookmark'] is ignored, |
|
5796 | # hg.addbranchrevs(). opts['bookmark'] is ignored, | |
5787 | # because 'checkout' is determined without it. |
|
5797 | # because 'checkout' is determined without it. | |
5788 | if opts.get('rev'): |
|
5798 | if opts.get('rev'): | |
5789 | brev = opts['rev'][0] |
|
5799 | brev = opts['rev'][0] | |
5790 | elif opts.get('branch'): |
|
5800 | elif opts.get('branch'): | |
5791 | brev = opts['branch'][0] |
|
5801 | brev = opts['branch'][0] | |
5792 | else: |
|
5802 | else: | |
5793 | brev = branches[0] |
|
5803 | brev = branches[0] | |
5794 | repo._subtoppath = source |
|
5804 | repo._subtoppath = source | |
5795 | try: |
|
5805 | try: | |
5796 | ret = postincoming(ui, repo, modheads, opts.get('update'), |
|
5806 | ret = postincoming(ui, repo, modheads, opts.get('update'), | |
5797 | checkout, brev) |
|
5807 | checkout, brev) | |
5798 |
|
5808 | |||
5799 | finally: |
|
5809 | finally: | |
5800 | del repo._subtoppath |
|
5810 | del repo._subtoppath | |
5801 |
|
5811 | |||
5802 | finally: |
|
5812 | finally: | |
5803 | other.close() |
|
5813 | other.close() | |
5804 | return ret |
|
5814 | return ret | |
5805 |
|
5815 | |||
5806 | @command('^push', |
|
5816 | @command('^push', | |
5807 | [('f', 'force', None, _('force push')), |
|
5817 | [('f', 'force', None, _('force push')), | |
5808 | ('r', 'rev', [], |
|
5818 | ('r', 'rev', [], | |
5809 | _('a changeset intended to be included in the destination'), |
|
5819 | _('a changeset intended to be included in the destination'), | |
5810 | _('REV')), |
|
5820 | _('REV')), | |
5811 | ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')), |
|
5821 | ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')), | |
5812 | ('b', 'branch', [], |
|
5822 | ('b', 'branch', [], | |
5813 | _('a specific branch you would like to push'), _('BRANCH')), |
|
5823 | _('a specific branch you would like to push'), _('BRANCH')), | |
5814 | ('', 'new-branch', False, _('allow pushing a new branch')), |
|
5824 | ('', 'new-branch', False, _('allow pushing a new branch')), | |
5815 | ] + remoteopts, |
|
5825 | ] + remoteopts, | |
5816 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')) |
|
5826 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')) | |
5817 | def push(ui, repo, dest=None, **opts): |
|
5827 | def push(ui, repo, dest=None, **opts): | |
5818 | """push changes to the specified destination |
|
5828 | """push changes to the specified destination | |
5819 |
|
5829 | |||
5820 | Push changesets from the local repository to the specified |
|
5830 | Push changesets from the local repository to the specified | |
5821 | destination. |
|
5831 | destination. | |
5822 |
|
5832 | |||
5823 | This operation is symmetrical to pull: it is identical to a pull |
|
5833 | This operation is symmetrical to pull: it is identical to a pull | |
5824 | in the destination repository from the current one. |
|
5834 | in the destination repository from the current one. | |
5825 |
|
5835 | |||
5826 | By default, push will not allow creation of new heads at the |
|
5836 | By default, push will not allow creation of new heads at the | |
5827 | destination, since multiple heads would make it unclear which head |
|
5837 | destination, since multiple heads would make it unclear which head | |
5828 | to use. In this situation, it is recommended to pull and merge |
|
5838 | to use. In this situation, it is recommended to pull and merge | |
5829 | before pushing. |
|
5839 | before pushing. | |
5830 |
|
5840 | |||
5831 | Use --new-branch if you want to allow push to create a new named |
|
5841 | Use --new-branch if you want to allow push to create a new named | |
5832 | branch that is not present at the destination. This allows you to |
|
5842 | branch that is not present at the destination. This allows you to | |
5833 | only create a new branch without forcing other changes. |
|
5843 | only create a new branch without forcing other changes. | |
5834 |
|
5844 | |||
5835 | .. note:: |
|
5845 | .. note:: | |
5836 |
|
5846 | |||
5837 | Extra care should be taken with the -f/--force option, |
|
5847 | Extra care should be taken with the -f/--force option, | |
5838 | which will push all new heads on all branches, an action which will |
|
5848 | which will push all new heads on all branches, an action which will | |
5839 | almost always cause confusion for collaborators. |
|
5849 | almost always cause confusion for collaborators. | |
5840 |
|
5850 | |||
5841 | If -r/--rev is used, the specified revision and all its ancestors |
|
5851 | If -r/--rev is used, the specified revision and all its ancestors | |
5842 | will be pushed to the remote repository. |
|
5852 | will be pushed to the remote repository. | |
5843 |
|
5853 | |||
5844 | If -B/--bookmark is used, the specified bookmarked revision, its |
|
5854 | If -B/--bookmark is used, the specified bookmarked revision, its | |
5845 | ancestors, and the bookmark will be pushed to the remote |
|
5855 | ancestors, and the bookmark will be pushed to the remote | |
5846 | repository. Specifying ``.`` is equivalent to specifying the active |
|
5856 | repository. Specifying ``.`` is equivalent to specifying the active | |
5847 | bookmark's name. |
|
5857 | bookmark's name. | |
5848 |
|
5858 | |||
5849 | Please see :hg:`help urls` for important details about ``ssh://`` |
|
5859 | Please see :hg:`help urls` for important details about ``ssh://`` | |
5850 | URLs. If DESTINATION is omitted, a default path will be used. |
|
5860 | URLs. If DESTINATION is omitted, a default path will be used. | |
5851 |
|
5861 | |||
5852 | Returns 0 if push was successful, 1 if nothing to push. |
|
5862 | Returns 0 if push was successful, 1 if nothing to push. | |
5853 | """ |
|
5863 | """ | |
5854 |
|
5864 | |||
5855 | if opts.get('bookmark'): |
|
5865 | if opts.get('bookmark'): | |
5856 | ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push') |
|
5866 | ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push') | |
5857 | for b in opts['bookmark']: |
|
5867 | for b in opts['bookmark']: | |
5858 | # translate -B options to -r so changesets get pushed |
|
5868 | # translate -B options to -r so changesets get pushed | |
5859 | b = repo._bookmarks.expandname(b) |
|
5869 | b = repo._bookmarks.expandname(b) | |
5860 | if b in repo._bookmarks: |
|
5870 | if b in repo._bookmarks: | |
5861 | opts.setdefault('rev', []).append(b) |
|
5871 | opts.setdefault('rev', []).append(b) | |
5862 | else: |
|
5872 | else: | |
5863 | # if we try to push a deleted bookmark, translate it to null |
|
5873 | # if we try to push a deleted bookmark, translate it to null | |
5864 | # this lets simultaneous -r, -b options continue working |
|
5874 | # this lets simultaneous -r, -b options continue working | |
5865 | opts.setdefault('rev', []).append("null") |
|
5875 | opts.setdefault('rev', []).append("null") | |
5866 |
|
5876 | |||
5867 | path = ui.paths.getpath(dest, default=('default-push', 'default')) |
|
5877 | path = ui.paths.getpath(dest, default=('default-push', 'default')) | |
5868 | if not path: |
|
5878 | if not path: | |
5869 | raise error.Abort(_('default repository not configured!'), |
|
5879 | raise error.Abort(_('default repository not configured!'), | |
5870 | hint=_("see 'hg help config.paths'")) |
|
5880 | hint=_("see 'hg help config.paths'")) | |
5871 | dest = path.pushloc or path.loc |
|
5881 | dest = path.pushloc or path.loc | |
5872 | branches = (path.branch, opts.get('branch') or []) |
|
5882 | branches = (path.branch, opts.get('branch') or []) | |
5873 | ui.status(_('pushing to %s\n') % util.hidepassword(dest)) |
|
5883 | ui.status(_('pushing to %s\n') % util.hidepassword(dest)) | |
5874 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
|
5884 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
5875 | other = hg.peer(repo, opts, dest) |
|
5885 | other = hg.peer(repo, opts, dest) | |
5876 |
|
5886 | |||
5877 | if revs: |
|
5887 | if revs: | |
5878 | revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] |
|
5888 | revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] | |
5879 | if not revs: |
|
5889 | if not revs: | |
5880 | raise error.Abort(_("specified revisions evaluate to an empty set"), |
|
5890 | raise error.Abort(_("specified revisions evaluate to an empty set"), | |
5881 | hint=_("use different revision arguments")) |
|
5891 | hint=_("use different revision arguments")) | |
5882 | elif path.pushrev: |
|
5892 | elif path.pushrev: | |
5883 | # It doesn't make any sense to specify ancestor revisions. So limit |
|
5893 | # It doesn't make any sense to specify ancestor revisions. So limit | |
5884 | # to DAG heads to make discovery simpler. |
|
5894 | # to DAG heads to make discovery simpler. | |
5885 | expr = revset.formatspec('heads(%r)', path.pushrev) |
|
5895 | expr = revset.formatspec('heads(%r)', path.pushrev) | |
5886 | revs = scmutil.revrange(repo, [expr]) |
|
5896 | revs = scmutil.revrange(repo, [expr]) | |
5887 | revs = [repo[rev].node() for rev in revs] |
|
5897 | revs = [repo[rev].node() for rev in revs] | |
5888 | if not revs: |
|
5898 | if not revs: | |
5889 | raise error.Abort(_('default push revset for path evaluates to an ' |
|
5899 | raise error.Abort(_('default push revset for path evaluates to an ' | |
5890 | 'empty set')) |
|
5900 | 'empty set')) | |
5891 |
|
5901 | |||
5892 | repo._subtoppath = dest |
|
5902 | repo._subtoppath = dest | |
5893 | try: |
|
5903 | try: | |
5894 | # push subrepos depth-first for coherent ordering |
|
5904 | # push subrepos depth-first for coherent ordering | |
5895 | c = repo[''] |
|
5905 | c = repo[''] | |
5896 | subs = c.substate # only repos that are committed |
|
5906 | subs = c.substate # only repos that are committed | |
5897 | for s in sorted(subs): |
|
5907 | for s in sorted(subs): | |
5898 | result = c.sub(s).push(opts) |
|
5908 | result = c.sub(s).push(opts) | |
5899 | if result == 0: |
|
5909 | if result == 0: | |
5900 | return not result |
|
5910 | return not result | |
5901 | finally: |
|
5911 | finally: | |
5902 | del repo._subtoppath |
|
5912 | del repo._subtoppath | |
5903 | pushop = exchange.push(repo, other, opts.get('force'), revs=revs, |
|
5913 | pushop = exchange.push(repo, other, opts.get('force'), revs=revs, | |
5904 | newbranch=opts.get('new_branch'), |
|
5914 | newbranch=opts.get('new_branch'), | |
5905 | bookmarks=opts.get('bookmark', ()), |
|
5915 | bookmarks=opts.get('bookmark', ()), | |
5906 | opargs=opts.get('opargs')) |
|
5916 | opargs=opts.get('opargs')) | |
5907 |
|
5917 | |||
5908 | result = not pushop.cgresult |
|
5918 | result = not pushop.cgresult | |
5909 |
|
5919 | |||
5910 | if pushop.bkresult is not None: |
|
5920 | if pushop.bkresult is not None: | |
5911 | if pushop.bkresult == 2: |
|
5921 | if pushop.bkresult == 2: | |
5912 | result = 2 |
|
5922 | result = 2 | |
5913 | elif not result and pushop.bkresult: |
|
5923 | elif not result and pushop.bkresult: | |
5914 | result = 2 |
|
5924 | result = 2 | |
5915 |
|
5925 | |||
5916 | return result |
|
5926 | return result | |
5917 |
|
5927 | |||
5918 | @command('recover', []) |
|
5928 | @command('recover', []) | |
5919 | def recover(ui, repo): |
|
5929 | def recover(ui, repo): | |
5920 | """roll back an interrupted transaction |
|
5930 | """roll back an interrupted transaction | |
5921 |
|
5931 | |||
5922 | Recover from an interrupted commit or pull. |
|
5932 | Recover from an interrupted commit or pull. | |
5923 |
|
5933 | |||
5924 | This command tries to fix the repository status after an |
|
5934 | This command tries to fix the repository status after an | |
5925 | interrupted operation. It should only be necessary when Mercurial |
|
5935 | interrupted operation. It should only be necessary when Mercurial | |
5926 | suggests it. |
|
5936 | suggests it. | |
5927 |
|
5937 | |||
5928 | Returns 0 if successful, 1 if nothing to recover or verify fails. |
|
5938 | Returns 0 if successful, 1 if nothing to recover or verify fails. | |
5929 | """ |
|
5939 | """ | |
5930 | if repo.recover(): |
|
5940 | if repo.recover(): | |
5931 | return hg.verify(repo) |
|
5941 | return hg.verify(repo) | |
5932 | return 1 |
|
5942 | return 1 | |
5933 |
|
5943 | |||
5934 | @command('^remove|rm', |
|
5944 | @command('^remove|rm', | |
5935 | [('A', 'after', None, _('record delete for missing files')), |
|
5945 | [('A', 'after', None, _('record delete for missing files')), | |
5936 | ('f', 'force', None, |
|
5946 | ('f', 'force', None, | |
5937 | _('forget added files, delete modified files')), |
|
5947 | _('forget added files, delete modified files')), | |
5938 | ] + subrepoopts + walkopts, |
|
5948 | ] + subrepoopts + walkopts, | |
5939 | _('[OPTION]... FILE...'), |
|
5949 | _('[OPTION]... FILE...'), | |
5940 | inferrepo=True) |
|
5950 | inferrepo=True) | |
5941 | def remove(ui, repo, *pats, **opts): |
|
5951 | def remove(ui, repo, *pats, **opts): | |
5942 | """remove the specified files on the next commit |
|
5952 | """remove the specified files on the next commit | |
5943 |
|
5953 | |||
5944 | Schedule the indicated files for removal from the current branch. |
|
5954 | Schedule the indicated files for removal from the current branch. | |
5945 |
|
5955 | |||
5946 | This command schedules the files to be removed at the next commit. |
|
5956 | This command schedules the files to be removed at the next commit. | |
5947 | To undo a remove before that, see :hg:`revert`. To undo added |
|
5957 | To undo a remove before that, see :hg:`revert`. To undo added | |
5948 | files, see :hg:`forget`. |
|
5958 | files, see :hg:`forget`. | |
5949 |
|
5959 | |||
5950 | .. container:: verbose |
|
5960 | .. container:: verbose | |
5951 |
|
5961 | |||
5952 | -A/--after can be used to remove only files that have already |
|
5962 | -A/--after can be used to remove only files that have already | |
5953 | been deleted, -f/--force can be used to force deletion, and -Af |
|
5963 | been deleted, -f/--force can be used to force deletion, and -Af | |
5954 | can be used to remove files from the next revision without |
|
5964 | can be used to remove files from the next revision without | |
5955 | deleting them from the working directory. |
|
5965 | deleting them from the working directory. | |
5956 |
|
5966 | |||
5957 | The following table details the behavior of remove for different |
|
5967 | The following table details the behavior of remove for different | |
5958 | file states (columns) and option combinations (rows). The file |
|
5968 | file states (columns) and option combinations (rows). The file | |
5959 | states are Added [A], Clean [C], Modified [M] and Missing [!] |
|
5969 | states are Added [A], Clean [C], Modified [M] and Missing [!] | |
5960 | (as reported by :hg:`status`). The actions are Warn, Remove |
|
5970 | (as reported by :hg:`status`). The actions are Warn, Remove | |
5961 | (from branch) and Delete (from disk): |
|
5971 | (from branch) and Delete (from disk): | |
5962 |
|
5972 | |||
5963 | ========= == == == == |
|
5973 | ========= == == == == | |
5964 | opt/state A C M ! |
|
5974 | opt/state A C M ! | |
5965 | ========= == == == == |
|
5975 | ========= == == == == | |
5966 | none W RD W R |
|
5976 | none W RD W R | |
5967 | -f R RD RD R |
|
5977 | -f R RD RD R | |
5968 | -A W W W R |
|
5978 | -A W W W R | |
5969 | -Af R R R R |
|
5979 | -Af R R R R | |
5970 | ========= == == == == |
|
5980 | ========= == == == == | |
5971 |
|
5981 | |||
5972 | .. note:: |
|
5982 | .. note:: | |
5973 |
|
5983 | |||
5974 | :hg:`remove` never deletes files in Added [A] state from the |
|
5984 | :hg:`remove` never deletes files in Added [A] state from the | |
5975 | working directory, not even if ``--force`` is specified. |
|
5985 | working directory, not even if ``--force`` is specified. | |
5976 |
|
5986 | |||
5977 | Returns 0 on success, 1 if any warnings encountered. |
|
5987 | Returns 0 on success, 1 if any warnings encountered. | |
5978 | """ |
|
5988 | """ | |
5979 |
|
5989 | |||
5980 | after, force = opts.get('after'), opts.get('force') |
|
5990 | after, force = opts.get('after'), opts.get('force') | |
5981 | if not pats and not after: |
|
5991 | if not pats and not after: | |
5982 | raise error.Abort(_('no files specified')) |
|
5992 | raise error.Abort(_('no files specified')) | |
5983 |
|
5993 | |||
5984 | m = scmutil.match(repo[None], pats, opts) |
|
5994 | m = scmutil.match(repo[None], pats, opts) | |
5985 | subrepos = opts.get('subrepos') |
|
5995 | subrepos = opts.get('subrepos') | |
5986 | return cmdutil.remove(ui, repo, m, "", after, force, subrepos) |
|
5996 | return cmdutil.remove(ui, repo, m, "", after, force, subrepos) | |
5987 |
|
5997 | |||
5988 | @command('rename|move|mv', |
|
5998 | @command('rename|move|mv', | |
5989 | [('A', 'after', None, _('record a rename that has already occurred')), |
|
5999 | [('A', 'after', None, _('record a rename that has already occurred')), | |
5990 | ('f', 'force', None, _('forcibly copy over an existing managed file')), |
|
6000 | ('f', 'force', None, _('forcibly copy over an existing managed file')), | |
5991 | ] + walkopts + dryrunopts, |
|
6001 | ] + walkopts + dryrunopts, | |
5992 | _('[OPTION]... SOURCE... DEST')) |
|
6002 | _('[OPTION]... SOURCE... DEST')) | |
5993 | def rename(ui, repo, *pats, **opts): |
|
6003 | def rename(ui, repo, *pats, **opts): | |
5994 | """rename files; equivalent of copy + remove |
|
6004 | """rename files; equivalent of copy + remove | |
5995 |
|
6005 | |||
5996 | Mark dest as copies of sources; mark sources for deletion. If dest |
|
6006 | Mark dest as copies of sources; mark sources for deletion. If dest | |
5997 | is a directory, copies are put in that directory. If dest is a |
|
6007 | is a directory, copies are put in that directory. If dest is a | |
5998 | file, there can only be one source. |
|
6008 | file, there can only be one source. | |
5999 |
|
6009 | |||
6000 | By default, this command copies the contents of files as they |
|
6010 | By default, this command copies the contents of files as they | |
6001 | exist in the working directory. If invoked with -A/--after, the |
|
6011 | exist in the working directory. If invoked with -A/--after, the | |
6002 | operation is recorded, but no copying is performed. |
|
6012 | operation is recorded, but no copying is performed. | |
6003 |
|
6013 | |||
6004 | This command takes effect at the next commit. To undo a rename |
|
6014 | This command takes effect at the next commit. To undo a rename | |
6005 | before that, see :hg:`revert`. |
|
6015 | before that, see :hg:`revert`. | |
6006 |
|
6016 | |||
6007 | Returns 0 on success, 1 if errors are encountered. |
|
6017 | Returns 0 on success, 1 if errors are encountered. | |
6008 | """ |
|
6018 | """ | |
6009 | with repo.wlock(False): |
|
6019 | with repo.wlock(False): | |
6010 | return cmdutil.copy(ui, repo, pats, opts, rename=True) |
|
6020 | return cmdutil.copy(ui, repo, pats, opts, rename=True) | |
6011 |
|
6021 | |||
6012 | @command('resolve', |
|
6022 | @command('resolve', | |
6013 | [('a', 'all', None, _('select all unresolved files')), |
|
6023 | [('a', 'all', None, _('select all unresolved files')), | |
6014 | ('l', 'list', None, _('list state of files needing merge')), |
|
6024 | ('l', 'list', None, _('list state of files needing merge')), | |
6015 | ('m', 'mark', None, _('mark files as resolved')), |
|
6025 | ('m', 'mark', None, _('mark files as resolved')), | |
6016 | ('u', 'unmark', None, _('mark files as unresolved')), |
|
6026 | ('u', 'unmark', None, _('mark files as unresolved')), | |
6017 | ('n', 'no-status', None, _('hide status prefix'))] |
|
6027 | ('n', 'no-status', None, _('hide status prefix'))] | |
6018 | + mergetoolopts + walkopts + formatteropts, |
|
6028 | + mergetoolopts + walkopts + formatteropts, | |
6019 | _('[OPTION]... [FILE]...'), |
|
6029 | _('[OPTION]... [FILE]...'), | |
6020 | inferrepo=True) |
|
6030 | inferrepo=True) | |
6021 | def resolve(ui, repo, *pats, **opts): |
|
6031 | def resolve(ui, repo, *pats, **opts): | |
6022 | """redo merges or set/view the merge status of files |
|
6032 | """redo merges or set/view the merge status of files | |
6023 |
|
6033 | |||
6024 | Merges with unresolved conflicts are often the result of |
|
6034 | Merges with unresolved conflicts are often the result of | |
6025 | non-interactive merging using the ``internal:merge`` configuration |
|
6035 | non-interactive merging using the ``internal:merge`` configuration | |
6026 | setting, or a command-line merge tool like ``diff3``. The resolve |
|
6036 | setting, or a command-line merge tool like ``diff3``. The resolve | |
6027 | command is used to manage the files involved in a merge, after |
|
6037 | command is used to manage the files involved in a merge, after | |
6028 | :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the |
|
6038 | :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the | |
6029 | working directory must have two parents). See :hg:`help |
|
6039 | working directory must have two parents). See :hg:`help | |
6030 | merge-tools` for information on configuring merge tools. |
|
6040 | merge-tools` for information on configuring merge tools. | |
6031 |
|
6041 | |||
6032 | The resolve command can be used in the following ways: |
|
6042 | The resolve command can be used in the following ways: | |
6033 |
|
6043 | |||
6034 | - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified |
|
6044 | - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified | |
6035 | files, discarding any previous merge attempts. Re-merging is not |
|
6045 | files, discarding any previous merge attempts. Re-merging is not | |
6036 | performed for files already marked as resolved. Use ``--all/-a`` |
|
6046 | performed for files already marked as resolved. Use ``--all/-a`` | |
6037 | to select all unresolved files. ``--tool`` can be used to specify |
|
6047 | to select all unresolved files. ``--tool`` can be used to specify | |
6038 | the merge tool used for the given files. It overrides the HGMERGE |
|
6048 | the merge tool used for the given files. It overrides the HGMERGE | |
6039 | environment variable and your configuration files. Previous file |
|
6049 | environment variable and your configuration files. Previous file | |
6040 | contents are saved with a ``.orig`` suffix. |
|
6050 | contents are saved with a ``.orig`` suffix. | |
6041 |
|
6051 | |||
6042 | - :hg:`resolve -m [FILE]`: mark a file as having been resolved |
|
6052 | - :hg:`resolve -m [FILE]`: mark a file as having been resolved | |
6043 | (e.g. after having manually fixed-up the files). The default is |
|
6053 | (e.g. after having manually fixed-up the files). The default is | |
6044 | to mark all unresolved files. |
|
6054 | to mark all unresolved files. | |
6045 |
|
6055 | |||
6046 | - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The |
|
6056 | - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The | |
6047 | default is to mark all resolved files. |
|
6057 | default is to mark all resolved files. | |
6048 |
|
6058 | |||
6049 | - :hg:`resolve -l`: list files which had or still have conflicts. |
|
6059 | - :hg:`resolve -l`: list files which had or still have conflicts. | |
6050 | In the printed list, ``U`` = unresolved and ``R`` = resolved. |
|
6060 | In the printed list, ``U`` = unresolved and ``R`` = resolved. | |
6051 |
|
6061 | |||
6052 | .. note:: |
|
6062 | .. note:: | |
6053 |
|
6063 | |||
6054 | Mercurial will not let you commit files with unresolved merge |
|
6064 | Mercurial will not let you commit files with unresolved merge | |
6055 | conflicts. You must use :hg:`resolve -m ...` before you can |
|
6065 | conflicts. You must use :hg:`resolve -m ...` before you can | |
6056 | commit after a conflicting merge. |
|
6066 | commit after a conflicting merge. | |
6057 |
|
6067 | |||
6058 | Returns 0 on success, 1 if any files fail a resolve attempt. |
|
6068 | Returns 0 on success, 1 if any files fail a resolve attempt. | |
6059 | """ |
|
6069 | """ | |
6060 |
|
6070 | |||
6061 | flaglist = 'all mark unmark list no_status'.split() |
|
6071 | flaglist = 'all mark unmark list no_status'.split() | |
6062 | all, mark, unmark, show, nostatus = \ |
|
6072 | all, mark, unmark, show, nostatus = \ | |
6063 | [opts.get(o) for o in flaglist] |
|
6073 | [opts.get(o) for o in flaglist] | |
6064 |
|
6074 | |||
6065 | if (show and (mark or unmark)) or (mark and unmark): |
|
6075 | if (show and (mark or unmark)) or (mark and unmark): | |
6066 | raise error.Abort(_("too many options specified")) |
|
6076 | raise error.Abort(_("too many options specified")) | |
6067 | if pats and all: |
|
6077 | if pats and all: | |
6068 | raise error.Abort(_("can't specify --all and patterns")) |
|
6078 | raise error.Abort(_("can't specify --all and patterns")) | |
6069 | if not (all or pats or show or mark or unmark): |
|
6079 | if not (all or pats or show or mark or unmark): | |
6070 | raise error.Abort(_('no files or directories specified'), |
|
6080 | raise error.Abort(_('no files or directories specified'), | |
6071 | hint=('use --all to re-merge all unresolved files')) |
|
6081 | hint=('use --all to re-merge all unresolved files')) | |
6072 |
|
6082 | |||
6073 | if show: |
|
6083 | if show: | |
6074 | fm = ui.formatter('resolve', opts) |
|
6084 | fm = ui.formatter('resolve', opts) | |
6075 | ms = mergemod.mergestate.read(repo) |
|
6085 | ms = mergemod.mergestate.read(repo) | |
6076 | m = scmutil.match(repo[None], pats, opts) |
|
6086 | m = scmutil.match(repo[None], pats, opts) | |
6077 | for f in ms: |
|
6087 | for f in ms: | |
6078 | if not m(f): |
|
6088 | if not m(f): | |
6079 | continue |
|
6089 | continue | |
6080 | l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved', |
|
6090 | l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved', | |
6081 | 'd': 'driverresolved'}[ms[f]] |
|
6091 | 'd': 'driverresolved'}[ms[f]] | |
6082 | fm.startitem() |
|
6092 | fm.startitem() | |
6083 | fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l) |
|
6093 | fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l) | |
6084 | fm.write('path', '%s\n', f, label=l) |
|
6094 | fm.write('path', '%s\n', f, label=l) | |
6085 | fm.end() |
|
6095 | fm.end() | |
6086 | return 0 |
|
6096 | return 0 | |
6087 |
|
6097 | |||
6088 | with repo.wlock(): |
|
6098 | with repo.wlock(): | |
6089 | ms = mergemod.mergestate.read(repo) |
|
6099 | ms = mergemod.mergestate.read(repo) | |
6090 |
|
6100 | |||
6091 | if not (ms.active() or repo.dirstate.p2() != nullid): |
|
6101 | if not (ms.active() or repo.dirstate.p2() != nullid): | |
6092 | raise error.Abort( |
|
6102 | raise error.Abort( | |
6093 | _('resolve command not applicable when not merging')) |
|
6103 | _('resolve command not applicable when not merging')) | |
6094 |
|
6104 | |||
6095 | wctx = repo[None] |
|
6105 | wctx = repo[None] | |
6096 |
|
6106 | |||
6097 | if ms.mergedriver and ms.mdstate() == 'u': |
|
6107 | if ms.mergedriver and ms.mdstate() == 'u': | |
6098 | proceed = mergemod.driverpreprocess(repo, ms, wctx) |
|
6108 | proceed = mergemod.driverpreprocess(repo, ms, wctx) | |
6099 | ms.commit() |
|
6109 | ms.commit() | |
6100 | # allow mark and unmark to go through |
|
6110 | # allow mark and unmark to go through | |
6101 | if not mark and not unmark and not proceed: |
|
6111 | if not mark and not unmark and not proceed: | |
6102 | return 1 |
|
6112 | return 1 | |
6103 |
|
6113 | |||
6104 | m = scmutil.match(wctx, pats, opts) |
|
6114 | m = scmutil.match(wctx, pats, opts) | |
6105 | ret = 0 |
|
6115 | ret = 0 | |
6106 | didwork = False |
|
6116 | didwork = False | |
6107 | runconclude = False |
|
6117 | runconclude = False | |
6108 |
|
6118 | |||
6109 | tocomplete = [] |
|
6119 | tocomplete = [] | |
6110 | for f in ms: |
|
6120 | for f in ms: | |
6111 | if not m(f): |
|
6121 | if not m(f): | |
6112 | continue |
|
6122 | continue | |
6113 |
|
6123 | |||
6114 | didwork = True |
|
6124 | didwork = True | |
6115 |
|
6125 | |||
6116 | # don't let driver-resolved files be marked, and run the conclude |
|
6126 | # don't let driver-resolved files be marked, and run the conclude | |
6117 | # step if asked to resolve |
|
6127 | # step if asked to resolve | |
6118 | if ms[f] == "d": |
|
6128 | if ms[f] == "d": | |
6119 | exact = m.exact(f) |
|
6129 | exact = m.exact(f) | |
6120 | if mark: |
|
6130 | if mark: | |
6121 | if exact: |
|
6131 | if exact: | |
6122 | ui.warn(_('not marking %s as it is driver-resolved\n') |
|
6132 | ui.warn(_('not marking %s as it is driver-resolved\n') | |
6123 | % f) |
|
6133 | % f) | |
6124 | elif unmark: |
|
6134 | elif unmark: | |
6125 | if exact: |
|
6135 | if exact: | |
6126 | ui.warn(_('not unmarking %s as it is driver-resolved\n') |
|
6136 | ui.warn(_('not unmarking %s as it is driver-resolved\n') | |
6127 | % f) |
|
6137 | % f) | |
6128 | else: |
|
6138 | else: | |
6129 | runconclude = True |
|
6139 | runconclude = True | |
6130 | continue |
|
6140 | continue | |
6131 |
|
6141 | |||
6132 | if mark: |
|
6142 | if mark: | |
6133 | ms.mark(f, "r") |
|
6143 | ms.mark(f, "r") | |
6134 | elif unmark: |
|
6144 | elif unmark: | |
6135 | ms.mark(f, "u") |
|
6145 | ms.mark(f, "u") | |
6136 | else: |
|
6146 | else: | |
6137 | # backup pre-resolve (merge uses .orig for its own purposes) |
|
6147 | # backup pre-resolve (merge uses .orig for its own purposes) | |
6138 | a = repo.wjoin(f) |
|
6148 | a = repo.wjoin(f) | |
6139 | try: |
|
6149 | try: | |
6140 | util.copyfile(a, a + ".resolve") |
|
6150 | util.copyfile(a, a + ".resolve") | |
6141 | except (IOError, OSError) as inst: |
|
6151 | except (IOError, OSError) as inst: | |
6142 | if inst.errno != errno.ENOENT: |
|
6152 | if inst.errno != errno.ENOENT: | |
6143 | raise |
|
6153 | raise | |
6144 |
|
6154 | |||
6145 | try: |
|
6155 | try: | |
6146 | # preresolve file |
|
6156 | # preresolve file | |
6147 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
6157 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | |
6148 | 'resolve') |
|
6158 | 'resolve') | |
6149 | complete, r = ms.preresolve(f, wctx) |
|
6159 | complete, r = ms.preresolve(f, wctx) | |
6150 | if not complete: |
|
6160 | if not complete: | |
6151 | tocomplete.append(f) |
|
6161 | tocomplete.append(f) | |
6152 | elif r: |
|
6162 | elif r: | |
6153 | ret = 1 |
|
6163 | ret = 1 | |
6154 | finally: |
|
6164 | finally: | |
6155 | ui.setconfig('ui', 'forcemerge', '', 'resolve') |
|
6165 | ui.setconfig('ui', 'forcemerge', '', 'resolve') | |
6156 | ms.commit() |
|
6166 | ms.commit() | |
6157 |
|
6167 | |||
6158 | # replace filemerge's .orig file with our resolve file, but only |
|
6168 | # replace filemerge's .orig file with our resolve file, but only | |
6159 | # for merges that are complete |
|
6169 | # for merges that are complete | |
6160 | if complete: |
|
6170 | if complete: | |
6161 | try: |
|
6171 | try: | |
6162 | util.rename(a + ".resolve", |
|
6172 | util.rename(a + ".resolve", | |
6163 | scmutil.origpath(ui, repo, a)) |
|
6173 | scmutil.origpath(ui, repo, a)) | |
6164 | except OSError as inst: |
|
6174 | except OSError as inst: | |
6165 | if inst.errno != errno.ENOENT: |
|
6175 | if inst.errno != errno.ENOENT: | |
6166 | raise |
|
6176 | raise | |
6167 |
|
6177 | |||
6168 | for f in tocomplete: |
|
6178 | for f in tocomplete: | |
6169 | try: |
|
6179 | try: | |
6170 | # resolve file |
|
6180 | # resolve file | |
6171 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
6181 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), | |
6172 | 'resolve') |
|
6182 | 'resolve') | |
6173 | r = ms.resolve(f, wctx) |
|
6183 | r = ms.resolve(f, wctx) | |
6174 | if r: |
|
6184 | if r: | |
6175 | ret = 1 |
|
6185 | ret = 1 | |
6176 | finally: |
|
6186 | finally: | |
6177 | ui.setconfig('ui', 'forcemerge', '', 'resolve') |
|
6187 | ui.setconfig('ui', 'forcemerge', '', 'resolve') | |
6178 | ms.commit() |
|
6188 | ms.commit() | |
6179 |
|
6189 | |||
6180 | # replace filemerge's .orig file with our resolve file |
|
6190 | # replace filemerge's .orig file with our resolve file | |
6181 | a = repo.wjoin(f) |
|
6191 | a = repo.wjoin(f) | |
6182 | try: |
|
6192 | try: | |
6183 | util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) |
|
6193 | util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) | |
6184 | except OSError as inst: |
|
6194 | except OSError as inst: | |
6185 | if inst.errno != errno.ENOENT: |
|
6195 | if inst.errno != errno.ENOENT: | |
6186 | raise |
|
6196 | raise | |
6187 |
|
6197 | |||
6188 | ms.commit() |
|
6198 | ms.commit() | |
6189 | ms.recordactions() |
|
6199 | ms.recordactions() | |
6190 |
|
6200 | |||
6191 | if not didwork and pats: |
|
6201 | if not didwork and pats: | |
6192 | hint = None |
|
6202 | hint = None | |
6193 | if not any([p for p in pats if p.find(':') >= 0]): |
|
6203 | if not any([p for p in pats if p.find(':') >= 0]): | |
6194 | pats = ['path:%s' % p for p in pats] |
|
6204 | pats = ['path:%s' % p for p in pats] | |
6195 | m = scmutil.match(wctx, pats, opts) |
|
6205 | m = scmutil.match(wctx, pats, opts) | |
6196 | for f in ms: |
|
6206 | for f in ms: | |
6197 | if not m(f): |
|
6207 | if not m(f): | |
6198 | continue |
|
6208 | continue | |
6199 | flags = ''.join(['-%s ' % o[0] for o in flaglist |
|
6209 | flags = ''.join(['-%s ' % o[0] for o in flaglist | |
6200 | if opts.get(o)]) |
|
6210 | if opts.get(o)]) | |
6201 | hint = _("(try: hg resolve %s%s)\n") % ( |
|
6211 | hint = _("(try: hg resolve %s%s)\n") % ( | |
6202 | flags, |
|
6212 | flags, | |
6203 | ' '.join(pats)) |
|
6213 | ' '.join(pats)) | |
6204 | break |
|
6214 | break | |
6205 | ui.warn(_("arguments do not match paths that need resolving\n")) |
|
6215 | ui.warn(_("arguments do not match paths that need resolving\n")) | |
6206 | if hint: |
|
6216 | if hint: | |
6207 | ui.warn(hint) |
|
6217 | ui.warn(hint) | |
6208 | elif ms.mergedriver and ms.mdstate() != 's': |
|
6218 | elif ms.mergedriver and ms.mdstate() != 's': | |
6209 | # run conclude step when either a driver-resolved file is requested |
|
6219 | # run conclude step when either a driver-resolved file is requested | |
6210 | # or there are no driver-resolved files |
|
6220 | # or there are no driver-resolved files | |
6211 | # we can't use 'ret' to determine whether any files are unresolved |
|
6221 | # we can't use 'ret' to determine whether any files are unresolved | |
6212 | # because we might not have tried to resolve some |
|
6222 | # because we might not have tried to resolve some | |
6213 | if ((runconclude or not list(ms.driverresolved())) |
|
6223 | if ((runconclude or not list(ms.driverresolved())) | |
6214 | and not list(ms.unresolved())): |
|
6224 | and not list(ms.unresolved())): | |
6215 | proceed = mergemod.driverconclude(repo, ms, wctx) |
|
6225 | proceed = mergemod.driverconclude(repo, ms, wctx) | |
6216 | ms.commit() |
|
6226 | ms.commit() | |
6217 | if not proceed: |
|
6227 | if not proceed: | |
6218 | return 1 |
|
6228 | return 1 | |
6219 |
|
6229 | |||
6220 | # Nudge users into finishing an unfinished operation |
|
6230 | # Nudge users into finishing an unfinished operation | |
6221 | unresolvedf = list(ms.unresolved()) |
|
6231 | unresolvedf = list(ms.unresolved()) | |
6222 | driverresolvedf = list(ms.driverresolved()) |
|
6232 | driverresolvedf = list(ms.driverresolved()) | |
6223 | if not unresolvedf and not driverresolvedf: |
|
6233 | if not unresolvedf and not driverresolvedf: | |
6224 | ui.status(_('(no more unresolved files)\n')) |
|
6234 | ui.status(_('(no more unresolved files)\n')) | |
6225 | cmdutil.checkafterresolved(repo) |
|
6235 | cmdutil.checkafterresolved(repo) | |
6226 | elif not unresolvedf: |
|
6236 | elif not unresolvedf: | |
6227 | ui.status(_('(no more unresolved files -- ' |
|
6237 | ui.status(_('(no more unresolved files -- ' | |
6228 | 'run "hg resolve --all" to conclude)\n')) |
|
6238 | 'run "hg resolve --all" to conclude)\n')) | |
6229 |
|
6239 | |||
6230 | return ret |
|
6240 | return ret | |
6231 |
|
6241 | |||
6232 | @command('revert', |
|
6242 | @command('revert', | |
6233 | [('a', 'all', None, _('revert all changes when no arguments given')), |
|
6243 | [('a', 'all', None, _('revert all changes when no arguments given')), | |
6234 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
|
6244 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), | |
6235 | ('r', 'rev', '', _('revert to the specified revision'), _('REV')), |
|
6245 | ('r', 'rev', '', _('revert to the specified revision'), _('REV')), | |
6236 | ('C', 'no-backup', None, _('do not save backup copies of files')), |
|
6246 | ('C', 'no-backup', None, _('do not save backup copies of files')), | |
6237 | ('i', 'interactive', None, |
|
6247 | ('i', 'interactive', None, | |
6238 | _('interactively select the changes (EXPERIMENTAL)')), |
|
6248 | _('interactively select the changes (EXPERIMENTAL)')), | |
6239 | ] + walkopts + dryrunopts, |
|
6249 | ] + walkopts + dryrunopts, | |
6240 | _('[OPTION]... [-r REV] [NAME]...')) |
|
6250 | _('[OPTION]... [-r REV] [NAME]...')) | |
6241 | def revert(ui, repo, *pats, **opts): |
|
6251 | def revert(ui, repo, *pats, **opts): | |
6242 | """restore files to their checkout state |
|
6252 | """restore files to their checkout state | |
6243 |
|
6253 | |||
6244 | .. note:: |
|
6254 | .. note:: | |
6245 |
|
6255 | |||
6246 | To check out earlier revisions, you should use :hg:`update REV`. |
|
6256 | To check out earlier revisions, you should use :hg:`update REV`. | |
6247 | To cancel an uncommitted merge (and lose your changes), |
|
6257 | To cancel an uncommitted merge (and lose your changes), | |
6248 | use :hg:`update --clean .`. |
|
6258 | use :hg:`update --clean .`. | |
6249 |
|
6259 | |||
6250 | With no revision specified, revert the specified files or directories |
|
6260 | With no revision specified, revert the specified files or directories | |
6251 | to the contents they had in the parent of the working directory. |
|
6261 | to the contents they had in the parent of the working directory. | |
6252 | This restores the contents of files to an unmodified |
|
6262 | This restores the contents of files to an unmodified | |
6253 | state and unschedules adds, removes, copies, and renames. If the |
|
6263 | state and unschedules adds, removes, copies, and renames. If the | |
6254 | working directory has two parents, you must explicitly specify a |
|
6264 | working directory has two parents, you must explicitly specify a | |
6255 | revision. |
|
6265 | revision. | |
6256 |
|
6266 | |||
6257 | Using the -r/--rev or -d/--date options, revert the given files or |
|
6267 | Using the -r/--rev or -d/--date options, revert the given files or | |
6258 | directories to their states as of a specific revision. Because |
|
6268 | directories to their states as of a specific revision. Because | |
6259 | revert does not change the working directory parents, this will |
|
6269 | revert does not change the working directory parents, this will | |
6260 | cause these files to appear modified. This can be helpful to "back |
|
6270 | cause these files to appear modified. This can be helpful to "back | |
6261 | out" some or all of an earlier change. See :hg:`backout` for a |
|
6271 | out" some or all of an earlier change. See :hg:`backout` for a | |
6262 | related method. |
|
6272 | related method. | |
6263 |
|
6273 | |||
6264 | Modified files are saved with a .orig suffix before reverting. |
|
6274 | Modified files are saved with a .orig suffix before reverting. | |
6265 | To disable these backups, use --no-backup. It is possible to store |
|
6275 | To disable these backups, use --no-backup. It is possible to store | |
6266 | the backup files in a custom directory relative to the root of the |
|
6276 | the backup files in a custom directory relative to the root of the | |
6267 | repository by setting the ``ui.origbackuppath`` configuration |
|
6277 | repository by setting the ``ui.origbackuppath`` configuration | |
6268 | option. |
|
6278 | option. | |
6269 |
|
6279 | |||
6270 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
6280 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
6271 |
|
6281 | |||
6272 | See :hg:`help backout` for a way to reverse the effect of an |
|
6282 | See :hg:`help backout` for a way to reverse the effect of an | |
6273 | earlier changeset. |
|
6283 | earlier changeset. | |
6274 |
|
6284 | |||
6275 | Returns 0 on success. |
|
6285 | Returns 0 on success. | |
6276 | """ |
|
6286 | """ | |
6277 |
|
6287 | |||
6278 | if opts.get("date"): |
|
6288 | if opts.get("date"): | |
6279 | if opts.get("rev"): |
|
6289 | if opts.get("rev"): | |
6280 | raise error.Abort(_("you can't specify a revision and a date")) |
|
6290 | raise error.Abort(_("you can't specify a revision and a date")) | |
6281 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
|
6291 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | |
6282 |
|
6292 | |||
6283 | parent, p2 = repo.dirstate.parents() |
|
6293 | parent, p2 = repo.dirstate.parents() | |
6284 | if not opts.get('rev') and p2 != nullid: |
|
6294 | if not opts.get('rev') and p2 != nullid: | |
6285 | # revert after merge is a trap for new users (issue2915) |
|
6295 | # revert after merge is a trap for new users (issue2915) | |
6286 | raise error.Abort(_('uncommitted merge with no revision specified'), |
|
6296 | raise error.Abort(_('uncommitted merge with no revision specified'), | |
6287 | hint=_("use 'hg update' or see 'hg help revert'")) |
|
6297 | hint=_("use 'hg update' or see 'hg help revert'")) | |
6288 |
|
6298 | |||
6289 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
6299 | ctx = scmutil.revsingle(repo, opts.get('rev')) | |
6290 |
|
6300 | |||
6291 | if (not (pats or opts.get('include') or opts.get('exclude') or |
|
6301 | if (not (pats or opts.get('include') or opts.get('exclude') or | |
6292 | opts.get('all') or opts.get('interactive'))): |
|
6302 | opts.get('all') or opts.get('interactive'))): | |
6293 | msg = _("no files or directories specified") |
|
6303 | msg = _("no files or directories specified") | |
6294 | if p2 != nullid: |
|
6304 | if p2 != nullid: | |
6295 | hint = _("uncommitted merge, use --all to discard all changes," |
|
6305 | hint = _("uncommitted merge, use --all to discard all changes," | |
6296 | " or 'hg update -C .' to abort the merge") |
|
6306 | " or 'hg update -C .' to abort the merge") | |
6297 | raise error.Abort(msg, hint=hint) |
|
6307 | raise error.Abort(msg, hint=hint) | |
6298 | dirty = any(repo.status()) |
|
6308 | dirty = any(repo.status()) | |
6299 | node = ctx.node() |
|
6309 | node = ctx.node() | |
6300 | if node != parent: |
|
6310 | if node != parent: | |
6301 | if dirty: |
|
6311 | if dirty: | |
6302 | hint = _("uncommitted changes, use --all to discard all" |
|
6312 | hint = _("uncommitted changes, use --all to discard all" | |
6303 | " changes, or 'hg update %s' to update") % ctx.rev() |
|
6313 | " changes, or 'hg update %s' to update") % ctx.rev() | |
6304 | else: |
|
6314 | else: | |
6305 | hint = _("use --all to revert all files," |
|
6315 | hint = _("use --all to revert all files," | |
6306 | " or 'hg update %s' to update") % ctx.rev() |
|
6316 | " or 'hg update %s' to update") % ctx.rev() | |
6307 | elif dirty: |
|
6317 | elif dirty: | |
6308 | hint = _("uncommitted changes, use --all to discard all changes") |
|
6318 | hint = _("uncommitted changes, use --all to discard all changes") | |
6309 | else: |
|
6319 | else: | |
6310 | hint = _("use --all to revert all files") |
|
6320 | hint = _("use --all to revert all files") | |
6311 | raise error.Abort(msg, hint=hint) |
|
6321 | raise error.Abort(msg, hint=hint) | |
6312 |
|
6322 | |||
6313 | return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts) |
|
6323 | return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts) | |
6314 |
|
6324 | |||
6315 | @command('rollback', dryrunopts + |
|
6325 | @command('rollback', dryrunopts + | |
6316 | [('f', 'force', False, _('ignore safety measures'))]) |
|
6326 | [('f', 'force', False, _('ignore safety measures'))]) | |
6317 | def rollback(ui, repo, **opts): |
|
6327 | def rollback(ui, repo, **opts): | |
6318 | """roll back the last transaction (DANGEROUS) (DEPRECATED) |
|
6328 | """roll back the last transaction (DANGEROUS) (DEPRECATED) | |
6319 |
|
6329 | |||
6320 | Please use :hg:`commit --amend` instead of rollback to correct |
|
6330 | Please use :hg:`commit --amend` instead of rollback to correct | |
6321 | mistakes in the last commit. |
|
6331 | mistakes in the last commit. | |
6322 |
|
6332 | |||
6323 | This command should be used with care. There is only one level of |
|
6333 | This command should be used with care. There is only one level of | |
6324 | rollback, and there is no way to undo a rollback. It will also |
|
6334 | rollback, and there is no way to undo a rollback. It will also | |
6325 | restore the dirstate at the time of the last transaction, losing |
|
6335 | restore the dirstate at the time of the last transaction, losing | |
6326 | any dirstate changes since that time. This command does not alter |
|
6336 | any dirstate changes since that time. This command does not alter | |
6327 | the working directory. |
|
6337 | the working directory. | |
6328 |
|
6338 | |||
6329 | Transactions are used to encapsulate the effects of all commands |
|
6339 | Transactions are used to encapsulate the effects of all commands | |
6330 | that create new changesets or propagate existing changesets into a |
|
6340 | that create new changesets or propagate existing changesets into a | |
6331 | repository. |
|
6341 | repository. | |
6332 |
|
6342 | |||
6333 | .. container:: verbose |
|
6343 | .. container:: verbose | |
6334 |
|
6344 | |||
6335 | For example, the following commands are transactional, and their |
|
6345 | For example, the following commands are transactional, and their | |
6336 | effects can be rolled back: |
|
6346 | effects can be rolled back: | |
6337 |
|
6347 | |||
6338 | - commit |
|
6348 | - commit | |
6339 | - import |
|
6349 | - import | |
6340 | - pull |
|
6350 | - pull | |
6341 | - push (with this repository as the destination) |
|
6351 | - push (with this repository as the destination) | |
6342 | - unbundle |
|
6352 | - unbundle | |
6343 |
|
6353 | |||
6344 | To avoid permanent data loss, rollback will refuse to rollback a |
|
6354 | To avoid permanent data loss, rollback will refuse to rollback a | |
6345 | commit transaction if it isn't checked out. Use --force to |
|
6355 | commit transaction if it isn't checked out. Use --force to | |
6346 | override this protection. |
|
6356 | override this protection. | |
6347 |
|
6357 | |||
6348 | The rollback command can be entirely disabled by setting the |
|
6358 | The rollback command can be entirely disabled by setting the | |
6349 | ``ui.rollback`` configuration setting to false. If you're here |
|
6359 | ``ui.rollback`` configuration setting to false. If you're here | |
6350 | because you want to use rollback and it's disabled, you can |
|
6360 | because you want to use rollback and it's disabled, you can | |
6351 | re-enable the command by setting ``ui.rollback`` to true. |
|
6361 | re-enable the command by setting ``ui.rollback`` to true. | |
6352 |
|
6362 | |||
6353 | This command is not intended for use on public repositories. Once |
|
6363 | This command is not intended for use on public repositories. Once | |
6354 | changes are visible for pull by other users, rolling a transaction |
|
6364 | changes are visible for pull by other users, rolling a transaction | |
6355 | back locally is ineffective (someone else may already have pulled |
|
6365 | back locally is ineffective (someone else may already have pulled | |
6356 | the changes). Furthermore, a race is possible with readers of the |
|
6366 | the changes). Furthermore, a race is possible with readers of the | |
6357 | repository; for example an in-progress pull from the repository |
|
6367 | repository; for example an in-progress pull from the repository | |
6358 | may fail if a rollback is performed. |
|
6368 | may fail if a rollback is performed. | |
6359 |
|
6369 | |||
6360 | Returns 0 on success, 1 if no rollback data is available. |
|
6370 | Returns 0 on success, 1 if no rollback data is available. | |
6361 | """ |
|
6371 | """ | |
6362 | if not ui.configbool('ui', 'rollback', True): |
|
6372 | if not ui.configbool('ui', 'rollback', True): | |
6363 | raise error.Abort(_('rollback is disabled because it is unsafe'), |
|
6373 | raise error.Abort(_('rollback is disabled because it is unsafe'), | |
6364 | hint=('see `hg help -v rollback` for information')) |
|
6374 | hint=('see `hg help -v rollback` for information')) | |
6365 | return repo.rollback(dryrun=opts.get('dry_run'), |
|
6375 | return repo.rollback(dryrun=opts.get('dry_run'), | |
6366 | force=opts.get('force')) |
|
6376 | force=opts.get('force')) | |
6367 |
|
6377 | |||
6368 | @command('root', []) |
|
6378 | @command('root', []) | |
6369 | def root(ui, repo): |
|
6379 | def root(ui, repo): | |
6370 | """print the root (top) of the current working directory |
|
6380 | """print the root (top) of the current working directory | |
6371 |
|
6381 | |||
6372 | Print the root directory of the current repository. |
|
6382 | Print the root directory of the current repository. | |
6373 |
|
6383 | |||
6374 | Returns 0 on success. |
|
6384 | Returns 0 on success. | |
6375 | """ |
|
6385 | """ | |
6376 | ui.write(repo.root + "\n") |
|
6386 | ui.write(repo.root + "\n") | |
6377 |
|
6387 | |||
6378 | @command('^serve', |
|
6388 | @command('^serve', | |
6379 | [('A', 'accesslog', '', _('name of access log file to write to'), |
|
6389 | [('A', 'accesslog', '', _('name of access log file to write to'), | |
6380 | _('FILE')), |
|
6390 | _('FILE')), | |
6381 | ('d', 'daemon', None, _('run server in background')), |
|
6391 | ('d', 'daemon', None, _('run server in background')), | |
6382 | ('', 'daemon-postexec', [], _('used internally by daemon mode')), |
|
6392 | ('', 'daemon-postexec', [], _('used internally by daemon mode')), | |
6383 | ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')), |
|
6393 | ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')), | |
6384 | # use string type, then we can check if something was passed |
|
6394 | # use string type, then we can check if something was passed | |
6385 | ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')), |
|
6395 | ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')), | |
6386 | ('a', 'address', '', _('address to listen on (default: all interfaces)'), |
|
6396 | ('a', 'address', '', _('address to listen on (default: all interfaces)'), | |
6387 | _('ADDR')), |
|
6397 | _('ADDR')), | |
6388 | ('', 'prefix', '', _('prefix path to serve from (default: server root)'), |
|
6398 | ('', 'prefix', '', _('prefix path to serve from (default: server root)'), | |
6389 | _('PREFIX')), |
|
6399 | _('PREFIX')), | |
6390 | ('n', 'name', '', |
|
6400 | ('n', 'name', '', | |
6391 | _('name to show in web pages (default: working directory)'), _('NAME')), |
|
6401 | _('name to show in web pages (default: working directory)'), _('NAME')), | |
6392 | ('', 'web-conf', '', |
|
6402 | ('', 'web-conf', '', | |
6393 | _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')), |
|
6403 | _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')), | |
6394 | ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'), |
|
6404 | ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'), | |
6395 | _('FILE')), |
|
6405 | _('FILE')), | |
6396 | ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')), |
|
6406 | ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')), | |
6397 | ('', 'stdio', None, _('for remote clients')), |
|
6407 | ('', 'stdio', None, _('for remote clients')), | |
6398 | ('', 'cmdserver', '', _('for remote clients'), _('MODE')), |
|
6408 | ('', 'cmdserver', '', _('for remote clients'), _('MODE')), | |
6399 | ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), |
|
6409 | ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), | |
6400 | ('', 'style', '', _('template style to use'), _('STYLE')), |
|
6410 | ('', 'style', '', _('template style to use'), _('STYLE')), | |
6401 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), |
|
6411 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), | |
6402 | ('', 'certificate', '', _('SSL certificate file'), _('FILE'))], |
|
6412 | ('', 'certificate', '', _('SSL certificate file'), _('FILE'))], | |
6403 | _('[OPTION]...'), |
|
6413 | _('[OPTION]...'), | |
6404 | optionalrepo=True) |
|
6414 | optionalrepo=True) | |
6405 | def serve(ui, repo, **opts): |
|
6415 | def serve(ui, repo, **opts): | |
6406 | """start stand-alone webserver |
|
6416 | """start stand-alone webserver | |
6407 |
|
6417 | |||
6408 | Start a local HTTP repository browser and pull server. You can use |
|
6418 | Start a local HTTP repository browser and pull server. You can use | |
6409 | this for ad-hoc sharing and browsing of repositories. It is |
|
6419 | this for ad-hoc sharing and browsing of repositories. It is | |
6410 | recommended to use a real web server to serve a repository for |
|
6420 | recommended to use a real web server to serve a repository for | |
6411 | longer periods of time. |
|
6421 | longer periods of time. | |
6412 |
|
6422 | |||
6413 | Please note that the server does not implement access control. |
|
6423 | Please note that the server does not implement access control. | |
6414 | This means that, by default, anybody can read from the server and |
|
6424 | This means that, by default, anybody can read from the server and | |
6415 | nobody can write to it by default. Set the ``web.allow_push`` |
|
6425 | nobody can write to it by default. Set the ``web.allow_push`` | |
6416 | option to ``*`` to allow everybody to push to the server. You |
|
6426 | option to ``*`` to allow everybody to push to the server. You | |
6417 | should use a real web server if you need to authenticate users. |
|
6427 | should use a real web server if you need to authenticate users. | |
6418 |
|
6428 | |||
6419 | By default, the server logs accesses to stdout and errors to |
|
6429 | By default, the server logs accesses to stdout and errors to | |
6420 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to |
|
6430 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to | |
6421 | files. |
|
6431 | files. | |
6422 |
|
6432 | |||
6423 | To have the server choose a free port number to listen on, specify |
|
6433 | To have the server choose a free port number to listen on, specify | |
6424 | a port number of 0; in this case, the server will print the port |
|
6434 | a port number of 0; in this case, the server will print the port | |
6425 | number it uses. |
|
6435 | number it uses. | |
6426 |
|
6436 | |||
6427 | Returns 0 on success. |
|
6437 | Returns 0 on success. | |
6428 | """ |
|
6438 | """ | |
6429 |
|
6439 | |||
6430 | if opts["stdio"] and opts["cmdserver"]: |
|
6440 | if opts["stdio"] and opts["cmdserver"]: | |
6431 | raise error.Abort(_("cannot use --stdio with --cmdserver")) |
|
6441 | raise error.Abort(_("cannot use --stdio with --cmdserver")) | |
6432 |
|
6442 | |||
6433 | if opts["stdio"]: |
|
6443 | if opts["stdio"]: | |
6434 | if repo is None: |
|
6444 | if repo is None: | |
6435 | raise error.RepoError(_("there is no Mercurial repository here" |
|
6445 | raise error.RepoError(_("there is no Mercurial repository here" | |
6436 | " (.hg not found)")) |
|
6446 | " (.hg not found)")) | |
6437 | s = sshserver.sshserver(ui, repo) |
|
6447 | s = sshserver.sshserver(ui, repo) | |
6438 | s.serve_forever() |
|
6448 | s.serve_forever() | |
6439 |
|
6449 | |||
6440 | if opts["cmdserver"]: |
|
6450 | if opts["cmdserver"]: | |
6441 | service = commandserver.createservice(ui, repo, opts) |
|
6451 | service = commandserver.createservice(ui, repo, opts) | |
6442 | else: |
|
6452 | else: | |
6443 | service = hgweb.createservice(ui, repo, opts) |
|
6453 | service = hgweb.createservice(ui, repo, opts) | |
6444 | return cmdutil.service(opts, initfn=service.init, runfn=service.run) |
|
6454 | return cmdutil.service(opts, initfn=service.init, runfn=service.run) | |
6445 |
|
6455 | |||
6446 | @command('^status|st', |
|
6456 | @command('^status|st', | |
6447 | [('A', 'all', None, _('show status of all files')), |
|
6457 | [('A', 'all', None, _('show status of all files')), | |
6448 | ('m', 'modified', None, _('show only modified files')), |
|
6458 | ('m', 'modified', None, _('show only modified files')), | |
6449 | ('a', 'added', None, _('show only added files')), |
|
6459 | ('a', 'added', None, _('show only added files')), | |
6450 | ('r', 'removed', None, _('show only removed files')), |
|
6460 | ('r', 'removed', None, _('show only removed files')), | |
6451 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), |
|
6461 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), | |
6452 | ('c', 'clean', None, _('show only files without changes')), |
|
6462 | ('c', 'clean', None, _('show only files without changes')), | |
6453 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), |
|
6463 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), | |
6454 | ('i', 'ignored', None, _('show only ignored files')), |
|
6464 | ('i', 'ignored', None, _('show only ignored files')), | |
6455 | ('n', 'no-status', None, _('hide status prefix')), |
|
6465 | ('n', 'no-status', None, _('hide status prefix')), | |
6456 | ('C', 'copies', None, _('show source of copied files')), |
|
6466 | ('C', 'copies', None, _('show source of copied files')), | |
6457 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
6467 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), | |
6458 | ('', 'rev', [], _('show difference from revision'), _('REV')), |
|
6468 | ('', 'rev', [], _('show difference from revision'), _('REV')), | |
6459 | ('', 'change', '', _('list the changed files of a revision'), _('REV')), |
|
6469 | ('', 'change', '', _('list the changed files of a revision'), _('REV')), | |
6460 | ] + walkopts + subrepoopts + formatteropts, |
|
6470 | ] + walkopts + subrepoopts + formatteropts, | |
6461 | _('[OPTION]... [FILE]...'), |
|
6471 | _('[OPTION]... [FILE]...'), | |
6462 | inferrepo=True) |
|
6472 | inferrepo=True) | |
6463 | def status(ui, repo, *pats, **opts): |
|
6473 | def status(ui, repo, *pats, **opts): | |
6464 | """show changed files in the working directory |
|
6474 | """show changed files in the working directory | |
6465 |
|
6475 | |||
6466 | Show status of files in the repository. If names are given, only |
|
6476 | Show status of files in the repository. If names are given, only | |
6467 | files that match are shown. Files that are clean or ignored or |
|
6477 | files that match are shown. Files that are clean or ignored or | |
6468 | the source of a copy/move operation, are not listed unless |
|
6478 | the source of a copy/move operation, are not listed unless | |
6469 | -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. |
|
6479 | -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. | |
6470 | Unless options described with "show only ..." are given, the |
|
6480 | Unless options described with "show only ..." are given, the | |
6471 | options -mardu are used. |
|
6481 | options -mardu are used. | |
6472 |
|
6482 | |||
6473 | Option -q/--quiet hides untracked (unknown and ignored) files |
|
6483 | Option -q/--quiet hides untracked (unknown and ignored) files | |
6474 | unless explicitly requested with -u/--unknown or -i/--ignored. |
|
6484 | unless explicitly requested with -u/--unknown or -i/--ignored. | |
6475 |
|
6485 | |||
6476 | .. note:: |
|
6486 | .. note:: | |
6477 |
|
6487 | |||
6478 | :hg:`status` may appear to disagree with diff if permissions have |
|
6488 | :hg:`status` may appear to disagree with diff if permissions have | |
6479 | changed or a merge has occurred. The standard diff format does |
|
6489 | changed or a merge has occurred. The standard diff format does | |
6480 | not report permission changes and diff only reports changes |
|
6490 | not report permission changes and diff only reports changes | |
6481 | relative to one merge parent. |
|
6491 | relative to one merge parent. | |
6482 |
|
6492 | |||
6483 | If one revision is given, it is used as the base revision. |
|
6493 | If one revision is given, it is used as the base revision. | |
6484 | If two revisions are given, the differences between them are |
|
6494 | If two revisions are given, the differences between them are | |
6485 | shown. The --change option can also be used as a shortcut to list |
|
6495 | shown. The --change option can also be used as a shortcut to list | |
6486 | the changed files of a revision from its first parent. |
|
6496 | the changed files of a revision from its first parent. | |
6487 |
|
6497 | |||
6488 | The codes used to show the status of files are:: |
|
6498 | The codes used to show the status of files are:: | |
6489 |
|
6499 | |||
6490 | M = modified |
|
6500 | M = modified | |
6491 | A = added |
|
6501 | A = added | |
6492 | R = removed |
|
6502 | R = removed | |
6493 | C = clean |
|
6503 | C = clean | |
6494 | ! = missing (deleted by non-hg command, but still tracked) |
|
6504 | ! = missing (deleted by non-hg command, but still tracked) | |
6495 | ? = not tracked |
|
6505 | ? = not tracked | |
6496 | I = ignored |
|
6506 | I = ignored | |
6497 | = origin of the previous file (with --copies) |
|
6507 | = origin of the previous file (with --copies) | |
6498 |
|
6508 | |||
6499 | .. container:: verbose |
|
6509 | .. container:: verbose | |
6500 |
|
6510 | |||
6501 | Examples: |
|
6511 | Examples: | |
6502 |
|
6512 | |||
6503 | - show changes in the working directory relative to a |
|
6513 | - show changes in the working directory relative to a | |
6504 | changeset:: |
|
6514 | changeset:: | |
6505 |
|
6515 | |||
6506 | hg status --rev 9353 |
|
6516 | hg status --rev 9353 | |
6507 |
|
6517 | |||
6508 | - show changes in the working directory relative to the |
|
6518 | - show changes in the working directory relative to the | |
6509 | current directory (see :hg:`help patterns` for more information):: |
|
6519 | current directory (see :hg:`help patterns` for more information):: | |
6510 |
|
6520 | |||
6511 | hg status re: |
|
6521 | hg status re: | |
6512 |
|
6522 | |||
6513 | - show all changes including copies in an existing changeset:: |
|
6523 | - show all changes including copies in an existing changeset:: | |
6514 |
|
6524 | |||
6515 | hg status --copies --change 9353 |
|
6525 | hg status --copies --change 9353 | |
6516 |
|
6526 | |||
6517 | - get a NUL separated list of added files, suitable for xargs:: |
|
6527 | - get a NUL separated list of added files, suitable for xargs:: | |
6518 |
|
6528 | |||
6519 | hg status -an0 |
|
6529 | hg status -an0 | |
6520 |
|
6530 | |||
6521 | Returns 0 on success. |
|
6531 | Returns 0 on success. | |
6522 | """ |
|
6532 | """ | |
6523 |
|
6533 | |||
6524 | revs = opts.get('rev') |
|
6534 | revs = opts.get('rev') | |
6525 | change = opts.get('change') |
|
6535 | change = opts.get('change') | |
6526 |
|
6536 | |||
6527 | if revs and change: |
|
6537 | if revs and change: | |
6528 | msg = _('cannot specify --rev and --change at the same time') |
|
6538 | msg = _('cannot specify --rev and --change at the same time') | |
6529 | raise error.Abort(msg) |
|
6539 | raise error.Abort(msg) | |
6530 | elif change: |
|
6540 | elif change: | |
6531 | node2 = scmutil.revsingle(repo, change, None).node() |
|
6541 | node2 = scmutil.revsingle(repo, change, None).node() | |
6532 | node1 = repo[node2].p1().node() |
|
6542 | node1 = repo[node2].p1().node() | |
6533 | else: |
|
6543 | else: | |
6534 | node1, node2 = scmutil.revpair(repo, revs) |
|
6544 | node1, node2 = scmutil.revpair(repo, revs) | |
6535 |
|
6545 | |||
6536 | if pats: |
|
6546 | if pats: | |
6537 | cwd = repo.getcwd() |
|
6547 | cwd = repo.getcwd() | |
6538 | else: |
|
6548 | else: | |
6539 | cwd = '' |
|
6549 | cwd = '' | |
6540 |
|
6550 | |||
6541 | if opts.get('print0'): |
|
6551 | if opts.get('print0'): | |
6542 | end = '\0' |
|
6552 | end = '\0' | |
6543 | else: |
|
6553 | else: | |
6544 | end = '\n' |
|
6554 | end = '\n' | |
6545 | copy = {} |
|
6555 | copy = {} | |
6546 | states = 'modified added removed deleted unknown ignored clean'.split() |
|
6556 | states = 'modified added removed deleted unknown ignored clean'.split() | |
6547 | show = [k for k in states if opts.get(k)] |
|
6557 | show = [k for k in states if opts.get(k)] | |
6548 | if opts.get('all'): |
|
6558 | if opts.get('all'): | |
6549 | show += ui.quiet and (states[:4] + ['clean']) or states |
|
6559 | show += ui.quiet and (states[:4] + ['clean']) or states | |
6550 | if not show: |
|
6560 | if not show: | |
6551 | if ui.quiet: |
|
6561 | if ui.quiet: | |
6552 | show = states[:4] |
|
6562 | show = states[:4] | |
6553 | else: |
|
6563 | else: | |
6554 | show = states[:5] |
|
6564 | show = states[:5] | |
6555 |
|
6565 | |||
6556 | m = scmutil.match(repo[node2], pats, opts) |
|
6566 | m = scmutil.match(repo[node2], pats, opts) | |
6557 | stat = repo.status(node1, node2, m, |
|
6567 | stat = repo.status(node1, node2, m, | |
6558 | 'ignored' in show, 'clean' in show, 'unknown' in show, |
|
6568 | 'ignored' in show, 'clean' in show, 'unknown' in show, | |
6559 | opts.get('subrepos')) |
|
6569 | opts.get('subrepos')) | |
6560 | changestates = zip(states, 'MAR!?IC', stat) |
|
6570 | changestates = zip(states, 'MAR!?IC', stat) | |
6561 |
|
6571 | |||
6562 | if (opts.get('all') or opts.get('copies') |
|
6572 | if (opts.get('all') or opts.get('copies') | |
6563 | or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'): |
|
6573 | or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'): | |
6564 | copy = copies.pathcopies(repo[node1], repo[node2], m) |
|
6574 | copy = copies.pathcopies(repo[node1], repo[node2], m) | |
6565 |
|
6575 | |||
6566 | fm = ui.formatter('status', opts) |
|
6576 | fm = ui.formatter('status', opts) | |
6567 | fmt = '%s' + end |
|
6577 | fmt = '%s' + end | |
6568 | showchar = not opts.get('no_status') |
|
6578 | showchar = not opts.get('no_status') | |
6569 |
|
6579 | |||
6570 | for state, char, files in changestates: |
|
6580 | for state, char, files in changestates: | |
6571 | if state in show: |
|
6581 | if state in show: | |
6572 | label = 'status.' + state |
|
6582 | label = 'status.' + state | |
6573 | for f in files: |
|
6583 | for f in files: | |
6574 | fm.startitem() |
|
6584 | fm.startitem() | |
6575 | fm.condwrite(showchar, 'status', '%s ', char, label=label) |
|
6585 | fm.condwrite(showchar, 'status', '%s ', char, label=label) | |
6576 | fm.write('path', fmt, repo.pathto(f, cwd), label=label) |
|
6586 | fm.write('path', fmt, repo.pathto(f, cwd), label=label) | |
6577 | if f in copy: |
|
6587 | if f in copy: | |
6578 | fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), |
|
6588 | fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), | |
6579 | label='status.copied') |
|
6589 | label='status.copied') | |
6580 | fm.end() |
|
6590 | fm.end() | |
6581 |
|
6591 | |||
6582 | @command('^summary|sum', |
|
6592 | @command('^summary|sum', | |
6583 | [('', 'remote', None, _('check for push and pull'))], '[--remote]') |
|
6593 | [('', 'remote', None, _('check for push and pull'))], '[--remote]') | |
6584 | def summary(ui, repo, **opts): |
|
6594 | def summary(ui, repo, **opts): | |
6585 | """summarize working directory state |
|
6595 | """summarize working directory state | |
6586 |
|
6596 | |||
6587 | This generates a brief summary of the working directory state, |
|
6597 | This generates a brief summary of the working directory state, | |
6588 | including parents, branch, commit status, phase and available updates. |
|
6598 | including parents, branch, commit status, phase and available updates. | |
6589 |
|
6599 | |||
6590 | With the --remote option, this will check the default paths for |
|
6600 | With the --remote option, this will check the default paths for | |
6591 | incoming and outgoing changes. This can be time-consuming. |
|
6601 | incoming and outgoing changes. This can be time-consuming. | |
6592 |
|
6602 | |||
6593 | Returns 0 on success. |
|
6603 | Returns 0 on success. | |
6594 | """ |
|
6604 | """ | |
6595 |
|
6605 | |||
6596 | ctx = repo[None] |
|
6606 | ctx = repo[None] | |
6597 | parents = ctx.parents() |
|
6607 | parents = ctx.parents() | |
6598 | pnode = parents[0].node() |
|
6608 | pnode = parents[0].node() | |
6599 | marks = [] |
|
6609 | marks = [] | |
6600 |
|
6610 | |||
6601 | ms = None |
|
6611 | ms = None | |
6602 | try: |
|
6612 | try: | |
6603 | ms = mergemod.mergestate.read(repo) |
|
6613 | ms = mergemod.mergestate.read(repo) | |
6604 | except error.UnsupportedMergeRecords as e: |
|
6614 | except error.UnsupportedMergeRecords as e: | |
6605 | s = ' '.join(e.recordtypes) |
|
6615 | s = ' '.join(e.recordtypes) | |
6606 | ui.warn( |
|
6616 | ui.warn( | |
6607 | _('warning: merge state has unsupported record types: %s\n') % s) |
|
6617 | _('warning: merge state has unsupported record types: %s\n') % s) | |
6608 | unresolved = 0 |
|
6618 | unresolved = 0 | |
6609 | else: |
|
6619 | else: | |
6610 | unresolved = [f for f in ms if ms[f] == 'u'] |
|
6620 | unresolved = [f for f in ms if ms[f] == 'u'] | |
6611 |
|
6621 | |||
6612 | for p in parents: |
|
6622 | for p in parents: | |
6613 | # label with log.changeset (instead of log.parent) since this |
|
6623 | # label with log.changeset (instead of log.parent) since this | |
6614 | # shows a working directory parent *changeset*: |
|
6624 | # shows a working directory parent *changeset*: | |
6615 | # i18n: column positioning for "hg summary" |
|
6625 | # i18n: column positioning for "hg summary" | |
6616 | ui.write(_('parent: %d:%s ') % (p.rev(), str(p)), |
|
6626 | ui.write(_('parent: %d:%s ') % (p.rev(), str(p)), | |
6617 | label='log.changeset changeset.%s' % p.phasestr()) |
|
6627 | label='log.changeset changeset.%s' % p.phasestr()) | |
6618 | ui.write(' '.join(p.tags()), label='log.tag') |
|
6628 | ui.write(' '.join(p.tags()), label='log.tag') | |
6619 | if p.bookmarks(): |
|
6629 | if p.bookmarks(): | |
6620 | marks.extend(p.bookmarks()) |
|
6630 | marks.extend(p.bookmarks()) | |
6621 | if p.rev() == -1: |
|
6631 | if p.rev() == -1: | |
6622 | if not len(repo): |
|
6632 | if not len(repo): | |
6623 | ui.write(_(' (empty repository)')) |
|
6633 | ui.write(_(' (empty repository)')) | |
6624 | else: |
|
6634 | else: | |
6625 | ui.write(_(' (no revision checked out)')) |
|
6635 | ui.write(_(' (no revision checked out)')) | |
6626 | ui.write('\n') |
|
6636 | ui.write('\n') | |
6627 | if p.description(): |
|
6637 | if p.description(): | |
6628 | ui.status(' ' + p.description().splitlines()[0].strip() + '\n', |
|
6638 | ui.status(' ' + p.description().splitlines()[0].strip() + '\n', | |
6629 | label='log.summary') |
|
6639 | label='log.summary') | |
6630 |
|
6640 | |||
6631 | branch = ctx.branch() |
|
6641 | branch = ctx.branch() | |
6632 | bheads = repo.branchheads(branch) |
|
6642 | bheads = repo.branchheads(branch) | |
6633 | # i18n: column positioning for "hg summary" |
|
6643 | # i18n: column positioning for "hg summary" | |
6634 | m = _('branch: %s\n') % branch |
|
6644 | m = _('branch: %s\n') % branch | |
6635 | if branch != 'default': |
|
6645 | if branch != 'default': | |
6636 | ui.write(m, label='log.branch') |
|
6646 | ui.write(m, label='log.branch') | |
6637 | else: |
|
6647 | else: | |
6638 | ui.status(m, label='log.branch') |
|
6648 | ui.status(m, label='log.branch') | |
6639 |
|
6649 | |||
6640 | if marks: |
|
6650 | if marks: | |
6641 | active = repo._activebookmark |
|
6651 | active = repo._activebookmark | |
6642 | # i18n: column positioning for "hg summary" |
|
6652 | # i18n: column positioning for "hg summary" | |
6643 | ui.write(_('bookmarks:'), label='log.bookmark') |
|
6653 | ui.write(_('bookmarks:'), label='log.bookmark') | |
6644 | if active is not None: |
|
6654 | if active is not None: | |
6645 | if active in marks: |
|
6655 | if active in marks: | |
6646 | ui.write(' *' + active, label=activebookmarklabel) |
|
6656 | ui.write(' *' + active, label=activebookmarklabel) | |
6647 | marks.remove(active) |
|
6657 | marks.remove(active) | |
6648 | else: |
|
6658 | else: | |
6649 | ui.write(' [%s]' % active, label=activebookmarklabel) |
|
6659 | ui.write(' [%s]' % active, label=activebookmarklabel) | |
6650 | for m in marks: |
|
6660 | for m in marks: | |
6651 | ui.write(' ' + m, label='log.bookmark') |
|
6661 | ui.write(' ' + m, label='log.bookmark') | |
6652 | ui.write('\n', label='log.bookmark') |
|
6662 | ui.write('\n', label='log.bookmark') | |
6653 |
|
6663 | |||
6654 | status = repo.status(unknown=True) |
|
6664 | status = repo.status(unknown=True) | |
6655 |
|
6665 | |||
6656 | c = repo.dirstate.copies() |
|
6666 | c = repo.dirstate.copies() | |
6657 | copied, renamed = [], [] |
|
6667 | copied, renamed = [], [] | |
6658 | for d, s in c.iteritems(): |
|
6668 | for d, s in c.iteritems(): | |
6659 | if s in status.removed: |
|
6669 | if s in status.removed: | |
6660 | status.removed.remove(s) |
|
6670 | status.removed.remove(s) | |
6661 | renamed.append(d) |
|
6671 | renamed.append(d) | |
6662 | else: |
|
6672 | else: | |
6663 | copied.append(d) |
|
6673 | copied.append(d) | |
6664 | if d in status.added: |
|
6674 | if d in status.added: | |
6665 | status.added.remove(d) |
|
6675 | status.added.remove(d) | |
6666 |
|
6676 | |||
6667 | subs = [s for s in ctx.substate if ctx.sub(s).dirty()] |
|
6677 | subs = [s for s in ctx.substate if ctx.sub(s).dirty()] | |
6668 |
|
6678 | |||
6669 | labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified), |
|
6679 | labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified), | |
6670 | (ui.label(_('%d added'), 'status.added'), status.added), |
|
6680 | (ui.label(_('%d added'), 'status.added'), status.added), | |
6671 | (ui.label(_('%d removed'), 'status.removed'), status.removed), |
|
6681 | (ui.label(_('%d removed'), 'status.removed'), status.removed), | |
6672 | (ui.label(_('%d renamed'), 'status.copied'), renamed), |
|
6682 | (ui.label(_('%d renamed'), 'status.copied'), renamed), | |
6673 | (ui.label(_('%d copied'), 'status.copied'), copied), |
|
6683 | (ui.label(_('%d copied'), 'status.copied'), copied), | |
6674 | (ui.label(_('%d deleted'), 'status.deleted'), status.deleted), |
|
6684 | (ui.label(_('%d deleted'), 'status.deleted'), status.deleted), | |
6675 | (ui.label(_('%d unknown'), 'status.unknown'), status.unknown), |
|
6685 | (ui.label(_('%d unknown'), 'status.unknown'), status.unknown), | |
6676 | (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved), |
|
6686 | (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved), | |
6677 | (ui.label(_('%d subrepos'), 'status.modified'), subs)] |
|
6687 | (ui.label(_('%d subrepos'), 'status.modified'), subs)] | |
6678 | t = [] |
|
6688 | t = [] | |
6679 | for l, s in labels: |
|
6689 | for l, s in labels: | |
6680 | if s: |
|
6690 | if s: | |
6681 | t.append(l % len(s)) |
|
6691 | t.append(l % len(s)) | |
6682 |
|
6692 | |||
6683 | t = ', '.join(t) |
|
6693 | t = ', '.join(t) | |
6684 | cleanworkdir = False |
|
6694 | cleanworkdir = False | |
6685 |
|
6695 | |||
6686 | if repo.vfs.exists('graftstate'): |
|
6696 | if repo.vfs.exists('graftstate'): | |
6687 | t += _(' (graft in progress)') |
|
6697 | t += _(' (graft in progress)') | |
6688 | if repo.vfs.exists('updatestate'): |
|
6698 | if repo.vfs.exists('updatestate'): | |
6689 | t += _(' (interrupted update)') |
|
6699 | t += _(' (interrupted update)') | |
6690 | elif len(parents) > 1: |
|
6700 | elif len(parents) > 1: | |
6691 | t += _(' (merge)') |
|
6701 | t += _(' (merge)') | |
6692 | elif branch != parents[0].branch(): |
|
6702 | elif branch != parents[0].branch(): | |
6693 | t += _(' (new branch)') |
|
6703 | t += _(' (new branch)') | |
6694 | elif (parents[0].closesbranch() and |
|
6704 | elif (parents[0].closesbranch() and | |
6695 | pnode in repo.branchheads(branch, closed=True)): |
|
6705 | pnode in repo.branchheads(branch, closed=True)): | |
6696 | t += _(' (head closed)') |
|
6706 | t += _(' (head closed)') | |
6697 | elif not (status.modified or status.added or status.removed or renamed or |
|
6707 | elif not (status.modified or status.added or status.removed or renamed or | |
6698 | copied or subs): |
|
6708 | copied or subs): | |
6699 | t += _(' (clean)') |
|
6709 | t += _(' (clean)') | |
6700 | cleanworkdir = True |
|
6710 | cleanworkdir = True | |
6701 | elif pnode not in bheads: |
|
6711 | elif pnode not in bheads: | |
6702 | t += _(' (new branch head)') |
|
6712 | t += _(' (new branch head)') | |
6703 |
|
6713 | |||
6704 | if parents: |
|
6714 | if parents: | |
6705 | pendingphase = max(p.phase() for p in parents) |
|
6715 | pendingphase = max(p.phase() for p in parents) | |
6706 | else: |
|
6716 | else: | |
6707 | pendingphase = phases.public |
|
6717 | pendingphase = phases.public | |
6708 |
|
6718 | |||
6709 | if pendingphase > phases.newcommitphase(ui): |
|
6719 | if pendingphase > phases.newcommitphase(ui): | |
6710 | t += ' (%s)' % phases.phasenames[pendingphase] |
|
6720 | t += ' (%s)' % phases.phasenames[pendingphase] | |
6711 |
|
6721 | |||
6712 | if cleanworkdir: |
|
6722 | if cleanworkdir: | |
6713 | # i18n: column positioning for "hg summary" |
|
6723 | # i18n: column positioning for "hg summary" | |
6714 | ui.status(_('commit: %s\n') % t.strip()) |
|
6724 | ui.status(_('commit: %s\n') % t.strip()) | |
6715 | else: |
|
6725 | else: | |
6716 | # i18n: column positioning for "hg summary" |
|
6726 | # i18n: column positioning for "hg summary" | |
6717 | ui.write(_('commit: %s\n') % t.strip()) |
|
6727 | ui.write(_('commit: %s\n') % t.strip()) | |
6718 |
|
6728 | |||
6719 | # all ancestors of branch heads - all ancestors of parent = new csets |
|
6729 | # all ancestors of branch heads - all ancestors of parent = new csets | |
6720 | new = len(repo.changelog.findmissing([pctx.node() for pctx in parents], |
|
6730 | new = len(repo.changelog.findmissing([pctx.node() for pctx in parents], | |
6721 | bheads)) |
|
6731 | bheads)) | |
6722 |
|
6732 | |||
6723 | if new == 0: |
|
6733 | if new == 0: | |
6724 | # i18n: column positioning for "hg summary" |
|
6734 | # i18n: column positioning for "hg summary" | |
6725 | ui.status(_('update: (current)\n')) |
|
6735 | ui.status(_('update: (current)\n')) | |
6726 | elif pnode not in bheads: |
|
6736 | elif pnode not in bheads: | |
6727 | # i18n: column positioning for "hg summary" |
|
6737 | # i18n: column positioning for "hg summary" | |
6728 | ui.write(_('update: %d new changesets (update)\n') % new) |
|
6738 | ui.write(_('update: %d new changesets (update)\n') % new) | |
6729 | else: |
|
6739 | else: | |
6730 | # i18n: column positioning for "hg summary" |
|
6740 | # i18n: column positioning for "hg summary" | |
6731 | ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % |
|
6741 | ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % | |
6732 | (new, len(bheads))) |
|
6742 | (new, len(bheads))) | |
6733 |
|
6743 | |||
6734 | t = [] |
|
6744 | t = [] | |
6735 | draft = len(repo.revs('draft()')) |
|
6745 | draft = len(repo.revs('draft()')) | |
6736 | if draft: |
|
6746 | if draft: | |
6737 | t.append(_('%d draft') % draft) |
|
6747 | t.append(_('%d draft') % draft) | |
6738 | secret = len(repo.revs('secret()')) |
|
6748 | secret = len(repo.revs('secret()')) | |
6739 | if secret: |
|
6749 | if secret: | |
6740 | t.append(_('%d secret') % secret) |
|
6750 | t.append(_('%d secret') % secret) | |
6741 |
|
6751 | |||
6742 | if draft or secret: |
|
6752 | if draft or secret: | |
6743 | ui.status(_('phases: %s\n') % ', '.join(t)) |
|
6753 | ui.status(_('phases: %s\n') % ', '.join(t)) | |
6744 |
|
6754 | |||
6745 | if obsolete.isenabled(repo, obsolete.createmarkersopt): |
|
6755 | if obsolete.isenabled(repo, obsolete.createmarkersopt): | |
6746 | for trouble in ("unstable", "divergent", "bumped"): |
|
6756 | for trouble in ("unstable", "divergent", "bumped"): | |
6747 | numtrouble = len(repo.revs(trouble + "()")) |
|
6757 | numtrouble = len(repo.revs(trouble + "()")) | |
6748 | # We write all the possibilities to ease translation |
|
6758 | # We write all the possibilities to ease translation | |
6749 | troublemsg = { |
|
6759 | troublemsg = { | |
6750 | "unstable": _("unstable: %d changesets"), |
|
6760 | "unstable": _("unstable: %d changesets"), | |
6751 | "divergent": _("divergent: %d changesets"), |
|
6761 | "divergent": _("divergent: %d changesets"), | |
6752 | "bumped": _("bumped: %d changesets"), |
|
6762 | "bumped": _("bumped: %d changesets"), | |
6753 | } |
|
6763 | } | |
6754 | if numtrouble > 0: |
|
6764 | if numtrouble > 0: | |
6755 | ui.status(troublemsg[trouble] % numtrouble + "\n") |
|
6765 | ui.status(troublemsg[trouble] % numtrouble + "\n") | |
6756 |
|
6766 | |||
6757 | cmdutil.summaryhooks(ui, repo) |
|
6767 | cmdutil.summaryhooks(ui, repo) | |
6758 |
|
6768 | |||
6759 | if opts.get('remote'): |
|
6769 | if opts.get('remote'): | |
6760 | needsincoming, needsoutgoing = True, True |
|
6770 | needsincoming, needsoutgoing = True, True | |
6761 | else: |
|
6771 | else: | |
6762 | needsincoming, needsoutgoing = False, False |
|
6772 | needsincoming, needsoutgoing = False, False | |
6763 | for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None): |
|
6773 | for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None): | |
6764 | if i: |
|
6774 | if i: | |
6765 | needsincoming = True |
|
6775 | needsincoming = True | |
6766 | if o: |
|
6776 | if o: | |
6767 | needsoutgoing = True |
|
6777 | needsoutgoing = True | |
6768 | if not needsincoming and not needsoutgoing: |
|
6778 | if not needsincoming and not needsoutgoing: | |
6769 | return |
|
6779 | return | |
6770 |
|
6780 | |||
6771 | def getincoming(): |
|
6781 | def getincoming(): | |
6772 | source, branches = hg.parseurl(ui.expandpath('default')) |
|
6782 | source, branches = hg.parseurl(ui.expandpath('default')) | |
6773 | sbranch = branches[0] |
|
6783 | sbranch = branches[0] | |
6774 | try: |
|
6784 | try: | |
6775 | other = hg.peer(repo, {}, source) |
|
6785 | other = hg.peer(repo, {}, source) | |
6776 | except error.RepoError: |
|
6786 | except error.RepoError: | |
6777 | if opts.get('remote'): |
|
6787 | if opts.get('remote'): | |
6778 | raise |
|
6788 | raise | |
6779 | return source, sbranch, None, None, None |
|
6789 | return source, sbranch, None, None, None | |
6780 | revs, checkout = hg.addbranchrevs(repo, other, branches, None) |
|
6790 | revs, checkout = hg.addbranchrevs(repo, other, branches, None) | |
6781 | if revs: |
|
6791 | if revs: | |
6782 | revs = [other.lookup(rev) for rev in revs] |
|
6792 | revs = [other.lookup(rev) for rev in revs] | |
6783 | ui.debug('comparing with %s\n' % util.hidepassword(source)) |
|
6793 | ui.debug('comparing with %s\n' % util.hidepassword(source)) | |
6784 | repo.ui.pushbuffer() |
|
6794 | repo.ui.pushbuffer() | |
6785 | commoninc = discovery.findcommonincoming(repo, other, heads=revs) |
|
6795 | commoninc = discovery.findcommonincoming(repo, other, heads=revs) | |
6786 | repo.ui.popbuffer() |
|
6796 | repo.ui.popbuffer() | |
6787 | return source, sbranch, other, commoninc, commoninc[1] |
|
6797 | return source, sbranch, other, commoninc, commoninc[1] | |
6788 |
|
6798 | |||
6789 | if needsincoming: |
|
6799 | if needsincoming: | |
6790 | source, sbranch, sother, commoninc, incoming = getincoming() |
|
6800 | source, sbranch, sother, commoninc, incoming = getincoming() | |
6791 | else: |
|
6801 | else: | |
6792 | source = sbranch = sother = commoninc = incoming = None |
|
6802 | source = sbranch = sother = commoninc = incoming = None | |
6793 |
|
6803 | |||
6794 | def getoutgoing(): |
|
6804 | def getoutgoing(): | |
6795 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
|
6805 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) | |
6796 | dbranch = branches[0] |
|
6806 | dbranch = branches[0] | |
6797 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
6807 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |
6798 | if source != dest: |
|
6808 | if source != dest: | |
6799 | try: |
|
6809 | try: | |
6800 | dother = hg.peer(repo, {}, dest) |
|
6810 | dother = hg.peer(repo, {}, dest) | |
6801 | except error.RepoError: |
|
6811 | except error.RepoError: | |
6802 | if opts.get('remote'): |
|
6812 | if opts.get('remote'): | |
6803 | raise |
|
6813 | raise | |
6804 | return dest, dbranch, None, None |
|
6814 | return dest, dbranch, None, None | |
6805 | ui.debug('comparing with %s\n' % util.hidepassword(dest)) |
|
6815 | ui.debug('comparing with %s\n' % util.hidepassword(dest)) | |
6806 | elif sother is None: |
|
6816 | elif sother is None: | |
6807 | # there is no explicit destination peer, but source one is invalid |
|
6817 | # there is no explicit destination peer, but source one is invalid | |
6808 | return dest, dbranch, None, None |
|
6818 | return dest, dbranch, None, None | |
6809 | else: |
|
6819 | else: | |
6810 | dother = sother |
|
6820 | dother = sother | |
6811 | if (source != dest or (sbranch is not None and sbranch != dbranch)): |
|
6821 | if (source != dest or (sbranch is not None and sbranch != dbranch)): | |
6812 | common = None |
|
6822 | common = None | |
6813 | else: |
|
6823 | else: | |
6814 | common = commoninc |
|
6824 | common = commoninc | |
6815 | if revs: |
|
6825 | if revs: | |
6816 | revs = [repo.lookup(rev) for rev in revs] |
|
6826 | revs = [repo.lookup(rev) for rev in revs] | |
6817 | repo.ui.pushbuffer() |
|
6827 | repo.ui.pushbuffer() | |
6818 | outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs, |
|
6828 | outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs, | |
6819 | commoninc=common) |
|
6829 | commoninc=common) | |
6820 | repo.ui.popbuffer() |
|
6830 | repo.ui.popbuffer() | |
6821 | return dest, dbranch, dother, outgoing |
|
6831 | return dest, dbranch, dother, outgoing | |
6822 |
|
6832 | |||
6823 | if needsoutgoing: |
|
6833 | if needsoutgoing: | |
6824 | dest, dbranch, dother, outgoing = getoutgoing() |
|
6834 | dest, dbranch, dother, outgoing = getoutgoing() | |
6825 | else: |
|
6835 | else: | |
6826 | dest = dbranch = dother = outgoing = None |
|
6836 | dest = dbranch = dother = outgoing = None | |
6827 |
|
6837 | |||
6828 | if opts.get('remote'): |
|
6838 | if opts.get('remote'): | |
6829 | t = [] |
|
6839 | t = [] | |
6830 | if incoming: |
|
6840 | if incoming: | |
6831 | t.append(_('1 or more incoming')) |
|
6841 | t.append(_('1 or more incoming')) | |
6832 | o = outgoing.missing |
|
6842 | o = outgoing.missing | |
6833 | if o: |
|
6843 | if o: | |
6834 | t.append(_('%d outgoing') % len(o)) |
|
6844 | t.append(_('%d outgoing') % len(o)) | |
6835 | other = dother or sother |
|
6845 | other = dother or sother | |
6836 | if 'bookmarks' in other.listkeys('namespaces'): |
|
6846 | if 'bookmarks' in other.listkeys('namespaces'): | |
6837 | counts = bookmarks.summary(repo, other) |
|
6847 | counts = bookmarks.summary(repo, other) | |
6838 | if counts[0] > 0: |
|
6848 | if counts[0] > 0: | |
6839 | t.append(_('%d incoming bookmarks') % counts[0]) |
|
6849 | t.append(_('%d incoming bookmarks') % counts[0]) | |
6840 | if counts[1] > 0: |
|
6850 | if counts[1] > 0: | |
6841 | t.append(_('%d outgoing bookmarks') % counts[1]) |
|
6851 | t.append(_('%d outgoing bookmarks') % counts[1]) | |
6842 |
|
6852 | |||
6843 | if t: |
|
6853 | if t: | |
6844 | # i18n: column positioning for "hg summary" |
|
6854 | # i18n: column positioning for "hg summary" | |
6845 | ui.write(_('remote: %s\n') % (', '.join(t))) |
|
6855 | ui.write(_('remote: %s\n') % (', '.join(t))) | |
6846 | else: |
|
6856 | else: | |
6847 | # i18n: column positioning for "hg summary" |
|
6857 | # i18n: column positioning for "hg summary" | |
6848 | ui.status(_('remote: (synced)\n')) |
|
6858 | ui.status(_('remote: (synced)\n')) | |
6849 |
|
6859 | |||
6850 | cmdutil.summaryremotehooks(ui, repo, opts, |
|
6860 | cmdutil.summaryremotehooks(ui, repo, opts, | |
6851 | ((source, sbranch, sother, commoninc), |
|
6861 | ((source, sbranch, sother, commoninc), | |
6852 | (dest, dbranch, dother, outgoing))) |
|
6862 | (dest, dbranch, dother, outgoing))) | |
6853 |
|
6863 | |||
6854 | @command('tag', |
|
6864 | @command('tag', | |
6855 | [('f', 'force', None, _('force tag')), |
|
6865 | [('f', 'force', None, _('force tag')), | |
6856 | ('l', 'local', None, _('make the tag local')), |
|
6866 | ('l', 'local', None, _('make the tag local')), | |
6857 | ('r', 'rev', '', _('revision to tag'), _('REV')), |
|
6867 | ('r', 'rev', '', _('revision to tag'), _('REV')), | |
6858 | ('', 'remove', None, _('remove a tag')), |
|
6868 | ('', 'remove', None, _('remove a tag')), | |
6859 | # -l/--local is already there, commitopts cannot be used |
|
6869 | # -l/--local is already there, commitopts cannot be used | |
6860 | ('e', 'edit', None, _('invoke editor on commit messages')), |
|
6870 | ('e', 'edit', None, _('invoke editor on commit messages')), | |
6861 | ('m', 'message', '', _('use text as commit message'), _('TEXT')), |
|
6871 | ('m', 'message', '', _('use text as commit message'), _('TEXT')), | |
6862 | ] + commitopts2, |
|
6872 | ] + commitopts2, | |
6863 | _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')) |
|
6873 | _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')) | |
6864 | def tag(ui, repo, name1, *names, **opts): |
|
6874 | def tag(ui, repo, name1, *names, **opts): | |
6865 | """add one or more tags for the current or given revision |
|
6875 | """add one or more tags for the current or given revision | |
6866 |
|
6876 | |||
6867 | Name a particular revision using <name>. |
|
6877 | Name a particular revision using <name>. | |
6868 |
|
6878 | |||
6869 | Tags are used to name particular revisions of the repository and are |
|
6879 | Tags are used to name particular revisions of the repository and are | |
6870 | very useful to compare different revisions, to go back to significant |
|
6880 | very useful to compare different revisions, to go back to significant | |
6871 | earlier versions or to mark branch points as releases, etc. Changing |
|
6881 | earlier versions or to mark branch points as releases, etc. Changing | |
6872 | an existing tag is normally disallowed; use -f/--force to override. |
|
6882 | an existing tag is normally disallowed; use -f/--force to override. | |
6873 |
|
6883 | |||
6874 | If no revision is given, the parent of the working directory is |
|
6884 | If no revision is given, the parent of the working directory is | |
6875 | used. |
|
6885 | used. | |
6876 |
|
6886 | |||
6877 | To facilitate version control, distribution, and merging of tags, |
|
6887 | To facilitate version control, distribution, and merging of tags, | |
6878 | they are stored as a file named ".hgtags" which is managed similarly |
|
6888 | they are stored as a file named ".hgtags" which is managed similarly | |
6879 | to other project files and can be hand-edited if necessary. This |
|
6889 | to other project files and can be hand-edited if necessary. This | |
6880 | also means that tagging creates a new commit. The file |
|
6890 | also means that tagging creates a new commit. The file | |
6881 | ".hg/localtags" is used for local tags (not shared among |
|
6891 | ".hg/localtags" is used for local tags (not shared among | |
6882 | repositories). |
|
6892 | repositories). | |
6883 |
|
6893 | |||
6884 | Tag commits are usually made at the head of a branch. If the parent |
|
6894 | Tag commits are usually made at the head of a branch. If the parent | |
6885 | of the working directory is not a branch head, :hg:`tag` aborts; use |
|
6895 | of the working directory is not a branch head, :hg:`tag` aborts; use | |
6886 | -f/--force to force the tag commit to be based on a non-head |
|
6896 | -f/--force to force the tag commit to be based on a non-head | |
6887 | changeset. |
|
6897 | changeset. | |
6888 |
|
6898 | |||
6889 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
6899 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
6890 |
|
6900 | |||
6891 | Since tag names have priority over branch names during revision |
|
6901 | Since tag names have priority over branch names during revision | |
6892 | lookup, using an existing branch name as a tag name is discouraged. |
|
6902 | lookup, using an existing branch name as a tag name is discouraged. | |
6893 |
|
6903 | |||
6894 | Returns 0 on success. |
|
6904 | Returns 0 on success. | |
6895 | """ |
|
6905 | """ | |
6896 | wlock = lock = None |
|
6906 | wlock = lock = None | |
6897 | try: |
|
6907 | try: | |
6898 | wlock = repo.wlock() |
|
6908 | wlock = repo.wlock() | |
6899 | lock = repo.lock() |
|
6909 | lock = repo.lock() | |
6900 | rev_ = "." |
|
6910 | rev_ = "." | |
6901 | names = [t.strip() for t in (name1,) + names] |
|
6911 | names = [t.strip() for t in (name1,) + names] | |
6902 | if len(names) != len(set(names)): |
|
6912 | if len(names) != len(set(names)): | |
6903 | raise error.Abort(_('tag names must be unique')) |
|
6913 | raise error.Abort(_('tag names must be unique')) | |
6904 | for n in names: |
|
6914 | for n in names: | |
6905 | scmutil.checknewlabel(repo, n, 'tag') |
|
6915 | scmutil.checknewlabel(repo, n, 'tag') | |
6906 | if not n: |
|
6916 | if not n: | |
6907 | raise error.Abort(_('tag names cannot consist entirely of ' |
|
6917 | raise error.Abort(_('tag names cannot consist entirely of ' | |
6908 | 'whitespace')) |
|
6918 | 'whitespace')) | |
6909 | if opts.get('rev') and opts.get('remove'): |
|
6919 | if opts.get('rev') and opts.get('remove'): | |
6910 | raise error.Abort(_("--rev and --remove are incompatible")) |
|
6920 | raise error.Abort(_("--rev and --remove are incompatible")) | |
6911 | if opts.get('rev'): |
|
6921 | if opts.get('rev'): | |
6912 | rev_ = opts['rev'] |
|
6922 | rev_ = opts['rev'] | |
6913 | message = opts.get('message') |
|
6923 | message = opts.get('message') | |
6914 | if opts.get('remove'): |
|
6924 | if opts.get('remove'): | |
6915 | if opts.get('local'): |
|
6925 | if opts.get('local'): | |
6916 | expectedtype = 'local' |
|
6926 | expectedtype = 'local' | |
6917 | else: |
|
6927 | else: | |
6918 | expectedtype = 'global' |
|
6928 | expectedtype = 'global' | |
6919 |
|
6929 | |||
6920 | for n in names: |
|
6930 | for n in names: | |
6921 | if not repo.tagtype(n): |
|
6931 | if not repo.tagtype(n): | |
6922 | raise error.Abort(_("tag '%s' does not exist") % n) |
|
6932 | raise error.Abort(_("tag '%s' does not exist") % n) | |
6923 | if repo.tagtype(n) != expectedtype: |
|
6933 | if repo.tagtype(n) != expectedtype: | |
6924 | if expectedtype == 'global': |
|
6934 | if expectedtype == 'global': | |
6925 | raise error.Abort(_("tag '%s' is not a global tag") % n) |
|
6935 | raise error.Abort(_("tag '%s' is not a global tag") % n) | |
6926 | else: |
|
6936 | else: | |
6927 | raise error.Abort(_("tag '%s' is not a local tag") % n) |
|
6937 | raise error.Abort(_("tag '%s' is not a local tag") % n) | |
6928 | rev_ = 'null' |
|
6938 | rev_ = 'null' | |
6929 | if not message: |
|
6939 | if not message: | |
6930 | # we don't translate commit messages |
|
6940 | # we don't translate commit messages | |
6931 | message = 'Removed tag %s' % ', '.join(names) |
|
6941 | message = 'Removed tag %s' % ', '.join(names) | |
6932 | elif not opts.get('force'): |
|
6942 | elif not opts.get('force'): | |
6933 | for n in names: |
|
6943 | for n in names: | |
6934 | if n in repo.tags(): |
|
6944 | if n in repo.tags(): | |
6935 | raise error.Abort(_("tag '%s' already exists " |
|
6945 | raise error.Abort(_("tag '%s' already exists " | |
6936 | "(use -f to force)") % n) |
|
6946 | "(use -f to force)") % n) | |
6937 | if not opts.get('local'): |
|
6947 | if not opts.get('local'): | |
6938 | p1, p2 = repo.dirstate.parents() |
|
6948 | p1, p2 = repo.dirstate.parents() | |
6939 | if p2 != nullid: |
|
6949 | if p2 != nullid: | |
6940 | raise error.Abort(_('uncommitted merge')) |
|
6950 | raise error.Abort(_('uncommitted merge')) | |
6941 | bheads = repo.branchheads() |
|
6951 | bheads = repo.branchheads() | |
6942 | if not opts.get('force') and bheads and p1 not in bheads: |
|
6952 | if not opts.get('force') and bheads and p1 not in bheads: | |
6943 | raise error.Abort(_('working directory is not at a branch head ' |
|
6953 | raise error.Abort(_('working directory is not at a branch head ' | |
6944 | '(use -f to force)')) |
|
6954 | '(use -f to force)')) | |
6945 | r = scmutil.revsingle(repo, rev_).node() |
|
6955 | r = scmutil.revsingle(repo, rev_).node() | |
6946 |
|
6956 | |||
6947 | if not message: |
|
6957 | if not message: | |
6948 | # we don't translate commit messages |
|
6958 | # we don't translate commit messages | |
6949 | message = ('Added tag %s for changeset %s' % |
|
6959 | message = ('Added tag %s for changeset %s' % | |
6950 | (', '.join(names), short(r))) |
|
6960 | (', '.join(names), short(r))) | |
6951 |
|
6961 | |||
6952 | date = opts.get('date') |
|
6962 | date = opts.get('date') | |
6953 | if date: |
|
6963 | if date: | |
6954 | date = util.parsedate(date) |
|
6964 | date = util.parsedate(date) | |
6955 |
|
6965 | |||
6956 | if opts.get('remove'): |
|
6966 | if opts.get('remove'): | |
6957 | editform = 'tag.remove' |
|
6967 | editform = 'tag.remove' | |
6958 | else: |
|
6968 | else: | |
6959 | editform = 'tag.add' |
|
6969 | editform = 'tag.add' | |
6960 | editor = cmdutil.getcommiteditor(editform=editform, **opts) |
|
6970 | editor = cmdutil.getcommiteditor(editform=editform, **opts) | |
6961 |
|
6971 | |||
6962 | # don't allow tagging the null rev |
|
6972 | # don't allow tagging the null rev | |
6963 | if (not opts.get('remove') and |
|
6973 | if (not opts.get('remove') and | |
6964 | scmutil.revsingle(repo, rev_).rev() == nullrev): |
|
6974 | scmutil.revsingle(repo, rev_).rev() == nullrev): | |
6965 | raise error.Abort(_("cannot tag null revision")) |
|
6975 | raise error.Abort(_("cannot tag null revision")) | |
6966 |
|
6976 | |||
6967 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date, |
|
6977 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date, | |
6968 | editor=editor) |
|
6978 | editor=editor) | |
6969 | finally: |
|
6979 | finally: | |
6970 | release(lock, wlock) |
|
6980 | release(lock, wlock) | |
6971 |
|
6981 | |||
6972 | @command('tags', formatteropts, '') |
|
6982 | @command('tags', formatteropts, '') | |
6973 | def tags(ui, repo, **opts): |
|
6983 | def tags(ui, repo, **opts): | |
6974 | """list repository tags |
|
6984 | """list repository tags | |
6975 |
|
6985 | |||
6976 | This lists both regular and local tags. When the -v/--verbose |
|
6986 | This lists both regular and local tags. When the -v/--verbose | |
6977 | switch is used, a third column "local" is printed for local tags. |
|
6987 | switch is used, a third column "local" is printed for local tags. | |
6978 | When the -q/--quiet switch is used, only the tag name is printed. |
|
6988 | When the -q/--quiet switch is used, only the tag name is printed. | |
6979 |
|
6989 | |||
6980 | Returns 0 on success. |
|
6990 | Returns 0 on success. | |
6981 | """ |
|
6991 | """ | |
6982 |
|
6992 | |||
6983 | fm = ui.formatter('tags', opts) |
|
6993 | fm = ui.formatter('tags', opts) | |
6984 | hexfunc = fm.hexfunc |
|
6994 | hexfunc = fm.hexfunc | |
6985 | tagtype = "" |
|
6995 | tagtype = "" | |
6986 |
|
6996 | |||
6987 | for t, n in reversed(repo.tagslist()): |
|
6997 | for t, n in reversed(repo.tagslist()): | |
6988 | hn = hexfunc(n) |
|
6998 | hn = hexfunc(n) | |
6989 | label = 'tags.normal' |
|
6999 | label = 'tags.normal' | |
6990 | tagtype = '' |
|
7000 | tagtype = '' | |
6991 | if repo.tagtype(t) == 'local': |
|
7001 | if repo.tagtype(t) == 'local': | |
6992 | label = 'tags.local' |
|
7002 | label = 'tags.local' | |
6993 | tagtype = 'local' |
|
7003 | tagtype = 'local' | |
6994 |
|
7004 | |||
6995 | fm.startitem() |
|
7005 | fm.startitem() | |
6996 | fm.write('tag', '%s', t, label=label) |
|
7006 | fm.write('tag', '%s', t, label=label) | |
6997 | fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s' |
|
7007 | fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s' | |
6998 | fm.condwrite(not ui.quiet, 'rev node', fmt, |
|
7008 | fm.condwrite(not ui.quiet, 'rev node', fmt, | |
6999 | repo.changelog.rev(n), hn, label=label) |
|
7009 | repo.changelog.rev(n), hn, label=label) | |
7000 | fm.condwrite(ui.verbose and tagtype, 'type', ' %s', |
|
7010 | fm.condwrite(ui.verbose and tagtype, 'type', ' %s', | |
7001 | tagtype, label=label) |
|
7011 | tagtype, label=label) | |
7002 | fm.plain('\n') |
|
7012 | fm.plain('\n') | |
7003 | fm.end() |
|
7013 | fm.end() | |
7004 |
|
7014 | |||
7005 | @command('tip', |
|
7015 | @command('tip', | |
7006 | [('p', 'patch', None, _('show patch')), |
|
7016 | [('p', 'patch', None, _('show patch')), | |
7007 | ('g', 'git', None, _('use git extended diff format')), |
|
7017 | ('g', 'git', None, _('use git extended diff format')), | |
7008 | ] + templateopts, |
|
7018 | ] + templateopts, | |
7009 | _('[-p] [-g]')) |
|
7019 | _('[-p] [-g]')) | |
7010 | def tip(ui, repo, **opts): |
|
7020 | def tip(ui, repo, **opts): | |
7011 | """show the tip revision (DEPRECATED) |
|
7021 | """show the tip revision (DEPRECATED) | |
7012 |
|
7022 | |||
7013 | The tip revision (usually just called the tip) is the changeset |
|
7023 | The tip revision (usually just called the tip) is the changeset | |
7014 | most recently added to the repository (and therefore the most |
|
7024 | most recently added to the repository (and therefore the most | |
7015 | recently changed head). |
|
7025 | recently changed head). | |
7016 |
|
7026 | |||
7017 | If you have just made a commit, that commit will be the tip. If |
|
7027 | If you have just made a commit, that commit will be the tip. If | |
7018 | you have just pulled changes from another repository, the tip of |
|
7028 | you have just pulled changes from another repository, the tip of | |
7019 | that repository becomes the current tip. The "tip" tag is special |
|
7029 | that repository becomes the current tip. The "tip" tag is special | |
7020 | and cannot be renamed or assigned to a different changeset. |
|
7030 | and cannot be renamed or assigned to a different changeset. | |
7021 |
|
7031 | |||
7022 | This command is deprecated, please use :hg:`heads` instead. |
|
7032 | This command is deprecated, please use :hg:`heads` instead. | |
7023 |
|
7033 | |||
7024 | Returns 0 on success. |
|
7034 | Returns 0 on success. | |
7025 | """ |
|
7035 | """ | |
7026 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
7036 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
7027 | displayer.show(repo['tip']) |
|
7037 | displayer.show(repo['tip']) | |
7028 | displayer.close() |
|
7038 | displayer.close() | |
7029 |
|
7039 | |||
7030 | @command('unbundle', |
|
7040 | @command('unbundle', | |
7031 | [('u', 'update', None, |
|
7041 | [('u', 'update', None, | |
7032 | _('update to new branch head if changesets were unbundled'))], |
|
7042 | _('update to new branch head if changesets were unbundled'))], | |
7033 | _('[-u] FILE...')) |
|
7043 | _('[-u] FILE...')) | |
7034 | def unbundle(ui, repo, fname1, *fnames, **opts): |
|
7044 | def unbundle(ui, repo, fname1, *fnames, **opts): | |
7035 | """apply one or more changegroup files |
|
7045 | """apply one or more changegroup files | |
7036 |
|
7046 | |||
7037 | Apply one or more compressed changegroup files generated by the |
|
7047 | Apply one or more compressed changegroup files generated by the | |
7038 | bundle command. |
|
7048 | bundle command. | |
7039 |
|
7049 | |||
7040 | Returns 0 on success, 1 if an update has unresolved files. |
|
7050 | Returns 0 on success, 1 if an update has unresolved files. | |
7041 | """ |
|
7051 | """ | |
7042 | fnames = (fname1,) + fnames |
|
7052 | fnames = (fname1,) + fnames | |
7043 |
|
7053 | |||
7044 | with repo.lock(): |
|
7054 | with repo.lock(): | |
7045 | for fname in fnames: |
|
7055 | for fname in fnames: | |
7046 | f = hg.openpath(ui, fname) |
|
7056 | f = hg.openpath(ui, fname) | |
7047 | gen = exchange.readbundle(ui, f, fname) |
|
7057 | gen = exchange.readbundle(ui, f, fname) | |
7048 | if isinstance(gen, bundle2.unbundle20): |
|
7058 | if isinstance(gen, bundle2.unbundle20): | |
7049 | tr = repo.transaction('unbundle') |
|
7059 | tr = repo.transaction('unbundle') | |
7050 | try: |
|
7060 | try: | |
7051 | op = bundle2.applybundle(repo, gen, tr, source='unbundle', |
|
7061 | op = bundle2.applybundle(repo, gen, tr, source='unbundle', | |
7052 | url='bundle:' + fname) |
|
7062 | url='bundle:' + fname) | |
7053 | tr.close() |
|
7063 | tr.close() | |
7054 | except error.BundleUnknownFeatureError as exc: |
|
7064 | except error.BundleUnknownFeatureError as exc: | |
7055 | raise error.Abort(_('%s: unknown bundle feature, %s') |
|
7065 | raise error.Abort(_('%s: unknown bundle feature, %s') | |
7056 | % (fname, exc), |
|
7066 | % (fname, exc), | |
7057 | hint=_("see https://mercurial-scm.org/" |
|
7067 | hint=_("see https://mercurial-scm.org/" | |
7058 | "wiki/BundleFeature for more " |
|
7068 | "wiki/BundleFeature for more " | |
7059 | "information")) |
|
7069 | "information")) | |
7060 | finally: |
|
7070 | finally: | |
7061 | if tr: |
|
7071 | if tr: | |
7062 | tr.release() |
|
7072 | tr.release() | |
7063 | changes = [r.get('return', 0) |
|
7073 | changes = [r.get('return', 0) | |
7064 | for r in op.records['changegroup']] |
|
7074 | for r in op.records['changegroup']] | |
7065 | modheads = changegroup.combineresults(changes) |
|
7075 | modheads = changegroup.combineresults(changes) | |
7066 | elif isinstance(gen, streamclone.streamcloneapplier): |
|
7076 | elif isinstance(gen, streamclone.streamcloneapplier): | |
7067 | raise error.Abort( |
|
7077 | raise error.Abort( | |
7068 | _('packed bundles cannot be applied with ' |
|
7078 | _('packed bundles cannot be applied with ' | |
7069 | '"hg unbundle"'), |
|
7079 | '"hg unbundle"'), | |
7070 | hint=_('use "hg debugapplystreamclonebundle"')) |
|
7080 | hint=_('use "hg debugapplystreamclonebundle"')) | |
7071 | else: |
|
7081 | else: | |
7072 | modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname) |
|
7082 | modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname) | |
7073 |
|
7083 | |||
7074 | return postincoming(ui, repo, modheads, opts.get('update'), None, None) |
|
7084 | return postincoming(ui, repo, modheads, opts.get('update'), None, None) | |
7075 |
|
7085 | |||
7076 | @command('^update|up|checkout|co', |
|
7086 | @command('^update|up|checkout|co', | |
7077 | [('C', 'clean', None, _('discard uncommitted changes (no backup)')), |
|
7087 | [('C', 'clean', None, _('discard uncommitted changes (no backup)')), | |
7078 | ('c', 'check', None, _('require clean working directory')), |
|
7088 | ('c', 'check', None, _('require clean working directory')), | |
7079 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
|
7089 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), | |
7080 | ('r', 'rev', '', _('revision'), _('REV')) |
|
7090 | ('r', 'rev', '', _('revision'), _('REV')) | |
7081 | ] + mergetoolopts, |
|
7091 | ] + mergetoolopts, | |
7082 | _('[-c] [-C] [-d DATE] [[-r] REV]')) |
|
7092 | _('[-c] [-C] [-d DATE] [[-r] REV]')) | |
7083 | def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False, |
|
7093 | def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False, | |
7084 | tool=None): |
|
7094 | tool=None): | |
7085 | """update working directory (or switch revisions) |
|
7095 | """update working directory (or switch revisions) | |
7086 |
|
7096 | |||
7087 | Update the repository's working directory to the specified |
|
7097 | Update the repository's working directory to the specified | |
7088 | changeset. If no changeset is specified, update to the tip of the |
|
7098 | changeset. If no changeset is specified, update to the tip of the | |
7089 | current named branch and move the active bookmark (see :hg:`help |
|
7099 | current named branch and move the active bookmark (see :hg:`help | |
7090 | bookmarks`). |
|
7100 | bookmarks`). | |
7091 |
|
7101 | |||
7092 | Update sets the working directory's parent revision to the specified |
|
7102 | Update sets the working directory's parent revision to the specified | |
7093 | changeset (see :hg:`help parents`). |
|
7103 | changeset (see :hg:`help parents`). | |
7094 |
|
7104 | |||
7095 | If the changeset is not a descendant or ancestor of the working |
|
7105 | If the changeset is not a descendant or ancestor of the working | |
7096 | directory's parent, the update is aborted. With the -c/--check |
|
7106 | directory's parent, the update is aborted. With the -c/--check | |
7097 | option, the working directory is checked for uncommitted changes; if |
|
7107 | option, the working directory is checked for uncommitted changes; if | |
7098 | none are found, the working directory is updated to the specified |
|
7108 | none are found, the working directory is updated to the specified | |
7099 | changeset. |
|
7109 | changeset. | |
7100 |
|
7110 | |||
7101 | .. container:: verbose |
|
7111 | .. container:: verbose | |
7102 |
|
7112 | |||
7103 | The following rules apply when the working directory contains |
|
7113 | The following rules apply when the working directory contains | |
7104 | uncommitted changes: |
|
7114 | uncommitted changes: | |
7105 |
|
7115 | |||
7106 | 1. If neither -c/--check nor -C/--clean is specified, and if |
|
7116 | 1. If neither -c/--check nor -C/--clean is specified, and if | |
7107 | the requested changeset is an ancestor or descendant of |
|
7117 | the requested changeset is an ancestor or descendant of | |
7108 | the working directory's parent, the uncommitted changes |
|
7118 | the working directory's parent, the uncommitted changes | |
7109 | are merged into the requested changeset and the merged |
|
7119 | are merged into the requested changeset and the merged | |
7110 | result is left uncommitted. If the requested changeset is |
|
7120 | result is left uncommitted. If the requested changeset is | |
7111 | not an ancestor or descendant (that is, it is on another |
|
7121 | not an ancestor or descendant (that is, it is on another | |
7112 | branch), the update is aborted and the uncommitted changes |
|
7122 | branch), the update is aborted and the uncommitted changes | |
7113 | are preserved. |
|
7123 | are preserved. | |
7114 |
|
7124 | |||
7115 | 2. With the -c/--check option, the update is aborted and the |
|
7125 | 2. With the -c/--check option, the update is aborted and the | |
7116 | uncommitted changes are preserved. |
|
7126 | uncommitted changes are preserved. | |
7117 |
|
7127 | |||
7118 | 3. With the -C/--clean option, uncommitted changes are discarded and |
|
7128 | 3. With the -C/--clean option, uncommitted changes are discarded and | |
7119 | the working directory is updated to the requested changeset. |
|
7129 | the working directory is updated to the requested changeset. | |
7120 |
|
7130 | |||
7121 | To cancel an uncommitted merge (and lose your changes), use |
|
7131 | To cancel an uncommitted merge (and lose your changes), use | |
7122 | :hg:`update --clean .`. |
|
7132 | :hg:`update --clean .`. | |
7123 |
|
7133 | |||
7124 | Use null as the changeset to remove the working directory (like |
|
7134 | Use null as the changeset to remove the working directory (like | |
7125 | :hg:`clone -U`). |
|
7135 | :hg:`clone -U`). | |
7126 |
|
7136 | |||
7127 | If you want to revert just one file to an older revision, use |
|
7137 | If you want to revert just one file to an older revision, use | |
7128 | :hg:`revert [-r REV] NAME`. |
|
7138 | :hg:`revert [-r REV] NAME`. | |
7129 |
|
7139 | |||
7130 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
7140 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
7131 |
|
7141 | |||
7132 | Returns 0 on success, 1 if there are unresolved files. |
|
7142 | Returns 0 on success, 1 if there are unresolved files. | |
7133 | """ |
|
7143 | """ | |
7134 | if rev and node: |
|
7144 | if rev and node: | |
7135 | raise error.Abort(_("please specify just one revision")) |
|
7145 | raise error.Abort(_("please specify just one revision")) | |
7136 |
|
7146 | |||
7137 | if rev is None or rev == '': |
|
7147 | if rev is None or rev == '': | |
7138 | rev = node |
|
7148 | rev = node | |
7139 |
|
7149 | |||
7140 | if date and rev is not None: |
|
7150 | if date and rev is not None: | |
7141 | raise error.Abort(_("you can't specify a revision and a date")) |
|
7151 | raise error.Abort(_("you can't specify a revision and a date")) | |
7142 |
|
7152 | |||
7143 | if check and clean: |
|
7153 | if check and clean: | |
7144 | raise error.Abort(_("cannot specify both -c/--check and -C/--clean")) |
|
7154 | raise error.Abort(_("cannot specify both -c/--check and -C/--clean")) | |
7145 |
|
7155 | |||
7146 | with repo.wlock(): |
|
7156 | with repo.wlock(): | |
7147 | cmdutil.clearunfinished(repo) |
|
7157 | cmdutil.clearunfinished(repo) | |
7148 |
|
7158 | |||
7149 | if date: |
|
7159 | if date: | |
7150 | rev = cmdutil.finddate(ui, repo, date) |
|
7160 | rev = cmdutil.finddate(ui, repo, date) | |
7151 |
|
7161 | |||
7152 | # if we defined a bookmark, we have to remember the original name |
|
7162 | # if we defined a bookmark, we have to remember the original name | |
7153 | brev = rev |
|
7163 | brev = rev | |
7154 | rev = scmutil.revsingle(repo, rev, rev).rev() |
|
7164 | rev = scmutil.revsingle(repo, rev, rev).rev() | |
7155 |
|
7165 | |||
7156 | if check: |
|
7166 | if check: | |
7157 | cmdutil.bailifchanged(repo, merge=False) |
|
7167 | cmdutil.bailifchanged(repo, merge=False) | |
7158 |
|
7168 | |||
7159 | repo.ui.setconfig('ui', 'forcemerge', tool, 'update') |
|
7169 | repo.ui.setconfig('ui', 'forcemerge', tool, 'update') | |
7160 |
|
7170 | |||
7161 | return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check) |
|
7171 | return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check) | |
7162 |
|
7172 | |||
7163 | @command('verify', []) |
|
7173 | @command('verify', []) | |
7164 | def verify(ui, repo): |
|
7174 | def verify(ui, repo): | |
7165 | """verify the integrity of the repository |
|
7175 | """verify the integrity of the repository | |
7166 |
|
7176 | |||
7167 | Verify the integrity of the current repository. |
|
7177 | Verify the integrity of the current repository. | |
7168 |
|
7178 | |||
7169 | This will perform an extensive check of the repository's |
|
7179 | This will perform an extensive check of the repository's | |
7170 | integrity, validating the hashes and checksums of each entry in |
|
7180 | integrity, validating the hashes and checksums of each entry in | |
7171 | the changelog, manifest, and tracked files, as well as the |
|
7181 | the changelog, manifest, and tracked files, as well as the | |
7172 | integrity of their crosslinks and indices. |
|
7182 | integrity of their crosslinks and indices. | |
7173 |
|
7183 | |||
7174 | Please see https://mercurial-scm.org/wiki/RepositoryCorruption |
|
7184 | Please see https://mercurial-scm.org/wiki/RepositoryCorruption | |
7175 | for more information about recovery from corruption of the |
|
7185 | for more information about recovery from corruption of the | |
7176 | repository. |
|
7186 | repository. | |
7177 |
|
7187 | |||
7178 | Returns 0 on success, 1 if errors are encountered. |
|
7188 | Returns 0 on success, 1 if errors are encountered. | |
7179 | """ |
|
7189 | """ | |
7180 | return hg.verify(repo) |
|
7190 | return hg.verify(repo) | |
7181 |
|
7191 | |||
7182 | @command('version', [] + formatteropts, norepo=True) |
|
7192 | @command('version', [] + formatteropts, norepo=True) | |
7183 | def version_(ui, **opts): |
|
7193 | def version_(ui, **opts): | |
7184 | """output version and copyright information""" |
|
7194 | """output version and copyright information""" | |
7185 | fm = ui.formatter("version", opts) |
|
7195 | fm = ui.formatter("version", opts) | |
7186 | fm.startitem() |
|
7196 | fm.startitem() | |
7187 | fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"), |
|
7197 | fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"), | |
7188 | util.version()) |
|
7198 | util.version()) | |
7189 | license = _( |
|
7199 | license = _( | |
7190 | "(see https://mercurial-scm.org for more information)\n" |
|
7200 | "(see https://mercurial-scm.org for more information)\n" | |
7191 | "\nCopyright (C) 2005-2016 Matt Mackall and others\n" |
|
7201 | "\nCopyright (C) 2005-2016 Matt Mackall and others\n" | |
7192 | "This is free software; see the source for copying conditions. " |
|
7202 | "This is free software; see the source for copying conditions. " | |
7193 | "There is NO\nwarranty; " |
|
7203 | "There is NO\nwarranty; " | |
7194 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
7204 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | |
7195 | ) |
|
7205 | ) | |
7196 | if not ui.quiet: |
|
7206 | if not ui.quiet: | |
7197 | fm.plain(license) |
|
7207 | fm.plain(license) | |
7198 |
|
7208 | |||
7199 | if ui.verbose: |
|
7209 | if ui.verbose: | |
7200 | fm.plain(_("\nEnabled extensions:\n\n")) |
|
7210 | fm.plain(_("\nEnabled extensions:\n\n")) | |
7201 | # format names and versions into columns |
|
7211 | # format names and versions into columns | |
7202 | names = [] |
|
7212 | names = [] | |
7203 | vers = [] |
|
7213 | vers = [] | |
7204 | isinternals = [] |
|
7214 | isinternals = [] | |
7205 | for name, module in extensions.extensions(): |
|
7215 | for name, module in extensions.extensions(): | |
7206 | names.append(name) |
|
7216 | names.append(name) | |
7207 | vers.append(extensions.moduleversion(module) or None) |
|
7217 | vers.append(extensions.moduleversion(module) or None) | |
7208 | isinternals.append(extensions.ismoduleinternal(module)) |
|
7218 | isinternals.append(extensions.ismoduleinternal(module)) | |
7209 | fn = fm.nested("extensions") |
|
7219 | fn = fm.nested("extensions") | |
7210 | if names: |
|
7220 | if names: | |
7211 | namefmt = " %%-%ds " % max(len(n) for n in names) |
|
7221 | namefmt = " %%-%ds " % max(len(n) for n in names) | |
7212 | places = [_("external"), _("internal")] |
|
7222 | places = [_("external"), _("internal")] | |
7213 | for n, v, p in zip(names, vers, isinternals): |
|
7223 | for n, v, p in zip(names, vers, isinternals): | |
7214 | fn.startitem() |
|
7224 | fn.startitem() | |
7215 | fn.condwrite(ui.verbose, "name", namefmt, n) |
|
7225 | fn.condwrite(ui.verbose, "name", namefmt, n) | |
7216 | if ui.verbose: |
|
7226 | if ui.verbose: | |
7217 | fn.plain("%s " % places[p]) |
|
7227 | fn.plain("%s " % places[p]) | |
7218 | fn.data(bundled=p) |
|
7228 | fn.data(bundled=p) | |
7219 | fn.condwrite(ui.verbose and v, "ver", "%s", v) |
|
7229 | fn.condwrite(ui.verbose and v, "ver", "%s", v) | |
7220 | if ui.verbose: |
|
7230 | if ui.verbose: | |
7221 | fn.plain("\n") |
|
7231 | fn.plain("\n") | |
7222 | fn.end() |
|
7232 | fn.end() | |
7223 | fm.end() |
|
7233 | fm.end() | |
7224 |
|
7234 | |||
7225 | def loadcmdtable(ui, name, cmdtable): |
|
7235 | def loadcmdtable(ui, name, cmdtable): | |
7226 | """Load command functions from specified cmdtable |
|
7236 | """Load command functions from specified cmdtable | |
7227 | """ |
|
7237 | """ | |
7228 | overrides = [cmd for cmd in cmdtable if cmd in table] |
|
7238 | overrides = [cmd for cmd in cmdtable if cmd in table] | |
7229 | if overrides: |
|
7239 | if overrides: | |
7230 | ui.warn(_("extension '%s' overrides commands: %s\n") |
|
7240 | ui.warn(_("extension '%s' overrides commands: %s\n") | |
7231 | % (name, " ".join(overrides))) |
|
7241 | % (name, " ".join(overrides))) | |
7232 | table.update(cmdtable) |
|
7242 | table.update(cmdtable) |
@@ -1,163 +1,171 b'' | |||||
1 | hg debuginstall |
|
1 | hg debuginstall | |
2 | $ hg debuginstall |
|
2 | $ hg debuginstall | |
3 | checking encoding (ascii)... |
|
3 | checking encoding (ascii)... | |
4 | checking Python executable (*) (glob) |
|
4 | checking Python executable (*) (glob) | |
5 | checking Python version (2.*) (glob) |
|
5 | checking Python version (2.*) (glob) | |
6 | checking Python lib (*lib*)... (glob) |
|
6 | checking Python lib (*lib*)... (glob) | |
7 | checking Python security support (*) (glob) |
|
7 | checking Python security support (*) (glob) | |
8 | TLS 1.2 not supported by Python install; network connections lack modern security (?) |
|
8 | TLS 1.2 not supported by Python install; network connections lack modern security (?) | |
9 | SNI not supported by Python install; may have connectivity issues with some servers (?) |
|
9 | SNI not supported by Python install; may have connectivity issues with some servers (?) | |
10 | checking Mercurial version (*) (glob) |
|
10 | checking Mercurial version (*) (glob) | |
11 | checking Mercurial custom build (*) (glob) |
|
11 | checking Mercurial custom build (*) (glob) | |
12 | checking module policy (*) (glob) |
|
12 | checking module policy (*) (glob) | |
13 | checking installed modules (*mercurial)... (glob) |
|
13 | checking installed modules (*mercurial)... (glob) | |
|
14 | checking registered compression engines (*zlib*) (glob) | |||
|
15 | checking available compression engines (*zlib*) (glob) | |||
14 | checking templates (*mercurial?templates)... (glob) |
|
16 | checking templates (*mercurial?templates)... (glob) | |
15 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
17 | checking default template (*mercurial?templates?map-cmdline.default) (glob) | |
16 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) |
|
18 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) | |
17 | checking username (test) |
|
19 | checking username (test) | |
18 | no problems detected |
|
20 | no problems detected | |
19 |
|
21 | |||
20 | hg debuginstall JSON |
|
22 | hg debuginstall JSON | |
21 | $ hg debuginstall -Tjson | sed 's|\\\\|\\|g' |
|
23 | $ hg debuginstall -Tjson | sed 's|\\\\|\\|g' | |
22 | [ |
|
24 | [ | |
23 | { |
|
25 | { | |
|
26 | "compengines": ["bz2", "bz2truncated", "none", "zlib"*], (glob) | |||
|
27 | "compenginesavail": ["bz2", "bz2truncated", "none", "zlib"*], (glob) | |||
24 | "defaulttemplate": "*mercurial?templates?map-cmdline.default", (glob) |
|
28 | "defaulttemplate": "*mercurial?templates?map-cmdline.default", (glob) | |
25 | "defaulttemplateerror": null, |
|
29 | "defaulttemplateerror": null, | |
26 | "defaulttemplatenotfound": "default", |
|
30 | "defaulttemplatenotfound": "default", | |
27 | "editor": "* -c \"import sys; sys.exit(0)\"", (glob) |
|
31 | "editor": "* -c \"import sys; sys.exit(0)\"", (glob) | |
28 | "editornotfound": false, |
|
32 | "editornotfound": false, | |
29 | "encoding": "ascii", |
|
33 | "encoding": "ascii", | |
30 | "encodingerror": null, |
|
34 | "encodingerror": null, | |
31 | "extensionserror": null, |
|
35 | "extensionserror": null, | |
32 | "hgmodulepolicy": "*", (glob) |
|
36 | "hgmodulepolicy": "*", (glob) | |
33 | "hgmodules": "*mercurial", (glob) |
|
37 | "hgmodules": "*mercurial", (glob) | |
34 | "hgver": "*", (glob) |
|
38 | "hgver": "*", (glob) | |
35 | "hgverextra": "*", (glob) |
|
39 | "hgverextra": "*", (glob) | |
36 | "problems": 0, |
|
40 | "problems": 0, | |
37 | "pythonexe": "*", (glob) |
|
41 | "pythonexe": "*", (glob) | |
38 | "pythonlib": "*", (glob) |
|
42 | "pythonlib": "*", (glob) | |
39 | "pythonsecurity": [*], (glob) |
|
43 | "pythonsecurity": [*], (glob) | |
40 | "pythonver": "*.*.*", (glob) |
|
44 | "pythonver": "*.*.*", (glob) | |
41 | "templatedirs": "*mercurial?templates", (glob) |
|
45 | "templatedirs": "*mercurial?templates", (glob) | |
42 | "username": "test", |
|
46 | "username": "test", | |
43 | "usernameerror": null, |
|
47 | "usernameerror": null, | |
44 | "vinotfound": false |
|
48 | "vinotfound": false | |
45 | } |
|
49 | } | |
46 | ] |
|
50 | ] | |
47 |
|
51 | |||
48 | hg debuginstall with no username |
|
52 | hg debuginstall with no username | |
49 | $ HGUSER= hg debuginstall |
|
53 | $ HGUSER= hg debuginstall | |
50 | checking encoding (ascii)... |
|
54 | checking encoding (ascii)... | |
51 | checking Python executable (*) (glob) |
|
55 | checking Python executable (*) (glob) | |
52 | checking Python version (2.*) (glob) |
|
56 | checking Python version (2.*) (glob) | |
53 | checking Python lib (*lib*)... (glob) |
|
57 | checking Python lib (*lib*)... (glob) | |
54 | checking Python security support (*) (glob) |
|
58 | checking Python security support (*) (glob) | |
55 | TLS 1.2 not supported by Python install; network connections lack modern security (?) |
|
59 | TLS 1.2 not supported by Python install; network connections lack modern security (?) | |
56 | SNI not supported by Python install; may have connectivity issues with some servers (?) |
|
60 | SNI not supported by Python install; may have connectivity issues with some servers (?) | |
57 | checking Mercurial version (*) (glob) |
|
61 | checking Mercurial version (*) (glob) | |
58 | checking Mercurial custom build (*) (glob) |
|
62 | checking Mercurial custom build (*) (glob) | |
59 | checking module policy (*) (glob) |
|
63 | checking module policy (*) (glob) | |
60 | checking installed modules (*mercurial)... (glob) |
|
64 | checking installed modules (*mercurial)... (glob) | |
|
65 | checking registered compression engines (*zlib*) (glob) | |||
|
66 | checking available compression engines (*zlib*) (glob) | |||
61 | checking templates (*mercurial?templates)... (glob) |
|
67 | checking templates (*mercurial?templates)... (glob) | |
62 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
68 | checking default template (*mercurial?templates?map-cmdline.default) (glob) | |
63 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) |
|
69 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) | |
64 | checking username... |
|
70 | checking username... | |
65 | no username supplied |
|
71 | no username supplied | |
66 | (specify a username in your configuration file) |
|
72 | (specify a username in your configuration file) | |
67 | 1 problems detected, please check your install! |
|
73 | 1 problems detected, please check your install! | |
68 | [1] |
|
74 | [1] | |
69 |
|
75 | |||
70 | path variables are expanded (~ is the same as $TESTTMP) |
|
76 | path variables are expanded (~ is the same as $TESTTMP) | |
71 | $ mkdir tools |
|
77 | $ mkdir tools | |
72 | $ touch tools/testeditor.exe |
|
78 | $ touch tools/testeditor.exe | |
73 | #if execbit |
|
79 | #if execbit | |
74 | $ chmod 755 tools/testeditor.exe |
|
80 | $ chmod 755 tools/testeditor.exe | |
75 | #endif |
|
81 | #endif | |
76 | $ hg debuginstall --config ui.editor=~/tools/testeditor.exe |
|
82 | $ hg debuginstall --config ui.editor=~/tools/testeditor.exe | |
77 | checking encoding (ascii)... |
|
83 | checking encoding (ascii)... | |
78 | checking Python executable (*) (glob) |
|
84 | checking Python executable (*) (glob) | |
79 | checking Python version (*) (glob) |
|
85 | checking Python version (*) (glob) | |
80 | checking Python lib (*lib*)... (glob) |
|
86 | checking Python lib (*lib*)... (glob) | |
81 | checking Python security support (*) (glob) |
|
87 | checking Python security support (*) (glob) | |
82 | TLS 1.2 not supported by Python install; network connections lack modern security (?) |
|
88 | TLS 1.2 not supported by Python install; network connections lack modern security (?) | |
83 | SNI not supported by Python install; may have connectivity issues with some servers (?) |
|
89 | SNI not supported by Python install; may have connectivity issues with some servers (?) | |
84 | checking Mercurial version (*) (glob) |
|
90 | checking Mercurial version (*) (glob) | |
85 | checking Mercurial custom build (*) (glob) |
|
91 | checking Mercurial custom build (*) (glob) | |
86 | checking module policy (*) (glob) |
|
92 | checking module policy (*) (glob) | |
87 | checking installed modules (*mercurial)... (glob) |
|
93 | checking installed modules (*mercurial)... (glob) | |
|
94 | checking registered compression engines (*zlib*) (glob) | |||
|
95 | checking available compression engines (*zlib*) (glob) | |||
88 | checking templates (*mercurial?templates)... (glob) |
|
96 | checking templates (*mercurial?templates)... (glob) | |
89 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
97 | checking default template (*mercurial?templates?map-cmdline.default) (glob) | |
90 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) |
|
98 | checking commit editor... (* -c "import sys; sys.exit(0)") (glob) | |
91 | checking username (test) |
|
99 | checking username (test) | |
92 | no problems detected |
|
100 | no problems detected | |
93 |
|
101 | |||
94 | #if test-repo |
|
102 | #if test-repo | |
95 | $ . "$TESTDIR/helpers-testrepo.sh" |
|
103 | $ . "$TESTDIR/helpers-testrepo.sh" | |
96 |
|
104 | |||
97 | $ cat >> wixxml.py << EOF |
|
105 | $ cat >> wixxml.py << EOF | |
98 | > import os, subprocess, sys |
|
106 | > import os, subprocess, sys | |
99 | > import xml.etree.ElementTree as ET |
|
107 | > import xml.etree.ElementTree as ET | |
100 | > |
|
108 | > | |
101 | > # MSYS mangles the path if it expands $TESTDIR |
|
109 | > # MSYS mangles the path if it expands $TESTDIR | |
102 | > testdir = os.environ['TESTDIR'] |
|
110 | > testdir = os.environ['TESTDIR'] | |
103 | > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'} |
|
111 | > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'} | |
104 | > |
|
112 | > | |
105 | > def directory(node, relpath): |
|
113 | > def directory(node, relpath): | |
106 | > '''generator of files in the xml node, rooted at relpath''' |
|
114 | > '''generator of files in the xml node, rooted at relpath''' | |
107 | > dirs = node.findall('./{%(wix)s}Directory' % ns) |
|
115 | > dirs = node.findall('./{%(wix)s}Directory' % ns) | |
108 | > |
|
116 | > | |
109 | > for d in dirs: |
|
117 | > for d in dirs: | |
110 | > for subfile in directory(d, relpath + d.attrib['Name'] + '/'): |
|
118 | > for subfile in directory(d, relpath + d.attrib['Name'] + '/'): | |
111 | > yield subfile |
|
119 | > yield subfile | |
112 | > |
|
120 | > | |
113 | > files = node.findall('./{%(wix)s}Component/{%(wix)s}File' % ns) |
|
121 | > files = node.findall('./{%(wix)s}Component/{%(wix)s}File' % ns) | |
114 | > |
|
122 | > | |
115 | > for f in files: |
|
123 | > for f in files: | |
116 | > yield relpath + f.attrib['Name'] |
|
124 | > yield relpath + f.attrib['Name'] | |
117 | > |
|
125 | > | |
118 | > def hgdirectory(relpath): |
|
126 | > def hgdirectory(relpath): | |
119 | > '''generator of tracked files, rooted at relpath''' |
|
127 | > '''generator of tracked files, rooted at relpath''' | |
120 | > hgdir = "%s/../mercurial" % (testdir) |
|
128 | > hgdir = "%s/../mercurial" % (testdir) | |
121 | > args = ['hg', '--cwd', hgdir, 'files', relpath] |
|
129 | > args = ['hg', '--cwd', hgdir, 'files', relpath] | |
122 | > proc = subprocess.Popen(args, stdout=subprocess.PIPE, |
|
130 | > proc = subprocess.Popen(args, stdout=subprocess.PIPE, | |
123 | > stderr=subprocess.PIPE) |
|
131 | > stderr=subprocess.PIPE) | |
124 | > output = proc.communicate()[0] |
|
132 | > output = proc.communicate()[0] | |
125 | > |
|
133 | > | |
126 | > slash = '/' |
|
134 | > slash = '/' | |
127 | > for line in output.splitlines(): |
|
135 | > for line in output.splitlines(): | |
128 | > if os.name == 'nt': |
|
136 | > if os.name == 'nt': | |
129 | > yield line.replace(os.sep, slash) |
|
137 | > yield line.replace(os.sep, slash) | |
130 | > else: |
|
138 | > else: | |
131 | > yield line |
|
139 | > yield line | |
132 | > |
|
140 | > | |
133 | > tracked = [f for f in hgdirectory(sys.argv[1])] |
|
141 | > tracked = [f for f in hgdirectory(sys.argv[1])] | |
134 | > |
|
142 | > | |
135 | > xml = ET.parse("%s/../contrib/wix/%s.wxs" % (testdir, sys.argv[1])) |
|
143 | > xml = ET.parse("%s/../contrib/wix/%s.wxs" % (testdir, sys.argv[1])) | |
136 | > root = xml.getroot() |
|
144 | > root = xml.getroot() | |
137 | > dir = root.find('.//{%(wix)s}DirectoryRef' % ns) |
|
145 | > dir = root.find('.//{%(wix)s}DirectoryRef' % ns) | |
138 | > |
|
146 | > | |
139 | > installed = [f for f in directory(dir, '')] |
|
147 | > installed = [f for f in directory(dir, '')] | |
140 | > |
|
148 | > | |
141 | > print('Not installed:') |
|
149 | > print('Not installed:') | |
142 | > for f in sorted(set(tracked) - set(installed)): |
|
150 | > for f in sorted(set(tracked) - set(installed)): | |
143 | > print(' %s' % f) |
|
151 | > print(' %s' % f) | |
144 | > |
|
152 | > | |
145 | > print('Not tracked:') |
|
153 | > print('Not tracked:') | |
146 | > for f in sorted(set(installed) - set(tracked)): |
|
154 | > for f in sorted(set(installed) - set(tracked)): | |
147 | > print(' %s' % f) |
|
155 | > print(' %s' % f) | |
148 | > EOF |
|
156 | > EOF | |
149 |
|
157 | |||
150 | $ python wixxml.py help |
|
158 | $ python wixxml.py help | |
151 | Not installed: |
|
159 | Not installed: | |
152 | help/common.txt |
|
160 | help/common.txt | |
153 | help/hg-ssh.8.txt |
|
161 | help/hg-ssh.8.txt | |
154 | help/hg.1.txt |
|
162 | help/hg.1.txt | |
155 | help/hgignore.5.txt |
|
163 | help/hgignore.5.txt | |
156 | help/hgrc.5.txt |
|
164 | help/hgrc.5.txt | |
157 | Not tracked: |
|
165 | Not tracked: | |
158 |
|
166 | |||
159 | $ python wixxml.py templates |
|
167 | $ python wixxml.py templates | |
160 | Not installed: |
|
168 | Not installed: | |
161 | Not tracked: |
|
169 | Not tracked: | |
162 |
|
170 | |||
163 | #endif |
|
171 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now