annotate mercurial-common/src/python/load-commands-command.py @ 971:c5dc2c802e4b Indore-2017.1.x

UP-8618
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Thu, 22 Jun 2017 12:54:00 +0200
parents 16ad8d51b001
children e7df2ef5064b 5bec80ce92ae
rev   line source
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
1 #!/usr/bin/env python
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
2 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
3 ## Copyright 2000-2014 JetBrains
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
4 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
5 ## Licensed under the Apache License, Version 2.0 (the "License");
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
6 ## you may not use this file except in compliance with the License.
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
7 ## You may obtain a copy of the License at
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
8 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
9 ## http://www.apache.org/licenses/LICENSE-2.0
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
10 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
11 ## Unless required by applicable law or agreed to in writing, software
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
12 ## distributed under the License is distributed on an "AS IS" BASIS,
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
13 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
14 ## See the License for the specific language governing permissions and
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
15 ## limitations under the License.
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
16 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
17 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
18 ## http://www.gnu.org/licenses/gpl-faq.html#GPLModuleLicense
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
19 ## http://www.gnu.org/licenses/license-list.html#apache2
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
20 ## http://en.wikipedia.org/wiki/Apache_License#GPL_compatibility
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
21 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
22 ##
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
23 """
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
24 load-commands-command
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
25 """
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
26
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
27 import codecs
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
28 from mercurial import dispatch
830
ef19cc8d5bc1 support parameters throug file for every mercurial command
eugene.petrenko@jetbrains.com
parents: 828
diff changeset
29 from mercurial import commands
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
30
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
31 def loadArguments(ui, params_file):
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
32 file_commands = []
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
33 with codecs.open(params_file, "r", "utf-8") as f:
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
34 for _line in f:
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
35 line = _line.strip()
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
36 if len(line) <= 0:
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
37 continue
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
38
919
16ad8d51b001 fix non-ascii characters support in commandline arguments
eugene.petrenko@jetbrains.com
parents: 830
diff changeset
39 file_commands.append(line.encode("utf-8"))
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
40 return file_commands
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
41
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
42
830
ef19cc8d5bc1 support parameters throug file for every mercurial command
eugene.petrenko@jetbrains.com
parents: 828
diff changeset
43 def load_commands_command(ui, params_file, *params):
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
44 command_arguments = loadArguments(ui, params_file)
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
45 return dispatch.dispatch(dispatch.request(command_arguments))
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
46
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
47 #so here goes command registration and options
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
48 cmdtable = {
830
ef19cc8d5bc1 support parameters throug file for every mercurial command
eugene.petrenko@jetbrains.com
parents: 828
diff changeset
49 "CMD": (load_commands_command, [], " OUTPUT_FILE")
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
50 }
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
51
830
ef19cc8d5bc1 support parameters throug file for every mercurial command
eugene.petrenko@jetbrains.com
parents: 828
diff changeset
52 commands.norepo += " CMD"
ef19cc8d5bc1 support parameters throug file for every mercurial command
eugene.petrenko@jetbrains.com
parents: 828
diff changeset
53
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
54 testedwith = '2.2.2'
971
c5dc2c802e4b UP-8618
Dmitry Neverov <dmitry.neverov@gmail.com>
parents: 919
diff changeset
55 buglink = "upsource-support@jetbrains.com"
828
8d02c7b1f812 use HG extension to pass infinite commandline arguments list
eugene.petrenko@jetbrains.com
parents:
diff changeset
56