Mercurial > hg-stable
changeset 6876:077f1e637cd8
Merge with stable
Simplify the copy search algorithm
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Aug 2008 18:38:43 -0500 |
parents | 0d714a48ab53 (diff) c7cc40fd74f6 (current diff) |
children | 11229144aa01 |
files | mercurial/context.py mercurial/localrepo.py templates/static/highlight.css |
diffstat | 6 files changed, 77 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Sat Jul 19 18:19:50 2008 +0200 +++ b/mercurial/context.py Sun Aug 10 18:38:43 2008 -0500 @@ -100,6 +100,14 @@ c = self._repo.changelog.children(self._node) return [changectx(self._repo, x) for x in c] + def ancestors(self): + for a in self._repo.changelog.ancestors(self._rev): + yield changectx(self._repo, a) + + def descendants(self): + for d in self._repo.changelog.descendants(self._rev): + yield changectx(self._repo, d) + def _fileinfo(self, path): if '_manifest' in self.__dict__: try:
--- a/mercurial/localrepo.py Sat Jul 19 18:19:50 2008 +0200 +++ b/mercurial/localrepo.py Sun Aug 10 18:38:43 2008 -0500 @@ -672,7 +672,6 @@ meta = {} cp = fctx.renamed() if cp and cp[0] != fn: - cp = cp[0] # 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 @@ -691,22 +690,30 @@ # \ / 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 + + cf = cp[0] + cr = manifest1.get(cf) + 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 + + # find source in nearest ancestor if we've lost track + if not cr: + self.ui.debug(_(" %s: searching for copy revision for %s\n") % + (fn, cf)) + for a in self['.'].ancestors(): + if cf in a: + cr = a[cf].filenode() + break + + 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)
--- a/tests/test-convert-mtn Sat Jul 19 18:19:50 2008 +0200 +++ b/tests/test-convert-mtn Sun Aug 10 18:38:43 2008 -0500 @@ -63,7 +63,7 @@ mkdir dir2/dir/subdir echo f > dir2/dir/subdir/f mkdir dir2/dir/emptydir -mtn add -R dir2/dir +mtn add --quiet -R dir2/dir mtn ci -m emptydir mtn drop -R dir2/dir mtn ci -m dropdirectory
--- a/tests/test-convert-mtn.out Sat Jul 19 18:19:50 2008 +0200 +++ b/tests/test-convert-mtn.out Sun Aug 10 18:38:43 2008 -0500 @@ -29,10 +29,6 @@ mtn: renaming dir to dir2 in workspace manifest mtn: beginning commit on branch 'com.selenic.test' mtn: committed revision 5de5abe7c15eae70cf3acdda23c9c319ea50c1af -mtn: adding dir2/dir to workspace manifest -mtn: adding dir2/dir/emptydir to workspace manifest -mtn: adding dir2/dir/subdir to workspace manifest -mtn: adding dir2/dir/subdir/f to workspace manifest mtn: beginning commit on branch 'com.selenic.test' mtn: committed revision 27a423be1e406595cc57f50f42a8790fa0a93d8e mtn: dropping dir2/dir/subdir/f from workspace manifest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-issue1175 Sun Aug 10 18:38:43 2008 -0500 @@ -0,0 +1,20 @@ +#!/bin/sh +rm -rf a +hg init a +cd a +touch a +hg ci -Am0 +hg mv a a1 +hg ci -m1 +hg co 0 +hg mv a a2 +hg up +hg ci -m2 + +touch a +hg ci -Am3 +hg mv a b +hg ci -Am4 a +hg ci --debug --traceback -Am5 b +hg verify +hg export --git tip
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-issue1175.out Sun Aug 10 18:38:43 2008 -0500 @@ -0,0 +1,24 @@ +adding a +1 files updated, 0 files merged, 1 files removed, 0 files unresolved +warning: detected divergent renames of a to: + a2 + a1 +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +adding a +b + b: searching for copy revision for a + b: copy a:b80de5d138758541c5f05265ad144ab9fa86d1db +checking changesets +checking manifests +crosschecking files in changesets and manifests +checking files +4 files, 6 changesets, 4 total revisions +# HG changeset patch +# User test +# Date 0 0 +# Node ID 755e75751bf67eb4378bca61987df035d90a7a06 +# Parent 7399822c2e395fe7d57c2fcf4b310f6fb22f8c2d +5 + +diff --git a/b b/b +new file mode 100644