changeset 21055:dbff8c119cf6

patchbomb: warn when emailing a dirty working directory parent
author Mads Kiilerich <madski@unity3d.com>
date Mon, 07 Apr 2014 23:10:20 +0200
parents fffa9f17c3ef
children d70703954a2a
files hgext/patchbomb.py tests/test-patchbomb.t
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 \