Mercurial > hg-stable
diff mercurial/localrepo.py @ 6874:8dc21876261e
commit: simplify file copy logic
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Aug 2008 18:01:03 -0500 |
parents | deda205a00e1 |
children | 0d714a48ab53 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sat Aug 09 11:46:20 2008 +0200 +++ b/mercurial/localrepo.py Sun Aug 10 18:01:03 2008 -0500 @@ -687,8 +687,8 @@ fp2 = manifest2.get(fn, nullid) meta = {} - cp = self.dirstate.copied(fn) - if cp and cp != fn: + cf = self.dirstate.copied(fn) + if cf and cf != fn: # 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 @@ -707,22 +707,20 @@ # \ / 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[cp]) - fp2 = nullid - elif fp2 != nullid: # copied on remote side - meta["copyrev"] = hex(manifest1[cp]) - elif fp1 != nullid: # copied on local side, reversed - meta["copyrev"] = hex(manifest2[cp]) - fp2 = fp1 - elif cp in manifest2: # directory rename on local side - meta["copyrev"] = hex(manifest2[cp]) - else: # directory rename on remote side - meta["copyrev"] = hex(manifest1[cp]) - self.ui.debug(_(" %s: copy %s:%s\n") % - (fn, cp, meta["copyrev"])) - fp1 = nullid + + cr = manifest1.get(cf, nullid) + nfp = fp2 + + if manifest2: # branch merge + if fp2 == nullid: # copied on remote side + if fp1 != nullid or cf in manifest2: + cr = manifest2[cf] + nfp = fp1 + + self.ui.debug(_(" %s: copy %s:%s\n") % (fn, cf, hex(cr))) + meta["copy"] = cf + meta["copyrev"] = hex(cr) + fp1, fp2 = nullid, nfp elif fp2 != nullid: # is one parent an ancestor of the other? fpa = fl.ancestor(fp1, fp2)