comparison mercurial/commands.py @ 6276:c93ca83a3354

status: find copies and renames beyond the working directory
author Matt Mackall <mpm@selenic.com>
date Sat, 15 Mar 2008 16:24:16 -0500
parents de7256c82fad
children a9e6b8875805
comparison
equal deleted inserted replaced
6275:fda369b5779c 6276:c93ca83a3354
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from repo import RepoError 9 from repo import RepoError
10 from i18n import _ 10 from i18n import _
11 import os, re, sys, urllib 11 import os, re, sys, urllib
12 import hg, util, revlog, bundlerepo, extensions 12 import hg, util, revlog, bundlerepo, extensions, copies
13 import difflib, patch, time, help, mdiff, tempfile 13 import difflib, patch, time, help, mdiff, tempfile
14 import version, socket 14 import version, socket
15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect 15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
16 16
17 # Commands start here, listed alphabetically 17 # Commands start here, listed alphabetically
2541 ('unknown', '?', unknown), 2541 ('unknown', '?', unknown),
2542 ('ignored', 'I', ignored)) 2542 ('ignored', 'I', ignored))
2543 2543
2544 explicit_changetypes = changetypes + (('clean', 'C', clean),) 2544 explicit_changetypes = changetypes + (('clean', 'C', clean),)
2545 2545
2546 copy = {}
2547 showcopy = {}
2548 if ((all or opts.get('copies')) and not opts.get('no_status')):
2549 if opts.get('rev') == []:
2550 # fast path, more correct with merge parents
2551 showcopy = copy = repo.dirstate.copies().copy()
2552 else:
2553 ctxn = repo.changectx(nullid)
2554 ctx1 = repo.changectx(node1)
2555 ctx2 = repo.changectx(node2)
2556 if node2 is None:
2557 ctx2 = repo.workingctx()
2558 copy, diverge = copies.copies(repo, ctx1, ctx2, ctxn)
2559 for k, v in copy.items():
2560 copy[v] = k
2561
2546 end = opts['print0'] and '\0' or '\n' 2562 end = opts['print0'] and '\0' or '\n'
2547 2563
2548 for opt, char, changes in ([ct for ct in explicit_changetypes 2564 for opt, char, changes in ([ct for ct in explicit_changetypes
2549 if all or opts[ct[0]]] 2565 if all or opts[ct[0]]]
2550 or changetypes): 2566 or changetypes):
2554 else: 2570 else:
2555 format = "%s %%s%s" % (char, end) 2571 format = "%s %%s%s" % (char, end)
2556 2572
2557 for f in changes: 2573 for f in changes:
2558 ui.write(format % repo.pathto(f, cwd)) 2574 ui.write(format % repo.pathto(f, cwd))
2559 if ((all or opts.get('copies')) and not opts.get('no_status')): 2575 if f in copy and (f in added or f in showcopy):
2560 copied = repo.dirstate.copied(f) 2576 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end))
2561 if copied:
2562 ui.write(' %s%s' % (repo.pathto(copied, cwd), end))
2563 2577
2564 def tag(ui, repo, name, rev_=None, **opts): 2578 def tag(ui, repo, name, rev_=None, **opts):
2565 """add a tag for the current or given revision 2579 """add a tag for the current or given revision
2566 2580
2567 Name a particular revision using <name>. 2581 Name a particular revision using <name>.