Commits

Anonymous committed a7c4bca

can omit branch_name now

  • Participants
  • Parent commits 65b5791
  • Branches develop

Comments (0)

Files changed (1)

File src/hgflow/hgflow.py

     else:
         ui.write(_('Invalid command, use `hg flow --help` for detail information' ), '\n')
 
+def hgflow_current_branch(hf, prefix):
+    ctx = hf.repo[None] 
+    current_branch = str(ctx.branch())
+    name = current_branch.replace(prefix, '')
+    if name == current_branch:
+        return None
+    return name
+    
+def hgfeature_cmd(ui, repo, *args, **opts):
+    hf = HgFlow(ui, repo)
+    if len(args) > 0 :
+        name = args[0]
+    else:
+        name = hgflow_current_branch(hf, hf.featurePrefix)
+        if name is None:
+            print "current branch is not feature branch"
+            return
+    HgFlow.hgflow_func_feature_short(hf, name,  args, opts)
+
+def hgrelease_cmd(ui, repo, *args, **opts):
+    hf = HgFlow(ui, repo)
+    if len(args) > 0 :
+        name = args[0]
+    else:
+        name = hgflow_current_branch(hf, hf.releasePrefix)
+        if name is None:
+            print "current branch is not release branch"
+            return
+    HgFlow.hgflow_func_release_short(hf, name,  args, opts)
+
+def hghotfix_cmd(ui, repo, *args, **opts):
+    hf = HgFlow(ui, repo)
+    if len(args) > 0 :
+        name = args[0]
+    else:
+        name = hgflow_current_branch(hf, hf.hotfixPrefix)
+        if name is None:
+            print "current branch is not hotfix branch"
+            return
+    HgFlow.hgflow_func_hotfix_short(hf, name,  args, opts)
+    
     '''
     print ui
     print repo
     print opts
     '''
 
-def hgfeature_cmd(ui, repo, name, *args, **opts):
-    hf = HgFlow(ui, repo)
-    HgFlow.hgflow_func_feature_short(hf, name,  args, opts)
-
-def hgrelease_cmd(ui, repo, name, *args, **opts):
-    hf = HgFlow(ui, repo)
-    HgFlow.hgflow_func_release_short(hf, name,  args, opts)
-
-def hghotfix_cmd(ui, repo, name, *args, **opts):
-    hf = HgFlow(ui, repo)
-    HgFlow.hgflow_func_hotfix_short(hf, name,  args, opts)
-    
 
 
 cmdtable = {
       [ ('c', 'close', None, 'close the branch'),
         ('s', 'switch', None, 'switch the branch'),
         ('f', 'finish', None, 'finish the branch') ],
-      ('hg feature [options] branch_name')
+      ('hg feature [options] [branch_name]')
       ),
     'release' : (
       hgrelease_cmd,
       [ ('c', 'close', None, 'close the branch'),
         ('s', 'switch', None, 'switch the branch'),
         ('f', 'finish', None, 'finish the branch') ],
-      ('hg release [options] branch_name')
+      ('hg release [options] [branch_name]')
       ),
     'hotfix' : (
       hghotfix_cmd,
       [ ('c', 'close', None, 'close the branch'),
         ('s', 'switch', None, 'switch the branch'),
         ('f', 'finish', None, 'finish the branch') ],
-      ('hg hotfix [options] branch_name')
+      ('hg hotfix [options] [branch_name]')
       )
     }