changeset 6888:7c36a4fb05a3

make commit fail when committing unresolved files
author Stefano Tortarolo <stefano.tortarolo@gmail.com>
date Wed, 13 Aug 2008 20:18:40 -0500
parents 304484c7e0ba
children c0bd7d8b69ef
files mercurial/localrepo.py tests/test-add tests/test-commit-unresolved tests/test-commit-unresolved.out tests/test-convert-svn-sink tests/test-merge7
diffstat 6 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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,
--- 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
--- /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
--- /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
--- 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
--- 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