Bug 966421 - Add --force option and make it only necessary when exporting the topmost patch, r=jdm
authorSteve Fink <sfink@mozilla.com>
Sat, 01 Feb 2014 12:13:12 -0800
changeset 134 b2e26e4759bc
parent 133 ff9678ca0c74
child 135 ccdd4e552096
push id63
push usersfink@mozilla.com
push date2014-02-01 20:13 +0000
reviewersjdm
bugs966421
Bug 966421 - Add --force option and make it only necessary when exporting the topmost patch, r=jdm
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -423,17 +423,18 @@ def infer_arguments(ui, repo, args, opts
     else:
         # Just right.
         rev, bug = args
 
     if rev is None:
         # Default to '.'
         rev = '.'
 
-    if repo[rev] == repo["."]:
+    # If no revision or '.' was given, complain about local changes
+    if rev == '.' and not opts['force']:
         m, a, r, d = repo.status()[:4]
         if (m or a or r or d):
             raise util.Abort(_("Local changes found; refresh first!"))
 
     if rev in [".", "tip", "qtip", "default"]:
         # Look for a nicer name in the MQ.
         if hasattr(repo, 'mq') and repo.mq.applied:
             rev = repo.mq.applied[-1].name
@@ -1154,23 +1155,27 @@ cmdtable = {
            'Update patch name and description to include bug number (only valid with --new)'),
           ('', 'no-update', None,
            'Suppress patch name/description update (override config file)'),
           ('', 'number', '',
            'When posting, prefix the patch description with "Patch <number> - "'),
           # The following option is passed through directly to patch.diffopts
           ('w', 'ignore_all_space', False,
            'Generate a diff that ignores whitespace changes'),
+          ('f', 'force', False,
+           'Proceed even if the working directory contains changes'),
           ] + newbug_opts,
          _('hg bzexport [options] [REV] [BUG]')),
 
     'newbug':
         (newbug,
          [('c', 'comment', '', 'Comment to add with the bug'),
           ('e', 'edit', False,
            'Open a text editor to modify bug fields'),
           ('i', 'interactive', False,
            'Interactive -- request confirmation before any permanent action'),
+          ('f', 'force', False,
+           'Proceed even if the working directory contains changes'),
           ('', 'take-bug', False,
            'Assign bug to myself'),
           ] + newbug_opts,
          _('hg newbug [-e] [[-t] TITLE] [[-c] COMMENT]' )),
 }