mercurial/copies.py
changeset 42593 11ceb1b8fd74
parent 42592 a48f6f18dc6d
child 42594 d013099c551b
equal deleted inserted replaced
42592:a48f6f18dc6d 42593:11ceb1b8fd74
   105     # yet the filelog has the copy information in rev 1 and we will not look
   105     # yet the filelog has the copy information in rev 1 and we will not look
   106     # back far enough unless we also look at the a and b as candidates.
   106     # back far enough unless we also look at the a and b as candidates.
   107     # This only occurs when a is a descendent of b or visa-versa.
   107     # This only occurs when a is a descendent of b or visa-versa.
   108     return min(limit, a, b)
   108     return min(limit, a, b)
   109 
   109 
   110 def _chainandfilter(src, dst, a, b):
   110 def _filter(src, dst, t):
   111     """chain two sets of copies 'a' and 'b' and filter result"""
   111     """filters out invalid copies after chaining"""
   112 
   112 
   113     # When chaining copies in 'a' (from 'src' via some other commit 'mid') with
   113     # When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid')
   114     # copies in 'b' (from 'mid' to 'dst'), we can get the different cases in the
   114     # with copies in 'b' (from 'mid' to 'dst'), we can get the different cases
   115     # following table (not including trivial cases). For example, case 2 is
   115     # in the following table (not including trivial cases). For example, case 2
   116     # where a file existed in 'src' and remained under that name in 'mid' and
   116     # is where a file existed in 'src' and remained under that name in 'mid' and
   117     # then was renamed between 'mid' and 'dst'.
   117     # then was renamed between 'mid' and 'dst'.
   118     #
   118     #
   119     # case src mid dst result
   119     # case src mid dst result
   120     #   1   x   y   -    -
   120     #   1   x   y   -    -
   121     #   2   x   y   y   x->y
   121     #   2   x   y   y   x->y
   127     # _chain() takes care of chaining the copies in 'a' and 'b', but it
   127     # _chain() takes care of chaining the copies in 'a' and 'b', but it
   128     # cannot tell the difference between cases 1 and 2, between 3 and 4, or
   128     # cannot tell the difference between cases 1 and 2, between 3 and 4, or
   129     # between 5 and 6, so it includes all cases in its result.
   129     # between 5 and 6, so it includes all cases in its result.
   130     # Cases 1, 3, and 5 are then removed by _filter().
   130     # Cases 1, 3, and 5 are then removed by _filter().
   131 
   131 
   132     t = _chain(a, b)
       
   133     _filter(src, dst, t)
       
   134     return t
       
   135 
       
   136 def _filter(src, dst, t):
       
   137     """filters out invalid copies after chaining"""
       
   138     for k, v in list(t.items()):
   132     for k, v in list(t.items()):
   139         # remove copies from files that didn't exist
   133         # remove copies from files that didn't exist
   140         if v not in src:
   134         if v not in src:
   141             del t[k]
   135             del t[k]
   142         # remove criss-crossed copies
   136         # remove criss-crossed copies
   324     match = a.repo().narrowmatch(match)
   318     match = a.repo().narrowmatch(match)
   325     # check for working copy
   319     # check for working copy
   326     if b.rev() is None:
   320     if b.rev() is None:
   327         cm = _committedforwardcopies(a, b.p1(), match)
   321         cm = _committedforwardcopies(a, b.p1(), match)
   328         # combine copies from dirstate if necessary
   322         # combine copies from dirstate if necessary
   329         copies = _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
   323         copies = _chain(cm, _dirstatecopies(b._repo, match))
       
   324         _filter(a, b, copies)
   330     else:
   325     else:
   331         copies  = _committedforwardcopies(a, b, match)
   326         copies  = _committedforwardcopies(a, b, match)
   332     return copies
   327     return copies
   333 
   328 
   334 def _backwardrenames(a, b, match):
   329 def _backwardrenames(a, b, match):
   374             repo.ui.debug('debug.copies: search mode: backward\n')
   369             repo.ui.debug('debug.copies: search mode: backward\n')
   375         copies = _backwardrenames(x, y, match=match)
   370         copies = _backwardrenames(x, y, match=match)
   376     else:
   371     else:
   377         if debug:
   372         if debug:
   378             repo.ui.debug('debug.copies: search mode: combined\n')
   373             repo.ui.debug('debug.copies: search mode: combined\n')
   379         copies = _chainandfilter(x, y, _backwardrenames(x, a, match=match),
   374         copies = _chain(_backwardrenames(x, a, match=match),
   380                                  _forwardcopies(a, y, match=match))
   375                         _forwardcopies(a, y, match=match))
       
   376         _filter(x, y, copies)
   381     return copies
   377     return copies
   382 
   378 
   383 def mergecopies(repo, c1, c2, base):
   379 def mergecopies(repo, c1, c2, base):
   384     """
   380     """
   385     Finds moves and copies between context c1 and c2 that are relevant for
   381     Finds moves and copies between context c1 and c2 that are relevant for