Patchwork hgk: use hg export to write commits

login
register
mail settings
Submitter Andrew Shadura
Date March 15, 2014, 6:20 p.m.
Message ID <5076a0d35bf7ee46f0a9.1394907610@localhost.localdomain>
Download mbox | patch
Permalink /patch/3949/
State Superseded
Commit 70f9a5d8c06fa53cfbbc01593c35540dc7eb1380
Headers show

Comments

Andrew Shadura - March 15, 2014, 6:20 p.m.
# HG changeset patch
# User Andrew Shadura <andrew@shadura.me>
# Date 1394904471 -3600
#      Sat Mar 15 18:27:51 2014 +0100
# Node ID 5076a0d35bf7ee46f0a9e4fba8580efaec81f7ea
# Parent  d1ef724df3b4d403338d986cf25a7e8bd5a67264
hgk: use hg export to write commits

Instead of calling internal command, use hg export to produce changeset
diffs compatible with hg import directly. Also, remove command entry from
the dialog box and append the .diff extension automatically.
Matt Mackall - March 16, 2014, 10:42 p.m.
On Sat, 2014-03-15 at 19:20 +0100, Andrew Shadura wrote:
> # HG changeset patch
> # User Andrew Shadura <andrew@shadura.me>
> # Date 1394904471 -3600
> #      Sat Mar 15 18:27:51 2014 +0100
> # Node ID 5076a0d35bf7ee46f0a9e4fba8580efaec81f7ea
> # Parent  d1ef724df3b4d403338d986cf25a7e8bd5a67264
> hgk: use hg export to write commits

> Instead of calling internal command, use hg export to produce changeset
> diffs compatible with hg import directly. Also, remove command entry from
> the dialog box and append the .diff extension automatically.

"Also" = "patch does more than one thing"

Patch

diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -3893,7 +3893,7 @@  proc mktaggo {} {
 }
 
 proc writecommit {} {
-    global rowmenuid wrcomtop commitinfo wrcomcmd
+    global rowmenuid wrcomtop commitinfo
 
     set top .writecommit
     set wrcomtop $top
@@ -3908,12 +3908,9 @@  proc writecommit {} {
     $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
     $top.head conf -state readonly
     grid x $top.head -sticky w
-    ttk::label $top.clab -text "Command:"
-    ttk::entry $top.cmd -width 60 -textvariable wrcomcmd
-    grid $top.clab $top.cmd -sticky w -pady 10
     ttk::label $top.flab -text "Output file:"
     ttk::entry $top.fname -width 60
-    $top.fname insert 0 [file normalize "commit-[string range $rowmenuid 0 6]"]
+    $top.fname insert 0 [file normalize "commit-[string range $rowmenuid 0 6].diff"]
     grid $top.flab $top.fname -sticky w
     ttk::frame $top.buts
     ttk::button $top.buts.gen -text "Write" -command wrcomgo
@@ -3931,9 +3928,8 @@  proc wrcomgo {} {
     global wrcomtop
 
     set id [$wrcomtop.sha1 get]
-    set cmd "echo $id | [$wrcomtop.cmd get]"
     set fname [$wrcomtop.fname get]
-    if {[catch {exec sh -c $cmd > $fname &} err]} {
+    if {[catch {exec $::env(HG) --config ui.report_untrusted=false export --git -o [string map {% %%} $fname] $id} err]} {
 	error_popup "Error writing commit: $err"
     }
     catch {destroy $wrcomtop}
@@ -4059,7 +4055,6 @@  proc getconfig {} {
 set datemode 0
 set boldnames 0
 set diffopts "-U 5 -p"
-set wrcomcmd "\"\$HG\" --config ui.report_untrusted=false debug-diff-tree --stdin -p --pretty"
 
 set mainfont {Helvetica 9}
 set curidfont {}