mercurial/commands.py
changeset 1619 1ba0d7041ac4
parent 1618 ff339dd21976
child 1622 5e9168401a68
equal deleted inserted replaced
1618:ff339dd21976 1619:1ba0d7041ac4
   262 
   262 
   263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
   263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
   264            changes=None, text=False):
   264            changes=None, text=False):
   265     if not changes:
   265     if not changes:
   266         changes = repo.changes(node1, node2, files, match=match)
   266         changes = repo.changes(node1, node2, files, match=match)
   267     modified, added, removed, unknown = changes
   267     modified, added, removed, deleted, unknown = changes
   268     if files:
   268     if files:
   269         modified, added, removed = map(lambda x: filterfiles(x, files),
   269         modified, added, removed = map(lambda x: filterfiles(x, files),
   270                                        (modified, added, removed))
   270                                        (modified, added, removed))
   271 
   271 
   272     if not modified and not added and not removed:
   272     if not modified and not added and not removed:
   783 
   783 
   784     if opts['addremove']:
   784     if opts['addremove']:
   785         addremove(ui, repo, *pats, **opts)
   785         addremove(ui, repo, *pats, **opts)
   786     fns, match, anypats, cwd = matchpats(repo, pats, opts)
   786     fns, match, anypats, cwd = matchpats(repo, pats, opts)
   787     if pats:
   787     if pats:
   788         modified, added, removed, unknown = (
   788         modified, added, removed, deleted, unknown = (
   789             repo.changes(files=fns, match=match))
   789             repo.changes(files=fns, match=match))
   790         files = (modified + added +
   790         files = modified + added + removed
   791                 [fn for fn in removed if repo.dirstate.state(fn) == 'r'])
       
   792     else:
   791     else:
   793         files = []
   792         files = []
   794     try:
   793     try:
   795         repo.commit(files, message, opts['user'], opts['date'], match)
   794         repo.commit(files, message, opts['user'], opts['date'], match)
   796     except ValueError, inst:
   795     except ValueError, inst:
  1379     if not parents:
  1378     if not parents:
  1380         ui.write(_("unknown\n"))
  1379         ui.write(_("unknown\n"))
  1381         return
  1380         return
  1382 
  1381 
  1383     hexfunc = ui.verbose and hex or short
  1382     hexfunc = ui.verbose and hex or short
  1384     modified, added, removed, unknown = repo.changes()
  1383     modified, added, removed, deleted, unknown = repo.changes()
  1385     output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
  1384     output = ["%s%s" %
  1386                         (modified or added or removed) and "+" or "")]
  1385               ('+'.join([hexfunc(parent) for parent in parents]),
       
  1386               (modified or added or removed or deleted) and "+" or "")]
  1387 
  1387 
  1388     if not ui.quiet:
  1388     if not ui.quiet:
  1389         # multiple tags for a single parent separated by '/'
  1389         # multiple tags for a single parent separated by '/'
  1390         parenttags = ['/'.join(tags)
  1390         parenttags = ['/'.join(tags)
  1391                       for tags in map(repo.nodetags, parents) if tags]
  1391                       for tags in map(repo.nodetags, parents) if tags]
  1410     safety check, not to import a real mail message.
  1410     safety check, not to import a real mail message.
  1411     """
  1411     """
  1412     patches = (patch1,) + patches
  1412     patches = (patch1,) + patches
  1413 
  1413 
  1414     if not opts['force']:
  1414     if not opts['force']:
  1415         modified, added, removed, unknown = repo.changes()
  1415         modified, added, removed, deleted, unknown = repo.changes()
  1416         if modified or added or removed:
  1416         if modified or added or removed or deleted:
  1417             raise util.Abort(_("outstanding uncommitted changes"))
  1417             raise util.Abort(_("outstanding uncommitted changes"))
  1418 
  1418 
  1419     d = opts["base"]
  1419     d = opts["base"]
  1420     strip = opts["strip"]
  1420     strip = opts["strip"]
  1421 
  1421 
  1827     entire project history.  If the files still exist in the working
  1827     entire project history.  If the files still exist in the working
  1828     directory, they will be deleted from it.
  1828     directory, they will be deleted from it.
  1829     """
  1829     """
  1830     names = []
  1830     names = []
  1831     def okaytoremove(abs, rel, exact):
  1831     def okaytoremove(abs, rel, exact):
  1832         modified, added, removed, unknown = repo.changes(files=[abs])
  1832         modified, added, removed, deleted, unknown = repo.changes(files=[abs])
  1833         reason = None
  1833         reason = None
  1834         if modified:
  1834         if modified:
  1835             reason = _('is modified')
  1835             reason = _('is modified')
  1836         elif added:
  1836         elif added:
  1837             reason = _('has been marked for add')
  1837             reason = _('has been marked for add')
  1891     """
  1891     """
  1892     node = opts['rev'] and repo.lookup(opts['rev']) or \
  1892     node = opts['rev'] and repo.lookup(opts['rev']) or \
  1893            repo.dirstate.parents()[0]
  1893            repo.dirstate.parents()[0]
  1894 
  1894 
  1895     files, choose, anypats, cwd = matchpats(repo, pats, opts)
  1895     files, choose, anypats, cwd = matchpats(repo, pats, opts)
  1896     modified, added, removed, unknown = repo.changes(match=choose)
  1896     modified, added, removed, deleted, unknown = repo.changes(match=choose)
  1897     repo.forget(added)
  1897     repo.forget(added)
  1898     repo.undelete(removed)
  1898     repo.undelete(removed + deleted)
  1899 
  1899 
  1900     return repo.update(node, False, True, choose, False)
  1900     return repo.update(node, False, True, choose, False)
  1901 
  1901 
  1902 def root(ui, repo):
  1902 def root(ui, repo):
  1903     """print the root (top) of the current working dir
  1903     """print the root (top) of the current working dir
  2020 
  2020 
  2021     The codes used to show the status of files are:
  2021     The codes used to show the status of files are:
  2022     M = modified
  2022     M = modified
  2023     A = added
  2023     A = added
  2024     R = removed
  2024     R = removed
       
  2025     ! = deleted, but still tracked
  2025     ? = not tracked
  2026     ? = not tracked
  2026     """
  2027     """
  2027 
  2028 
  2028     files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
  2029     files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
  2029     modified, added, removed, unknown = [
  2030     modified, added, removed, deleted, unknown = [
  2030         [util.pathto(cwd, x) for x in n]
  2031         [util.pathto(cwd, x) for x in n]
  2031         for n in repo.changes(files=files, match=matchfn)]
  2032         for n in repo.changes(files=files, match=matchfn)]
  2032 
  2033 
  2033     changetypes = [(_('modified'), 'M', modified),
  2034     changetypes = [(_('modified'), 'M', modified),
  2034                    (_('added'), 'A', added),
  2035                    (_('added'), 'A', added),
  2035                    (_('removed'), 'R', removed),
  2036                    (_('removed'), 'R', removed),
       
  2037                    (_('deleted'), '!', deleted),
  2036                    (_('unknown'), '?', unknown)]
  2038                    (_('unknown'), '?', unknown)]
  2037 
  2039 
  2038     end = opts['print0'] and '\0' or '\n'
  2040     end = opts['print0'] and '\0' or '\n'
  2039 
  2041 
  2040     for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
  2042     for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
  2435     "^status|st":
  2437     "^status|st":
  2436         (status,
  2438         (status,
  2437          [('m', 'modified', None, _('show only modified files')),
  2439          [('m', 'modified', None, _('show only modified files')),
  2438           ('a', 'added', None, _('show only added files')),
  2440           ('a', 'added', None, _('show only added files')),
  2439           ('r', 'removed', None, _('show only removed files')),
  2441           ('r', 'removed', None, _('show only removed files')),
       
  2442           ('d', 'deleted', None, _('show only deleted (but tracked) files')),
  2440           ('u', 'unknown', None, _('show only unknown (not tracked) files')),
  2443           ('u', 'unknown', None, _('show only unknown (not tracked) files')),
  2441           ('n', 'no-status', None, _('hide status prefix')),
  2444           ('n', 'no-status', None, _('hide status prefix')),
  2442           ('0', 'print0', None,
  2445           ('0', 'print0', None,
  2443            _('end filenames with NUL, for use with xargs')),
  2446            _('end filenames with NUL, for use with xargs')),
  2444           ('I', 'include', [], _('include names matching the given patterns')),
  2447           ('I', 'include', [], _('include names matching the given patterns')),