# HG changeset patch # User Stefano Tortarolo # Date 1218676720 18000 # Node ID 7c36a4fb05a3703b8c43445f519fb418f8fc22c5 # Parent 304484c7e0ba9d2fcec0d31e4fcaf9b5d5246dfc make commit fail when committing unresolved files diff -r 304484c7e0ba -r 7c36a4fb05a3 mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Aug 13 20:18:40 2008 -0500 +++ b/mercurial/localrepo.py Wed Aug 13 20:18:40 2008 -0500 @@ -12,6 +12,7 @@ import lock, transaction, stat, errno, ui, store import os, revlog, time, util, extensions, hook, inspect import match as match_ +import merge as merge_ class localrepository(repo.repository): capabilities = util.set(('lookup', 'changegroupsubset')) @@ -777,6 +778,11 @@ update_dirstate = (self.dirstate.parents()[0] == p1) changes = [files, [], [], [], []] + ms = merge_.mergestate(self) + for f in changes[0]: + if f in ms and ms[f] == 'u': + raise util.Abort(_("unresolved merge conflicts " + "(see hg resolve)")) wctx = context.workingctx(self, (p1, p2), text, user, date, extra, changes) return self._commitctx(wctx, force, force_editor, empty_ok, diff -r 304484c7e0ba -r 7c36a4fb05a3 tests/test-add --- a/tests/test-add Wed Aug 13 20:18:40 2008 -0500 +++ b/tests/test-add Wed Aug 13 20:18:40 2008 -0500 @@ -32,6 +32,7 @@ echo % should fail hg add a hg st +hg resolve -m a hg ci -m merge echo % issue683 diff -r 304484c7e0ba -r 7c36a4fb05a3 tests/test-commit-unresolved --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-commit-unresolved Wed Aug 13 20:18:40 2008 -0500 @@ -0,0 +1,40 @@ +#!/bin/sh + +echo "[extensions]" >> $HGRCPATH +echo "graphlog=" >> $HGRCPATH + +function addcommit { + echo $1 > $1 + hg add $1 + hg commit -d "${2} 0" -u test -m $1 +} +function commit { + hg commit -d "${2} 0" -u test -m $1 +} + +hg init a +cd a +addcommit "A" 0 +addcommit "B" 1 +echo "C" >> A +commit "C" 2 + +hg update -C 0 +echo "D" >> A +commit "D" 3 + +echo +echo "% Merging a conflict araises" +hg merge + +echo +echo "% Correct the conflict without marking the file as resolved" +echo "ABCD" > A +hg commit -m "Merged" + +echo +echo "% Mark the conflict as resolved and commit" +hg resolve -m A +hg commit -m "Merged" + +exit 0 diff -r 304484c7e0ba -r 7c36a4fb05a3 tests/test-commit-unresolved.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-commit-unresolved.out Wed Aug 13 20:18:40 2008 -0500 @@ -0,0 +1,14 @@ +1 files updated, 0 files merged, 1 files removed, 0 files unresolved +created new head + +% Merging a conflict araises +merging A +warning: conflicts during merge. +merging A failed! +1 files updated, 0 files merged, 0 files removed, 1 files unresolved +use 'hg resolve' to retry unresolved file merges + +% Correct the conflict without marking the file as resolved +abort: unresolved merge conflicts (see hg resolve) + +% Mark the conflict as resolved and commit diff -r 304484c7e0ba -r 7c36a4fb05a3 tests/test-convert-svn-sink --- a/tests/test-convert-svn-sink Wed Aug 13 20:18:40 2008 -0500 +++ b/tests/test-convert-svn-sink Wed Aug 13 20:18:40 2008 -0500 @@ -128,6 +128,7 @@ hg --cwd b up -C 2 hg --cwd b merge hg --cwd b revert -r 2 b +hg resolve -m b hg --cwd b ci -d '5 0' -m 'merge' hg convert -d svn b diff -r 304484c7e0ba -r 7c36a4fb05a3 tests/test-merge7 --- a/tests/test-merge7 Wed Aug 13 20:18:40 2008 -0500 +++ b/tests/test-merge7 Wed Aug 13 20:18:40 2008 -0500 @@ -43,6 +43,7 @@ three EOF rm -f *.orig +hg resolve -m test.txt hg commit -m "Merge 1" -d "1000000 0" # change test-a again