168 except KeyError, inst: |
168 except KeyError, inst: |
169 raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
169 raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
170 inst.args[0]) |
170 inst.args[0]) |
171 |
171 |
172 def makefileobj(repo, pat, node=None, desc=None, total=None, |
172 def makefileobj(repo, pat, node=None, desc=None, total=None, |
173 seqno=None, revwidth=None, mode='wb', modemap={}, |
173 seqno=None, revwidth=None, mode='wb', modemap=None, |
174 pathname=None): |
174 pathname=None): |
175 |
175 |
176 writable = mode not in ('r', 'rb') |
176 writable = mode not in ('r', 'rb') |
177 |
177 |
178 if not pat or pat == '-': |
178 if not pat or pat == '-': |
196 if util.safehasattr(pat, 'write') and writable: |
196 if util.safehasattr(pat, 'write') and writable: |
197 return pat |
197 return pat |
198 if util.safehasattr(pat, 'read') and 'r' in mode: |
198 if util.safehasattr(pat, 'read') and 'r' in mode: |
199 return pat |
199 return pat |
200 fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname) |
200 fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname) |
201 mode = modemap.get(fn, mode) |
201 if modemap is not None: |
202 if mode == 'wb': |
202 mode = modemap.get(fn, mode) |
203 modemap[fn] = 'ab' |
203 if mode == 'wb': |
|
204 modemap[fn] = 'ab' |
204 return open(fn, mode) |
205 return open(fn, mode) |
205 |
206 |
206 def openrevlog(repo, cmd, file_, opts): |
207 def openrevlog(repo, cmd, file_, opts): |
207 """opens the changelog, manifest, a filelog or a given revlog""" |
208 """opens the changelog, manifest, a filelog or a given revlog""" |
208 cl = opts['changelog'] |
209 cl = opts['changelog'] |