Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 1615:83238c1db6de
Cleanup of indentation, spacing, newlines, strings and line length
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 12 Jan 2006 07:57:58 +0100 |
parents | d72d27ee72b9 |
children | ff339dd21976 |
comparison
equal
deleted
inserted
replaced
1614:0952d164030e | 1615:83238c1db6de |
---|---|
168 return defval | 168 return defval |
169 try: | 169 try: |
170 num = int(val) | 170 num = int(val) |
171 if str(num) != val: | 171 if str(num) != val: |
172 raise ValueError | 172 raise ValueError |
173 if num < 0: num += revcount | 173 if num < 0: |
174 if num < 0: num = 0 | 174 num += revcount |
175 if num < 0: | |
176 num = 0 | |
175 elif num >= revcount: | 177 elif num >= revcount: |
176 raise ValueError | 178 raise ValueError |
177 except ValueError: | 179 except ValueError: |
178 try: | 180 try: |
179 num = repo.changelog.rev(repo.lookup(val)) | 181 num = repo.changelog.rev(repo.lookup(val)) |
189 start, end = spec.split(revrangesep, 1) | 191 start, end = spec.split(revrangesep, 1) |
190 start = fix(start, 0) | 192 start = fix(start, 0) |
191 end = fix(end, revcount - 1) | 193 end = fix(end, revcount - 1) |
192 step = start > end and -1 or 1 | 194 step = start > end and -1 or 1 |
193 for rev in xrange(start, end+step, step): | 195 for rev in xrange(start, end+step, step): |
194 if rev in seen: continue | 196 if rev in seen: |
197 continue | |
195 seen[rev] = 1 | 198 seen[rev] = 1 |
196 yield str(rev) | 199 yield str(rev) |
197 else: | 200 else: |
198 rev = fix(spec, None) | 201 rev = fix(spec, None) |
199 if rev in seen: continue | 202 if rev in seen: |
203 continue | |
200 seen[rev] = 1 | 204 seen[rev] = 1 |
201 yield str(rev) | 205 yield str(rev) |
202 | 206 |
203 def make_filename(repo, r, pat, node=None, | 207 def make_filename(repo, r, pat, node=None, |
204 total=None, seqno=None, revwidth=None, pathname=None): | 208 total=None, seqno=None, revwidth=None, pathname=None): |
437 continue | 441 continue |
438 d = "" | 442 d = "" |
439 if e[0].__doc__: | 443 if e[0].__doc__: |
440 d = e[0].__doc__.splitlines(0)[0].rstrip() | 444 d = e[0].__doc__.splitlines(0)[0].rstrip() |
441 h[f] = d | 445 h[f] = d |
442 cmds[f]=c.lstrip("^") | 446 cmds[f] = c.lstrip("^") |
443 | 447 |
444 fns = h.keys() | 448 fns = h.keys() |
445 fns.sort() | 449 fns.sort() |
446 m = max(map(len, fns)) | 450 m = max(map(len, fns)) |
447 for f in fns: | 451 for f in fns: |
448 if ui.verbose: | 452 if ui.verbose: |
449 commands = cmds[f].replace("|",", ") | 453 commands = cmds[f].replace("|",", ") |
450 ui.write(" %s:\n %s\n"%(commands,h[f])) | 454 ui.write(" %s:\n %s\n"%(commands, h[f])) |
451 else: | 455 else: |
452 ui.write(' %-*s %s\n' % (m, f, h[f])) | 456 ui.write(' %-*s %s\n' % (m, f, h[f])) |
453 | 457 |
454 # global options | 458 # global options |
455 if ui.verbose: | 459 if ui.verbose: |
488 """ | 492 """ |
489 | 493 |
490 names = [] | 494 names = [] |
491 for src, abs, rel, exact in walk(repo, pats, opts): | 495 for src, abs, rel, exact in walk(repo, pats, opts): |
492 if exact: | 496 if exact: |
493 if ui.verbose: ui.status(_('adding %s\n') % rel) | 497 if ui.verbose: |
498 ui.status(_('adding %s\n') % rel) | |
494 names.append(abs) | 499 names.append(abs) |
495 elif repo.dirstate.state(abs) == '?': | 500 elif repo.dirstate.state(abs) == '?': |
496 ui.status(_('adding %s\n') % rel) | 501 ui.status(_('adding %s\n') % rel) |
497 names.append(abs) | 502 names.append(abs) |
498 repo.add(names) | 503 repo.add(names) |
538 cl = repo.changelog.read(repo.changelog.node(rev)) | 543 cl = repo.changelog.read(repo.changelog.node(rev)) |
539 return trimuser(ui, cl[1], rev, ucache) | 544 return trimuser(ui, cl[1], rev, ucache) |
540 | 545 |
541 dcache = {} | 546 dcache = {} |
542 def getdate(rev): | 547 def getdate(rev): |
543 datestr = dcache.get(rev) | 548 datestr = dcache.get(rev) |
544 if datestr is None: | 549 if datestr is None: |
545 cl = repo.changelog.read(repo.changelog.node(rev)) | 550 cl = repo.changelog.read(repo.changelog.node(rev)) |
546 datestr = dcache[rev] = util.datestr(cl[2]) | 551 datestr = dcache[rev] = util.datestr(cl[2]) |
547 return datestr | 552 return datestr |
548 | 553 |
549 if not pats: | 554 if not pats: |
550 raise util.Abort(_('at least one file name or pattern required')) | 555 raise util.Abort(_('at least one file name or pattern required')) |
551 | 556 |
552 opmap = [['user', getname], ['number', str], ['changeset', getnode], | 557 opmap = [['user', getname], ['number', str], ['changeset', getnode], |
721 src = os.path.join(source, ".hg", f) | 726 src = os.path.join(source, ".hg", f) |
722 dst = os.path.join(dest, ".hg", f) | 727 dst = os.path.join(dest, ".hg", f) |
723 try: | 728 try: |
724 util.copyfiles(src, dst) | 729 util.copyfiles(src, dst) |
725 except OSError, inst: | 730 except OSError, inst: |
726 if inst.errno != errno.ENOENT: raise | 731 if inst.errno != errno.ENOENT: |
732 raise | |
727 | 733 |
728 repo = hg.repository(ui, dest) | 734 repo = hg.repository(ui, dest) |
729 | 735 |
730 else: | 736 else: |
731 revs = None | 737 revs = None |
797 def okaytocopy(abs, rel, exact): | 803 def okaytocopy(abs, rel, exact): |
798 reasons = {'?': _('is not managed'), | 804 reasons = {'?': _('is not managed'), |
799 'a': _('has been marked for add')} | 805 'a': _('has been marked for add')} |
800 reason = reasons.get(repo.dirstate.state(abs)) | 806 reason = reasons.get(repo.dirstate.state(abs)) |
801 if reason: | 807 if reason: |
802 if exact: ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) | 808 if exact: |
809 ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) | |
803 else: | 810 else: |
804 return True | 811 return True |
805 | 812 |
806 def copy(abssrc, relsrc, target, exact): | 813 def copy(abssrc, relsrc, target, exact): |
807 abstarget = util.canonpath(repo.root, cwd, target) | 814 abstarget = util.canonpath(repo.root, cwd, target) |
1274 r = rev | 1281 r = rev |
1275 else: | 1282 else: |
1276 change = ((l in states) and '-') or '+' | 1283 change = ((l in states) and '-') or '+' |
1277 r = prev[fn] | 1284 r = prev[fn] |
1278 cols = [fn, str(rev)] | 1285 cols = [fn, str(rev)] |
1279 if opts['line_number']: cols.append(str(l.linenum)) | 1286 if opts['line_number']: |
1280 if opts['all']: cols.append(change) | 1287 cols.append(str(l.linenum)) |
1281 if opts['user']: cols.append(trimuser(ui, getchange(rev)[1], rev, | 1288 if opts['all']: |
1289 cols.append(change) | |
1290 if opts['user']: | |
1291 cols.append(trimuser(ui, getchange(rev)[1], rev, | |
1282 ucache)) | 1292 ucache)) |
1283 if opts['files_with_matches']: | 1293 if opts['files_with_matches']: |
1284 c = (fn, rev) | 1294 c = (fn, rev) |
1285 if c in filerevmatches: continue | 1295 if c in filerevmatches: |
1296 continue | |
1286 filerevmatches[c] = 1 | 1297 filerevmatches[c] = 1 |
1287 else: | 1298 else: |
1288 cols.append(l.line) | 1299 cols.append(l.line) |
1289 ui.write(sep.join(cols), eol) | 1300 ui.write(sep.join(cols), eol) |
1290 counts[change] += 1 | 1301 counts[change] += 1 |
1302 elif st == 'add': | 1313 elif st == 'add': |
1303 change = repo.changelog.read(repo.lookup(str(rev))) | 1314 change = repo.changelog.read(repo.lookup(str(rev))) |
1304 mf = repo.manifest.read(change[0]) | 1315 mf = repo.manifest.read(change[0]) |
1305 matches[rev] = {} | 1316 matches[rev] = {} |
1306 for fn in fns: | 1317 for fn in fns: |
1307 if fn in skip: continue | 1318 if fn in skip: |
1319 continue | |
1308 fstate.setdefault(fn, {}) | 1320 fstate.setdefault(fn, {}) |
1309 try: | 1321 try: |
1310 grepbody(fn, rev, getfile(fn).read(mf[fn])) | 1322 grepbody(fn, rev, getfile(fn).read(mf[fn])) |
1311 except KeyError: | 1323 except KeyError: |
1312 pass | 1324 pass |
1313 elif st == 'iter': | 1325 elif st == 'iter': |
1314 states = matches[rev].items() | 1326 states = matches[rev].items() |
1315 states.sort() | 1327 states.sort() |
1316 for fn, m in states: | 1328 for fn, m in states: |
1317 if fn in skip: continue | 1329 if fn in skip: |
1330 continue | |
1318 if incrementing or not opts['all'] or fstate[fn]: | 1331 if incrementing or not opts['all'] or fstate[fn]: |
1319 pos, neg = display(fn, rev, m, fstate[fn]) | 1332 pos, neg = display(fn, rev, m, fstate[fn]) |
1320 count += pos + neg | 1333 count += pos + neg |
1321 if pos and not opts['all']: | 1334 if pos and not opts['all']: |
1322 skip[fn] = True | 1335 skip[fn] = True |
1325 | 1338 |
1326 if not incrementing: | 1339 if not incrementing: |
1327 fstate = fstate.items() | 1340 fstate = fstate.items() |
1328 fstate.sort() | 1341 fstate.sort() |
1329 for fn, state in fstate: | 1342 for fn, state in fstate: |
1330 if fn in skip: continue | 1343 if fn in skip: |
1344 continue | |
1331 display(fn, rev, {}, state) | 1345 display(fn, rev, {}, state) |
1332 return (count == 0 and 1) or 0 | 1346 return (count == 0 and 1) or 0 |
1333 | 1347 |
1334 def heads(ui, repo, **opts): | 1348 def heads(ui, repo, **opts): |
1335 """show current repository heads | 1349 """show current repository heads |
1420 hgpatch = False | 1434 hgpatch = False |
1421 for line in file(pf): | 1435 for line in file(pf): |
1422 line = line.rstrip() | 1436 line = line.rstrip() |
1423 if (not message and not hgpatch and | 1437 if (not message and not hgpatch and |
1424 mailre.match(line) and not opts['force']): | 1438 mailre.match(line) and not opts['force']): |
1425 if len(line) > 35: line = line[:32] + '...' | 1439 if len(line) > 35: |
1440 line = line[:32] + '...' | |
1426 raise util.Abort(_('first line looks like a ' | 1441 raise util.Abort(_('first line looks like a ' |
1427 'mail header: ') + line) | 1442 'mail header: ') + line) |
1428 if diffre.match(line): | 1443 if diffre.match(line): |
1429 break | 1444 break |
1430 elif hgpatch: | 1445 elif hgpatch: |
1563 du.bump(rev) | 1578 du.bump(rev) |
1564 changenode = repo.changelog.node(rev) | 1579 changenode = repo.changelog.node(rev) |
1565 parents = [p for p in repo.changelog.parents(changenode) | 1580 parents = [p for p in repo.changelog.parents(changenode) |
1566 if p != nullid] | 1581 if p != nullid] |
1567 if opts['no_merges'] and len(parents) == 2: | 1582 if opts['no_merges'] and len(parents) == 2: |
1568 continue | 1583 continue |
1569 if opts['only_merges'] and len(parents) != 2: | 1584 if opts['only_merges'] and len(parents) != 2: |
1570 continue | 1585 continue |
1571 | 1586 |
1572 br = None | 1587 br = None |
1573 if opts['keyword']: | 1588 if opts['keyword']: |
1574 changes = getchange(rev) | 1589 changes = getchange(rev) |
1575 miss = 0 | 1590 miss = 0 |
1812 """ | 1827 """ |
1813 names = [] | 1828 names = [] |
1814 def okaytoremove(abs, rel, exact): | 1829 def okaytoremove(abs, rel, exact): |
1815 c, a, d, u = repo.changes(files = [abs]) | 1830 c, a, d, u = repo.changes(files = [abs]) |
1816 reason = None | 1831 reason = None |
1817 if c: reason = _('is modified') | 1832 if c: |
1818 elif a: reason = _('has been marked for add') | 1833 reason = _('is modified') |
1819 elif u: reason = _('is not managed') | 1834 elif a: |
1835 reason = _('has been marked for add') | |
1836 elif u: | |
1837 reason = _('is not managed') | |
1820 if reason: | 1838 if reason: |
1821 if exact: ui.warn(_('not removing %s: file %s\n') % (rel, reason)) | 1839 if exact: |
1840 ui.warn(_('not removing %s: file %s\n') % (rel, reason)) | |
1822 else: | 1841 else: |
1823 return True | 1842 return True |
1824 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): | 1843 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): |
1825 if okaytoremove(abs, rel, exact): | 1844 if okaytoremove(abs, rel, exact): |
1826 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) | 1845 if ui.verbose or not exact: |
1846 ui.status(_('removing %s\n') % rel) | |
1827 names.append(abs) | 1847 names.append(abs) |
1828 repo.remove(names, unlink=True) | 1848 repo.remove(names, unlink=True) |
1829 | 1849 |
1830 def rename(ui, repo, *pats, **opts): | 1850 def rename(ui, repo, *pats, **opts): |
1831 """rename files; equivalent of copy + remove | 1851 """rename files; equivalent of copy + remove |
1845 fully used by merge, nor fully reported by log. | 1865 fully used by merge, nor fully reported by log. |
1846 """ | 1866 """ |
1847 errs, copied = docopy(ui, repo, pats, opts) | 1867 errs, copied = docopy(ui, repo, pats, opts) |
1848 names = [] | 1868 names = [] |
1849 for abs, rel, exact in copied: | 1869 for abs, rel, exact in copied: |
1850 if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) | 1870 if ui.verbose or not exact: |
1871 ui.status(_('removing %s\n') % rel) | |
1851 names.append(abs) | 1872 names.append(abs) |
1852 repo.remove(names, unlink=True) | 1873 repo.remove(names, unlink=True) |
1853 return errs | 1874 return errs |
1854 | 1875 |
1855 def revert(ui, repo, *pats, **opts): | 1876 def revert(ui, repo, *pats, **opts): |
2196 table = { | 2217 table = { |
2197 "^add": | 2218 "^add": |
2198 (add, | 2219 (add, |
2199 [('I', 'include', [], _('include names matching the given patterns')), | 2220 [('I', 'include', [], _('include names matching the given patterns')), |
2200 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2221 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2201 "hg add [OPTION]... [FILE]..."), | 2222 _('hg add [OPTION]... [FILE]...')), |
2202 "addremove": | 2223 "addremove": |
2203 (addremove, | 2224 (addremove, |
2204 [('I', 'include', [], _('include names matching the given patterns')), | 2225 [('I', 'include', [], _('include names matching the given patterns')), |
2205 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2226 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2206 "hg addremove [OPTION]... [FILE]..."), | 2227 _('hg addremove [OPTION]... [FILE]...')), |
2207 "^annotate": | 2228 "^annotate": |
2208 (annotate, | 2229 (annotate, |
2209 [('r', 'rev', '', _('annotate the specified revision')), | 2230 [('r', 'rev', '', _('annotate the specified revision')), |
2210 ('a', 'text', None, _('treat all files as text')), | 2231 ('a', 'text', None, _('treat all files as text')), |
2211 ('u', 'user', None, _('list the author')), | 2232 ('u', 'user', None, _('list the author')), |
2221 _('hg bundle FILE DEST')), | 2242 _('hg bundle FILE DEST')), |
2222 "cat": | 2243 "cat": |
2223 (cat, | 2244 (cat, |
2224 [('I', 'include', [], _('include names matching the given patterns')), | 2245 [('I', 'include', [], _('include names matching the given patterns')), |
2225 ('X', 'exclude', [], _('exclude names matching the given patterns')), | 2246 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2226 ('o', 'output', "", _('print output to file with formatted name')), | 2247 ('o', 'output', '', _('print output to file with formatted name')), |
2227 ('r', 'rev', '', _('print the given revision'))], | 2248 ('r', 'rev', '', _('print the given revision'))], |
2228 _('hg cat [OPTION]... FILE...')), | 2249 _('hg cat [OPTION]... FILE...')), |
2229 "^clone": | 2250 "^clone": |
2230 (clone, | 2251 (clone, |
2231 [('U', 'noupdate', None, _('do not update the new working directory')), | 2252 [('U', 'noupdate', None, _('do not update the new working directory')), |
2232 ('e', 'ssh', "", _('specify ssh command to use')), | 2253 ('e', 'ssh', '', _('specify ssh command to use')), |
2233 ('', 'pull', None, _('use pull protocol to copy metadata')), | 2254 ('', 'pull', None, _('use pull protocol to copy metadata')), |
2234 ('r', 'rev', [], | 2255 ('r', 'rev', [], |
2235 _('a changeset you would like to have after cloning')), | 2256 _('a changeset you would like to have after cloning')), |
2236 ('', 'remotecmd', "", | 2257 ('', 'remotecmd', '', |
2237 _('specify hg command to run on the remote side'))], | 2258 _('specify hg command to run on the remote side'))], |
2238 _('hg clone [OPTION]... SOURCE [DEST]')), | 2259 _('hg clone [OPTION]... SOURCE [DEST]')), |
2239 "^commit|ci": | 2260 "^commit|ci": |
2240 (commit, | 2261 (commit, |
2241 [('A', 'addremove', None, _('run addremove during commit')), | 2262 [('A', 'addremove', None, _('run addremove during commit')), |
2242 ('I', 'include', [], _('include names matching the given patterns')), | 2263 ('I', 'include', [], _('include names matching the given patterns')), |
2243 ('X', 'exclude', [], _('exclude names matching the given patterns')), | 2264 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2244 ('m', 'message', "", _('use <text> as commit message')), | 2265 ('m', 'message', '', _('use <text> as commit message')), |
2245 ('l', 'logfile', "", _('read the commit message from <file>')), | 2266 ('l', 'logfile', '', _('read the commit message from <file>')), |
2246 ('d', 'date', "", _('record datecode as commit date')), | 2267 ('d', 'date', '', _('record datecode as commit date')), |
2247 ('u', 'user', "", _('record user as commiter'))], | 2268 ('u', 'user', '', _('record user as commiter'))], |
2248 _('hg commit [OPTION]... [FILE]...')), | 2269 _('hg commit [OPTION]... [FILE]...')), |
2249 "copy|cp": (copy, | 2270 "copy|cp": |
2250 [('I', 'include', [], | 2271 (copy, |
2251 _('include names matching the given patterns')), | 2272 [('I', 'include', [], _('include names matching the given patterns')), |
2252 ('X', 'exclude', [], | 2273 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2253 _('exclude names matching the given patterns')), | 2274 ('A', 'after', None, _('record a copy that has already occurred')), |
2254 ('A', 'after', None, | 2275 ('f', 'force', None, |
2255 _('record a copy that has already occurred')), | 2276 _('forcibly copy over an existing managed file'))], |
2256 ('f', 'force', None, | 2277 _('hg copy [OPTION]... [SOURCE]... DEST')), |
2257 _('forcibly copy over an existing managed file'))], | |
2258 _('hg copy [OPTION]... [SOURCE]... DEST')), | |
2259 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), | 2278 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
2260 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), | 2279 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
2261 "debugconfig": (debugconfig, [], _('debugconfig')), | 2280 "debugconfig": (debugconfig, [], _('debugconfig')), |
2262 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), | 2281 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
2263 "debugstate": (debugstate, [], _('debugstate')), | 2282 "debugstate": (debugstate, [], _('debugstate')), |
2277 ('I', 'include', [], _('include names matching the given patterns')), | 2296 ('I', 'include', [], _('include names matching the given patterns')), |
2278 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2297 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2279 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), | 2298 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2280 "^export": | 2299 "^export": |
2281 (export, | 2300 (export, |
2282 [('o', 'output', "", _('print output to file with formatted name')), | 2301 [('o', 'output', '', _('print output to file with formatted name')), |
2283 ('a', 'text', None, _('treat all files as text')), | 2302 ('a', 'text', None, _('treat all files as text')), |
2284 ('', 'switch-parent', None, _('diff against the second parent'))], | 2303 ('', 'switch-parent', None, _('diff against the second parent'))], |
2285 "hg export [-a] [-o OUTFILE] REV..."), | 2304 _('hg export [-a] [-o OUTFILE] REV...')), |
2286 "forget": | 2305 "forget": |
2287 (forget, | 2306 (forget, |
2288 [('I', 'include', [], _('include names matching the given patterns')), | 2307 [('I', 'include', [], _('include names matching the given patterns')), |
2289 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2308 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2290 "hg forget [OPTION]... FILE..."), | 2309 _('hg forget [OPTION]... FILE...')), |
2291 "grep": | 2310 "grep": |
2292 (grep, | 2311 (grep, |
2293 [('0', 'print0', None, _('end fields with NUL')), | 2312 [('0', 'print0', None, _('end fields with NUL')), |
2294 ('I', 'include', [], _('include names matching the given patterns')), | 2313 ('I', 'include', [], _('include names matching the given patterns')), |
2295 ('X', 'exclude', [], _('exclude names matching the given patterns')), | 2314 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2298 ('l', 'files-with-matches', None, | 2317 ('l', 'files-with-matches', None, |
2299 _('print only filenames and revs that match')), | 2318 _('print only filenames and revs that match')), |
2300 ('n', 'line-number', None, _('print matching line numbers')), | 2319 ('n', 'line-number', None, _('print matching line numbers')), |
2301 ('r', 'rev', [], _('search in given revision range')), | 2320 ('r', 'rev', [], _('search in given revision range')), |
2302 ('u', 'user', None, _('print user who committed change'))], | 2321 ('u', 'user', None, _('print user who committed change'))], |
2303 "hg grep [OPTION]... PATTERN [FILE]..."), | 2322 _('hg grep [OPTION]... PATTERN [FILE]...')), |
2304 "heads": | 2323 "heads": |
2305 (heads, | 2324 (heads, |
2306 [('b', 'branches', None, _('find branch info')), | 2325 [('b', 'branches', None, _('find branch info')), |
2307 ('r', 'rev', "", _('show only heads which are descendants of rev'))], | 2326 ('r', 'rev', '', _('show only heads which are descendants of rev'))], |
2308 _('hg heads [-b] [-r <rev>]')), | 2327 _('hg heads [-b] [-r <rev>]')), |
2309 "help": (help_, [], _('hg help [COMMAND]')), | 2328 "help": (help_, [], _('hg help [COMMAND]')), |
2310 "identify|id": (identify, [], _('hg identify')), | 2329 "identify|id": (identify, [], _('hg identify')), |
2311 "import|patch": | 2330 "import|patch": |
2312 (import_, | 2331 (import_, |
2313 [('p', 'strip', 1, | 2332 [('p', 'strip', 1, |
2314 _('directory strip option for patch. This has the same\n') + | 2333 _('directory strip option for patch. This has the same\n') + |
2315 _('meaning as the corresponding patch option')), | 2334 _('meaning as the corresponding patch option')), |
2316 ('f', 'force', None, | 2335 ('f', 'force', None, |
2317 _('skip check for outstanding uncommitted changes')), | 2336 _('skip check for outstanding uncommitted changes')), |
2318 ('b', 'base', "", _('base path'))], | 2337 ('b', 'base', '', _('base path'))], |
2319 "hg import [-f] [-p NUM] [-b BASE] PATCH..."), | 2338 _('hg import [-f] [-p NUM] [-b BASE] PATCH...')), |
2320 "incoming|in": (incoming, | 2339 "incoming|in": (incoming, |
2321 [('M', 'no-merges', None, _("do not show merges")), | 2340 [('M', 'no-merges', None, _('do not show merges')), |
2322 ('p', 'patch', None, _('show patch')), | 2341 ('p', 'patch', None, _('show patch')), |
2323 ('n', 'newest-first', None, _('show newest record first'))], | 2342 ('n', 'newest-first', None, _('show newest record first'))], |
2324 _('hg incoming [-p] [-n] [-M] [SOURCE]')), | 2343 _('hg incoming [-p] [-n] [-M] [SOURCE]')), |
2325 "^init": (init, [], _('hg init [DEST]')), | 2344 "^init": (init, [], _('hg init [DEST]')), |
2326 "locate": | 2345 "locate": |
2338 [('I', 'include', [], _('include names matching the given patterns')), | 2357 [('I', 'include', [], _('include names matching the given patterns')), |
2339 ('X', 'exclude', [], _('exclude names matching the given patterns')), | 2358 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2340 ('b', 'branch', None, _('show branches')), | 2359 ('b', 'branch', None, _('show branches')), |
2341 ('k', 'keyword', [], _('search for a keyword')), | 2360 ('k', 'keyword', [], _('search for a keyword')), |
2342 ('r', 'rev', [], _('show the specified revision or range')), | 2361 ('r', 'rev', [], _('show the specified revision or range')), |
2343 ('M', 'no-merges', None, _("do not show merges")), | 2362 ('M', 'no-merges', None, _('do not show merges')), |
2344 ('m', 'only-merges', None, _("show only merges")), | 2363 ('m', 'only-merges', None, _('show only merges')), |
2345 ('p', 'patch', None, _('show patch'))], | 2364 ('p', 'patch', None, _('show patch'))], |
2346 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')), | 2365 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')), |
2347 "manifest": (manifest, [], _('hg manifest [REV]')), | 2366 "manifest": (manifest, [], _('hg manifest [REV]')), |
2348 "outgoing|out": (outgoing, | 2367 "outgoing|out": (outgoing, |
2349 [('M', 'no-merges', None, _("do not show merges")), | 2368 [('M', 'no-merges', None, _('do not show merges')), |
2350 ('p', 'patch', None, _('show patch')), | 2369 ('p', 'patch', None, _('show patch')), |
2351 ('n', 'newest-first', None, _('show newest record first'))], | 2370 ('n', 'newest-first', None, _('show newest record first'))], |
2352 _('hg outgoing [-p] [-n] [-M] [DEST]')), | 2371 _('hg outgoing [-p] [-n] [-M] [DEST]')), |
2353 "^parents": (parents, [], _('hg parents [REV]')), | 2372 "^parents": (parents, [], _('hg parents [REV]')), |
2354 "paths": (paths, [], _('hg paths [NAME]')), | 2373 "paths": (paths, [], _('hg paths [NAME]')), |
2355 "^pull": | 2374 "^pull": |
2356 (pull, | 2375 (pull, |
2357 [('u', 'update', None, | 2376 [('u', 'update', None, |
2358 _('update the working directory to tip after pull')), | 2377 _('update the working directory to tip after pull')), |
2359 ('e', 'ssh', "", _('specify ssh command to use')), | 2378 ('e', 'ssh', '', _('specify ssh command to use')), |
2360 ('r', 'rev', [], _('a specific revision you would like to pull')), | 2379 ('r', 'rev', [], _('a specific revision you would like to pull')), |
2361 ('', 'remotecmd', "", | 2380 ('', 'remotecmd', '', |
2362 _('specify hg command to run on the remote side'))], | 2381 _('specify hg command to run on the remote side'))], |
2363 _('hg pull [-u] [-e FILE] [-r rev] [--remotecmd FILE] [SOURCE]')), | 2382 _('hg pull [-u] [-e FILE] [-r rev] [--remotecmd FILE] [SOURCE]')), |
2364 "^push": | 2383 "^push": |
2365 (push, | 2384 (push, |
2366 [('f', 'force', None, _('force push')), | 2385 [('f', 'force', None, _('force push')), |
2367 ('e', 'ssh', "", _('specify ssh command to use')), | 2386 ('e', 'ssh', '', _('specify ssh command to use')), |
2368 ('', 'remotecmd', "", | 2387 ('', 'remotecmd', '', |
2369 _('specify hg command to run on the remote side'))], | 2388 _('specify hg command to run on the remote side'))], |
2370 _('hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]')), | 2389 _('hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]')), |
2371 "rawcommit": | 2390 "rawcommit": |
2372 (rawcommit, | 2391 (rawcommit, |
2373 [('p', 'parent', [], _('parent')), | 2392 [('p', 'parent', [], _('parent')), |
2374 ('d', 'date', "", _('date code')), | 2393 ('d', 'date', '', _('date code')), |
2375 ('u', 'user', "", _('user')), | 2394 ('u', 'user', '', _('user')), |
2376 ('F', 'files', "", _('file list')), | 2395 ('F', 'files', '', _('file list')), |
2377 ('m', 'message', "", _('commit message')), | 2396 ('m', 'message', '', _('commit message')), |
2378 ('l', 'logfile', "", _('commit message file'))], | 2397 ('l', 'logfile', '', _('commit message file'))], |
2379 _('hg rawcommit [OPTION]... [FILE]...')), | 2398 _('hg rawcommit [OPTION]... [FILE]...')), |
2380 "recover": (recover, [], _("hg recover")), | 2399 "recover": (recover, [], _('hg recover')), |
2381 "^remove|rm": (remove, | 2400 "^remove|rm": |
2382 [('I', 'include', [], | 2401 (remove, |
2383 _('include names matching the given patterns')), | 2402 [('I', 'include', [], _('include names matching the given patterns')), |
2384 ('X', 'exclude', [], | 2403 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2385 _('exclude names matching the given patterns'))], | 2404 _('hg remove [OPTION]... FILE...')), |
2386 _("hg remove [OPTION]... FILE...")), | 2405 "rename|mv": |
2387 "rename|mv": (rename, | 2406 (rename, |
2388 [('I', 'include', [], | 2407 [('I', 'include', [], _('include names matching the given patterns')), |
2389 _('include names matching the given patterns')), | 2408 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2390 ('X', 'exclude', [], | 2409 ('A', 'after', None, _('record a rename that has already occurred')), |
2391 _('exclude names matching the given patterns')), | 2410 ('f', 'force', None, |
2392 ('A', 'after', None, | 2411 _('forcibly copy over an existing managed file'))], |
2393 _('record a rename that has already occurred')), | 2412 _('hg rename [OPTION]... [SOURCE]... DEST')), |
2394 ('f', 'force', None, | |
2395 _('forcibly copy over an existing managed file'))], | |
2396 _('hg rename [OPTION]... [SOURCE]... DEST')), | |
2397 "^revert": | 2413 "^revert": |
2398 (revert, | 2414 (revert, |
2399 [('I', 'include', [], _('include names matching the given patterns')), | 2415 [('I', 'include', [], _('include names matching the given patterns')), |
2400 ('X', 'exclude', [], _('exclude names matching the given patterns')), | 2416 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2401 ("r", "rev", "", _("revision to revert to"))], | 2417 ('r', 'rev', '', _('revision to revert to'))], |
2402 _("hg revert [-n] [-r REV] [NAME]...")), | 2418 _('hg revert [-n] [-r REV] [NAME]...')), |
2403 "root": (root, [], _("hg root")), | 2419 "root": (root, [], _('hg root')), |
2404 "^serve": | 2420 "^serve": |
2405 (serve, | 2421 (serve, |
2406 [('A', 'accesslog', '', _('name of access log file to write to')), | 2422 [('A', 'accesslog', '', _('name of access log file to write to')), |
2407 ('E', 'errorlog', '', _('name of error log file to write to')), | 2423 ('E', 'errorlog', '', _('name of error log file to write to')), |
2408 ('p', 'port', 0, _('port to use (default: 8000)')), | 2424 ('p', 'port', 0, _('port to use (default: 8000)')), |
2409 ('a', 'address', '', _('address to use')), | 2425 ('a', 'address', '', _('address to use')), |
2410 ('n', 'name', "", | 2426 ('n', 'name', '', |
2411 _('name to show in web pages (default: working dir)')), | 2427 _('name to show in web pages (default: working dir)')), |
2412 ('', 'stdio', None, _('for remote clients')), | 2428 ('', 'stdio', None, _('for remote clients')), |
2413 ('t', 'templates', "", _('web templates to use')), | 2429 ('t', 'templates', '', _('web templates to use')), |
2414 ('', 'style', "", _('template style to use')), | 2430 ('', 'style', '', _('template style to use')), |
2415 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], | 2431 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], |
2416 _("hg serve [OPTION]...")), | 2432 _('hg serve [OPTION]...')), |
2417 "^status|st": | 2433 "^status|st": |
2418 (status, | 2434 (status, |
2419 [('m', 'modified', None, _('show only modified files')), | 2435 [('m', 'modified', None, _('show only modified files')), |
2420 ('a', 'added', None, _('show only added files')), | 2436 ('a', 'added', None, _('show only added files')), |
2421 ('r', 'removed', None, _('show only removed files')), | 2437 ('r', 'removed', None, _('show only removed files')), |
2423 ('n', 'no-status', None, _('hide status prefix')), | 2439 ('n', 'no-status', None, _('hide status prefix')), |
2424 ('0', 'print0', None, | 2440 ('0', 'print0', None, |
2425 _('end filenames with NUL, for use with xargs')), | 2441 _('end filenames with NUL, for use with xargs')), |
2426 ('I', 'include', [], _('include names matching the given patterns')), | 2442 ('I', 'include', [], _('include names matching the given patterns')), |
2427 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 2443 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2428 _("hg status [OPTION]... [FILE]...")), | 2444 _('hg status [OPTION]... [FILE]...')), |
2429 "tag": | 2445 "tag": |
2430 (tag, | 2446 (tag, |
2431 [('l', 'local', None, _('make the tag local')), | 2447 [('l', 'local', None, _('make the tag local')), |
2432 ('m', 'message', "", _('message for tag commit log entry')), | 2448 ('m', 'message', '', _('message for tag commit log entry')), |
2433 ('d', 'date', "", _('record datecode as commit date')), | 2449 ('d', 'date', '', _('record datecode as commit date')), |
2434 ('u', 'user', "", _('record user as commiter')), | 2450 ('u', 'user', '', _('record user as commiter')), |
2435 ('r', 'rev', "", _('revision to tag'))], | 2451 ('r', 'rev', '', _('revision to tag'))], |
2436 _('hg tag [OPTION]... NAME [REV]')), | 2452 _('hg tag [OPTION]... NAME [REV]')), |
2437 "tags": (tags, [], _('hg tags')), | 2453 "tags": (tags, [], _('hg tags')), |
2438 "tip": (tip, [], _('hg tip')), | 2454 "tip": (tip, [], _('hg tip')), |
2439 "unbundle": | 2455 "unbundle": |
2440 (unbundle, | 2456 (unbundle, |
2442 _('update the working directory to tip after unbundle'))], | 2458 _('update the working directory to tip after unbundle'))], |
2443 _('hg unbundle [-u] FILE')), | 2459 _('hg unbundle [-u] FILE')), |
2444 "undo": (undo, [], _('hg undo')), | 2460 "undo": (undo, [], _('hg undo')), |
2445 "^update|up|checkout|co": | 2461 "^update|up|checkout|co": |
2446 (update, | 2462 (update, |
2447 [('b', 'branch', "", _('checkout the head of a specific branch')), | 2463 [('b', 'branch', '', _('checkout the head of a specific branch')), |
2448 ('m', 'merge', None, _('allow merging of branches')), | 2464 ('m', 'merge', None, _('allow merging of branches')), |
2449 ('C', 'clean', None, _('overwrite locally modified files')), | 2465 ('C', 'clean', None, _('overwrite locally modified files')), |
2450 ('f', 'force', None, _('force a merge with outstanding changes'))], | 2466 ('f', 'force', None, _('force a merge with outstanding changes'))], |
2451 _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), | 2467 _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), |
2452 "verify": (verify, [], _('hg verify')), | 2468 "verify": (verify, [], _('hg verify')), |
2453 "version": (show_version, [], _('hg version')), | 2469 "version": (show_version, [], _('hg version')), |
2454 } | 2470 } |
2455 | 2471 |
2456 globalopts = [ | 2472 globalopts = [ |
2457 ('R', 'repository', "", _("repository root directory")), | 2473 ('R', 'repository', '', _('repository root directory')), |
2458 ('', 'cwd', '', _("change working directory")), | 2474 ('', 'cwd', '', _('change working directory')), |
2459 ('y', 'noninteractive', None, | 2475 ('y', 'noninteractive', None, |
2460 _("do not prompt, assume 'yes' for any required answers")), | 2476 _('do not prompt, assume \'yes\' for any required answers')), |
2461 ('q', 'quiet', None, _("suppress output")), | 2477 ('q', 'quiet', None, _('suppress output')), |
2462 ('v', 'verbose', None, _("enable additional output")), | 2478 ('v', 'verbose', None, _('enable additional output')), |
2463 ('', 'debug', None, _("enable debugging output")), | 2479 ('', 'debug', None, _('enable debugging output')), |
2464 ('', 'debugger', None, _("start debugger")), | 2480 ('', 'debugger', None, _('start debugger')), |
2465 ('', 'traceback', None, _("print traceback on exception")), | 2481 ('', 'traceback', None, _('print traceback on exception')), |
2466 ('', 'time', None, _("time how long the command takes")), | 2482 ('', 'time', None, _('time how long the command takes')), |
2467 ('', 'profile', None, _("print command execution profile")), | 2483 ('', 'profile', None, _('print command execution profile')), |
2468 ('', 'version', None, _("output version information and exit")), | 2484 ('', 'version', None, _('output version information and exit')), |
2469 ('h', 'help', None, _("display help and exit")), | 2485 ('h', 'help', None, _('display help and exit')), |
2470 ] | 2486 ] |
2471 | 2487 |
2472 norepo = ("clone init version help debugancestor debugconfig debugdata" | 2488 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2473 " debugindex debugindexdot paths") | 2489 " debugindex debugindexdot paths") |
2474 | 2490 |
2647 | 2663 |
2648 if cmd not in norepo.split(): | 2664 if cmd not in norepo.split(): |
2649 path = options["repository"] or "" | 2665 path = options["repository"] or "" |
2650 repo = hg.repository(ui=u, path=path) | 2666 repo = hg.repository(ui=u, path=path) |
2651 for x in external: | 2667 for x in external: |
2652 if hasattr(x, 'reposetup'): x.reposetup(u, repo) | 2668 if hasattr(x, 'reposetup'): |
2669 x.reposetup(u, repo) | |
2653 d = lambda: func(u, repo, *args, **cmdoptions) | 2670 d = lambda: func(u, repo, *args, **cmdoptions) |
2654 else: | 2671 else: |
2655 d = lambda: func(u, *args, **cmdoptions) | 2672 d = lambda: func(u, *args, **cmdoptions) |
2656 | 2673 |
2657 if options['profile']: | 2674 if options['profile']: |