[PATCH] qnew: ignore force option

Augie Fackler durin42 at gmail.com
Sun Feb 7 08:01:44 CST 2010


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1265549825 21600
# Node ID 002f915e7bff0a226427298ebac24114649265cf
# Parent  f05e0d54f424a116098ac3a3b638c7fcd73b3118
qnew: ignore force option

This makes the default behavior the same as qnew --force, and
deprecates the force option.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -784,12 +784,11 @@
 
     def check_localchanges(self, repo, force=False, refresh=True):
         m, a, r, d = repo.status()[:4]
-        if m or a or r or d:
-            if not force:
-                if refresh:
-                    raise util.Abort(_("local changes found, refresh first"))
-                else:
-                    raise util.Abort(_("local changes found"))
+        if (m or a or r or d) and not force:
+            if refresh:
+                raise util.Abort(_("local changes found, refresh first"))
+            else:
+                raise util.Abort(_("local changes found"))
         return m, a, r, d
 
     _reserved = ('series', 'status', 'guards')
@@ -804,7 +803,6 @@
            msg: a string or a no-argument function returning a string
         """
         msg = opts.get('msg')
-        force = opts.get('force')
         user = opts.get('user')
         date = opts.get('date')
         if date:
@@ -821,12 +819,10 @@
             match.bad = badfn
             m, a, r, d = repo.status(match=match)[:4]
         else:
-            m, a, r, d = self.check_localchanges(repo, force)
+            m, a, r, d = self.check_localchanges(repo, force=True)
             match = cmdutil.matchfiles(repo, m + a + r)
-        if force:
-            p = repo[None].parents()
-            if len(p) > 1:
-                raise util.Abort(_('cannot manage merge changesets'))
+        if len(repo[None].parents()) > 1:
+            raise util.Abort(_('cannot manage merge changesets'))
         commitfiles = m + a + r
         self.check_toppatch(repo)
         insert = self.full_series_end()
@@ -2682,7 +2678,7 @@
     "qnew":
         (new,
          [('e', 'edit', None, _('edit commit message')),
-          ('f', 'force', None, _('import uncommitted changes into patch')),
+          ('f', 'force', None, _('import uncommitted changes into patch (deprecated)')),
           ('g', 'git', None, _('use git extended diff format')),
           ('U', 'currentuser', None, _('add "From: <current user>" to patch')),
           ('u', 'user', '', _('add "From: <given user>" to patch')),
diff --git a/tests/test-mq-qnew b/tests/test-mq-qnew
--- a/tests/test-mq-qnew
+++ b/tests/test-mq-qnew
@@ -23,11 +23,8 @@
 hg qnew uncommitted.patch
 hg st
 hg qseries
-hg revert --no-backup somefile
-rm somefile
 
 echo '% qnew implies add'
-hg qnew test.patch
 hg -R .hg/patches st
 
 echo '% qnew missing'
diff --git a/tests/test-mq-qnew.out b/tests/test-mq-qnew.out
--- a/tests/test-mq-qnew.out
+++ b/tests/test-mq-qnew.out
@@ -5,12 +5,11 @@
 abort: "guards" cannot be used as the name of a patch
 abort: ".hgignore" cannot be used as the name of a patch
 % qnew with uncommitted changes
-abort: local changes found, refresh first
-A somefile
+uncommitted.patch
 % qnew implies add
 A .hgignore
 A series
-A test.patch
+A uncommitted.patch
 % qnew missing
 abort: missing: No such file or directory
 % qnew -m
@@ -22,7 +21,7 @@
 % qnew -f from a subdirectory
 popping first.patch
 popping mtest.patch
-popping test.patch
+popping uncommitted.patch
 patch queue now empty
 adding d/b
 M d/b


More information about the Mercurial-devel mailing list