hgeditor and diffs (was: Re: Harden uses of os.system)

Thomas Arendsen Hein thomas at intevation.de
Sun Jun 26 10:36:29 UTC 2005


* Matt Mackall <mpm at selenic.com> [20050626 01:23]:
> Are you using hgeditor? It basically does that, but without the GUI
> bits. Though TAH broke it so it now shows diffs of everything rather
> than just what's in the commit.

My hgeditor changes fixed the case where you are in a subdirectory
and say 'hg commit', but it broke the other case where you are in
the root and say 'hg commit file1...fileN'.

Files containing spaces and doing 'hg commit file1...fileN' in a
subdirectory were broken before, too, so I considered my way of
generating diffs better, though not perfect.

Thanks to the new 'hg root' command a fix for everything is easy,
the patch is attached and of course pullable from
http://hg.intevation.org/mercurial-tah/

Thomas

-- 
Email: thomas at intevation.de
http://intevation.de/~thomas/
-------------- next part --------------
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID ab53998b9dcd43e464a8116239fd1a3ff72667b7
# Parent  5914e27dc717232d00585518484438a9be815d6f

Fixed diff generation in hgeditor if a list of files is given to hg commit.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fixed diff generation in hgeditor if a list of files is given to hg commit.

manifest hash: 3eadc3637963778a35000fa75f229eb6b44ffc3d
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCvoRsW7P1GVgWeRoRArNpAJ4p5NQBkv1X+eHwWU7+aqoGkcqwlACgklk2
e/vr9qiIPcOVrbYViapZD9E=
=3fRb
-----END PGP SIGNATURE-----

diff -r 5914e27dc717 -r ab53998b9dcd hgeditor
--- a/hgeditor	Sun Jun 26 00:31:43 2005
+++ b/hgeditor	Sun Jun 26 10:33:16 2005
@@ -27,7 +27,12 @@
 
     echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
     grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
-    hg diff >> "$T2"
+    (
+        cd "`hg root`"
+        grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
+            hg diff "$changed" >> "$T2"
+        done
+    )
 
     CHECKSUM=`md5sum "$T1"`
     $EDITOR "$T1" "$T2" || cleanup_exit $?


More information about the Mercurial mailing list