comparison mercurial/commands.py @ 27388:4a921d66617f

import: refactor exact flag
author timeless <timeless@mozdev.org>
date Tue, 15 Dec 2015 07:54:01 +0000
parents 20e7de6205e7
children 7edd78690c57
comparison
equal deleted inserted replaced
27387:dfab0afde928 27388:4a921d66617f
4663 4663
4664 date = opts.get('date') 4664 date = opts.get('date')
4665 if date: 4665 if date:
4666 opts['date'] = util.parsedate(date) 4666 opts['date'] = util.parsedate(date)
4667 4667
4668 exact = opts.get('exact')
4668 update = not opts.get('bypass') 4669 update = not opts.get('bypass')
4669 if not update and opts.get('no_commit'): 4670 if not update and opts.get('no_commit'):
4670 raise error.Abort(_('cannot use --no-commit with --bypass')) 4671 raise error.Abort(_('cannot use --no-commit with --bypass'))
4671 try: 4672 try:
4672 sim = float(opts.get('similarity') or 0) 4673 sim = float(opts.get('similarity') or 0)
4674 raise error.Abort(_('similarity must be a number')) 4675 raise error.Abort(_('similarity must be a number'))
4675 if sim < 0 or sim > 100: 4676 if sim < 0 or sim > 100:
4676 raise error.Abort(_('similarity must be between 0 and 100')) 4677 raise error.Abort(_('similarity must be between 0 and 100'))
4677 if sim and not update: 4678 if sim and not update:
4678 raise error.Abort(_('cannot use --similarity with --bypass')) 4679 raise error.Abort(_('cannot use --similarity with --bypass'))
4679 if opts.get('exact') and opts.get('edit'): 4680 if exact:
4680 raise error.Abort(_('cannot use --exact with --edit')) 4681 if opts.get('edit'):
4681 if opts.get('exact') and opts.get('prefix'): 4682 raise error.Abort(_('cannot use --exact with --edit'))
4682 raise error.Abort(_('cannot use --exact with --prefix')) 4683 if opts.get('prefix'):
4684 raise error.Abort(_('cannot use --exact with --prefix'))
4683 4685
4684 base = opts["base"] 4686 base = opts["base"]
4685 wlock = dsguard = lock = tr = None 4687 wlock = dsguard = lock = tr = None
4686 msgs = [] 4688 msgs = []
4687 ret = 0 4689 ret = 0
4691 try: 4693 try:
4692 wlock = repo.wlock() 4694 wlock = repo.wlock()
4693 4695
4694 if update: 4696 if update:
4695 cmdutil.checkunfinished(repo) 4697 cmdutil.checkunfinished(repo)
4696 if (opts.get('exact') or not opts.get('force')) and update: 4698 if (exact or not opts.get('force')):
4697 cmdutil.bailifchanged(repo) 4699 cmdutil.bailifchanged(repo)
4698 4700
4699 if not opts.get('no_commit'): 4701 if not opts.get('no_commit'):
4700 lock = repo.lock() 4702 lock = repo.lock()
4701 tr = repo.transaction('import') 4703 tr = repo.transaction('import')
4702 else: 4704 else:
4718 parents, opts, 4720 parents, opts,
4719 msgs, hg.clean) 4721 msgs, hg.clean)
4720 if msg: 4722 if msg:
4721 haspatch = True 4723 haspatch = True
4722 ui.note(msg + '\n') 4724 ui.note(msg + '\n')
4723 if update or opts.get('exact'): 4725 if update or exact:
4724 parents = repo[None].parents() 4726 parents = repo[None].parents()
4725 else: 4727 else:
4726 parents = [repo[node]] 4728 parents = [repo[node]]
4727 if rej: 4729 if rej:
4728 ui.write_err(_("patch applied partially\n")) 4730 ui.write_err(_("patch applied partially\n"))