Commit 62834956 authored by Matthias Putz's avatar Matthias Putz

--amend

parent 21987131
This diff is collapsed.
...@@ -51,7 +51,7 @@ if portable.isLinux(): ...@@ -51,7 +51,7 @@ if portable.isLinux():
#os.environ['GIT_PAGER'] = 'less' #os.environ['GIT_PAGER'] = 'less'
pass pass
else: else:
os.environ['GIT_PAGER'] = '' os.environ['GIT_PAGER'] = 'less'
...@@ -74,6 +74,20 @@ global_options.add_option('--version', ...@@ -74,6 +74,20 @@ global_options.add_option('--version',
dest='show_version', action='store_true', dest='show_version', action='store_true',
help='display this version of repo') help='display this version of repo')
def _UsePager(name, cmd, gopts, copts):
if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
config = cmd.manifest.globalConfig
if gopts.pager:
use_pager = True
else:
use_pager = config.GetBoolean('pager.%s' % name)
if use_pager is None:
use_pager = cmd.WantPager(copts)
return use_pager
else:
return False
class _Repo(object): class _Repo(object):
def __init__(self, repodir): def __init__(self, repodir):
self.repodir = repodir self.repodir = repodir
...@@ -81,8 +95,7 @@ class _Repo(object): ...@@ -81,8 +95,7 @@ class _Repo(object):
# add 'branch' as an alias for 'branches' # add 'branch' as an alias for 'branches'
all_commands['branch'] = all_commands['branches'] all_commands['branch'] = all_commands['branches']
def _Run(self, argv): def _Config(self, argv):
result = 0
name = None name = None
glob = [] glob = []
...@@ -97,6 +110,7 @@ class _Repo(object): ...@@ -97,6 +110,7 @@ class _Repo(object):
glob = argv glob = argv
name = 'help' name = 'help'
argv = [] argv = []
gopts, _gargs = global_options.parse_args(glob) gopts, _gargs = global_options.parse_args(glob)
if gopts.trace: if gopts.trace:
...@@ -127,16 +141,19 @@ class _Repo(object): ...@@ -127,16 +141,19 @@ class _Repo(object):
copts, cargs = cmd.OptionParser.parse_args(argv) copts, cargs = cmd.OptionParser.parse_args(argv)
copts = cmd.ReadEnvironmentOptions(copts) copts = cmd.ReadEnvironmentOptions(copts)
if not gopts.no_pager and not isinstance(cmd, InteractiveCommand): self.config = name, cmd, gopts, _gargs, copts, cargs, argv
return 0
def _Run(self):
if self.config:
(name, cmd, gopts, _gargs, copts, cargs, argv) = self.config
else:
print("repo was not configured, run _Config(argv) before calling _Run(..)")
return 1
if portable.isLinux() and _UsePager(name, cmd, gopts, copts):
config = cmd.manifest.globalConfig config = cmd.manifest.globalConfig
if gopts.pager: RunPager(config)
use_pager = True
else:
use_pager = config.GetBoolean('pager.%s' % name)
if use_pager is None:
use_pager = cmd.WantPager(copts)
if use_pager:
RunPager(config)
start = time.time() start = time.time()
try: try:
...@@ -389,6 +406,13 @@ def _Debug(host, env): ...@@ -389,6 +406,13 @@ def _Debug(host, env):
sys.stderr.write("Error: you must add pydevd in a pysrc folder (e.g. in eclipse plugin) to your PYTHONPATH.\n") sys.stderr.write("Error: you must add pydevd in a pysrc folder (e.g. in eclipse plugin) to your PYTHONPATH.\n")
sys.exit(1) sys.exit(1)
def _WindowsPager(repo):
(name, cmd, gopts, _gargs, copts, cargs, argv) = repo.config
if _UsePager(name, cmd, gopts, copts):
print("USE PAGER")
return True
return False
def _Main(argv): def _Main(argv):
result = 0 result = 0
...@@ -402,13 +426,10 @@ def _Main(argv): ...@@ -402,13 +426,10 @@ def _Main(argv):
opt.add_option("-d", "--debug", action="store_true", dest="debug", default=False) opt.add_option("-d", "--debug", action="store_true", dest="debug", default=False)
opt.add_option("--debug-host", dest="debug_host", default='localhost') opt.add_option("--debug-host", dest="debug_host", default='localhost')
opt.add_option("--debug-env", dest="debug_env", default="intellij") opt.add_option("--debug-env", dest="debug_env", default="intellij")
_PruneOptions(argv, opt) _PruneOptions(argv, opt)
opt, argv = opt.parse_args(argv) opt, argv = opt.parse_args(argv)
if opt.debug:
print("enter debug mode, host %s" % opt.debug_host)
_Debug(opt.debug_host, opt.debug_env)
_CheckWrapperVersion(opt.wrapper_version, opt.wrapper_path) _CheckWrapperVersion(opt.wrapper_version, opt.wrapper_path)
_CheckRepoDir(opt.repodir) _CheckRepoDir(opt.repodir)
...@@ -416,11 +437,20 @@ def _Main(argv): ...@@ -416,11 +437,20 @@ def _Main(argv):
Version.wrapper_path = opt.wrapper_path Version.wrapper_path = opt.wrapper_path
repo = _Repo(opt.repodir) repo = _Repo(opt.repodir)
repo._Config(argv)
if not portable.isLinux():
if _WindowsPager(repo):
exit(0);
if opt.debug:
print("enter debug mode, host %s" % opt.debug_host)
_Debug(opt.debug_host, opt.debug_env)
try: try:
try: try:
init_ssh() init_ssh()
init_http() init_http()
result = repo._Run(argv) or 0 result = repo._Run() or 0
finally: finally:
close_ssh() close_ssh()
except KeyboardInterrupt: except KeyboardInterrupt:
......
...@@ -716,7 +716,7 @@ class Project(object): ...@@ -716,7 +716,7 @@ class Project(object):
output: If specified, redirect the output to this object. output: If specified, redirect the output to this object.
""" """
if not os.path.isdir(self.worktree): if not os.path.isdir(self.worktree):
if output_redir == None: if output_redir is None:
output_redir = sys.stdout output_redir = sys.stdout
print(file=output_redir) print(file=output_redir)
print('project %s/' % self.relpath, file=output_redir) print('project %s/' % self.relpath, file=output_redir)
...@@ -2036,11 +2036,11 @@ class Project(object): ...@@ -2036,11 +2036,11 @@ class Project(object):
out = p.process.stdout.read() out = p.process.stdout.read()
r = {} r = {}
if out: if out:
out = iter(out[:-1].split('\0')) # pylint: disable=W1401 out = iter(portable.stream2str(out)[:-1].split('\0')) # pylint: disable=W1401
while out: while out:
try: try:
info = out.next() info = out.__next__()
path = out.next() path = out.__next__()
except StopIteration: except StopIteration:
break break
...@@ -2193,7 +2193,7 @@ class Project(object): ...@@ -2193,7 +2193,7 @@ class Project(object):
self._project.name, self._project.name,
name, name,
p.stderr)) p.stderr))
r = str(p.stdout, encoding='UTF-8') r = portable.stream2str(p.stdout)
if r.endswith('\n') and r.index('\n') == len(r) - 1: if r.endswith('\n') and r.index('\n') == len(r) - 1:
return r[:-1] return r[:-1]
return r return r
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment