1. Flávio Coelho
  2. hgflow

Commits

yinwm  committed e0b6e84 Merge

hg flow, merge release `hotfix` to develop branch `develop`

  • Participants
  • Parent commits c271675, 6a69ff4
  • Branches develop

Comments (0)

Files changed (1)

File src/hgflow/hgflow.py

View file
  • Ignore whitespace
 
         func(action, name, target_branch)
 
-        
-
     def hgflow_func_release(self, args, opts):
         def _release_func(action, name, target_branch):
             if 'start' == action:
                 '''
 
                 if not self._findBranch(target_branch, name):
-                    return 
+                    return
 
-                commands.update(self.ui, self.repo, target_branch)
-                commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
-                commands.update(self.ui, self.repo, self.publishBranch)
+                self._mergeIntoPublishBranch(target_branch, name)
 
-                commands.merge(self.ui, self.repo, target_branch)
-                commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
-
-
-                tag_name = '%s%s' % (self.versionTagPrefix, name)
-                commands.tag(self.ui, self.repo, tag_name)
-
-
-                #merge it into develop branch, there should be many confilct code
-                commands.update(self.ui, self.repo, self.developBranch)
-                commands.merge(self.ui, self.repo, target_branch)
-
-                commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
-
-                #self.outputln(_('WARNING: No automatic commit after merge from release `%s`, you should resolve the confict (if any) then commit manually' % (name, )))
             else:
                 self.outputln(_('Please give a valid action.'))
 
+        self._hgflow_func_base(args, opts, self.releasePrefix, _release_func)
 
-        self._hgflow_func_base(args, opts, self.releasePrefix, _release_func)
+    def hgflow_func_hotfix(self, args, opts):
+        def _hotfix_func(action, name, target_branch):
+            if 'start' == action:
+                '''Create hotfix branch from publish branch
+                '''
+                self._startBranch(target_branch, self.publishBranch)
+            elif 'finish' == action:
+                '''finish the hotfix
+                1, Check publish branch version and current version
+                2, Close this branch
+                3, Merge it into publich branch
+                4, Tag publish branch with hotfix branch name
+                5, Merge it into develop branch. Always not successed, otherwise should manually do that
+                '''
+
+                if not self._findBranch(target_branch, name):
+                    return
+
+                self._mergeIntoPublishBranch(target_branch, name)
+
+            else:
+                self.outputln(_('Please give a valid action.'))
+
+        self._hgflow_func_base(args, opts, self.hotfixPrefix, _hotfix_func)
+                
+    def _mergeIntoPublishBranch(self, target_branch, name):
+        commands.update(self.ui, self.repo, target_branch)
+        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
+        commands.update(self.ui, self.repo, self.publishBranch)
+
+        commands.merge(self.ui, self.repo, target_branch)
+        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
+
+        tag_name = '%s%s' % (self.versionTagPrefix, name)
+        commands.tag(self.ui, self.repo, tag_name)
+
+        #merge it into develop branch, there should be many confilct code
+        commands.update(self.ui, self.repo, self.developBranch)
+        commands.merge(self.ui, self.repo, self.publishBranch)
+        
+        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
+
+        #self.outputln(_('WARNING: No automatic commit after merge from release `%s`, you should resolve the confict (if any) then commit manually' % (name, )))
 
     
 
     'init'      : HgFlow.hgflow_func_init,
     'feature'   : HgFlow.hgflow_func_feature,
     'release'   : HgFlow.hgflow_func_release,
+    'hotfix'    : HgFlow.hgflow_func_hotfix,
     }