[PATCH 08 of 19] mq: make qsave implementation more explicit

Mads Kiilerich mads at kiilerich.com
Thu Jan 12 19:32:42 CST 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1326245395 -3600
# Node ID 84f79598db7e418e12fd54359225df235004cce5
# Parent  17f3c59f987c5e7cd49186650c3a8bf7a1251ebe
mq: make qsave implementation more explicit

It wasn't obvious from the code how qsave mocked around with .hg/patches and
.hg/patches.? and what was going on.

This makes it more explicit so it will survive future refactorings.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2652,7 +2652,7 @@
     ret = q.save(repo, msg=message)
     if ret:
         return ret
-    q.savedirty()
+    q.savedirty() # save to .hg/patches before copying
     if opts.get('copy'):
         path = q.path
         if opts.get('name'):
@@ -2669,10 +2669,9 @@
         ui.warn(_("copy %s to %s\n") % (path, newpath))
         util.copyfiles(path, newpath)
     if opts.get('empty'):
-        try:
-            os.unlink(q.join(q.statuspath))
-        except:
-            pass
+        del q.applied[:]
+        q.applieddirty = True
+        q.savedirty()
     return 0
 
 @command("strip",
diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t
--- a/tests/test-check-code-hg.t
+++ b/tests/test-check-code-hg.t
@@ -245,7 +245,6 @@
   hgext/mq.py:0:
    >         except:
    warning: naked except clause
-   warning: naked except clause
   hgext/mq.py:0:
    >         ui.write("mq:     %s\n" % ', '.join(m))
    warning: unwrapped ui message


More information about the Mercurial-devel mailing list