Show More
@@ -0,0 +1,27 b'' | |||||
|
1 | # scmutil.py - Mercurial core utility functions | |||
|
2 | # | |||
|
3 | # Copyright Matt Mackall <mpm@selenic.com> | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms of the | |||
|
6 | # GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | from i18n import _ | |||
|
9 | import util, error | |||
|
10 | import os | |||
|
11 | ||||
|
12 | def checkportable(ui, f): | |||
|
13 | '''Check if filename f is portable and warn or abort depending on config''' | |||
|
14 | util.checkfilename(f) | |||
|
15 | val = ui.config('ui', 'portablefilenames', 'warn') | |||
|
16 | lval = val.lower() | |||
|
17 | abort = os.name == 'nt' or lval == 'abort' | |||
|
18 | bval = util.parsebool(val) | |||
|
19 | if abort or lval == 'warn' or bval: | |||
|
20 | msg = util.checkwinfilename(f) | |||
|
21 | if msg: | |||
|
22 | if abort: | |||
|
23 | raise util.Abort("%s: %r" % (msg, f)) | |||
|
24 | ui.warn(_("warning: %s: %r\n") % (msg, f)) | |||
|
25 | elif bval is None and lval != 'ignore': | |||
|
26 | raise error.ConfigError( | |||
|
27 | _("ui.portablefilenames value is invalid ('%s')") % val) |
@@ -910,6 +910,16 b' User interface controls.' | |||||
910 | The conflict resolution program to use during a manual merge. |
|
910 | The conflict resolution program to use during a manual merge. | |
911 | For more information on merge tools see :hg:`help merge-tools`. |
|
911 | For more information on merge tools see :hg:`help merge-tools`. | |
912 | For configuring merge tools see the merge-tools_ section. |
|
912 | For configuring merge tools see the merge-tools_ section. | |
|
913 | ``portablefilenames`` | |||
|
914 | Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``. | |||
|
915 | Default is ``warn``. | |||
|
916 | If set to ``warn`` (or ``true``), a warning message is printed on POSIX | |||
|
917 | platforms, if a file with a non-portable filename is added (e.g. a file | |||
|
918 | with a name that can't be created on Windows because it contains reserved | |||
|
919 | parts like ``AUX`` or reserved characters like ``:``). | |||
|
920 | If set to ``ignore`` (or ``false``), no warning is printed. | |||
|
921 | If set to ``abort``, the command is aborted. | |||
|
922 | On Windows, this configuration option is ignored and the command aborted. | |||
913 | ``quiet`` |
|
923 | ``quiet`` | |
914 | Reduce the amount of output printed. True or False. Default is False. |
|
924 | Reduce the amount of output printed. True or False. Default is False. | |
915 | ``remotecmd`` |
|
925 | ``remotecmd`` |
@@ -8,7 +8,7 b'' | |||||
8 | from node import hex, nullid, nullrev, short |
|
8 | from node import hex, nullid, nullrev, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import os, sys, errno, re, glob, tempfile |
|
10 | import os, sys, errno, re, glob, tempfile | |
11 | import util, templater, patch, error, encoding, templatekw |
|
11 | import util, scmutil, templater, patch, error, encoding, templatekw | |
12 | import match as matchmod |
|
12 | import match as matchmod | |
13 | import similar, revset, subrepo |
|
13 | import similar, revset, subrepo | |
14 |
|
14 | |||
@@ -435,7 +435,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
435 | src = repo.wjoin(abssrc) |
|
435 | src = repo.wjoin(abssrc) | |
436 | state = repo.dirstate[abstarget] |
|
436 | state = repo.dirstate[abstarget] | |
437 |
|
437 | |||
438 |
util.check |
|
438 | scmutil.checkportable(ui, abstarget) | |
439 |
|
439 | |||
440 | # check for collisions |
|
440 | # check for collisions | |
441 | prevsrc = targets.get(abstarget) |
|
441 | prevsrc = targets.get(abstarget) |
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from node import nullid, nullrev, short, hex |
|
8 | from node import nullid, nullrev, short, hex | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import ancestor, bdiff, error, util, subrepo, patch, encoding |
|
10 | import ancestor, bdiff, error, util, scmutil, subrepo, patch, encoding | |
11 | import os, errno, stat |
|
11 | import os, errno, stat | |
12 |
|
12 | |||
13 | propertycache = util.propertycache |
|
13 | propertycache = util.propertycache | |
@@ -801,6 +801,7 b' class workingctx(changectx):' | |||||
801 | try: |
|
801 | try: | |
802 | rejected = [] |
|
802 | rejected = [] | |
803 | for f in list: |
|
803 | for f in list: | |
|
804 | scmutil.checkportable(ui, join(f)) | |||
804 | p = self._repo.wjoin(f) |
|
805 | p = self._repo.wjoin(f) | |
805 | try: |
|
806 | try: | |
806 | st = os.lstat(p) |
|
807 | st = os.lstat(p) |
@@ -33,6 +33,41 b' should fail' | |||||
33 | A a |
|
33 | A a | |
34 | A b |
|
34 | A b | |
35 |
|
35 | |||
|
36 | $ echo foo > con.xml | |||
|
37 | $ hg --config ui.portablefilenames=jump add con.xml | |||
|
38 | abort: ui.portablefilenames value is invalid ('jump') | |||
|
39 | [255] | |||
|
40 | $ hg --config ui.portablefilenames=abort add con.xml | |||
|
41 | abort: filename contains 'con', which is reserved on Windows: 'con.xml' | |||
|
42 | [255] | |||
|
43 | $ hg st | |||
|
44 | A a | |||
|
45 | A b | |||
|
46 | ? con.xml | |||
|
47 | $ hg add con.xml | |||
|
48 | warning: filename contains 'con', which is reserved on Windows: 'con.xml' | |||
|
49 | $ hg st | |||
|
50 | A a | |||
|
51 | A b | |||
|
52 | A con.xml | |||
|
53 | $ echo bla > 'hello:world' | |||
|
54 | $ hg --config ui.portablefilenames=abort add | |||
|
55 | adding hello:world | |||
|
56 | abort: filename contains ':', which is reserved on Windows: 'hello:world' | |||
|
57 | [255] | |||
|
58 | $ hg st | |||
|
59 | A a | |||
|
60 | A b | |||
|
61 | A con.xml | |||
|
62 | ? hello:world | |||
|
63 | $ hg --config ui.portablefilenames=ignore add | |||
|
64 | adding hello:world | |||
|
65 | $ hg st | |||
|
66 | A a | |||
|
67 | A b | |||
|
68 | A con.xml | |||
|
69 | A hello:world | |||
|
70 | ||||
36 | $ hg ci -m 0 --traceback |
|
71 | $ hg ci -m 0 --traceback | |
37 |
|
72 | |||
38 | should fail |
|
73 | should fail |
@@ -10,14 +10,17 b'' | |||||
10 | foo |
|
10 | foo | |
11 | committed changeset 0:6f7f953567a2 |
|
11 | committed changeset 0:6f7f953567a2 | |
12 | $ cd dir/ |
|
12 | $ cd dir/ | |
13 | $ touch ../foo_2 bar_2 |
|
13 | $ touch ../foo_2 bar_2 con.xml | |
14 | $ hg -v addremove |
|
14 | $ hg -v addremove | |
15 | adding dir/bar_2 |
|
15 | adding dir/bar_2 | |
|
16 | adding dir/con.xml | |||
16 | adding foo_2 |
|
17 | adding foo_2 | |
|
18 | warning: filename contains 'con', which is reserved on Windows: 'dir/con.xml' | |||
17 | $ hg -v commit -m "add 2" |
|
19 | $ hg -v commit -m "add 2" | |
18 | dir/bar_2 |
|
20 | dir/bar_2 | |
|
21 | dir/con.xml | |||
19 | foo_2 |
|
22 | foo_2 | |
20 |
committed changeset 1: |
|
23 | committed changeset 1:6bb597da00f1 | |
21 |
|
24 | |||
22 | $ cd .. |
|
25 | $ cd .. | |
23 | $ hg init sim |
|
26 | $ hg init sim |
@@ -4,6 +4,9 b'' | |||||
4 | $ hg commit -m "1" |
|
4 | $ hg commit -m "1" | |
5 | $ hg status |
|
5 | $ hg status | |
6 | $ hg copy a b |
|
6 | $ hg copy a b | |
|
7 | $ hg --config ui.portablefilenames=abort copy a con.xml | |||
|
8 | abort: filename contains 'con', which is reserved on Windows: 'con.xml' | |||
|
9 | [255] | |||
7 | $ hg status |
|
10 | $ hg status | |
8 | A b |
|
11 | A b | |
9 | $ hg sum |
|
12 | $ hg sum |
@@ -10,6 +10,7 b' Test raw style of hgweb' | |||||
10 | > care about things like that. |
|
10 | > care about things like that. | |
11 | > ENDSOME |
|
11 | > ENDSOME | |
12 | $ hg add 'sub/some "text".txt' |
|
12 | $ hg add 'sub/some "text".txt' | |
|
13 | warning: filename contains '"', which is reserved on Windows: 'sub/some "text".txt' | |||
13 | $ hg commit -d "1 0" -m "Just some text" |
|
14 | $ hg commit -d "1 0" -m "Just some text" | |
14 |
|
15 | |||
15 | $ hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid |
|
16 | $ hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid |
@@ -11,6 +11,9 b'' | |||||
11 | rename a single file |
|
11 | rename a single file | |
12 |
|
12 | |||
13 | $ hg rename d1/d11/a1 d2/c |
|
13 | $ hg rename d1/d11/a1 d2/c | |
|
14 | $ hg --config ui.portablefilenames=abort rename d1/a d1/con.xml | |||
|
15 | abort: filename contains 'con', which is reserved on Windows: 'd1/con.xml' | |||
|
16 | [255] | |||
14 | $ hg sum |
|
17 | $ hg sum | |
15 | parent: 0:9b4b6e7b2c26 tip |
|
18 | parent: 0:9b4b6e7b2c26 tip | |
16 | 1 |
|
19 | 1 |
@@ -28,6 +28,7 b'' | |||||
28 | adding mammals/Procyonidae/coatimundi |
|
28 | adding mammals/Procyonidae/coatimundi | |
29 | adding mammals/Procyonidae/raccoon |
|
29 | adding mammals/Procyonidae/raccoon | |
30 | adding mammals/skunk |
|
30 | adding mammals/skunk | |
|
31 | warning: filename contains ':', which is reserved on Windows: 'glob:glob' | |||
31 | $ hg commit -m "commit #0" |
|
32 | $ hg commit -m "commit #0" | |
32 |
|
33 | |||
33 | $ hg debugwalk |
|
34 | $ hg debugwalk |
General Comments 0
You need to be logged in to leave comments.
Login now