6 # of the GNU General Public License, incorporated herein by reference. |
6 # of the GNU General Public License, incorporated herein by reference. |
7 |
7 |
8 from demandload import demandload |
8 from demandload import demandload |
9 from node import * |
9 from node import * |
10 from i18n import gettext as _ |
10 from i18n import gettext as _ |
11 demandload(globals(), "os re sys signal shutil imp urllib pdb") |
11 demandload(globals(), "os re sys signal shutil imp urllib pdb shlex") |
12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
13 demandload(globals(), "fnmatch difflib patch random signal tempfile time") |
13 demandload(globals(), "fnmatch difflib patch random signal tempfile time") |
14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
15 demandload(globals(), "archival cStringIO changegroup") |
15 demandload(globals(), "archival cStringIO changegroup") |
16 demandload(globals(), "cmdutil hgweb.server sshserver") |
16 demandload(globals(), "cmdutil hgweb.server sshserver") |
48 except IOError, inst: |
48 except IOError, inst: |
49 raise util.Abort(_("can't read commit message '%s': %s") % |
49 raise util.Abort(_("can't read commit message '%s': %s") % |
50 (logfile, inst.strerror)) |
50 (logfile, inst.strerror)) |
51 return message |
51 return message |
52 |
52 |
|
53 def defaultrev(repo, rev=None, default='tip'): |
|
54 """returns rev if it is specified, otherwise the working dir |
|
55 parent if there is only one, or tip if there is no working |
|
56 dir""" |
|
57 if rev: |
|
58 return rev |
|
59 |
|
60 p1, p2 = repo.dirstate.parents() |
|
61 if p2 != nullid: |
|
62 raise util.Abort(_('uncommitted merge - please provide a ' |
|
63 'specific revision')) |
|
64 if p1 != nullid: |
|
65 return hex(p1) |
|
66 return default |
|
67 |
53 def walkchangerevs(ui, repo, pats, opts): |
68 def walkchangerevs(ui, repo, pats, opts): |
54 '''Iterate over files and the revs they changed in. |
69 '''Iterate over files and the revs they changed in. |
55 |
70 |
56 Callers most commonly need to iterate backwards over the history |
71 Callers most commonly need to iterate backwards over the history |
57 it is interested in. Doing so has awful (quadratic-looking) |
72 it is interested in. Doing so has awful (quadratic-looking) |
97 |
112 |
98 if repo.changelog.count() == 0: |
113 if repo.changelog.count() == 0: |
99 return [], False, matchfn |
114 return [], False, matchfn |
100 |
115 |
101 if follow: |
116 if follow: |
102 p = repo.dirstate.parents()[0] |
117 defrange = '%s:0' % defaultrev(repo) |
103 if p == nullid: |
|
104 ui.warn(_('No working directory revision; defaulting to tip\n')) |
|
105 start = 'tip' |
|
106 else: |
|
107 start = repo.changelog.rev(p) |
|
108 defrange = '%s:0' % start |
|
109 else: |
118 else: |
110 defrange = 'tip:0' |
119 defrange = 'tip:0' |
111 revs = map(int, revrange(ui, repo, opts['rev'] or [defrange])) |
120 revs = map(int, cmdutil.revrange(ui, repo, opts['rev'] or [defrange])) |
112 wanted = {} |
121 wanted = {} |
113 slowpath = anypats |
122 slowpath = anypats |
114 fncache = {} |
123 fncache = {} |
115 |
124 |
116 chcache = {} |
125 chcache = {} |
250 yield 'add', rev, fns |
259 yield 'add', rev, fns |
251 for rev in nrevs: |
260 for rev in nrevs: |
252 yield 'iter', rev, None |
261 yield 'iter', rev, None |
253 return iterate(), getchange, matchfn |
262 return iterate(), getchange, matchfn |
254 |
263 |
255 revrangesep = ':' |
|
256 |
|
257 def revfix(repo, val, defval): |
|
258 '''turn user-level id of changeset into rev number. |
|
259 user-level id can be tag, changeset, rev number, or negative rev |
|
260 number relative to number of revs (-1 is tip, etc).''' |
|
261 if not val: |
|
262 return defval |
|
263 try: |
|
264 num = int(val) |
|
265 if str(num) != val: |
|
266 raise ValueError |
|
267 if num < 0: |
|
268 num += repo.changelog.count() |
|
269 if num < 0: |
|
270 num = 0 |
|
271 elif num >= repo.changelog.count(): |
|
272 raise ValueError |
|
273 except ValueError: |
|
274 try: |
|
275 num = repo.changelog.rev(repo.lookup(val)) |
|
276 except KeyError: |
|
277 raise util.Abort(_('invalid revision identifier %s'), val) |
|
278 return num |
|
279 |
|
280 def revpair(ui, repo, revs): |
|
281 '''return pair of nodes, given list of revisions. second item can |
|
282 be None, meaning use working dir.''' |
|
283 if not revs: |
|
284 return repo.dirstate.parents()[0], None |
|
285 end = None |
|
286 if len(revs) == 1: |
|
287 start = revs[0] |
|
288 if revrangesep in start: |
|
289 start, end = start.split(revrangesep, 1) |
|
290 start = revfix(repo, start, 0) |
|
291 end = revfix(repo, end, repo.changelog.count() - 1) |
|
292 else: |
|
293 start = revfix(repo, start, None) |
|
294 elif len(revs) == 2: |
|
295 if revrangesep in revs[0] or revrangesep in revs[1]: |
|
296 raise util.Abort(_('too many revisions specified')) |
|
297 start = revfix(repo, revs[0], None) |
|
298 end = revfix(repo, revs[1], None) |
|
299 else: |
|
300 raise util.Abort(_('too many revisions specified')) |
|
301 if end is not None: end = repo.lookup(str(end)) |
|
302 return repo.lookup(str(start)), end |
|
303 |
|
304 def revrange(ui, repo, revs): |
|
305 """Yield revision as strings from a list of revision specifications.""" |
|
306 seen = {} |
|
307 for spec in revs: |
|
308 if revrangesep in spec: |
|
309 start, end = spec.split(revrangesep, 1) |
|
310 start = revfix(repo, start, 0) |
|
311 end = revfix(repo, end, repo.changelog.count() - 1) |
|
312 step = start > end and -1 or 1 |
|
313 for rev in xrange(start, end+step, step): |
|
314 if rev in seen: |
|
315 continue |
|
316 seen[rev] = 1 |
|
317 yield str(rev) |
|
318 else: |
|
319 rev = revfix(repo, spec, None) |
|
320 if rev in seen: |
|
321 continue |
|
322 seen[rev] = 1 |
|
323 yield str(rev) |
|
324 |
|
325 def write_bundle(cg, filename=None, compress=True): |
264 def write_bundle(cg, filename=None, compress=True): |
326 """Write a bundle file and return its filename. |
265 """Write a bundle file and return its filename. |
327 |
266 |
328 Existing files will not be overwritten. |
267 Existing files will not be overwritten. |
329 If no filename is specified, a temporary file is created. |
268 If no filename is specified, a temporary file is created. |
705 opmap = [['user', getname], ['number', str], ['changeset', getnode], |
644 opmap = [['user', getname], ['number', str], ['changeset', getnode], |
706 ['date', getdate]] |
645 ['date', getdate]] |
707 if not opts['user'] and not opts['changeset'] and not opts['date']: |
646 if not opts['user'] and not opts['changeset'] and not opts['date']: |
708 opts['number'] = 1 |
647 opts['number'] = 1 |
709 |
648 |
710 ctx = repo.changectx(opts['rev'] or repo.dirstate.parents()[0]) |
649 ctx = repo.changectx(defaultrev(repo, opts['rev'])) |
711 |
650 |
712 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
651 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
713 node=ctx.node()): |
652 node=ctx.node()): |
714 fctx = ctx.filectx(abs) |
653 fctx = ctx.filectx(abs) |
715 if not opts['text'] and util.binary(fctx.data()): |
654 if not opts['text'] and util.binary(fctx.data()): |
752 Each member added to an archive file has a directory prefix |
691 Each member added to an archive file has a directory prefix |
753 prepended. Use "-p" to specify a format string for the prefix. |
692 prepended. Use "-p" to specify a format string for the prefix. |
754 The default is the basename of the archive, with suffixes removed. |
693 The default is the basename of the archive, with suffixes removed. |
755 ''' |
694 ''' |
756 |
695 |
757 if opts['rev']: |
696 node = repo.lookup(defaultrev(repo, opts['rev'])) |
758 node = repo.lookup(opts['rev']) |
|
759 else: |
|
760 node, p2 = repo.dirstate.parents() |
|
761 if p2 != nullid: |
|
762 raise util.Abort(_('uncommitted merge - please provide a ' |
|
763 'specific revision')) |
|
764 |
|
765 dest = cmdutil.make_filename(repo, dest, node) |
697 dest = cmdutil.make_filename(repo, dest, node) |
766 if os.path.realpath(dest) == repo.root: |
698 if os.path.realpath(dest) == repo.root: |
767 raise util.Abort(_('repository root cannot be destination')) |
699 raise util.Abort(_('repository root cannot be destination')) |
768 dummy, matchfn, dummy = cmdutil.matchpats(repo, [], opts) |
700 dummy, matchfn, dummy = cmdutil.matchpats(repo, [], opts) |
769 kind = opts.get('type') or 'files' |
701 kind = opts.get('type') or 'files' |
865 |
797 |
866 def cat(ui, repo, file1, *pats, **opts): |
798 def cat(ui, repo, file1, *pats, **opts): |
867 """output the latest or given revisions of files |
799 """output the latest or given revisions of files |
868 |
800 |
869 Print the specified files as they were at the given revision. |
801 Print the specified files as they were at the given revision. |
870 If no revision is given then the tip is used. |
802 If no revision is given then working dir parent is used, or tip |
|
803 if no revision is checked out. |
871 |
804 |
872 Output may be to a file, in which case the name of the file is |
805 Output may be to a file, in which case the name of the file is |
873 given using a format string. The formatting rules are the same as |
806 given using a format string. The formatting rules are the same as |
874 for the export command, with the following additions: |
807 for the export command, with the following additions: |
875 |
808 |
876 %s basename of file being printed |
809 %s basename of file being printed |
877 %d dirname of file being printed, or '.' if in repo root |
810 %d dirname of file being printed, or '.' if in repo root |
878 %p root-relative path name of file being printed |
811 %p root-relative path name of file being printed |
879 """ |
812 """ |
880 ctx = repo.changectx(opts['rev'] or "-1") |
813 ctx = repo.changectx(defaultrev(repo, opts['rev'])) |
881 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts, |
814 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts, |
882 ctx.node()): |
815 ctx.node()): |
883 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs) |
816 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs) |
884 fp.write(ctx.filectx(abs).data()) |
817 fp.write(ctx.filectx(abs).data()) |
885 |
818 |
1267 r = revlog.revlog(util.opener(os.getcwd(), audit=False), |
1200 r = revlog.revlog(util.opener(os.getcwd(), audit=False), |
1268 file_[:-2] + ".i", file_, 0) |
1201 file_[:-2] + ".i", file_, 0) |
1269 try: |
1202 try: |
1270 ui.write(r.revision(r.lookup(rev))) |
1203 ui.write(r.revision(r.lookup(rev))) |
1271 except KeyError: |
1204 except KeyError: |
1272 raise util.Abort(_('invalid revision identifier %s'), rev) |
1205 raise util.Abort(_('invalid revision identifier %s') % rev) |
1273 |
1206 |
1274 def debugindex(ui, file_): |
1207 def debugindex(ui, file_): |
1275 """dump the contents of an index file""" |
1208 """dump the contents of an index file""" |
1276 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0) |
1209 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0) |
1277 ui.write(" rev offset length base linkrev" + |
1210 ui.write(" rev offset length base linkrev" + |
1342 |
1275 |
1343 Without the -a option, diff will avoid generating diffs of files |
1276 Without the -a option, diff will avoid generating diffs of files |
1344 it detects as binary. With -a, diff will generate a diff anyway, |
1277 it detects as binary. With -a, diff will generate a diff anyway, |
1345 probably with undesirable results. |
1278 probably with undesirable results. |
1346 """ |
1279 """ |
1347 node1, node2 = revpair(ui, repo, opts['rev']) |
1280 node1, node2 = cmdutil.revpair(ui, repo, opts['rev']) |
1348 |
1281 |
1349 fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
1282 fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
1350 |
1283 |
1351 patch.diff(repo, node1, node2, fns, match=matchfn, |
1284 patch.diff(repo, node1, node2, fns, match=matchfn, |
1352 opts=patch.diffopts(ui, opts)) |
1285 opts=patch.diffopts(ui, opts)) |
1378 With the --switch-parent option, the diff will be against the second |
1311 With the --switch-parent option, the diff will be against the second |
1379 parent. It can be useful to review a merge. |
1312 parent. It can be useful to review a merge. |
1380 """ |
1313 """ |
1381 if not changesets: |
1314 if not changesets: |
1382 raise util.Abort(_("export requires at least one changeset")) |
1315 raise util.Abort(_("export requires at least one changeset")) |
1383 revs = list(revrange(ui, repo, changesets)) |
1316 revs = list(cmdutil.revrange(ui, repo, changesets)) |
1384 if len(revs) > 1: |
1317 if len(revs) > 1: |
1385 ui.note(_('exporting patches:\n')) |
1318 ui.note(_('exporting patches:\n')) |
1386 else: |
1319 else: |
1387 ui.note(_('exporting patch:\n')) |
1320 ui.note(_('exporting patch:\n')) |
1388 patch.export(repo, map(repo.lookup, revs), template=opts['output'], |
1321 patch.export(repo, map(repo.lookup, revs), template=opts['output'], |
1938 head revision, and the repository contains exactly one other head, |
1871 head revision, and the repository contains exactly one other head, |
1939 the other head is merged with by default. Otherwise, an explicit |
1872 the other head is merged with by default. Otherwise, an explicit |
1940 revision to merge with must be provided. |
1873 revision to merge with must be provided. |
1941 """ |
1874 """ |
1942 |
1875 |
1943 if node: |
1876 if node or branch: |
1944 node = _lookup(repo, node, branch) |
1877 node = _lookup(repo, node, branch) |
1945 else: |
1878 else: |
1946 heads = repo.heads() |
1879 heads = repo.heads() |
1947 if len(heads) > 2: |
1880 if len(heads) > 2: |
1948 raise util.Abort(_('repo has %d heads - ' |
1881 raise util.Abort(_('repo has %d heads - ' |
2270 explicitly specify the revision to revert to. |
2203 explicitly specify the revision to revert to. |
2271 |
2204 |
2272 Modified files are saved with a .orig suffix before reverting. |
2205 Modified files are saved with a .orig suffix before reverting. |
2273 To disable these backups, use --no-backup. |
2206 To disable these backups, use --no-backup. |
2274 |
2207 |
2275 Using the -r option, revert the given files or directories to |
2208 Using the -r option, revert the given files or directories to their |
2276 their contents as of a specific revision. This can be helpful to"roll |
2209 contents as of a specific revision. This can be helpful to "roll |
2277 back" some or all of a change that should not have been committed. |
2210 back" some or all of a change that should not have been committed. |
2278 |
2211 |
2279 Revert modifies the working directory. It does not commit any |
2212 Revert modifies the working directory. It does not commit any |
2280 changes, or change the parent of the working directory. If you |
2213 changes, or change the parent of the working directory. If you |
2281 revert to a revision other than the parent of the working |
2214 revert to a revision other than the parent of the working |
2289 |
2222 |
2290 If no arguments are given, no files are reverted. |
2223 If no arguments are given, no files are reverted. |
2291 """ |
2224 """ |
2292 |
2225 |
2293 if not pats and not opts['all']: |
2226 if not pats and not opts['all']: |
2294 raise util.Abort(_('no files or directories specified')) |
2227 raise util.Abort(_('no files or directories specified; ' |
|
2228 'use --all to revert the whole repo')) |
2295 |
2229 |
2296 parent, p2 = repo.dirstate.parents() |
2230 parent, p2 = repo.dirstate.parents() |
2297 if opts['rev']: |
2231 node = repo.lookup(defaultrev(repo, opts['rev'])) |
2298 node = repo.lookup(opts['rev']) |
|
2299 elif p2 != nullid: |
|
2300 raise util.Abort(_('working dir has two parents; ' |
|
2301 'you must specify the revision to revert to')) |
|
2302 else: |
|
2303 node = parent |
|
2304 mf = repo.manifest.read(repo.changelog.read(node)[0]) |
2232 mf = repo.manifest.read(repo.changelog.read(node)[0]) |
2305 if node == parent: |
2233 if node == parent: |
2306 pmf = mf |
2234 pmf = mf |
2307 else: |
2235 else: |
2308 pmf = None |
2236 pmf = None |
2455 stderr. Use the "-A" and "-E" options to log to files. |
2383 stderr. Use the "-A" and "-E" options to log to files. |
2456 """ |
2384 """ |
2457 |
2385 |
2458 if opts["stdio"]: |
2386 if opts["stdio"]: |
2459 if repo is None: |
2387 if repo is None: |
2460 raise hg.RepoError(_('no repo found')) |
2388 raise hg.RepoError(_("There is no Mercurial repository here" |
|
2389 " (.hg not found)")) |
2461 s = sshserver.sshserver(ui, repo) |
2390 s = sshserver.sshserver(ui, repo) |
2462 s.serve_forever() |
2391 s.serve_forever() |
2463 |
2392 |
2464 optlist = ("name templates style address port ipv6" |
2393 optlist = ("name templates style address port ipv6" |
2465 " accesslog errorlog webdir_conf") |
2394 " accesslog errorlog webdir_conf") |
2466 for o in optlist.split(): |
2395 for o in optlist.split(): |
2467 if opts[o]: |
2396 if opts[o]: |
2468 ui.setconfig("web", o, opts[o]) |
2397 ui.setconfig("web", o, opts[o]) |
2469 |
2398 |
2470 if repo is None and not ui.config("web", "webdir_conf"): |
2399 if repo is None and not ui.config("web", "webdir_conf"): |
2471 raise hg.RepoError(_('no repo found')) |
2400 raise hg.RepoError(_("There is no Mercurial repository here" |
|
2401 " (.hg not found)")) |
2472 |
2402 |
2473 if opts['daemon'] and not opts['daemon_pipefds']: |
2403 if opts['daemon'] and not opts['daemon_pipefds']: |
2474 rfd, wfd = os.pipe() |
2404 rfd, wfd = os.pipe() |
2475 args = sys.argv[:] |
2405 args = sys.argv[:] |
2476 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
2406 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
2596 "please use 'hg tag [-r REV] NAME' instead\n")) |
2526 "please use 'hg tag [-r REV] NAME' instead\n")) |
2597 if opts['rev']: |
2527 if opts['rev']: |
2598 raise util.Abort(_("use only one form to specify the revision")) |
2528 raise util.Abort(_("use only one form to specify the revision")) |
2599 if opts['rev']: |
2529 if opts['rev']: |
2600 rev_ = opts['rev'] |
2530 rev_ = opts['rev'] |
2601 if rev_: |
2531 r = defaultrev(repo, rev_, nullid) |
2602 r = repo.lookup(rev_) |
2532 if r == nullid: |
2603 else: |
2533 raise util.Abort(_('no revision to tag')) |
2604 p1, p2 = repo.dirstate.parents() |
2534 r = repo.lookup(r) |
2605 if p1 == nullid: |
|
2606 raise util.Abort(_('no revision to tag')) |
|
2607 if p2 != nullid: |
|
2608 raise util.Abort(_('outstanding uncommitted merges')) |
|
2609 r = p1 |
|
2610 |
2535 |
2611 message = opts['message'] |
2536 message = opts['message'] |
2612 if not message: |
2537 if not message: |
2613 message = _('Added tag %s for changeset %s') % (name, short(r)) |
2538 message = _('Added tag %s for changeset %s') % (name, short(r)) |
2614 |
2539 |
2884 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2809 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2885 "^export": |
2810 "^export": |
2886 (export, |
2811 (export, |
2887 [('o', 'output', '', _('print output to file with formatted name')), |
2812 [('o', 'output', '', _('print output to file with formatted name')), |
2888 ('a', 'text', None, _('treat all files as text')), |
2813 ('a', 'text', None, _('treat all files as text')), |
|
2814 ('g', 'git', None, _('use git extended diff format')), |
2889 ('', 'switch-parent', None, _('diff against the second parent'))], |
2815 ('', 'switch-parent', None, _('diff against the second parent'))], |
2890 _('hg export [-a] [-o OUTFILESPEC] REV...')), |
2816 _('hg export [-a] [-o OUTFILESPEC] REV...')), |
2891 "debugforget|forget": |
2817 "debugforget|forget": |
2892 (forget, |
2818 (forget, |
2893 [('I', 'include', [], _('include names matching the given patterns')), |
2819 [('I', 'include', [], _('include names matching the given patterns')), |
3303 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
3229 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
3304 num = getattr(signal, name, None) |
3230 num = getattr(signal, name, None) |
3305 if num: signal.signal(num, catchterm) |
3231 if num: signal.signal(num, catchterm) |
3306 |
3232 |
3307 try: |
3233 try: |
3308 u = ui.ui(traceback='--traceback' in sys.argv[1:], |
3234 u = ui.ui(traceback='--traceback' in sys.argv[1:]) |
3309 readhooks=[load_extensions]) |
|
3310 except util.Abort, inst: |
3235 except util.Abort, inst: |
3311 sys.stderr.write(_("abort: %s\n") % inst) |
3236 sys.stderr.write(_("abort: %s\n") % inst) |
3312 return -1 |
3237 return -1 |
|
3238 |
|
3239 load_extensions(u) |
|
3240 u.addreadhook(load_extensions) |
3313 |
3241 |
3314 try: |
3242 try: |
3315 cmd, func, args, options, cmdoptions = parse(u, args) |
3243 cmd, func, args, options, cmdoptions = parse(u, args) |
3316 if options["time"]: |
3244 if options["time"]: |
3317 def get_times(): |
3245 def get_times(): |
3443 u.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) |
3371 u.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) |
3444 except lock.LockUnavailable, inst: |
3372 except lock.LockUnavailable, inst: |
3445 u.warn(_("abort: could not lock %s: %s\n") % |
3373 u.warn(_("abort: could not lock %s: %s\n") % |
3446 (inst.desc or inst.filename, inst.strerror)) |
3374 (inst.desc or inst.filename, inst.strerror)) |
3447 except revlog.RevlogError, inst: |
3375 except revlog.RevlogError, inst: |
3448 u.warn(_("abort: "), inst, "!\n") |
3376 u.warn(_("abort: %s!\n") % inst) |
3449 except util.SignalInterrupt: |
3377 except util.SignalInterrupt: |
3450 u.warn(_("killed!\n")) |
3378 u.warn(_("killed!\n")) |
3451 except KeyboardInterrupt: |
3379 except KeyboardInterrupt: |
3452 try: |
3380 try: |
3453 u.warn(_("interrupted!\n")) |
3381 u.warn(_("interrupted!\n")) |
3465 elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
3393 elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
3466 if u.debugflag: |
3394 if u.debugflag: |
3467 u.warn(_("broken pipe\n")) |
3395 u.warn(_("broken pipe\n")) |
3468 elif getattr(inst, "strerror", None): |
3396 elif getattr(inst, "strerror", None): |
3469 if getattr(inst, "filename", None): |
3397 if getattr(inst, "filename", None): |
3470 u.warn(_("abort: %s - %s\n") % (inst.strerror, inst.filename)) |
3398 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
3471 else: |
3399 else: |
3472 u.warn(_("abort: %s\n") % inst.strerror) |
3400 u.warn(_("abort: %s\n") % inst.strerror) |
3473 else: |
3401 else: |
3474 raise |
3402 raise |
3475 except OSError, inst: |
3403 except OSError, inst: |
3476 if hasattr(inst, "filename"): |
3404 if getattr(inst, "filename", None): |
3477 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
3405 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
3478 else: |
3406 else: |
3479 u.warn(_("abort: %s\n") % inst.strerror) |
3407 u.warn(_("abort: %s\n") % inst.strerror) |
3480 except util.Abort, inst: |
3408 except util.Abort, inst: |
3481 u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n') |
3409 u.warn(_("abort: %s\n") % inst) |
3482 except TypeError, inst: |
3410 except TypeError, inst: |
3483 # was this an argument error? |
3411 # was this an argument error? |
3484 tb = traceback.extract_tb(sys.exc_info()[2]) |
3412 tb = traceback.extract_tb(sys.exc_info()[2]) |
3485 if len(tb) > 2: # no |
3413 if len(tb) > 2: # no |
3486 raise |
3414 raise |