[PATCH] mq: Require '-f' option to 'qheader' to change applied patch headers

Peter Williams pwil3058 at bigpond.net.au
Sat Aug 22 22:09:34 CDT 2009


# HG changeset patch
# User Peter Williams <pwil3058 at bigpond.net.au>
# Date 1250996952 -36000
# Node ID 605cb2bf3b49e0cbc6122172d157401b12ea9128
# Parent  08f49696ecc450e63166b698b911dad06e418f05
mq: Require '-f' option to 'qheader' to change applied patch headers

Change 'qheader' to refuse to change headers of applied patches but
allow override by the use of the '-f' option.

diff -r 08f49696ecc4 -r 605cb2bf3b49 hgext/mq.py
--- a/hgext/mq.py	Sun Aug 23 13:06:49 2009 +1000
+++ b/hgext/mq.py	Sun Aug 23 13:09:12 2009 +1000
@@ -2096,6 +2096,9 @@ def header(ui, repo, patch=None, **opts)
     -u/--user and -d/--date can be used to set the (specified) user and
     date, respectively. -U/--currentuser and -D/--currentdate set user
     to current user and date to current date.
+
+    Modifications to applied patches will be refused unless -f/--force
+    is specified.
     """
     def get_patch_diff(patch):
         patchf = q.opener(patch, 'r')
@@ -2124,6 +2127,8 @@ def header(ui, repo, patch=None, **opts)
         patch = q.lookup('qtip')
 
     if [val for val in opts.values() if val]: # any options supplied?
+        if q.isapplied(patch) and not opts.get('force'):
+            raise util.Abort(_('%s is applied (use -f to force)') % patch)
         setupheaderopts(ui, opts)
         newuser = opts.get('user')
         newdate = opts.get('date')
@@ -2642,6 +2647,7 @@ cmdtable = {
     'qheader':
         (header,
          [('e', 'edit', None, _('edit commit message')),
+          ('f', 'force', None, _('modify applied patch header')),
          ] + userdateopts + commands.commitopts,
          _('hg qheader [[-e] | [-m TEXT] | [-l FILE]] [PATCH]')),
     "^qimport":


More information about the Mercurial-devel mailing list