mercurial/copies.py
changeset 20294 243ea5ffdf31
parent 19178 4327687ca757
child 20641 3db9e798e004
equal deleted inserted replaced
20293:2f6b3900be64 20294:243ea5ffdf31
    96         if k in src and v in dst:
    96         if k in src and v in dst:
    97             del t[k]
    97             del t[k]
    98 
    98 
    99     return t
    99     return t
   100 
   100 
   101 def _tracefile(fctx, actx):
   101 def _tracefile(fctx, am, limit=-1):
   102     '''return file context that is the ancestor of fctx present in actx'''
   102     '''return file context that is the ancestor of fctx present in ancestor
   103     stop = actx.rev()
   103     manifest am, stopping after the first ancestor lower than limit'''
   104     am = actx.manifest()
       
   105 
   104 
   106     for f in fctx.ancestors():
   105     for f in fctx.ancestors():
   107         if am.get(f.path(), None) == f.filenode():
   106         if am.get(f.path(), None) == f.filenode():
   108             return f
   107             return f
   109         if f.rev() < stop:
   108         if f.rev() < limit:
   110             return None
   109             return None
   111 
   110 
   112 def _dirstatecopies(d):
   111 def _dirstatecopies(d):
   113     ds = d._repo.dirstate
   112     ds = d._repo.dirstate
   114     c = ds.copies().copy()
   113     c = ds.copies().copy()
   127         b = w.p1()
   126         b = w.p1()
   128         if a == b:
   127         if a == b:
   129             # short-circuit to avoid issues with merge states
   128             # short-circuit to avoid issues with merge states
   130             return _dirstatecopies(w)
   129             return _dirstatecopies(w)
   131 
   130 
       
   131     # files might have to be traced back to the fctx parent of the last
       
   132     # one-side-only changeset, but not further back than that
       
   133     limit = _findlimit(a._repo, a.rev(), b.rev())
       
   134     if limit is None:
       
   135         limit = -1
       
   136     am = a.manifest()
       
   137 
   132     # find where new files came from
   138     # find where new files came from
   133     # we currently don't try to find where old files went, too expensive
   139     # we currently don't try to find where old files went, too expensive
   134     # this means we can miss a case like 'hg rm b; hg cp a b'
   140     # this means we can miss a case like 'hg rm b; hg cp a b'
   135     cm = {}
   141     cm = {}
   136     missing = set(b.manifest().iterkeys())
   142     missing = set(b.manifest().iterkeys())
   137     missing.difference_update(a.manifest().iterkeys())
   143     missing.difference_update(a.manifest().iterkeys())
   138 
   144 
   139     for f in missing:
   145     for f in missing:
   140         ofctx = _tracefile(b[f], a)
   146         ofctx = _tracefile(b[f], am, limit)
   141         if ofctx:
   147         if ofctx:
   142             cm[f] = ofctx.path()
   148             cm[f] = ofctx.path()
   143 
   149 
   144     # combine copies from dirstate if necessary
   150     # combine copies from dirstate if necessary
   145     if w is not None:
   151     if w is not None: