histedit: allow "-" as a command file
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 16 Apr 2013 20:48:37 +0200
changeset 19018 730614b9b352
parent 19017 c5c8613f265e
child 19019 53060cc1b601
histedit: allow "-" as a command file When "-" is specified as a command file, we read rules from stdin. Alter a single test to demo the behavior, but most of them could benefit from this. There is minor change in test output resulting from the fact we no longer change log messages.
hgext/histedit.py
tests/test-histedit-fold.t
--- a/hgext/histedit.py	Tue Apr 16 16:58:25 2013 +0200
+++ b/hgext/histedit.py	Tue Apr 16 20:48:37 2013 +0200
@@ -143,6 +143,7 @@
 except ImportError:
     import pickle
 import os
+import sys
 
 from mercurial import cmdutil
 from mercurial import discovery
@@ -515,7 +516,10 @@
             f.write(rules)
             f.close()
         else:
-            f = open(rules)
+            if rules == '-':
+                f = sys.stdin
+            else:
+                f = open(rules)
             rules = f.read()
             f.close()
         rules = [l for l in (r.strip() for r in rules.splitlines())
--- a/tests/test-histedit-fold.t	Tue Apr 16 16:58:25 2013 +0200
+++ b/tests/test-histedit-fold.t	Tue Apr 16 20:48:37 2013 +0200
@@ -49,14 +49,12 @@
   o  0:cb9a9f314b8b a
   
 
-  $ EDITED="$TESTTMP/editedhistory"
-  $ cat > $EDITED <<EOF
+  $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
   > pick e860deea161a e
   > pick 652413bf663e f
   > fold 177f92b77385 c
   > pick 055a42cdd887 d
   > EOF
-  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
   0 files updated, 0 files merged, 4 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -67,9 +65,9 @@
 
 log after edit
   $ hg logt --graph
-  @  4:7e0a290363ed d
+  @  4:9c277da72c9b d
   |
-  o  3:5e24935bad3d pick e860deea161a e
+  o  3:6de59d13424a f
   |
   o  2:ee283cb5f2d5 e
   |
@@ -138,6 +136,7 @@
   o  0:0189ba417d34 1+2+3
   
 
+  $ EDITED="$TESTTMP/editedhistory"
   $ cat > $EDITED <<EOF
   > pick 617f94f13c0f 1 +4
   > drop 888f9082bf99 2 +5