chiark / gitweb /
Allow patch refreshing for some files only
[stgit] / stgit / stack.py
index 8b7c29620d6479299f065fd6237be6e754dafcd0..b081c9502a0676308037a7f9327661c618db5233 100644 (file)
@@ -257,21 +257,23 @@ class Series:
     def __init__(self, name = None):
         """Takes a series name as the parameter.
         """
-        if name:
-            self.__name = name
-        else:
-            self.__name = git.get_head_file()
-
-        if self.__name:
+        try:
+            if name:
+                self.__name = name
+            else:
+                self.__name = git.get_head_file()
             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')
+        except git.GitException, ex:
+            raise StackException, 'GIT tree not initialised: %s' % ex
+
+        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')
 
     def get_branch(self):
         """Return the branch name for the Series object
@@ -474,7 +476,8 @@ class Series:
         if os.path.exists(self.__base_file):
             os.remove(self.__base_file)
 
-    def refresh_patch(self, message = None, edit = False, show_patch = False,
+    def refresh_patch(self, files = None, message = None, edit = False,
+                      show_patch = False,
                       cache_update = True,
                       author_name = None, author_email = None,
                       author_date = None,
@@ -510,7 +513,8 @@ class Series:
         if not committer_email:
             committer_email = patch.get_commemail()
 
-        commit_id = git.commit(message = descr, parents = [patch.get_bottom()],
+        commit_id = git.commit(files = files,
+                               message = descr, parents = [patch.get_bottom()],
                                cache_update = cache_update,
                                allowempty = True,
                                author_name = author_name,