[PATCH 7/7] Use a separate directory for patches under each branch subdir

From: Chuck Lever <cel@netapp.com>
Date: 2005-11-30 09:09:52
Currently you can't specify a patch name that matches the name of one of
the stgit special files under .git/patches/<branch-name>.  Let's use a
new subdirectory under .git/patches/<branch-name> to contain just the
patch directories to remove this limitation.

Signed-off-by: Chuck Lever <cel@netapp.com>
---

 stgit/stack.py |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/stgit/stack.py b/stgit/stack.py
index 2866121..46b404c 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -264,14 +264,19 @@ class Series:
 
         if self.__name:
             base_dir = git.get_base_dir()
-            self.__patch_dir = os.path.join(base_dir, 'patches',
-                                            self.__name)
             self.__base_file = os.path.join(base_dir, 'refs', 'bases',
                                             self.__name)
-            self.__applied_file = os.path.join(self.__patch_dir, 'applied')
-            self.__unapplied_file = os.path.join(self.__patch_dir, 'unapplied')
-            self.__current_file = os.path.join(self.__patch_dir, 'current')
-            self.__descr_file = os.path.join(self.__patch_dir, 'description')
+            self.__series_dir = os.path.join(base_dir, 'patches',
+                                             self.__name)
+
+            self.__applied_file = os.path.join(self.__series_dir, 'applied')
+            self.__unapplied_file = os.path.join(self.__series_dir, 'unapplied')
+            self.__current_file = os.path.join(self.__series_dir, 'current')
+            self.__descr_file = os.path.join(self.__series_dir, 'description')
+
+            self.__patch_dir = os.path.join(self.__series_dir, 'patches')
+            if not os.path.isdir(self.__patch_dir):
+                self.__patch_dir = self.__series_dir
 
     def get_branch(self):
         """Return the branch name for the Series object
@@ -323,15 +328,15 @@ class Series:
         return self.__base_file
 
     def get_protected(self):
-        return os.path.isfile(os.path.join(self.__patch_dir, 'protected'))
+        return os.path.isfile(os.path.join(self.__series_dir, 'protected'))
 
     def protect(self):
-        protect_file = os.path.join(self.__patch_dir, 'protected')
+        protect_file = os.path.join(self.__series_dir, 'protected')
         if not os.path.isfile(protect_file):
             create_empty_file(protect_file)
 
     def unprotect(self):
-        protect_file = os.path.join(self.__patch_dir, 'protected')
+        protect_file = os.path.join(self.__series_dir, 'protected')
         if os.path.isfile(protect_file):
             os.remove(protect_file)
 
@@ -399,6 +404,7 @@ class Series:
         create_empty_file(self.__applied_file)
         create_empty_file(self.__unapplied_file)
         create_empty_file(self.__descr_file)
+        os.makedirs(os.path.join(self.__series_dir, 'patches'))
         self.__begin_stack_check()
 
     def rename(self, to_name):

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed Nov 30 09:10:15 2005

This archive was generated by hypermail 2.1.8 : 2005-11-30 09:14:50 EST