mercurial/cmdutil.py
changeset 6762 f67d1468ac50
parent 6760 4faaa0535ea7
child 6953 63b5f4c73c98
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
   651         if copies and self.ui.verbose:
   651         if copies and self.ui.verbose:
   652             copies = ['%s (%s)' % c for c in copies]
   652             copies = ['%s (%s)' % c for c in copies]
   653             self.ui.write(_("copies:      %s\n") % ' '.join(copies))
   653             self.ui.write(_("copies:      %s\n") % ' '.join(copies))
   654 
   654 
   655         if extra and self.ui.debugflag:
   655         if extra and self.ui.debugflag:
   656             extraitems = extra.items()
   656             for key, value in util.sort(extra.items()):
   657             extraitems.sort()
       
   658             for key, value in extraitems:
       
   659                 self.ui.write(_("extra:       %s=%s\n")
   657                 self.ui.write(_("extra:       %s=%s\n")
   660                               % (key, value.encode('string_escape')))
   658                               % (key, value.encode('string_escape')))
   661 
   659 
   662         description = changes[4].strip()
   660         description = changes[4].strip()
   663         if description:
   661         if description:
   797 
   795 
   798         def showtags(**args):
   796         def showtags(**args):
   799             return showlist('tag', self.repo.nodetags(changenode), **args)
   797             return showlist('tag', self.repo.nodetags(changenode), **args)
   800 
   798 
   801         def showextras(**args):
   799         def showextras(**args):
   802             extras = changes[5].items()
   800             for key, value in util.sort(changes[5].items()):
   803             extras.sort()
       
   804             for key, value in extras:
       
   805                 args = args.copy()
   801                 args = args.copy()
   806                 args.update(dict(key=key, value=value))
   802                 args.update(dict(key=key, value=value))
   807                 yield self.t('extra', **args)
   803                 yield self.t('extra', **args)
   808 
   804 
   809         def showcopies(**args):
   805         def showcopies(**args):
  1127                 return rev in wanted
  1123                 return rev in wanted
  1128 
  1124 
  1129         for i, window in increasing_windows(0, len(revs)):
  1125         for i, window in increasing_windows(0, len(revs)):
  1130             yield 'window', revs[0] < revs[-1], revs[-1]
  1126             yield 'window', revs[0] < revs[-1], revs[-1]
  1131             nrevs = [rev for rev in revs[i:i+window] if want(rev)]
  1127             nrevs = [rev for rev in revs[i:i+window] if want(rev)]
  1132             srevs = list(nrevs)
  1128             for rev in util.sort(list(nrevs)):
  1133             srevs.sort()
       
  1134             for rev in srevs:
       
  1135                 fns = fncache.get(rev)
  1129                 fns = fncache.get(rev)
  1136                 if not fns:
  1130                 if not fns:
  1137                     def fns_generator():
  1131                     def fns_generator():
  1138                         for f in change(rev)[3]:
  1132                         for f in change(rev)[3]:
  1139                             if m(f):
  1133                             if m(f):
  1157         addremove(repo, pats, opts)
  1151         addremove(repo, pats, opts)
  1158 
  1152 
  1159     m = match(repo, pats, opts)
  1153     m = match(repo, pats, opts)
  1160     if pats:
  1154     if pats:
  1161         modified, added, removed = repo.status(match=m)[:3]
  1155         modified, added, removed = repo.status(match=m)[:3]
  1162         files = modified + added + removed
  1156         files = util.sort(modified + added + removed)
  1163         slist = None
  1157         slist = None
  1164         for f in m.files():
  1158         for f in m.files():
  1165             if f == '.':
  1159             if f == '.':
  1166                 continue
  1160                 continue
  1167             if f not in files:
  1161             if f not in files:
  1171                     mode = os.lstat(rf)[stat.ST_MODE]
  1165                     mode = os.lstat(rf)[stat.ST_MODE]
  1172                 except OSError:
  1166                 except OSError:
  1173                     raise util.Abort(_("file %s not found!") % rel)
  1167                     raise util.Abort(_("file %s not found!") % rel)
  1174                 if stat.S_ISDIR(mode):
  1168                 if stat.S_ISDIR(mode):
  1175                     name = f + '/'
  1169                     name = f + '/'
  1176                     if slist is None:
  1170                     i = bisect.bisect(files, name)
  1177                         slist = list(files)
  1171                     if i >= len(files) or not files[i].startswith(name):
  1178                         slist.sort()
       
  1179                     i = bisect.bisect(slist, name)
       
  1180                     if i >= len(slist) or not slist[i].startswith(name):
       
  1181                         raise util.Abort(_("no match under directory %s!")
  1172                         raise util.Abort(_("no match under directory %s!")
  1182                                          % rel)
  1173                                          % rel)
  1183                 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
  1174                 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
  1184                     raise util.Abort(_("can't commit %s: "
  1175                     raise util.Abort(_("can't commit %s: "
  1185                                        "unsupported file type!") % rel)
  1176                                        "unsupported file type!") % rel)