diff mercurial/localrepo.py @ 4058:e7282dede8cd

filecommit: don't forget the local parent on a merge with a local rename
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 30 Jan 2007 19:09:08 -0200
parents 27230c29bfec
children 431f3c1d3a37 43d8f7466920
line wrap: on
line diff
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -607,6 +607,24 @@ class localrepository(repo.repository):
         meta = {}
         cp = self.dirstate.copied(fn)
         if cp:
+            # Mark the new revision of this file as a copy of another
+            # file.  This copy data will effectively act as a parent 
+            # of this new revision.  If this is a merge, the first 
+            # parent will be the nullid (meaning "look up the copy data")
+            # and the second one will be the other parent.  For example:
+            #
+            # 0 --- 1 --- 3   rev1 changes file foo
+            #   \       /     rev2 renames foo to bar and changes it
+            #    \- 2 -/      rev3 should have bar with all changes and
+            #                      should record that bar descends from
+            #                      bar in rev2 and foo in rev1
+            #
+            # this allows this merge to succeed:
+            #
+            # 0 --- 1 --- 3   rev4 reverts the content change from rev2
+            #   \       /     merging rev3 and rev4 should use bar@rev2
+            #    \- 2 --- 4        as the merge base
+            #
             meta["copy"] = cp
             if not manifest2: # not a branch merge
                 meta["copyrev"] = hex(manifest1.get(cp, nullid))
@@ -615,7 +633,7 @@ class localrepository(repo.repository):
                 meta["copyrev"] = hex(manifest1.get(cp, nullid))
             elif fp1 != nullid: # copied on local side, reversed
                 meta["copyrev"] = hex(manifest2.get(cp))
-                fp2 = nullid
+                fp2 = fp1
             else: # directory rename
                 meta["copyrev"] = hex(manifest1.get(cp, nullid))
             self.ui.debug(_(" %s: copy %s:%s\n") %