Show More
@@ -1359,8 +1359,7 b' def overridecat(orig, ui, repo, file1, *' | |||||
1359 | m.visitdir = lfvisitdirfn |
|
1359 | m.visitdir = lfvisitdirfn | |
1360 |
|
1360 | |||
1361 | for f in ctx.walk(m): |
|
1361 | for f in ctx.walk(m): | |
1362 |
with cmdutil.makefileobj( |
|
1362 | with cmdutil.makefileobj(ctx, opts.get('output'), pathname=f) as fp: | |
1363 | pathname=f) as fp: |
|
|||
1364 | lf = lfutil.splitstandin(f) |
|
1363 | lf = lfutil.splitstandin(f) | |
1365 | if lf is None or origmatchfn(f): |
|
1364 | if lf is None or origmatchfn(f): | |
1366 | # duplicating unreachable code from commands.cat |
|
1365 | # duplicating unreachable code from commands.cat |
@@ -956,19 +956,19 b' class _unclosablefile(object):' | |||||
956 | def __exit__(self, exc_type, exc_value, exc_tb): |
|
956 | def __exit__(self, exc_type, exc_value, exc_tb): | |
957 | pass |
|
957 | pass | |
958 |
|
958 | |||
959 |
def makefileobj( |
|
959 | def makefileobj(ctx, pat, desc=None, total=None, | |
960 | seqno=None, revwidth=None, mode='wb', modemap=None, |
|
960 | seqno=None, revwidth=None, mode='wb', modemap=None, | |
961 | pathname=None): |
|
961 | pathname=None): | |
962 |
|
962 | |||
963 | writable = mode not in ('r', 'rb') |
|
963 | writable = mode not in ('r', 'rb') | |
964 |
|
964 | |||
965 | if isstdiofilename(pat): |
|
965 | if isstdiofilename(pat): | |
|
966 | repo = ctx.repo() | |||
966 | if writable: |
|
967 | if writable: | |
967 | fp = repo.ui.fout |
|
968 | fp = repo.ui.fout | |
968 | else: |
|
969 | else: | |
969 | fp = repo.ui.fin |
|
970 | fp = repo.ui.fin | |
970 | return _unclosablefile(fp) |
|
971 | return _unclosablefile(fp) | |
971 | ctx = repo[node] |
|
|||
972 | fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname) |
|
972 | fn = makefilename(ctx, pat, desc, total, seqno, revwidth, pathname) | |
973 | if modemap is not None: |
|
973 | if modemap is not None: | |
974 | mode = modemap.get(fn, mode) |
|
974 | mode = modemap.get(fn, mode) | |
@@ -1546,7 +1546,7 b" def export(repo, revs, fntemplate='hg-%h" | |||||
1546 | if not fp and fntemplate: |
|
1546 | if not fp and fntemplate: | |
1547 | desc_lines = ctx.description().rstrip().split('\n') |
|
1547 | desc_lines = ctx.description().rstrip().split('\n') | |
1548 | desc = desc_lines[0] #Commit always has a first line. |
|
1548 | desc = desc_lines[0] #Commit always has a first line. | |
1549 |
fo = makefileobj( |
|
1549 | fo = makefileobj(ctx, fntemplate, desc=desc, | |
1550 | total=total, seqno=seqno, revwidth=revwidth, |
|
1550 | total=total, seqno=seqno, revwidth=revwidth, | |
1551 | mode='wb', modemap=filemode) |
|
1551 | mode='wb', modemap=filemode) | |
1552 | dest = fo.name |
|
1552 | dest = fo.name |
@@ -486,7 +486,7 b' def archive(ui, repo, dest, **opts):' | |||||
486 | if dest == '-': |
|
486 | if dest == '-': | |
487 | if kind == 'files': |
|
487 | if kind == 'files': | |
488 | raise error.Abort(_('cannot archive plain files to stdout')) |
|
488 | raise error.Abort(_('cannot archive plain files to stdout')) | |
489 |
dest = cmdutil.makefileobj( |
|
489 | dest = cmdutil.makefileobj(ctx, dest) | |
490 | if not prefix: |
|
490 | if not prefix: | |
491 | prefix = os.path.basename(repo.root) + '-%h' |
|
491 | prefix = os.path.basename(repo.root) + '-%h' | |
492 |
|
492 |
@@ -1642,8 +1642,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1642 | # TODO: add support for non-plain formatter (see cmdutil.cat()) |
|
1642 | # TODO: add support for non-plain formatter (see cmdutil.cat()) | |
1643 | for f in match.files(): |
|
1643 | for f in match.files(): | |
1644 | output = self._gitcommand(["show", "%s:%s" % (rev, f)]) |
|
1644 | output = self._gitcommand(["show", "%s:%s" % (rev, f)]) | |
1645 |
fp = cmdutil.makefileobj(self._ |
|
1645 | fp = cmdutil.makefileobj(self._ctx, fntemplate, | |
1646 | self._ctx.node(), |
|
|||
1647 | pathname=self.wvfs.reljoin(prefix, f)) |
|
1646 | pathname=self.wvfs.reljoin(prefix, f)) | |
1648 | fp.write(output) |
|
1647 | fp.write(output) | |
1649 | fp.close() |
|
1648 | fp.close() |
General Comments 0
You need to be logged in to leave comments.
Login now