Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 14639:e59a7b8f521a
commands: use ui descriptors when reading/writing from stdin/out
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Wed, 08 Jun 2011 14:54:52 +0300 |
parents | 217b7d83afc3 |
children | e4cfdff6d3f4 |
comparison
equal
deleted
inserted
replaced
14638:1bdbca0b6604 | 14639:e59a7b8f521a |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from node import hex, bin, nullid, nullrev, short | 8 from node import hex, bin, nullid, nullrev, short |
9 from lock import release | 9 from lock import release |
10 from i18n import _, gettext | 10 from i18n import _, gettext |
11 import os, re, sys, difflib, time, tempfile, errno | 11 import os, re, difflib, time, tempfile, errno |
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks | 12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks |
13 import patch, help, url, encoding, templatekw, discovery | 13 import patch, help, url, encoding, templatekw, discovery |
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server | 14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server |
15 import merge as mergemod | 15 import merge as mergemod |
16 import minirst, revset, fileset | 16 import minirst, revset, fileset |
334 prefix = opts.get('prefix') | 334 prefix = opts.get('prefix') |
335 | 335 |
336 if dest == '-': | 336 if dest == '-': |
337 if kind == 'files': | 337 if kind == 'files': |
338 raise util.Abort(_('cannot archive plain files to stdout')) | 338 raise util.Abort(_('cannot archive plain files to stdout')) |
339 dest = sys.stdout | 339 dest = ui.fout |
340 if not prefix: | 340 if not prefix: |
341 prefix = os.path.basename(repo.root) + '-%h' | 341 prefix = os.path.basename(repo.root) + '-%h' |
342 | 342 |
343 prefix = cmdutil.makefilename(repo, prefix, node) | 343 prefix = cmdutil.makefilename(repo, prefix, node) |
344 matchfn = scmutil.match(repo, [], opts) | 344 matchfn = scmutil.match(repo, [], opts) |
1230 be enclosed in double quotes ("..."), with "\\" as escape character. | 1230 be enclosed in double quotes ("..."), with "\\" as escape character. |
1231 """ | 1231 """ |
1232 | 1232 |
1233 if text is None: | 1233 if text is None: |
1234 ui.status(_("reading DAG from stdin\n")) | 1234 ui.status(_("reading DAG from stdin\n")) |
1235 text = sys.stdin.read() | 1235 text = ui.fin.read() |
1236 | 1236 |
1237 cl = repo.changelog | 1237 cl = repo.changelog |
1238 if len(cl) > 0: | 1238 if len(cl) > 0: |
1239 raise util.Abort(_('repository is not empty')) | 1239 raise util.Abort(_('repository is not empty')) |
1240 | 1240 |
3192 for p in patches: | 3192 for p in patches: |
3193 pf = os.path.join(d, p) | 3193 pf = os.path.join(d, p) |
3194 | 3194 |
3195 if pf == '-': | 3195 if pf == '-': |
3196 ui.status(_("applying patch from stdin\n")) | 3196 ui.status(_("applying patch from stdin\n")) |
3197 pf = sys.stdin | 3197 pf = ui.fin |
3198 else: | 3198 else: |
3199 ui.status(_("applying %s\n") % p) | 3199 ui.status(_("applying %s\n") % p) |
3200 pf = url.open(ui, pf) | 3200 pf = url.open(ui, pf) |
3201 | 3201 |
3202 haspatch = False | 3202 haspatch = False |