patchbomb: warn when emailing a dirty working directory parent
authorMads Kiilerich <madski@unity3d.com>
Mon, 07 Apr 2014 23:10:20 +0200
changeset 21055 dbff8c119cf6
parent 21054 fffa9f17c3ef
child 21056 d70703954a2a
patchbomb: warn when emailing a dirty working directory parent
hgext/patchbomb.py
tests/test-patchbomb.t
--- a/hgext/patchbomb.py	Wed Mar 19 00:19:54 2014 +0100
+++ b/hgext/patchbomb.py	Mon Apr 07 23:10:20 2014 +0200
@@ -291,7 +291,11 @@
         return [str(r) for r in revs]
 
     def getpatches(revs):
+        prev = repo['.'].rev()
         for r in scmutil.revrange(repo, revs):
+            if r == prev and (repo[None].files() or repo[None].deleted()):
+                ui.warn(_('warning: working directory has '
+                          'uncommitted changes\n'))
             output = cStringIO.StringIO()
             cmdutil.export(repo, [r], fp=output,
                          opts=patch.diffopts(ui, opts))
--- a/tests/test-patchbomb.t	Wed Mar 19 00:19:54 2014 +0100
+++ b/tests/test-patchbomb.t	Mon Apr 07 23:10:20 2014 +0200
@@ -1805,7 +1805,9 @@
   +b
   
 
-test single flag for single patch:
+test single flag for single patch (and no warning when not mailing dirty rev):
+  $ hg up -qr1
+  $ echo dirt > a
   $ hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \
   >  -r 2
   this patch series consists of 1 patches.
@@ -1839,9 +1841,10 @@
   +c
   
 
-test single flag for multiple patches:
+test single flag for multiple patches (and warning when mailing dirty rev):
   $ hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \
   >  -r 0:1
+  warning: working directory has uncommitted changes
   this patch series consists of 2 patches.
   
   
@@ -1919,6 +1922,8 @@
   @@ -0,0 +1,1 @@
   +b
   
+  $ hg revert --no-b a
+  $ hg up -q
 
 test multiple flags for single patch:
   $ hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \