From: Catalin Marinas Date: Wed, 5 Oct 2005 15:58:18 +0000 (+0100) Subject: Add a --reset option to resolved X-Git-Tag: v0.14.3~634 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/7c47d096c74a2654fc9d67490adbe3066d24df98 Add a --reset option to resolved With this option one can ask for a conflicted file to be reset to one of the local, remote or older states. Signed-off-by: Catalin Marinas --- diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 4e4a79f..7a9df6e 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -99,18 +99,26 @@ def print_crt_patch(): else: print 'No patches applied' -def resolved(filename): +def resolved(filename, reset = None): + if reset: + reset_file = filename + '.' + reset + if os.path.isfile(reset_file): + if os.path.isfile(filename): + os.remove(filename) + os.rename(reset_file, filename) + git.update_cache([filename], force = True) + for ext in ['.local', '.older', '.remote']: fn = filename + ext if os.path.isfile(fn): os.remove(fn) -def resolved_all(): +def resolved_all(reset = None): conflicts = git.get_conflicts() if conflicts: for filename in conflicts: - resolved(filename) + resolved(filename, reset) os.remove(os.path.join(git.base_dir, 'conflicts')) def name_email(string): diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py index d98ca9a..d21ecc9 100644 --- a/stgit/commands/resolved.py +++ b/stgit/commands/resolved.py @@ -33,14 +33,19 @@ Mark a merge conflict as resolved. The conflicts can be seen with the options = [make_option('-a', '--all', help = 'mark all conflicts as solved', - action = 'store_true')] + action = 'store_true'), + make_option('-r', '--reset', metavar = '(local|remote|older)', + help = 'reset the file(s) to the given state')] def func(parser, options, args): """Mark the conflict as resolved """ + if options.reset and options.reset not in ['local', 'remote', 'older']: + raise CmdException, 'Unknown reset state: %s' % options.reset + if options.all: - resolved_all() + resolved_all(options.reset) return if len(args) == 0: @@ -55,7 +60,7 @@ def func(parser, options, args): raise CmdException, 'No conflicts for "%s"' % filename # resolved for filename in args: - resolved(filename) + resolved(filename, options.reset) del conflicts[conflicts.index(filename)] # save or remove the conflicts file