##// END OF EJS Templates
sparse: shorten try..except block in updateconfig()...
Gregory Szorc -
r33376:d5a38eae default
parent child Browse files
Show More
@@ -599,7 +599,6 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:
603 if reset:
602 if reset:
604 newinclude = set()
603 newinclude = set()
605 newexclude = set()
604 newexclude = set()
@@ -612,9 +611,8 def updateconfig(repo, pats, opts, inclu
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('/')]))
618 elif include:
616 elif include:
619 newinclude.update(pats)
617 newinclude.update(pats)
620 elif exclude:
618 elif exclude:
@@ -627,18 +625,22 def updateconfig(repo, pats, opts, inclu
627 newinclude.difference_update(pats)
625 newinclude.difference_update(pats)
628 newexclude.difference_update(pats)
626 newexclude.difference_update(pats)
629
627
630 writeconfig(repo, newinclude, newexclude, newprofiles)
631
632 fcounts = map(
633 len,
634 refreshwdir(repo, oldstatus, oldmatcher, force=force))
635
636 profilecount = (len(newprofiles - oldprofiles) -
628 profilecount = (len(newprofiles - oldprofiles) -
637 len(oldprofiles - newprofiles))
629 len(oldprofiles - newprofiles))
638 includecount = (len(newinclude - oldinclude) -
630 includecount = (len(newinclude - oldinclude) -
639 len(oldinclude - newinclude))
631 len(oldinclude - newinclude))
640 excludecount = (len(newexclude - oldexclude) -
632 excludecount = (len(newexclude - oldexclude) -
641 len(oldexclude - newexclude))
633 len(oldexclude - newexclude))
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:
640 fcounts = map(
641 len,
642 refreshwdir(repo, oldstatus, oldmatcher, force=force))
643
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