diff --git a/mercurial/merge.py b/mercurial/merge.py
index 02c3d4d44a92515ebcae8743bcb872f63ebbb9f7_bWVyY3VyaWFsL21lcmdlLnB5..9d67277c9204fea7aaf6dcb03fe053c190d154a8_bWVyY3VyaWFsL21lcmdlLnB5 100644
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -439,7 +439,7 @@
                 if f:
                     repo.dirstate.forget(f)
 
-def update(repo, node, branchmerge, force, partial):
+def update(repo, node, branchmerge, force, partial, ancestor=None):
     """
     Perform a merge between the working directory and the given node
 
@@ -492,7 +492,11 @@
         overwrite = force and not branchmerge
         pl = wc.parents()
         p1, p2 = pl[0], repo[node]
-        pa = p1.ancestor(p2)
+        if ancestor:
+            pa = repo[ancestor]
+        else:
+            pa = p1.ancestor(p2)
+
         fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
 
         ### check phase