| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,8 @@ def _init_externals(): | |||
| 49 | 49 | LockFile, | |
| 50 | 50 | BlockingLockFile, | |
| 51 | 51 | Stats, | |
| 52 | - Actor | ||
| 52 | + Actor, | ||
| 53 | + rmtree, | ||
| 53 | 54 | ) | |
| 54 | 55 | ||
| 55 | 56 | #} END imports | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -823,27 +823,30 @@ def _call_process(self, method, *args, **kwargs): | |||
| 823 | 823 | is realized as non-existent | |
| 824 | 824 | ||
| 825 | 825 | :param kwargs: | |
| 826 | - is a dict of keyword arguments. | ||
| 827 | - This function accepts the same optional keyword arguments | ||
| 828 | - as execute(). | ||
| 829 | - | ||
| 830 | - ``Examples``:: | ||
| 826 | + It contains key-values for the following: | ||
| 827 | + - the :meth:`execute()` kwds, as listed in :var:`execute_kwargs`; | ||
| 828 | + - "command options" to be converted by :meth:`transform_kwargs()`; | ||
| 829 | + - the `'insert_kwargs_after'` key which its value must match one of ``*args``, | ||
| 830 | + and any cmd-options will be appended after the matched arg. | ||
| 831 | + | ||
| 832 | + Examples:: | ||
| 833 | + | ||
| 831 | 834 | git.rev_list('master', max_count=10, header=True) | |
| 835 | + | ||
| 836 | + turns into:: | ||
| 837 | + | ||
| 838 | + git rev-list max-count 10 --header master | ||
| 832 | 839 | ||
| 833 | 840 | :return: Same as ``execute``""" | |
| 834 | 841 | # Handle optional arguments prior to calling transform_kwargs | |
| 835 | 842 | # otherwise these'll end up in args, which is bad. | |
| 836 | - _kwargs = dict() | ||
| 837 | - for kwarg in execute_kwargs: | ||
| 838 | - try: | ||
| 839 | - _kwargs[kwarg] = kwargs.pop(kwarg) | ||
| 840 | - except KeyError: | ||
| 841 | - pass | ||
| 843 | + exec_kwargs = dict((k, v) for k, v in kwargs.items() if k in execute_kwargs) | ||
| 844 | + opts_kwargs = dict((k, v) for k, v in kwargs.items() if k not in execute_kwargs) | ||
| 842 | 845 | ||
| 843 | - insert_after_this_arg = kwargs.pop('insert_kwargs_after', None) | ||
| 846 | + insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None) | ||
| 844 | 847 | ||
| 845 | 848 | # Prepare the argument list | |
| 846 | - opt_args = self.transform_kwargs(**kwargs) | ||
| 849 | + opt_args = self.transform_kwargs(**opts_kwargs) | ||
| 847 | 850 | ext_args = self.__unpack_args([a for a in args if a is not None]) | |
| 848 | 851 | ||
| 849 | 852 | if insert_after_this_arg is None: | |
@@ -852,11 +855,11 @@ def _call_process(self, method, *args, **kwargs): | |||
| 852 | 855 | try: | |
| 853 | 856 | index = ext_args.index(insert_after_this_arg) | |
| 854 | 857 | except ValueError: | |
| 855 | - raise ValueError("Couldn't find argument '%s' in args %s to insert kwargs after" | ||
| 858 | + raise ValueError("Couldn't find argument '%s' in args %s to insert cmd options after" | ||
| 856 | 859 | % (insert_after_this_arg, str(ext_args))) | |
| 857 | 860 | # end handle error | |
| 858 | 861 | args = ext_args[:index + 1] + opt_args + ext_args[index + 1:] | |
| 859 | - # end handle kwargs | ||
| 862 | + # end handle opts_kwargs | ||
| 860 | 863 | ||
| 861 | 864 | call = [self.GIT_PYTHON_GIT_EXECUTABLE] | |
| 862 | 865 | ||
@@ -871,7 +874,7 @@ def _call_process(self, method, *args, **kwargs): | |||
| 871 | 874 | call.append(dashify(method)) | |
| 872 | 875 | call.extend(args) | |
| 873 | 876 | ||
| 874 | - return self.execute(call, **_kwargs) | ||
| 877 | + return self.execute(call, **exec_kwargs) | ||
| 875 | 878 | ||
| 876 | 879 | def _parse_object_header(self, header_line): | |
| 877 | 880 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,8 @@ | |||
| 33 | 33 | import os.path as osp | |
| 34 | 34 | ||
| 35 | 35 | from .fun import rev_parse, is_git_dir, find_submodule_git_dir, touch | |
| 36 | + import gc | ||
| 37 | + import gitdb | ||
| 36 | 38 | ||
| 37 | 39 | ||
| 38 | 40 | log = logging.getLogger(__name__) | |
@@ -177,9 +179,21 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals | |||
| 177 | 179 | args.append(self.git) | |
| 178 | 180 | self.odb = odbt(*args) | |
| 179 | 181 | ||
| 182 | + def __enter__(self): | ||
| 183 | + return self | ||
| 184 | + | ||
| 185 | + def __exit__(self, exc_type, exc_value, traceback): | ||
| 186 | + self.close() | ||
| 187 | + | ||
| 180 | 188 | def __del__(self): | |
| 189 | + self.close() | ||
| 190 | + | ||
| 191 | + def close(self): | ||
| 181 | 192 | if self.git: | |
| 182 | 193 | self.git.clear_cache() | |
| 194 | + gc.collect() | ||
| 195 | + gitdb.util.mman.collect() | ||
| 196 | + gc.collect() | ||
| 183 | 197 | ||
| 184 | 198 | def __eq__(self, rhs): | |
| 185 | 199 | if isinstance(rhs, Repo): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,18 +7,22 @@ | |||
| 7 | 7 | ||
| 8 | 8 | import contextlib | |
| 9 | 9 | from functools import wraps | |
| 10 | - import sys | ||
| 10 | + import gc | ||
| 11 | 11 | import io | |
| 12 | 12 | import logging | |
| 13 | 13 | import os | |
| 14 | + import sys | ||
| 14 | 15 | import tempfile | |
| 15 | 16 | import textwrap | |
| 16 | 17 | import time | |
| 17 | 18 | ||
| 18 | 19 | from git.compat import string_types, is_win | |
| 19 | 20 | from git.util import rmtree, cwd | |
| 21 | + import gitdb | ||
| 20 | 22 | ||
| 21 | 23 | import os.path as osp | |
| 24 | + | ||
| 25 | + | ||
| 22 | 26 | if sys.version_info[0:2] == (2, 6): | |
| 23 | 27 | import unittest2 as unittest | |
| 24 | 28 | else: | |
@@ -96,7 +100,6 @@ def wrapper(self): | |||
| 96 | 100 | # a windows-only issue. In fact things should be deleted, as well as | |
| 97 | 101 | # memory maps closed, once objects go out of scope. For some reason | |
| 98 | 102 | # though this is not the case here unless we collect explicitly. | |
| 99 | - import gc | ||
| 100 | 103 | gc.collect() | |
| 101 | 104 | if not keep: | |
| 102 | 105 | rmtree(path) | |
@@ -144,9 +147,10 @@ def repo_creator(self): | |||
| 144 | 147 | os.chdir(prev_cwd) | |
| 145 | 148 | rw_repo.git.clear_cache() | |
| 146 | 149 | rw_repo = None | |
| 147 | - import gc | ||
| 148 | - gc.collect() | ||
| 149 | 150 | if repo_dir is not None: | |
| 151 | + gc.collect() | ||
| 152 | + gitdb.util.mman.collect() | ||
| 153 | + gc.collect() | ||
| 150 | 154 | rmtree(repo_dir) | |
| 151 | 155 | # END rm test repo if possible | |
| 152 | 156 | # END cleanup | |
@@ -303,7 +307,8 @@ def remote_repo_creator(self): | |||
| 303 | 307 | rw_daemon_repo.git.clear_cache() | |
| 304 | 308 | del rw_repo | |
| 305 | 309 | del rw_daemon_repo | |
| 306 | - import gc | ||
| 310 | + gc.collect() | ||
| 311 | + gitdb.util.mman.collect() | ||
| 307 | 312 | gc.collect() | |
| 308 | 313 | if rw_repo_dir: | |
| 309 | 314 | rmtree(rw_repo_dir) | |
@@ -357,7 +362,6 @@ def setUpClass(cls): | |||
| 357 | 362 | each test type has its own repository | |
| 358 | 363 | """ | |
| 359 | 364 | from git import Repo | |
| 360 | - import gc | ||
| 361 | 365 | gc.collect() | |
| 362 | 366 | cls.rorepo = Repo(GIT_REPO) | |
| 363 | 367 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments