Yujie Wu avatar Yujie Wu committed 25902ee

Fixed bug that `finish` could proceed with uncommitted changes present in workspace dir.

Comments (0)

Files changed (1)

             if (value in [None, ""]) :
+            # If the command is `hg commit --message <commit-hint> --force-editor [other-options...]`, we will drop the
+            # `--message <commit-hint> --force-editor` part from the command string because `--force-editor` is not a command
+            # option (it avails only programmatically).
+            if (cmd == "commit" and (key in ["message", "force_editor",]) and "force_editor" in kwarg) :
+                continue
             new_key = ""
             for e in key :
                 new_key += "-" if (e == "_") else e
         Construct a C{Flow} instance that will execute the workflow.
         Construction will fail if the C{flow} extension has not been initialized for the repository.
         A warning message will be issued if the repository has uncommitted changes.
         @type  init: C{boolean}
         @param init: If true, a C{Flow} object will be constructed for initialization of hgflow. Such constructed object does
                      not supply all functionalities and is only meant to execute the `hg flow init` command.
-    def _commit_change( self, opt, erase_branch = False ) :
+    def _commit_change( self, opt, commit_hint, is_erasing = False ) :
         Commit the changes in the workspace.
         Note that this method can potentially mutate C{opt}. Specifically, it will delete the C{commit} and C{message} keys if
         if (opt.get( "commit" )) :
             del opt["commit"]
+            msg = opt.get( "message" )
+            if (msg is None) :
+                opt["force_editor"] = True
+                opt["message"] = "\n\nHG: flow: %s" % commit_hint
             self._commit( **opt )
-            try :
-                del opt["message"]
-            except KeyError :
-                pass
+            del opt["message"]
+            if (msg is None) :
+                del opt["force_editor"]
         elif (opt.get( "message" )) :
-            if (erase_branch) :
+            if (is_erasing) :
                 del opt["message"]
             else :
                 raise AbortFlow( "Cannot use the specified commit message.", "Did you forget to specify the -c option?" )
                 raise AbortFlow( "'--erase' cannot be applied to branches with multiple merge destinations." )
         # Commits changes (if any) in the current branch.
-        self._commit_change( kwarg, should_erase )
+        self._commit_change( kwarg, "Finishing '%s' branch" % curr_workspace, should_erase )
+        if (self._has_uncommitted_changes()) :
+            raise AbortFlow( "Cannot finish '%s' branch because it has uncommitted changes." % curr_workspace )
         # For destin streams without trunks, we need to create a branch in each of these destin streams.
         # Each newly created branch will be named after the pattern: <stream-prefix>/<current-branch-basename> and will be from
         # the current branch. The current branch will be closed. Note that there is no need to merge the current branch because
- -c --commit        Commit changes before close the branch.
+ -c --commit        Commit changes before closing the branch.
  -m --message TEXT  Record TEXT as commit message.
  -p --stamp TEXT    Append TEXT to all commit messages.
  -d --date DATE     Record the specified DATE as commit date.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.