mercurial/copies.py
changeset 35421 9cf37d111acb
parent 35420 7ddc1e96d9b0
child 35422 8801cdcea01f
equal deleted inserted replaced
35420:7ddc1e96d9b0 35421:9cf37d111acb
   105     # back far enough unless we also look at the a and b as candidates.
   105     # back far enough unless we also look at the a and b as candidates.
   106     # This only occurs when a is a descendent of b or visa-versa.
   106     # This only occurs when a is a descendent of b or visa-versa.
   107     return min(limit, a, b)
   107     return min(limit, a, b)
   108 
   108 
   109 def _chain(src, dst, a, b):
   109 def _chain(src, dst, a, b):
   110     '''chain two sets of copies a->b'''
   110     """chain two sets of copies a->b"""
   111     t = a.copy()
   111     t = a.copy()
   112     for k, v in b.iteritems():
   112     for k, v in b.iteritems():
   113         if v in t:
   113         if v in t:
   114             # found a chain
   114             # found a chain
   115             if t[v] != k:
   115             if t[v] != k:
   128             del t[k]
   128             del t[k]
   129 
   129 
   130     return t
   130     return t
   131 
   131 
   132 def _tracefile(fctx, am, limit=-1):
   132 def _tracefile(fctx, am, limit=-1):
   133     '''return file context that is the ancestor of fctx present in ancestor
   133     """return file context that is the ancestor of fctx present in ancestor
   134     manifest am, stopping after the first ancestor lower than limit'''
   134     manifest am, stopping after the first ancestor lower than limit"""
   135 
   135 
   136     for f in fctx.ancestors():
   136     for f in fctx.ancestors():
   137         if am.get(f.path(), None) == f.filenode():
   137         if am.get(f.path(), None) == f.filenode():
   138             return f
   138             return f
   139         if limit >= 0 and f.linkrev() < limit and f.rev() < limit:
   139         if limit >= 0 and f.linkrev() < limit and f.rev() < limit:
   155     ma = a.manifest()
   155     ma = a.manifest()
   156     mb = b.manifest()
   156     mb = b.manifest()
   157     return mb.filesnotin(ma, match=match)
   157     return mb.filesnotin(ma, match=match)
   158 
   158 
   159 def _forwardcopies(a, b, match=None):
   159 def _forwardcopies(a, b, match=None):
   160     '''find {dst@b: src@a} copy mapping where a is an ancestor of b'''
   160     """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
   161 
   161 
   162     # check for working copy
   162     # check for working copy
   163     w = None
   163     w = None
   164     if b.rev() is None:
   164     if b.rev() is None:
   165         w = b
   165         w = b
   221             continue
   221             continue
   222         r[v] = k
   222         r[v] = k
   223     return r
   223     return r
   224 
   224 
   225 def pathcopies(x, y, match=None):
   225 def pathcopies(x, y, match=None):
   226     '''find {dst@y: src@x} copy mapping for directed compare'''
   226     """find {dst@y: src@x} copy mapping for directed compare"""
   227     if x == y or not x or not y:
   227     if x == y or not x or not y:
   228         return {}
   228         return {}
   229     a = y.ancestor(x)
   229     a = y.ancestor(x)
   230     if a == x:
   230     if a == x:
   231         return _forwardcopies(x, y, match=match)
   231         return _forwardcopies(x, y, match=match)
   859                     else:
   859                     else:
   860                         data['incompletediverge'][sf] = [of, f]
   860                         data['incompletediverge'][sf] = [of, f]
   861                     return
   861                     return
   862 
   862 
   863 def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None):
   863 def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None):
   864     '''reproduce copies from fromrev to rev in the dirstate
   864     """reproduce copies from fromrev to rev in the dirstate
   865 
   865 
   866     If skiprev is specified, it's a revision that should be used to
   866     If skiprev is specified, it's a revision that should be used to
   867     filter copy records. Any copies that occur between fromrev and
   867     filter copy records. Any copies that occur between fromrev and
   868     skiprev will not be duplicated, even if they appear in the set of
   868     skiprev will not be duplicated, even if they appear in the set of
   869     copies between fromrev and rev.
   869     copies between fromrev and rev.
   870     '''
   870     """
   871     exclude = {}
   871     exclude = {}
   872     if (skiprev is not None and
   872     if (skiprev is not None and
   873         repo.ui.config('experimental', 'copytrace') != 'off'):
   873         repo.ui.config('experimental', 'copytrace') != 'off'):
   874         # copytrace='off' skips this line, but not the entire function because
   874         # copytrace='off' skips this line, but not the entire function because
   875         # the line below is O(size of the repo) during a rebase, while the rest
   875         # the line below is O(size of the repo) during a rebase, while the rest