Show More
@@ -109,12 +109,13 b' def loglimit(opts):' | |||||
109 | limit = None |
|
109 | limit = None | |
110 | return limit |
|
110 | return limit | |
111 |
|
111 | |||
112 | def makefilename(repo, pat, node, |
|
112 | def makefilename(repo, pat, node, desc=None, | |
113 | total=None, seqno=None, revwidth=None, pathname=None): |
|
113 | total=None, seqno=None, revwidth=None, pathname=None): | |
114 | node_expander = { |
|
114 | node_expander = { | |
115 | 'H': lambda: hex(node), |
|
115 | 'H': lambda: hex(node), | |
116 | 'R': lambda: str(repo.changelog.rev(node)), |
|
116 | 'R': lambda: str(repo.changelog.rev(node)), | |
117 | 'h': lambda: short(node), |
|
117 | 'h': lambda: short(node), | |
|
118 | 'm': lambda: re.sub('[^\w]', '_', str(desc)) | |||
118 | } |
|
119 | } | |
119 | expander = { |
|
120 | expander = { | |
120 | '%': lambda: '%', |
|
121 | '%': lambda: '%', | |
@@ -154,7 +155,7 b' def makefilename(repo, pat, node,' | |||||
154 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
|
155 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % | |
155 | inst.args[0]) |
|
156 | inst.args[0]) | |
156 |
|
157 | |||
157 | def makefileobj(repo, pat, node=None, total=None, |
|
158 | def makefileobj(repo, pat, node=None, desc=None, total=None, | |
158 | seqno=None, revwidth=None, mode='wb', pathname=None): |
|
159 | seqno=None, revwidth=None, mode='wb', pathname=None): | |
159 |
|
160 | |||
160 | writable = mode not in ('r', 'rb') |
|
161 | writable = mode not in ('r', 'rb') | |
@@ -181,7 +182,7 b' def makefileobj(repo, pat, node=None, to' | |||||
181 | return pat |
|
182 | return pat | |
182 | if util.safehasattr(pat, 'read') and 'r' in mode: |
|
183 | if util.safehasattr(pat, 'read') and 'r' in mode: | |
183 | return pat |
|
184 | return pat | |
184 | return open(makefilename(repo, pat, node, total, seqno, revwidth, |
|
185 | return open(makefilename(repo, pat, node, desc, total, seqno, revwidth, | |
185 | pathname), |
|
186 | pathname), | |
186 | mode) |
|
187 | mode) | |
187 |
|
188 | |||
@@ -516,8 +517,10 b" def export(repo, revs, template='hg-%h.p" | |||||
516 |
|
517 | |||
517 | shouldclose = False |
|
518 | shouldclose = False | |
518 | if not fp: |
|
519 | if not fp: | |
519 | fp = makefileobj(repo, template, node, total=total, seqno=seqno, |
|
520 | desc_lines = ctx.description().rstrip().split('\n') | |
520 | revwidth=revwidth, mode='ab') |
|
521 | desc = desc_lines[0] #Commit always has a first line. | |
|
522 | fp = makefileobj(repo, template, node, desc=desc, total=total, | |||
|
523 | seqno=seqno, revwidth=revwidth, mode='ab') | |||
521 | if fp != template: |
|
524 | if fp != template: | |
522 | shouldclose = True |
|
525 | shouldclose = True | |
523 | if fp != sys.stdout and util.safehasattr(fp, 'name'): |
|
526 | if fp != sys.stdout and util.safehasattr(fp, 'name'): |
@@ -2229,6 +2229,7 b' def export(ui, repo, *changesets, **opts' | |||||
2229 | :``%R``: changeset revision number |
|
2229 | :``%R``: changeset revision number | |
2230 | :``%b``: basename of the exporting repository |
|
2230 | :``%b``: basename of the exporting repository | |
2231 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
2231 | :``%h``: short-form changeset hash (12 hexadecimal digits) | |
|
2232 | :``%m``: first line of the commit message (only alphanumeric characters) | |||
2232 | :``%n``: zero-padded sequence number, starting at 1 |
|
2233 | :``%n``: zero-padded sequence number, starting at 1 | |
2233 | :``%r``: zero-padded changeset revision number |
|
2234 | :``%r``: zero-padded changeset revision number | |
2234 |
|
2235 |
@@ -7,7 +7,7 b'' | |||||
7 | > hg ci -m "foo-$i" |
|
7 | > hg ci -m "foo-$i" | |
8 | > done |
|
8 | > done | |
9 |
|
9 | |||
10 | $ for out in "%nof%N" "%%%H" "%b-%R" "%h" "%r"; do |
|
10 | $ for out in "%nof%N" "%%%H" "%b-%R" "%h" "%r" "%m"; do | |
11 | > echo |
|
11 | > echo | |
12 | > echo "# foo-$out.patch" |
|
12 | > echo "# foo-$out.patch" | |
13 | > hg export -v -o "foo-$out.patch" 2:tip |
|
13 | > hg export -v -o "foo-$out.patch" 2:tip | |
@@ -77,6 +77,19 b'' | |||||
77 | foo-09.patch |
|
77 | foo-09.patch | |
78 | foo-10.patch |
|
78 | foo-10.patch | |
79 | foo-11.patch |
|
79 | foo-11.patch | |
|
80 | ||||
|
81 | # foo-%m.patch | |||
|
82 | exporting patches: | |||
|
83 | foo-foo_2.patch | |||
|
84 | foo-foo_3.patch | |||
|
85 | foo-foo_4.patch | |||
|
86 | foo-foo_5.patch | |||
|
87 | foo-foo_6.patch | |||
|
88 | foo-foo_7.patch | |||
|
89 | foo-foo_8.patch | |||
|
90 | foo-foo_9.patch | |||
|
91 | foo-foo_10.patch | |||
|
92 | foo-foo_11.patch | |||
80 |
|
93 | |||
81 | Exporting 4 changesets to a file: |
|
94 | Exporting 4 changesets to a file: | |
82 |
|
95 | |||
@@ -108,3 +121,11 b' Exporting revision -2 to a file:' | |||||
108 | foo-9 |
|
121 | foo-9 | |
109 | +foo-10 |
|
122 | +foo-10 | |
110 |
|
123 | |||
|
124 | Checking if only alphanumeric characters are used in the file name (%m option): | |||
|
125 | ||||
|
126 | $ echo "line" >> foo | |||
|
127 | $ hg commit -m " !\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~" | |||
|
128 | $ hg export -v -o %m.patch tip | |||
|
129 | exporting patch: | |||
|
130 | ____________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch | |||
|
131 |
General Comments 0
You need to be logged in to leave comments.
Login now