summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b993d23)
This patch adds the IndexAndWorktree.mergetool() function responsible
for calling 'git mergetool' to interactively solve conflicts. The
function may also be called from IndexAndWorktree.merge() if the
standard 'git merge-recursive' fails and 'interactive == True'. The
'allow_interactive' parameter is passed to Transaction.push_patch() from
the functions allowing interactive merging.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
Acked-by: Karl Hasselström <kha@treskal.com>
trans.patches[patchname] = stack.repository.commit(cd)
try:
for pn in popped:
trans.patches[patchname] = stack.repository.commit(cd)
try:
for pn in popped:
- trans.push_patch(pn, iw)
+ trans.push_patch(pn, iw, allow_interactive = True)
except transaction.TransactionHalted:
pass
try:
except transaction.TransactionHalted:
pass
try:
elif patch in trans.unapplied:
try:
for pn in trans.unapplied[:trans.unapplied.index(patch)+1]:
elif patch in trans.unapplied:
try:
for pn in trans.unapplied[:trans.unapplied.index(patch)+1]:
- trans.push_patch(pn, iw)
+ trans.push_patch(pn, iw, allow_interactive = True)
except transaction.TransactionHalted:
pass
elif patch in trans.hidden:
except transaction.TransactionHalted:
pass
elif patch in trans.hidden:
).discard_output()
except run.RunException:
raise CheckoutException('Index/workdir dirty')
).discard_output()
except run.RunException:
raise CheckoutException('Index/workdir dirty')
- def merge(self, base, ours, theirs):
+ def merge(self, base, ours, theirs, interactive = False):
assert isinstance(base, Tree)
assert isinstance(ours, Tree)
assert isinstance(theirs, Tree)
assert isinstance(base, Tree)
assert isinstance(ours, Tree)
assert isinstance(theirs, Tree)
output = r.output_lines()
if r.exitcode:
# There were conflicts
output = r.output_lines()
if r.exitcode:
# There were conflicts
- conflicts = [l for l in output if l.startswith('CONFLICT')]
- raise MergeConflictException(conflicts)
+ if interactive:
+ self.mergetool()
+ else:
+ conflicts = [l for l in output if l.startswith('CONFLICT')]
+ raise MergeConflictException(conflicts)
except run.RunException, e:
raise MergeException('Index/worktree dirty')
except run.RunException, e:
raise MergeException('Index/worktree dirty')
+ def mergetool(self, files = ()):
+ """Invoke 'git mergetool' on the current IndexAndWorktree to resolve
+ any outstanding conflicts. If 'not files', all the files in an
+ unmerged state will be processed."""
+ self.run(['git', 'mergetool'] + list(files)).returns([0, 1]).run()
+ # check for unmerged entries (prepend 'CONFLICT ' for consistency with
+ # merge())
+ conflicts = ['CONFLICT ' + f for f in self.index.conflicts()]
+ if conflicts:
+ raise MergeConflictException(conflicts)
def changed_files(self, tree, pathlimits = []):
"""Return the set of files in the worktree that have changed with
respect to C{tree}. The listing is optionally restricted to
def changed_files(self, tree, pathlimits = []):
"""Return the set of files in the worktree that have changed with
respect to C{tree}. The listing is optionally restricted to
from stgit.utils import any, all
from stgit.out import *
from stgit.lib import git, log
from stgit.utils import any, all
from stgit.out import *
from stgit.lib import git, log
+from stgit.config import config
class TransactionException(exception.StgException):
"""Exception raised when something goes wrong with a
class TransactionException(exception.StgException):
"""Exception raised when something goes wrong with a
out.info('Deleted %s%s' % (pn, s))
return popped
out.info('Deleted %s%s' % (pn, s))
return popped
- def push_patch(self, pn, iw = None):
+ def push_patch(self, pn, iw = None, allow_interactive = False):
"""Attempt to push the named patch. If this results in conflicts,
halts the transaction. If index+worktree are given, spill any
conflicts to them."""
"""Attempt to push the named patch. If this results in conflicts,
halts the transaction. If index+worktree are given, spill any
conflicts to them."""
except git.CheckoutException:
self.__halt('Index/worktree dirty')
try:
except git.CheckoutException:
self.__halt('Index/worktree dirty')
try:
- iw.merge(base, ours, theirs)
+ interactive = (allow_interactive and
+ config.get('stgit.autoimerge') == 'yes')
+ iw.merge(base, ours, theirs, interactive = interactive)
tree = iw.index.write_tree()
self.__current_tree = tree
s = ' (modified)'
tree = iw.index.write_tree()
self.__current_tree = tree
s = ' (modified)'