mercurial/revset.py
changeset 16445 453c8670566c
parent 16444 432f198600c6
child 16446 984e0412e82b
equal deleted inserted replaced
16444:432f198600c6 16445:453c8670566c
   968         getfield = _funcs.get(info, None)
   968         getfield = _funcs.get(info, None)
   969         if getfield is None:
   969         if getfield is None:
   970             raise error.ParseError(
   970             raise error.ParseError(
   971                 _("unexpected field name passed to matching: %s") % info)
   971                 _("unexpected field name passed to matching: %s") % info)
   972         getfieldfuncs.append(getfield)
   972         getfieldfuncs.append(getfield)
   973 
       
   974     # convert the getfield array of functions into a "getinfo" function
   973     # convert the getfield array of functions into a "getinfo" function
   975     # which returns an array of field values (or a single value if there
   974     # which returns an array of field values (or a single value if there
   976     # is only one field to match)
   975     # is only one field to match)
   977     if len(getfieldfuncs) == 1:
   976     getinfo = lambda r: [f(r) for f in getfieldfuncs]
   978         getinfo = getfieldfuncs[0]
       
   979     else:
       
   980         getinfo = lambda r: [f(r) for f in getfieldfuncs]
       
   981 
   977 
   982     matches = []
   978     matches = []
   983     for rev in revs:
   979     for rev in revs:
   984         target = getinfo(rev)
   980         target = getinfo(rev)
   985         matches += [r for r in subset if getinfo(r) == target]
   981         for r in subset:
       
   982             match = True
       
   983             for n, f in enumerate(getfieldfuncs):
       
   984                 if target[n] != f(r):
       
   985                     match = False
       
   986                     break
       
   987             if match:
       
   988                 matches.append(r)
   986     if len(revs) > 1:
   989     if len(revs) > 1:
   987         matches = sorted(set(matches))
   990         matches = sorted(set(matches))
   988     return matches
   991     return matches
   989 
   992 
   990 def reverse(repo, subset, x):
   993 def reverse(repo, subset, x):