From 0fbf98010616f6c12312b8153dd34c462565a74d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Wed, 19 Dec 2007 18:00:13 +0000 Subject: [PATCH] Refactoring: pass more than one file to resolved() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This lets us cut down on the number of calls to git. Signed-off-by: Karl Hasselström --- stgit/commands/common.py | 14 +++++++------- stgit/commands/resolved.py | 6 +++--- stgit/commands/status.py | 3 +-- stgit/run.py | 3 +++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/stgit/commands/common.py b/stgit/commands/common.py index d040ee9..a0ec90e 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -145,18 +145,18 @@ def print_crt_patch(crt_series, branch = None): else: out.info('No patches applied') -def resolved(filename, reset = None): +def resolved(filenames, reset = None): if reset: stage = {'ancestor': 1, 'current': 2, 'patched': 3}[reset] - Run('git', 'checkout-index', '--no-create', '--stage=%d' % stage, '--', - filename).no_output() - git.add([filename]) - os.utime(filename, None) # update the access and modificatied times + Run('git', 'checkout-index', '--no-create', '--stage=%d' % stage, + '--stdin', '-z').input_nulterm(filenames).no_output() + git.add(filenames) + for filename in filenames: + os.utime(filename, None) # update the access and modificatied times def resolved_all(reset = None): conflicts = git.get_conflicts() - for filename in conflicts: - resolved(filename, reset) + resolved(conflicts, reset) def push_patches(crt_series, patches, check_merged = False): """Push multiple patches onto the stack. This function is shared diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py index 845eca0..792dee5 100644 --- a/stgit/commands/resolved.py +++ b/stgit/commands/resolved.py @@ -77,7 +77,7 @@ def func(parser, options, args): raise CmdException, 'No conflicts for "%s"' % filename # resolved - for filename in files: - if options.interactive: + if options.interactive: + for filename in files: interactive_merge(filename) - resolved(filename, options.reset) + resolved(files, options.reset) diff --git a/stgit/commands/status.py b/stgit/commands/status.py index 20614b0..370e033 100644 --- a/stgit/commands/status.py +++ b/stgit/commands/status.py @@ -109,8 +109,7 @@ def func(parser, options, args): if options.reset: if args: - for f in args: - resolved(f) + resolved(args) git.reset(args) else: resolved_all() diff --git a/stgit/run.py b/stgit/run.py index fa304d0..78537db 100644 --- a/stgit/run.py +++ b/stgit/run.py @@ -110,6 +110,9 @@ class Run: def input_lines(self, lines): self.__indata = ''.join(['%s\n' % line for line in lines]) return self + def input_nulterm(self, lines): + self.__indata = ''.join('%s\0' % line for line in lines) + return self def no_output(self): outdata = self.__run_io() if outdata: -- 2.11.0