diff mercurial/localrepo.py @ 1581:db10b7114de0

abort when merging two heads and repository has local changes
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 14 Dec 2005 22:19:03 -0600
parents 59b3639df0a9
children 5c5aaaa9ab6f
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Dec 14 22:12:18 2005 -0600
+++ b/mercurial/localrepo.py	Wed Dec 14 22:19:03 2005 -0600
@@ -1358,7 +1358,7 @@
         return
 
     def update(self, node, allow=False, force=False, choose=None,
-               moddirstate=True):
+               moddirstate=True, forcemerge=False):
         pl = self.dirstate.parents()
         if not force and pl[1] != nullid:
             self.ui.warn(_("aborting: outstanding uncommitted merges\n"))
@@ -1378,6 +1378,18 @@
 
         (c, a, d, u) = self.changes()
 
+        if allow and not forcemerge:
+            if c or a or d:
+                raise util.Abort(_("outstanding uncommited changes"))
+        if not forcemerge and not force:
+            for f in u:
+                if f in m2:
+                     t1 = self.wread(f)
+                     t2 = self.file(f).read(m2[f])
+                     if cmp(t1, t2) != 0:
+                        raise util.Abort(_("'%s' already exists in the working"
+                                           " dir and differs from remote") % f)
+
         # is this a jump, or a merge?  i.e. is there a linear path
         # from p1 to p2?
         linear_path = (pa == p1 or pa == p2)