diff mercurial/cmdutil.py @ 30755:0fbb3a5c188e

rebase: provide detailed hint to abort message if working dir is not clean Detailed hint message is now provided when 'pull --rebase' operation detects unclean working dir, for example: abort: uncommitted changes (cannot pull with rebase: please commit or shelve your changes first) Added tests for uncommitted merge, and for subrepo support verifying that same hint is also passed to subrepo state check.
author Valters Vingolds <valters@vingolds.ch>
date Tue, 10 Jan 2017 09:32:27 +0100
parents ee47e951c6f9
children bd5e9647f646
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Jan 09 16:02:56 2017 +0900
+++ b/mercurial/cmdutil.py	Tue Jan 10 09:32:27 2017 +0100
@@ -355,15 +355,23 @@
 
     return p
 
-def bailifchanged(repo, merge=True):
+def bailifchanged(repo, merge=True, hint=None):
+    """ enforce the precondition that working directory must be clean.
+
+    'merge' can be set to false if a pending uncommitted merge should be
+    ignored (such as when 'update --check' runs).
+
+    'hint' is the usual hint given to Abort exception.
+    """
+
     if merge and repo.dirstate.p2() != nullid:
-        raise error.Abort(_('outstanding uncommitted merge'))
+        raise error.Abort(_('outstanding uncommitted merge'), hint=hint)
     modified, added, removed, deleted = repo.status()[:4]
     if modified or added or removed or deleted:
-        raise error.Abort(_('uncommitted changes'))
+        raise error.Abort(_('uncommitted changes'), hint=hint)
     ctx = repo[None]
     for s in sorted(ctx.substate):
-        ctx.sub(s).bailifchanged()
+        ctx.sub(s).bailifchanged(hint=hint)
 
 def logmessage(ui, opts):
     """ get the log message according to -m and -l option """