[PATCH 1 of 6 misc] patchbomb: warn when emailing a dirty working directory parent

Mads Kiilerich mads at kiilerich.com
Mon Apr 7 21:11:33 UTC 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1396905020 -7200
#      Mon Apr 07 23:10:20 2014 +0200
# Node ID ac4eb6bcdb81df536110ab0b09026539749599a0
# Parent  12f161f08d744f0e4b6eef9c905670afb5c24dd4
patchbomb: warn when emailing a dirty working directory parent

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -291,7 +291,11 @@ def patchbomb(ui, repo, *revs, **opts):
         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))
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -1805,7 +1805,9 @@ no intro message in non-interactive mode
   +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 @@ test single flag for single patch:
   +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 @@ test single flag for multiple patches:
   @@ -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 \


More information about the Mercurial-devel mailing list