From 504a4470e47ca9679da3d0b315b9c9b1562d8e86 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Wed, 13 Mar 2013 04:43:15 +0100 Subject: [PATCH] Define portage.const.VCS_DIRS and use it in some modules. --- pym/_emerge/actions.py | 5 ++--- pym/_emerge/depgraph.py | 5 ++--- pym/portage/const.py | 2 ++ pym/portage/manifest.py | 5 +++-- pym/portage/update.py | 5 ++--- pym/portage/util/__init__.py | 4 ++-- pym/portage/util/listdir.py | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index fae293ee2..7fe8e8388 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -37,8 +37,7 @@ from portage import os from portage import shutil from portage import eapi_is_supported, _encodings, _unicode_decode from portage.cache.cache_errors import CacheError -from portage.const import GLOBAL_CONFIG_PATH -from portage.const import _DEPCLEAN_LIB_CHECK_DEFAULT +from portage.const import GLOBAL_CONFIG_PATH, VCS_DIRS, _DEPCLEAN_LIB_CHECK_DEFAULT from portage.dbapi.dep_expand import dep_expand from portage.dbapi._expand_new_virt import expand_new_virt from portage.dep import Atom @@ -2083,7 +2082,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): noiselevel=-1, level=logging.ERROR) return 1 - vcs_dirs = frozenset([".git", ".svn", "CVS", ".hg"]) + vcs_dirs = frozenset(VCS_DIRS) vcs_dirs = vcs_dirs.intersection(os.listdir(myportdir)) os.umask(0o022) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 34ad41353..965d3bcef 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -15,7 +15,7 @@ from itertools import chain import portage from portage import os, OrderedDict from portage import _unicode_decode, _unicode_encode, _encodings -from portage.const import PORTAGE_PACKAGE_ATOM, USER_CONFIG_PATH +from portage.const import PORTAGE_PACKAGE_ATOM, USER_CONFIG_PATH, VCS_DIRS from portage.dbapi import dbapi from portage.dbapi.dep_expand import dep_expand from portage.dbapi._similar_name_search import similar_name_search @@ -40,7 +40,6 @@ from portage.util import cmp_sort_key, writemsg, writemsg_stdout from portage.util import ensure_dirs from portage.util import writemsg_level, write_atomic from portage.util.digraph import digraph -from portage.util.listdir import _ignorecvs_dirs from portage.util._async.TaskScheduler import TaskScheduler from portage.versions import catpkgsplit @@ -6822,7 +6821,7 @@ class depgraph(object): if stat.S_ISREG(st.st_mode): last_file_path = p elif stat.S_ISDIR(st.st_mode): - if os.path.basename(p) in _ignorecvs_dirs: + if os.path.basename(p) in VCS_DIRS: continue try: contents = os.listdir(p) diff --git a/pym/portage/const.py b/pym/portage/const.py index 3859a1666..fdd33e63c 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -163,6 +163,8 @@ if "PORTAGE_OVERRIDE_EPREFIX" in os.environ: if EPREFIX: EPREFIX = os.path.normpath(EPREFIX) +VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn") + # =========================================================================== # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT # =========================================================================== diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 513f1ca8f..5b4082686 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -25,7 +25,8 @@ from portage.exception import DigestException, FileNotFound, \ InvalidDataType, MissingParameter, PermissionDenied, \ PortageException, PortagePackageException from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS, - MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH) + MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH, + VCS_DIRS) from portage.localization import _ _manifest_re = re.compile( @@ -53,7 +54,7 @@ def manifest2AuxfileFilter(filename): def manifest2MiscfileFilter(filename): filename = filename.strip(os.sep) - return not (filename in ["CVS", ".svn", "files", "Manifest"] or filename.endswith(".ebuild")) + return not (filename in VCS_DIRS + ("files", "Manifest") or filename.endswith(".ebuild")) def guessManifestFileType(filename): """ Perform a best effort guess of which type the given filename is, avoid using this if possible """ diff --git a/pym/portage/update.py b/pym/portage/update.py index f518510c4..1b45a7aaf 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -19,10 +19,9 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.dep:Atom,dep_getkey,isvalidatom,_get_slot_re', 'portage.util:ConfigProtect,new_protect_filename,' + \ 'normalize_path,write_atomic,writemsg', - 'portage.util.listdir:_ignorecvs_dirs', ) -from portage.const import USER_CONFIG_PATH +from portage.const import USER_CONFIG_PATH, VCS_DIRS from portage.dep import match_from_list from portage.eapi import _get_eapi_attrs from portage.exception import DirectoryNotFound, InvalidAtom, PortageException @@ -327,7 +326,7 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c except UnicodeDecodeError: dirs.remove(y_enc) continue - if y.startswith(".") or y in _ignorecvs_dirs: + if y.startswith(".") or y in VCS_DIRS: dirs.remove(y_enc) for y in files: try: diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index da5277bff..5085a8bb9 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -31,7 +31,6 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'pickle', 'portage.dep:Atom', - 'portage.util.listdir:_ignorecvs_dirs', 'subprocess', ) @@ -40,6 +39,7 @@ from portage import _encodings from portage import _os_merge from portage import _unicode_encode from portage import _unicode_decode +from portage.const import VCS_DIRS from portage.exception import InvalidAtom, PortageException, FileNotFound, \ OperationNotPermitted, ParseError, PermissionDenied, ReadOnlyFileSystem from portage.localization import _ @@ -480,7 +480,7 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0, allow_wildcard=Fals def grablines(myfilename, recursive=0, remember_source_file=False): mylines=[] if recursive and os.path.isdir(myfilename): - if os.path.basename(myfilename) in _ignorecvs_dirs: + if os.path.basename(myfilename) in VCS_DIRS: return mylines try: dirlist = os.listdir(myfilename) diff --git a/pym/portage/util/listdir.py b/pym/portage/util/listdir.py index c2628cbfe..b78ed19fe 100644 --- a/pym/portage/util/listdir.py +++ b/pym/portage/util/listdir.py @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = ['cacheddir', 'listdir'] @@ -8,10 +8,10 @@ import stat import time from portage import os +from portage.const import VCS_DIRS from portage.exception import DirectoryNotFound, PermissionDenied, PortageException from portage.util import normalize_path, writemsg -_ignorecvs_dirs = ('CVS', 'RCS', 'SCCS', '.svn', '.git') dircache = {} cacheHit = 0 cacheMiss = 0 @@ -77,7 +77,7 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli pass elif ignorecvs: if list[x][:2] != ".#" and \ - not (ftype[x] == 1 and list[x] in _ignorecvs_dirs): + not (ftype[x] == 1 and list[x] in VCS_DIRS): ret_list.append(list[x]) ret_ftype.append(ftype[x]) else: @@ -98,7 +98,7 @@ def listdir(mypath, recursive=False, filesonly=False, ignorecvs=False, ignorelis @type recursive: Boolean @param filesonly; Only return files, not more directories @type filesonly: Boolean - @param ignorecvs: Ignore CVS directories ('CVS','SCCS','.svn','.git') + @param ignorecvs: Ignore VCS directories @type ignorecvs: Boolean @param ignorelist: List of filenames/directories to exclude @type ignorelist: List -- 2.26.2