mercurial/commands.py
changeset 6605 bf2bf986ff87
parent 6603 41eb20cc1c02
child 6615 0697e7818d07
equal deleted inserted replaced
6604:98b6e6f0e49b 6605:bf2bf986ff87
  2622     ? = not tracked
  2622     ? = not tracked
  2623     I = ignored
  2623     I = ignored
  2624       = the previous added file was copied from here
  2624       = the previous added file was copied from here
  2625     """
  2625     """
  2626 
  2626 
  2627     all = opts['all']
       
  2628     node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
  2627     node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
  2629 
       
  2630     matcher = cmdutil.match(repo, pats, opts)
       
  2631     cwd = (pats and repo.getcwd()) or ''
  2628     cwd = (pats and repo.getcwd()) or ''
  2632     modified, added, removed, deleted, unknown, ignored, clean = [
  2629     end = opts['print0'] and '\0' or '\n'
  2633         n for n in repo.status(node1, node2, matcher,
       
  2634                                list_ignored=opts['ignored']
       
  2635                                             or all and not ui.quiet,
       
  2636                                list_clean=opts['clean'] or all,
       
  2637                                list_unknown=opts['unknown']
       
  2638                                             or not (ui.quiet or
       
  2639                                                     opts['modified'] or
       
  2640                                                     opts['added'] or
       
  2641                                                     opts['removed'] or
       
  2642                                                     opts['deleted'] or
       
  2643                                                     opts['ignored']))]
       
  2644 
       
  2645     changetypes = (('modified', 'M', modified),
       
  2646                    ('added', 'A', added),
       
  2647                    ('removed', 'R', removed),
       
  2648                    ('deleted', '!', deleted),
       
  2649                    ('unknown', '?', unknown),
       
  2650                    ('ignored', 'I', ignored))
       
  2651 
       
  2652     explicit_changetypes = changetypes + (('clean', 'C', clean),)
       
  2653 
       
  2654     copy = {}
  2630     copy = {}
  2655     showcopy = {}
  2631     states = 'modified added removed deleted unknown ignored clean'.split()
  2656     if ((all or opts.get('copies')) and not opts.get('no_status')):
  2632     show = [k for k in states if opts[k]]
       
  2633     if opts['all']:
       
  2634         show += ui.quiet and (states[:4] + ['clean']) or states
       
  2635     if not show:
       
  2636         show = ui.quiet and states[:4] or states[:5]
       
  2637 
       
  2638     stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
       
  2639                        'ignored' in show, 'clean' in show, 'unknown' in show)
       
  2640     changestates = zip(states, 'MAR!?IC', stat)
       
  2641 
       
  2642     if (opts['all'] or opts['copies']) and not opts['no_status']:
  2657         if opts.get('rev') == []:
  2643         if opts.get('rev') == []:
  2658             # fast path, more correct with merge parents
  2644             # fast path, more correct with merge parents
  2659             showcopy = copy = repo.dirstate.copies().copy()
  2645             copy = repo.dirstate.copies()
  2660         else:
  2646         else:
  2661             ctxn = repo.changectx(nullid)
  2647             ctxn = repo.changectx(nullid)
  2662             ctx1 = repo.changectx(node1)
  2648             ctx1 = repo.changectx(node1)
  2663             ctx2 = repo.changectx(node2)
  2649             ctx2 = repo.changectx(node2)
  2664             if node2 is None:
  2650             if node2 is None:
  2665                 ctx2 = repo.workingctx()
  2651                 ctx2 = repo.workingctx()
  2666             copy, diverge = copies.copies(repo, ctx1, ctx2, ctxn)
  2652             for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items():
  2667             for k, v in copy.items():
  2653                 if v in stat.added:
  2668                 copy[v] = k
  2654                     copy[v] = k
  2669 
  2655                 elif k in stat.added:
  2670     end = opts['print0'] and '\0' or '\n'
  2656                     copy[k] = v
  2671 
  2657 
  2672     for opt, char, changes in ([ct for ct in explicit_changetypes
  2658     for state, char, files in changestates:
  2673                                 if all or opts[ct[0]]]
  2659         if state in show:
  2674                                or changetypes):
       
  2675 
       
  2676         if opts['no_status']:
       
  2677             format = "%%s%s" % end
       
  2678         else:
       
  2679             format = "%s %%s%s" % (char, end)
  2660             format = "%s %%s%s" % (char, end)
  2680 
  2661             if opts['no_status']:
  2681         for f in changes:
  2662                 format = "%%s%s" % end
  2682             ui.write(format % repo.pathto(f, cwd))
  2663 
  2683             if f in copy and (f in added or f in showcopy):
  2664             for f in files:
  2684                 ui.write('  %s%s' % (repo.pathto(copy[f], cwd), end))
  2665                 ui.write(format % repo.pathto(f, cwd))
       
  2666                 if f in copy:
       
  2667                     ui.write('  %s%s' % (repo.pathto(copy[f], cwd), end))
  2685 
  2668 
  2686 def tag(ui, repo, name1, *names, **opts):
  2669 def tag(ui, repo, name1, *names, **opts):
  2687     """add one or more tags for the current or given revision
  2670     """add one or more tags for the current or given revision
  2688 
  2671 
  2689     Name a particular revision using <name>.
  2672     Name a particular revision using <name>.