mercurial/commands.py
changeset 3499 ceaa3fefc10c
parent 3467 df7202f6887c
child 3502 8dc14d630b29
equal deleted inserted replaced
3498:ff06fe0703ef 3499:ceaa3fefc10c
   217     # is descending and the prune args are all within that range
   217     # is descending and the prune args are all within that range
   218     for rev in opts.get('prune', ()):
   218     for rev in opts.get('prune', ()):
   219         rev = repo.changelog.rev(repo.lookup(rev))
   219         rev = repo.changelog.rev(repo.lookup(rev))
   220         ff = followfilter()
   220         ff = followfilter()
   221         stop = min(revs[0], revs[-1])
   221         stop = min(revs[0], revs[-1])
   222         for x in range(rev, stop-1, -1):
   222         for x in xrange(rev, stop-1, -1):
   223             if ff.match(x) and wanted.has_key(x):
   223             if ff.match(x) and wanted.has_key(x):
   224                 del wanted[x]
   224                 del wanted[x]
   225 
   225 
   226     def iterate():
   226     def iterate():
   227         if follow and not files:
   227         if follow and not files:
   324             self.ui.write("%d:%s\n" % (rev, short(changenode)))
   324             self.ui.write("%d:%s\n" % (rev, short(changenode)))
   325             return
   325             return
   326 
   326 
   327         changes = log.read(changenode)
   327         changes = log.read(changenode)
   328         date = util.datestr(changes[2])
   328         date = util.datestr(changes[2])
   329         branch = changes[5].get("branch")
   329         extra = changes[5]
       
   330         branch = extra.get("branch")
   330 
   331 
   331         hexfunc = self.ui.debugflag and hex or short
   332         hexfunc = self.ui.debugflag and hex or short
   332 
   333 
   333         parents = [(log.rev(p), hexfunc(p)) for p in log.parents(changenode)
   334         parents = [(log.rev(p), hexfunc(p)) for p in log.parents(changenode)
   334                    if self.ui.debugflag or p != nullid]
   335                    if self.ui.debugflag or p != nullid]
   358             files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
   359             files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
   359             for key, value in zip([_("files:"), _("files+:"), _("files-:")],
   360             for key, value in zip([_("files:"), _("files+:"), _("files-:")],
   360                                   files):
   361                                   files):
   361                 if value:
   362                 if value:
   362                     self.ui.note("%-12s %s\n" % (key, " ".join(value)))
   363                     self.ui.note("%-12s %s\n" % (key, " ".join(value)))
   363         else:
   364         elif changes[3]:
   364             self.ui.note(_("files:       %s\n") % " ".join(changes[3]))
   365             self.ui.note(_("files:       %s\n") % " ".join(changes[3]))
   365         if copies:
   366         if copies:
   366             copies = ['%s (%s)' % c for c in copies]
   367             copies = ['%s (%s)' % c for c in copies]
   367             self.ui.note(_("copies:      %s\n") % ' '.join(copies))
   368             self.ui.note(_("copies:      %s\n") % ' '.join(copies))
       
   369 
       
   370         if extra and self.ui.debugflag:
       
   371             extraitems = extra.items()
       
   372             extraitems.sort()
       
   373             for key, value in extraitems:
       
   374                 self.ui.debug(_("extra:       %s=%s\n")
       
   375                               % (key, value.encode('string_escape')))
   368 
   376 
   369         description = changes[4].strip()
   377         description = changes[4].strip()
   370         if description:
   378         if description:
   371             if self.ui.verbose:
   379             if self.ui.verbose:
   372                 self.ui.status(_("description:\n"))
   380                 self.ui.status(_("description:\n"))
  1235 def debugindex(ui, file_):
  1243 def debugindex(ui, file_):
  1236     """dump the contents of an index file"""
  1244     """dump the contents of an index file"""
  1237     r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
  1245     r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
  1238     ui.write("   rev    offset  length   base linkrev" +
  1246     ui.write("   rev    offset  length   base linkrev" +
  1239              " nodeid       p1           p2\n")
  1247              " nodeid       p1           p2\n")
  1240     for i in range(r.count()):
  1248     for i in xrange(r.count()):
  1241         node = r.node(i)
  1249         node = r.node(i)
  1242         pp = r.parents(node)
  1250         pp = r.parents(node)
  1243         ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
  1251         ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
  1244                 i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
  1252                 i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
  1245             short(node), short(pp[0]), short(pp[1])))
  1253             short(node), short(pp[0]), short(pp[1])))
  1246 
  1254 
  1247 def debugindexdot(ui, file_):
  1255 def debugindexdot(ui, file_):
  1248     """dump an index DAG as a .dot file"""
  1256     """dump an index DAG as a .dot file"""
  1249     r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
  1257     r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
  1250     ui.write("digraph G {\n")
  1258     ui.write("digraph G {\n")
  1251     for i in range(r.count()):
  1259     for i in xrange(r.count()):
  1252         node = r.node(i)
  1260         node = r.node(i)
  1253         pp = r.parents(node)
  1261         pp = r.parents(node)
  1254         ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
  1262         ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
  1255         if pp[1] != nullid:
  1263         if pp[1] != nullid:
  1256             ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
  1264             ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
  1433 
  1441 
  1434     def difflinestates(a, b):
  1442     def difflinestates(a, b):
  1435         sm = difflib.SequenceMatcher(None, a, b)
  1443         sm = difflib.SequenceMatcher(None, a, b)
  1436         for tag, alo, ahi, blo, bhi in sm.get_opcodes():
  1444         for tag, alo, ahi, blo, bhi in sm.get_opcodes():
  1437             if tag == 'insert':
  1445             if tag == 'insert':
  1438                 for i in range(blo, bhi):
  1446                 for i in xrange(blo, bhi):
  1439                     yield ('+', b[i])
  1447                     yield ('+', b[i])
  1440             elif tag == 'delete':
  1448             elif tag == 'delete':
  1441                 for i in range(alo, ahi):
  1449                 for i in xrange(alo, ahi):
  1442                     yield ('-', a[i])
  1450                     yield ('-', a[i])
  1443             elif tag == 'replace':
  1451             elif tag == 'replace':
  1444                 for i in range(alo, ahi):
  1452                 for i in xrange(alo, ahi):
  1445                     yield ('-', a[i])
  1453                     yield ('-', a[i])
  1446                 for i in range(blo, bhi):
  1454                 for i in xrange(blo, bhi):
  1447                     yield ('+', b[i])
  1455                     yield ('+', b[i])
  1448 
  1456 
  1449     prev = {}
  1457     prev = {}
  1450     ucache = {}
  1458     ucache = {}
  1451     def display(fn, rev, states, prevstates):
  1459     def display(fn, rev, states, prevstates):
  1646             else:
  1654             else:
  1647                 # launch the editor
  1655                 # launch the editor
  1648                 message = None
  1656                 message = None
  1649             ui.debug(_('message:\n%s\n') % message)
  1657             ui.debug(_('message:\n%s\n') % message)
  1650 
  1658 
  1651             files, fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root)
  1659             files = {}
  1652             files = patch.updatedir(ui, repo, files, wlock=wlock)
  1660             try:
       
  1661                 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
       
  1662                                    files=files)
       
  1663             finally:
       
  1664                 files = patch.updatedir(ui, repo, files, wlock=wlock)
  1653             repo.commit(files, message, user, date, wlock=wlock, lock=lock)
  1665             repo.commit(files, message, user, date, wlock=wlock, lock=lock)
  1654         finally:
  1666         finally:
  1655             os.unlink(tmpname)
  1667             os.unlink(tmpname)
  1656 
  1668 
  1657 def incoming(ui, repo, source="default", **opts):
  1669 def incoming(ui, repo, source="default", **opts):
  2089       and a copy of hg in the remote path or specified with as remotecmd.
  2101       and a copy of hg in the remote path or specified with as remotecmd.
  2090     - path is relative to the remote user's home directory by default.
  2102     - path is relative to the remote user's home directory by default.
  2091       Use an extra slash at the start of a path to specify an absolute path:
  2103       Use an extra slash at the start of a path to specify an absolute path:
  2092         ssh://example.com//tmp/repository
  2104         ssh://example.com//tmp/repository
  2093     - Mercurial doesn't use its own compression via SSH; the right thing
  2105     - Mercurial doesn't use its own compression via SSH; the right thing
  2094       to do is to configure it in your ~/.ssh/ssh_config, e.g.:
  2106       to do is to configure it in your ~/.ssh/config, e.g.:
  2095         Host *.mylocalnetwork.example.com
  2107         Host *.mylocalnetwork.example.com
  2096           Compression off
  2108           Compression no
  2097         Host *
  2109         Host *
  2098           Compression on
  2110           Compression yes
  2099       Alternatively specify "ssh -C" as your ssh command in your hgrc or
  2111       Alternatively specify "ssh -C" as your ssh command in your hgrc or
  2100       with the --ssh command line option.
  2112       with the --ssh command line option.
  2101     """
  2113     """
  2102     source = ui.expandpath(source)
  2114     source = ui.expandpath(source)
  2103     setremoteconfig(ui, opts)
  2115     setremoteconfig(ui, opts)
  2536 
  2548 
  2537     Show status of files in the repository.  If names are given, only
  2549     Show status of files in the repository.  If names are given, only
  2538     files that match are shown.  Files that are clean or ignored, are
  2550     files that match are shown.  Files that are clean or ignored, are
  2539     not listed unless -c (clean), -i (ignored) or -A is given.
  2551     not listed unless -c (clean), -i (ignored) or -A is given.
  2540 
  2552 
       
  2553     If one revision is given, it is used as the base revision.
       
  2554     If two revisions are given, the difference between them is shown.
       
  2555 
  2541     The codes used to show the status of files are:
  2556     The codes used to show the status of files are:
  2542     M = modified
  2557     M = modified
  2543     A = added
  2558     A = added
  2544     R = removed
  2559     R = removed
  2545     C = clean
  2560     C = clean
  2548     I = ignored (not shown by default)
  2563     I = ignored (not shown by default)
  2549       = the previous added file was copied from here
  2564       = the previous added file was copied from here
  2550     """
  2565     """
  2551 
  2566 
  2552     all = opts['all']
  2567     all = opts['all']
       
  2568     node1, node2 = cmdutil.revpair(ui, repo, opts.get('rev'))
  2553 
  2569 
  2554     files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
  2570     files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
  2555     cwd = (pats and repo.getcwd()) or ''
  2571     cwd = (pats and repo.getcwd()) or ''
  2556     modified, added, removed, deleted, unknown, ignored, clean = [
  2572     modified, added, removed, deleted, unknown, ignored, clean = [
  2557         [util.pathto(cwd, x) for x in n]
  2573         [util.pathto(cwd, x) for x in n]
  2558         for n in repo.status(files=files, match=matchfn,
  2574         for n in repo.status(node1=node1, node2=node2, files=files,
       
  2575                              match=matchfn,
  2559                              list_ignored=all or opts['ignored'],
  2576                              list_ignored=all or opts['ignored'],
  2560                              list_clean=all or opts['clean'])]
  2577                              list_clean=all or opts['clean'])]
  2561 
  2578 
  2562     changetypes = (('modified', 'M', modified),
  2579     changetypes = (('modified', 'M', modified),
  2563                    ('added', 'A', added),
  2580                    ('added', 'A', added),
  3099           ('i', 'ignored', None, _('show ignored files')),
  3116           ('i', 'ignored', None, _('show ignored files')),
  3100           ('n', 'no-status', None, _('hide status prefix')),
  3117           ('n', 'no-status', None, _('hide status prefix')),
  3101           ('C', 'copies', None, _('show source of copied files')),
  3118           ('C', 'copies', None, _('show source of copied files')),
  3102           ('0', 'print0', None,
  3119           ('0', 'print0', None,
  3103            _('end filenames with NUL, for use with xargs')),
  3120            _('end filenames with NUL, for use with xargs')),
       
  3121           ('', 'rev', [], _('show difference from revision')),
  3104          ] + walkopts,
  3122          ] + walkopts,
  3105          _('hg status [OPTION]... [FILE]...')),
  3123          _('hg status [OPTION]... [FILE]...')),
  3106     "tag":
  3124     "tag":
  3107         (tag,
  3125         (tag,
  3108          [('l', 'local', None, _('make the tag local')),
  3126          [('l', 'local', None, _('make the tag local')),