Commits

Augie Fackler committed 50144f9

Add --commands flag to accept an input file for edit commands.

This is mostly useful to me for testing purposes, but it seems like it
might be more generally useful.

  • Participants
  • Parent commits a153d0c

Comments (0)

Files changed (2)

 
         ctxs = [repo[r] for r in revs]
         existing = [r.node() for r in ctxs]
-        rules = '\n'.join([('pick %s %s' % (c.hex()[:12],
-                                         c.description().splitlines()[0]))[:80]
-                           for c in ctxs])
-
-        rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12], )
-
-        rules = ui.edit(rules, ui.username())
+        rules = opts.get('commands', '')
+        if not rules:
+            rules = '\n'.join([('pick %s %s' % (
+                c.hex()[:12], c.description().splitlines()[0]))[:80]
+                               for c in ctxs])
+            rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12], )
+            rules = ui.edit(rules, ui.username())
+        else:
+            f = open(rules)
+            rules = f.read()
+            f.close()
+        rules = [l for l in (r.strip() for r in rules.splitlines())
+                 if l and not l[0] == '#']
+        rules = verifyrules(rules, repo, ctxs)
 
         parentctx = repo[parent].parents()[0]
-
-        rules = [l for l in (r.strip() for r in rules.splitlines()) if l and not l[0] == '#']
-        rules = verifyrules(rules, repo, ctxs)
         keep = opts.get('keep', False)
         replaced = []
         tmpnodes = []
 cmdtable = {
     "histedit":
         (histedit,
-         [('c', 'continue', False, 'continue an edit already in progress', ),
+         [('', 'commands', '', 'Read history edits from the specified file.'),
+          ('c', 'continue', False, 'continue an edit already in progress', ),
           ('k', 'keep', False, 'strip old nodes after edit is complete', ),
           ('', 'abort', False, 'abort an edit in progress', ),
           ('o', 'outgoing', False, 'changesets not found in destination'),

tests/test-histedit-commute

 pick 7c6fdd608667 e
 pick 99a62755c625 c
 EOF
-HGEDITOR="cat $EDITED > " hg histedit --rev -2 2>&1 | fixbundle
+hg histedit --commands "$EDITED" --rev -2 2>&1 | fixbundle
 hg log --graph