Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 2085:f71e9656524f
merge revlogng with mpm tip
author | Chris Mason <mason@suse.com> |
---|---|
date | Tue, 18 Apr 2006 19:50:12 -0400 |
parents | 345107e167a0 fef2d653beaf |
children | 1d3c6e63d703 |
comparison
equal
deleted
inserted
replaced
2084:d66278012853 | 2085:f71e9656524f |
---|---|
2257 This command tries to fix the repository status after an interrupted | 2257 This command tries to fix the repository status after an interrupted |
2258 operation. It should only be necessary when Mercurial suggests it. | 2258 operation. It should only be necessary when Mercurial suggests it. |
2259 """ | 2259 """ |
2260 if repo.recover(): | 2260 if repo.recover(): |
2261 return repo.verify() | 2261 return repo.verify() |
2262 return False | 2262 return 1 |
2263 | 2263 |
2264 def remove(ui, repo, pat, *pats, **opts): | 2264 def remove(ui, repo, pat, *pats, **opts): |
2265 """remove the specified files on the next commit | 2265 """remove the specified files on the next commit |
2266 | 2266 |
2267 Schedule the indicated files for removal from the repository. | 2267 Schedule the indicated files for removal from the repository. |
3257 | 3257 |
3258 try: | 3258 try: |
3259 u = ui.ui() | 3259 u = ui.ui() |
3260 except util.Abort, inst: | 3260 except util.Abort, inst: |
3261 sys.stderr.write(_("abort: %s\n") % inst) | 3261 sys.stderr.write(_("abort: %s\n") % inst) |
3262 sys.exit(1) | 3262 return -1 |
3263 | 3263 |
3264 external = [] | 3264 external = [] |
3265 for x in u.extensions(): | 3265 for x in u.extensions(): |
3266 def on_exception(exc, inst): | 3266 try: |
3267 u.warn(_("*** failed to import extension %s\n") % x[1]) | 3267 if x[1]: |
3268 u.warn("%s\n" % inst) | |
3269 if "--traceback" in sys.argv[1:]: | |
3270 traceback.print_exc() | |
3271 if x[1]: | |
3272 try: | |
3273 mod = imp.load_source(x[0], x[1]) | 3268 mod = imp.load_source(x[0], x[1]) |
3274 except Exception, inst: | 3269 else: |
3275 on_exception(Exception, inst) | 3270 def importh(name): |
3276 continue | 3271 mod = __import__(name) |
3277 else: | 3272 components = name.split('.') |
3278 def importh(name): | 3273 for comp in components[1:]: |
3279 mod = __import__(name) | 3274 mod = getattr(mod, comp) |
3280 components = name.split('.') | 3275 return mod |
3281 for comp in components[1:]: | |
3282 mod = getattr(mod, comp) | |
3283 return mod | |
3284 try: | |
3285 try: | 3276 try: |
3286 mod = importh("hgext." + x[0]) | 3277 mod = importh("hgext." + x[0]) |
3287 except ImportError: | 3278 except ImportError: |
3288 mod = importh(x[0]) | 3279 mod = importh(x[0]) |
3289 except Exception, inst: | 3280 external.append(mod) |
3290 on_exception(Exception, inst) | 3281 except Exception, inst: |
3291 continue | 3282 u.warn(_("*** failed to import extension %s: %s\n") % (x[0], inst)) |
3292 | 3283 if "--traceback" in sys.argv[1:]: |
3293 external.append(mod) | 3284 traceback.print_exc() |
3285 return 1 | |
3286 continue | |
3287 | |
3294 for x in external: | 3288 for x in external: |
3295 cmdtable = getattr(x, 'cmdtable', {}) | 3289 cmdtable = getattr(x, 'cmdtable', {}) |
3296 for t in cmdtable: | 3290 for t in cmdtable: |
3297 if t in table: | 3291 if t in table: |
3298 u.warn(_("module %s overrides %s\n") % (x.__name__, t)) | 3292 u.warn(_("module %s overrides %s\n") % (x.__name__, t)) |
3330 | 3324 |
3331 path = u.expandpath(options["repository"]) or "" | 3325 path = u.expandpath(options["repository"]) or "" |
3332 repo = path and hg.repository(u, path=path) or None | 3326 repo = path and hg.repository(u, path=path) or None |
3333 | 3327 |
3334 if options['help']: | 3328 if options['help']: |
3335 help_(u, cmd, options['version']) | 3329 return help_(u, cmd, options['version']) |
3336 sys.exit(0) | |
3337 elif options['version']: | 3330 elif options['version']: |
3338 show_version(u) | 3331 return show_version(u) |
3339 sys.exit(0) | |
3340 elif not cmd: | 3332 elif not cmd: |
3341 help_(u, 'shortlist') | 3333 return help_(u, 'shortlist') |
3342 sys.exit(0) | |
3343 | 3334 |
3344 if cmd not in norepo.split(): | 3335 if cmd not in norepo.split(): |
3345 try: | 3336 try: |
3346 if not repo: | 3337 if not repo: |
3347 repo = hg.repository(u, path=path) | 3338 repo = hg.repository(u, path=path) |
3392 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) | 3383 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
3393 help_(u, inst.args[0]) | 3384 help_(u, inst.args[0]) |
3394 else: | 3385 else: |
3395 u.warn(_("hg: %s\n") % inst.args[1]) | 3386 u.warn(_("hg: %s\n") % inst.args[1]) |
3396 help_(u, 'shortlist') | 3387 help_(u, 'shortlist') |
3397 sys.exit(-1) | |
3398 except AmbiguousCommand, inst: | 3388 except AmbiguousCommand, inst: |
3399 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % | 3389 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
3400 (inst.args[0], " ".join(inst.args[1]))) | 3390 (inst.args[0], " ".join(inst.args[1]))) |
3401 sys.exit(1) | |
3402 except UnknownCommand, inst: | 3391 except UnknownCommand, inst: |
3403 u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | 3392 u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
3404 help_(u, 'shortlist') | 3393 help_(u, 'shortlist') |
3405 sys.exit(1) | |
3406 except hg.RepoError, inst: | 3394 except hg.RepoError, inst: |
3407 u.warn(_("abort: "), inst, "!\n") | 3395 u.warn(_("abort: "), inst, "!\n") |
3408 except lock.LockHeld, inst: | 3396 except lock.LockHeld, inst: |
3409 if inst.errno == errno.ETIMEDOUT: | 3397 if inst.errno == errno.ETIMEDOUT: |
3410 reason = _('timed out waiting for lock held by %s') % inst.locker | 3398 reason = _('timed out waiting for lock held by %s') % inst.locker |
3447 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) | 3435 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
3448 else: | 3436 else: |
3449 u.warn(_("abort: %s\n") % inst.strerror) | 3437 u.warn(_("abort: %s\n") % inst.strerror) |
3450 except util.Abort, inst: | 3438 except util.Abort, inst: |
3451 u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n') | 3439 u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n') |
3452 sys.exit(1) | |
3453 except TypeError, inst: | 3440 except TypeError, inst: |
3454 # was this an argument error? | 3441 # was this an argument error? |
3455 tb = traceback.extract_tb(sys.exc_info()[2]) | 3442 tb = traceback.extract_tb(sys.exc_info()[2]) |
3456 if len(tb) > 2: # no | 3443 if len(tb) > 2: # no |
3457 raise | 3444 raise |
3458 u.debug(inst, "\n") | 3445 u.debug(inst, "\n") |
3459 u.warn(_("%s: invalid arguments\n") % cmd) | 3446 u.warn(_("%s: invalid arguments\n") % cmd) |
3460 help_(u, cmd) | 3447 help_(u, cmd) |
3461 except SystemExit: | 3448 except SystemExit, inst: |
3462 # don't catch this in the catch-all below | 3449 # Commands shouldn't sys.exit directly, but give a return code. |
3463 raise | 3450 # Just in case catch this and and pass exit code to caller. |
3451 return inst.code | |
3464 except: | 3452 except: |
3465 u.warn(_("** unknown exception encountered, details follow\n")) | 3453 u.warn(_("** unknown exception encountered, details follow\n")) |
3466 u.warn(_("** report bug details to mercurial@selenic.com\n")) | 3454 u.warn(_("** report bug details to mercurial@selenic.com\n")) |
3467 u.warn(_("** Mercurial Distributed SCM (version %s)\n") | 3455 u.warn(_("** Mercurial Distributed SCM (version %s)\n") |
3468 % version.get_version()) | 3456 % version.get_version()) |
3469 raise | 3457 raise |
3470 | 3458 |
3471 sys.exit(-1) | 3459 return -1 |