]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Ignore py files generated by emacs
authorMarkus Mattes <mmattes87@gmail.com>
Mon, 28 Nov 2016 22:32:27 +0000 (17:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 Nov 2016 22:43:34 +0000 (17:43 -0500)
Added a file ignore for Python files of the form ``.#<name>.py``,
which are generated by the Emacs editor.  Pull request courtesy
Markus Mattes.

Change-Id: I06861c2ba7b8e6730948c01ff0690b50bdb26f0f
Pull-request: https://github.com/zzzeek/alembic/pull/32
Fixes: #356
alembic/script/base.py
docs/build/changelog.rst
tests/test_script_consumption.py

index 3a0a6fd94150d2e3ecd1f5b149ae1b0e113ac078..a79ec09c2a615914ed40020c3554e9f6ed4eebb9 100644 (file)
@@ -9,8 +9,8 @@ from ..runtime import migration
 
 from contextlib import contextmanager
 
-_sourceless_rev_file = re.compile(r'(?!__init__)(.*\.py)(c|o)?$')
-_only_source_rev_file = re.compile(r'(?!__init__)(.*\.py)$')
+_sourceless_rev_file = re.compile(r'(?!\.\#|__init__)(.*\.py)(c|o)?$')
+_only_source_rev_file = re.compile(r'(?!\.\#|__init__)(.*\.py)$')
 _legacy_rev = re.compile(r'([a-f0-9]+)\.py$')
 _mod_def_re = re.compile(r'(upgrade|downgrade)_([a-z0-9]+)')
 _slug_re = re.compile(r'\w+')
index f4b332cd82756c33ac4d023c7a679e2544a47d84..b2ac08435a387edb4d83cc968150f8cc79454b99 100644 (file)
@@ -6,6 +6,14 @@ Changelog
 .. changelog::
     :version: 0.8.10
 
+    .. change:: 356
+      :tags: bug, versioning
+      :tickets: 356
+
+      Added a file ignore for Python files of the form ``.#<name>.py``,
+      which are generated by the Emacs editor.  Pull request courtesy
+      Markus Mattes.
+
 .. changelog::
     :version: 0.8.9
     :released: November 28, 2016
index fc9d9aa01da3923301f38d2043e3498bf859c0b8..a86430f74547f7327007a9f6e23f3d9cacaa423d 100644 (file)
@@ -301,7 +301,7 @@ def downgrade():
             Script._from_path, script, path)
 
 
-class IgnoreInitTest(TestBase):
+class IgnoreFilesTest(TestBase):
     sourceless = False
 
     def setUp(self):
@@ -312,12 +312,11 @@ class IgnoreInitTest(TestBase):
     def tearDown(self):
         clear_staging_env()
 
-    def _test_ignore_init_py(self, ext):
-        """test that __init__.py is ignored."""
+    def _test_ignore_file_py(self, fname):
 
         command.revision(self.cfg, message="some rev")
         script = ScriptDirectory.from_config(self.cfg)
-        path = os.path.join(script.versions, "__init__.%s" % ext)
+        path = os.path.join(script.versions, fname)
         with open(path, 'w') as f:
             f.write(
                 "crap, crap -> crap"
@@ -326,20 +325,42 @@ class IgnoreInitTest(TestBase):
 
         script.get_revision('head')
 
-    def test_ignore_py(self):
+    def _test_ignore_init_py(self, ext):
+        """test that __init__.py is ignored."""
+
+        self._test_ignore_file_py("__init__.%s" % ext)
+
+    def _test_ignore_dot_hash_py(self, ext):
+        """test that .#test.py is ignored."""
+
+        self._test_ignore_file_py(".#test.%s" % ext)
+
+    def test_ignore_init_py(self):
         self._test_ignore_init_py("py")
 
-    def test_ignore_pyc(self):
+    def test_ignore_init_pyc(self):
         self._test_ignore_init_py("pyc")
 
-    def test_ignore_pyx(self):
+    def test_ignore_init_pyx(self):
         self._test_ignore_init_py("pyx")
 
-    def test_ignore_pyo(self):
+    def test_ignore_init_pyo(self):
         self._test_ignore_init_py("pyo")
 
+    def test_ignore_dot_hash_py(self):
+        self._test_ignore_dot_hash_py("py")
+
+    def test_ignore_dot_hash_pyc(self):
+        self._test_ignore_dot_hash_py("pyc")
+
+    def test_ignore_dot_hash_pyx(self):
+        self._test_ignore_dot_hash_py("pyx")
+
+    def test_ignore_dot_hash_pyo(self):
+        self._test_ignore_dot_hash_py("pyo")
+
 
-class SourcelessIgnoreInitTest(IgnoreInitTest):
+class SourcelessIgnoreFilesTest(IgnoreFilesTest):
     sourceless = True