--- a/hgext/push-to-try/__init__.py
+++ b/hgext/push-to-try/__init__.py
@@ -1,31 +1,44 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
-from mercurial import commands, context, cmdutil
+from mercurial import (
+ cmdutil,
+ commands,
+ context,
+ scmutil,
+)
from mercurial.i18n import _
+from mercurial.node import nullid
OUR_DIR = os.path.normpath(os.path.dirname(__file__))
execfile(os.path.join(OUR_DIR, '..', 'bootstrap.py'))
from mozhg.rewrite import preservefilectx
cmdtable = {}
command = cmdutil.command(cmdtable)
testedwith = '3.3 3.4 3.5 3.6'
@command('push-to-try', [
('m', 'message', '', 'commit message to use', 'MESSAGE'),
('s', 'server', 'ssh://hg.mozilla.org/try', 'push destination', 'URL'),
-], '-m MESSAGE -s URL')
-def push_to_try(ui, repo, server, message=None):
+ ('r', 'rev', '.', 'single changeset intended to be pushed to try', 'REV'),
+], '-m MESSAGE -s URL [-r REV]')
+def push_to_try(ui, repo, server, message=None, rev='.'):
+
+ revs = scmutil.revrange(repo, [rev])
+ if len(revs) != 1:
+ ui.status("STOP! A single changest to push to try is required.\n")
+ return
+ parent, = tuple(revs)
nodate = ui.configbool('push-to-try', 'nodate')
if not message or 'try:' not in message:
ui.status("STOP! A commit message with try syntax is required.\n")
return
cctx = context.workingctx(repo)
@@ -41,17 +54,17 @@ def push_to_try(ui, repo, server, messag
def mk_memfilectx(repo, memctx, path):
if path not in status.removed:
return preserve_ctx(repo, memctx, path)
return None
# Invent a temporary commit with our message.
ui.status("Creating temporary commit for remote...\n")
mctx = context.memctx(repo,
- repo.dirstate.parents(),
+ [parent, nullid],
message,
cctx.files(),
mk_memfilectx,
date="0 0" if nodate else None)
# These messages are expected when we abort our transaction, but aren't
# helpful to a user and may be misleading so we surpress them here.
filtered_phrases = {_("transaction abort!\n"),