##// END OF EJS Templates
sparse: shorten try..except block in updateconfig()...
Gregory Szorc -
r33376:d5a38eae default
parent child Browse files
Show More
@@ -599,46 +599,48 b' def updateconfig(repo, pats, opts, inclu'
599 oldinclude, oldexclude, oldprofiles = parseconfig(repo.ui, raw)
599 oldinclude, oldexclude, oldprofiles = parseconfig(repo.ui, raw)
600 oldprofiles = set(oldprofiles)
600 oldprofiles = set(oldprofiles)
601
601
602 try:
602 if reset:
603 if reset:
603 newinclude = set()
604 newinclude = set()
604 newexclude = set()
605 newexclude = set()
605 newprofiles = set()
606 newprofiles = set()
606 else:
607 else:
607 newinclude = set(oldinclude)
608 newinclude = set(oldinclude)
608 newexclude = set(oldexclude)
609 newexclude = set(oldexclude)
609 newprofiles = set(oldprofiles)
610 newprofiles = set(oldprofiles)
611
610
612 oldstatus = repo.status()
611 oldstatus = repo.status()
613
612
614 if any(pat.startswith('/') for pat in pats):
613 if any(pat.startswith('/') for pat in pats):
615 repo.ui.warn(_('warning: paths cannot start with /, '
614 repo.ui.warn(_('warning: paths cannot start with /, ignoring: %s\n')
616 'ignoring: %s\n') %
615 % ([pat for pat in pats if pat.startswith('/')]))
617 ([pat for pat in pats if pat.startswith('/')]))
616 elif include:
618 elif include:
617 newinclude.update(pats)
619 newinclude.update(pats)
618 elif exclude:
620 elif exclude:
619 newexclude.update(pats)
621 newexclude.update(pats)
620 elif enableprofile:
622 elif enableprofile:
621 newprofiles.update(pats)
623 newprofiles.update(pats)
622 elif disableprofile:
624 elif disableprofile:
623 newprofiles.difference_update(pats)
625 newprofiles.difference_update(pats)
624 elif delete:
626 elif delete:
625 newinclude.difference_update(pats)
627 newinclude.difference_update(pats)
626 newexclude.difference_update(pats)
628 newexclude.difference_update(pats)
629
627
630 writeconfig(repo, newinclude, newexclude, newprofiles)
628 profilecount = (len(newprofiles - oldprofiles) -
629 len(oldprofiles - newprofiles))
630 includecount = (len(newinclude - oldinclude) -
631 len(oldinclude - newinclude))
632 excludecount = (len(newexclude - oldexclude) -
633 len(oldexclude - newexclude))
631
634
635 # TODO clean up this writeconfig() + try..except pattern once we can.
636 # See comment in importfromfiles() explaining it.
637 writeconfig(repo, newinclude, newexclude, newprofiles)
638
639 try:
632 fcounts = map(
640 fcounts = map(
633 len,
641 len,
634 refreshwdir(repo, oldstatus, oldmatcher, force=force))
642 refreshwdir(repo, oldstatus, oldmatcher, force=force))
635
643
636 profilecount = (len(newprofiles - oldprofiles) -
637 len(oldprofiles - newprofiles))
638 includecount = (len(newinclude - oldinclude) -
639 len(oldinclude - newinclude))
640 excludecount = (len(newexclude - oldexclude) -
641 len(oldexclude - newexclude))
642 printchanges(repo.ui, opts, profilecount, includecount,
644 printchanges(repo.ui, opts, profilecount, includecount,
643 excludecount, *fcounts)
645 excludecount, *fcounts)
644 except Exception:
646 except Exception:
General Comments 0
You need to be logged in to leave comments. Login now