# HG changeset patch # User Jelmer Vernooij # Date 1610840892 0 # Sat Jan 16 23:48:12 2021 +0000 # Node ID 38c1e6be78d321265c496cbf5c337313d2c4a4d9 # Parent 14bc8b0103a3956a059ff4fe73a7398aba348388 Inline _get_ignore_manager. diff --git a/dulwich/porcelain.py b/dulwich/porcelain.py --- a/dulwich/porcelain.py +++ b/dulwich/porcelain.py @@ -1160,10 +1160,14 @@ index: Index to check against exclude_ignored: Whether to exclude ignored paths """ - ignore_manager = _get_ignore_manager(frompath, exclude_ignored) + if exclude_ignored: + with open_repo_closing(frompath) as r: + ignore_manager = IgnoreFilterManager.from_repo(r) + else: + ignore_manager = None for ap, is_dir in _walk_working_dir_paths(frompath, basepath): - if (exclude_ignored and + if (ignore_manager is not None and ignore_manager.is_ignored(os.path.relpath(ap, frompath))): continue if not is_dir: @@ -1172,20 +1176,6 @@ yield os.path.relpath(ap, frompath) -def _get_ignore_manager(frompath, exclude_ignored): - """Get a repo's IgnoreFilterManager from a path if required. - - Args: - frompath: The path of the repo - exclude_ignored: Whether to return the IgnoreFilterManager - """ - if exclude_ignored: - with open_repo_closing(frompath) as r: - ignore_manager = IgnoreFilterManager.from_repo(r) - - return ignore_manager - - def get_tree_changes(repo): """Return add/delete/modify changes to tree by comparing index to HEAD.