##// END OF EJS Templates
export: clobber files with -o (bc) (issue3652)...
Augie Fackler -
r18613:1a2f4c63 default
parent child Browse files
Show More
@@ -170,7 +170,8 b' def makefilename(repo, pat, node, desc=N'
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', pathname=None):
173 seqno=None, revwidth=None, mode='wb', modemap={},
174 pathname=None):
174
175
175 writable = mode not in ('r', 'rb')
176 writable = mode not in ('r', 'rb')
176
177
@@ -196,9 +197,11 b' def makefileobj(repo, pat, node=None, de'
196 return pat
197 return pat
197 if util.safehasattr(pat, 'read') and 'r' in mode:
198 if util.safehasattr(pat, 'read') and 'r' in mode:
198 return pat
199 return pat
199 return open(makefilename(repo, pat, node, desc, total, seqno, revwidth,
200 fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname)
200 pathname),
201 mode = modemap.get(fn, mode)
201 mode)
202 if mode == 'wb':
203 modemap[fn] = 'ab'
204 return open(fn, mode)
202
205
203 def openrevlog(repo, cmd, file_, opts):
206 def openrevlog(repo, cmd, file_, opts):
204 """opens the changelog, manifest, a filelog or a given revlog"""
207 """opens the changelog, manifest, a filelog or a given revlog"""
@@ -539,6 +542,7 b" def export(repo, revs, template='hg-%h.p"
539
542
540 total = len(revs)
543 total = len(revs)
541 revwidth = max([len(str(rev)) for rev in revs])
544 revwidth = max([len(str(rev)) for rev in revs])
545 filemode = {}
542
546
543 def single(rev, seqno, fp):
547 def single(rev, seqno, fp):
544 ctx = repo[rev]
548 ctx = repo[rev]
@@ -554,7 +558,8 b" def export(repo, revs, template='hg-%h.p"
554 desc_lines = ctx.description().rstrip().split('\n')
558 desc_lines = ctx.description().rstrip().split('\n')
555 desc = desc_lines[0] #Commit always has a first line.
559 desc = desc_lines[0] #Commit always has a first line.
556 fp = makefileobj(repo, template, node, desc=desc, total=total,
560 fp = makefileobj(repo, template, node, desc=desc, total=total,
557 seqno=seqno, revwidth=revwidth, mode='ab')
561 seqno=seqno, revwidth=revwidth, mode='wb',
562 modemap=filemode)
558 if fp != template:
563 if fp != template:
559 shouldclose = True
564 shouldclose = True
560 if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
565 if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
@@ -91,13 +91,28 b''
91 foo-foo_10.patch
91 foo-foo_10.patch
92 foo-foo_11.patch
92 foo-foo_11.patch
93
93
94 Doing it again clobbers the files rather than appending:
95 $ hg export -v -o "foo-%m.patch" 2:3
96 exporting patches:
97 foo-foo_2.patch
98 foo-foo_3.patch
99 $ grep HG foo-foo_2.patch | wc -l
100 \s*1 (re)
101 $ grep HG foo-foo_3.patch | wc -l
102 \s*1 (re)
103
94 Exporting 4 changesets to a file:
104 Exporting 4 changesets to a file:
95
105
96 $ hg export -o export_internal 1 2 3 4
106 $ hg export -o export_internal 1 2 3 4
97 $ grep HG export_internal | wc -l
107 $ grep HG export_internal | wc -l
98 \s*4 (re)
108 \s*4 (re)
99
109
100 Exporting 4 changesets to a file:
110 Doing it again clobbers the file rather than appending:
111 $ hg export -o export_internal 1 2 3 4
112 $ grep HG export_internal | wc -l
113 \s*4 (re)
114
115 Exporting 4 changesets to stdout:
101
116
102 $ hg export 1 2 3 4 | grep HG | wc -l
117 $ hg export 1 2 3 4 | grep HG | wc -l
103 \s*4 (re)
118 \s*4 (re)
General Comments 0
You need to be logged in to leave comments. Login now