From: Karl Hasselström Date: Wed, 19 Dec 2007 18:00:13 +0000 (+0000) Subject: Refactoring: pass more than one file to resolved() X-Git-Tag: v0.15-rc1~332 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/0fbf98010616f6c12312b8153dd34c462565a74d Refactoring: pass more than one file to resolved() This lets us cut down on the number of calls to git. Signed-off-by: Karl Hasselström --- 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: