mq: make qsave implementation more explicit
authorMads Kiilerich <mads@kiilerich.com>
Wed, 11 Jan 2012 02:29:55 +0100
changeset 15880 02b135558756
parent 15879 710e6bf15538
child 15881 3862369cf9b9
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.
hgext/mq.py
tests/test-check-code-hg.t
--- a/hgext/mq.py	Wed Jan 11 02:28:36 2012 +0100
+++ b/hgext/mq.py	Wed Jan 11 02:29:55 2012 +0100
@@ -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",
--- a/tests/test-check-code-hg.t	Wed Jan 11 02:28:36 2012 +0100
+++ b/tests/test-check-code-hg.t	Wed Jan 11 02:29:55 2012 +0100
@@ -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