Mercurial > hg
annotate hgext/largefiles/uisetup.py @ 17844:b32e55e6c3c7 stable
clone: don't %-escape the default destination (issue3145)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 19 Oct 2012 14:47:55 -0500 |
parents | a02c1ffddae9 |
children | d1d0140287b8 |
rev | line source |
---|---|
15168 | 1 # Copyright 2009-2010 Gregory P. Ward |
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated | |
3 # Copyright 2010-2011 Fog Creek Software | |
4 # Copyright 2010-2011 Unity Technologies | |
5 # | |
6 # This software may be used and distributed according to the terms of the | |
7 # GNU General Public License version 2 or any later version. | |
8 | |
9 '''setup for largefiles extension: uisetup''' | |
10 | |
11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ | |
17658
a02c1ffddae9
largefiles: handle commit -A properly, after a --large commit (issue3542)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17601
diff
changeset
|
12 httppeer, localrepo, merge, scmutil, sshpeer, sshserver, wireproto |
15168 | 13 from mercurial.i18n import _ |
16449
874a680a3e23
largefiles: hide .hglf/ prefix for largefiles in hgweb
Martin Geisler <mg@lazybytes.net>
parents:
16439
diff
changeset
|
14 from mercurial.hgweb import hgweb_mod, protocol, webcommands |
16515
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
15 from mercurial.subrepo import hgsubrepo |
15168 | 16 |
17 import overrides | |
18 import proto | |
19 | |
20 def uisetup(ui): | |
21 # Disable auto-status for some commands which assume that all | |
22 # files in the result are under Mercurial's control | |
23 | |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
24 entry = extensions.wrapcommand(commands.table, 'add', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
25 overrides.overrideadd) |
15168 | 26 addopt = [('', 'large', None, _('add as largefile')), |
15944
f19d5c852f9b
largefiles: add --normal option to hg add (issue3061)
Na'Tosha Bard <natosha@unity3d.com>
parents:
15674
diff
changeset
|
27 ('', 'normal', None, _('add as normal file')), |
15627
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
28 ('', 'lfsize', '', _('add all files above this size ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
29 '(in megabytes) as largefiles ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
30 '(default: 10)'))] |
15168 | 31 entry[1].extend(addopt) |
32 | |
17658
a02c1ffddae9
largefiles: handle commit -A properly, after a --large commit (issue3542)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17601
diff
changeset
|
33 # The scmutil function is called both by the (trivial) addremove command, |
a02c1ffddae9
largefiles: handle commit -A properly, after a --large commit (issue3542)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17601
diff
changeset
|
34 # and in the process of handling commit -A (issue3542) |
a02c1ffddae9
largefiles: handle commit -A properly, after a --large commit (issue3542)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17601
diff
changeset
|
35 entry = extensions.wrapfunction(scmutil, 'addremove', |
a02c1ffddae9
largefiles: handle commit -A properly, after a --large commit (issue3542)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17601
diff
changeset
|
36 overrides.scmutiladdremove) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
37 entry = extensions.wrapcommand(commands.table, 'remove', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
38 overrides.overrideremove) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
39 entry = extensions.wrapcommand(commands.table, 'forget', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
40 overrides.overrideforget) |
16515
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
41 |
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
42 # Subrepos call status function |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
43 entry = extensions.wrapcommand(commands.table, 'status', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
44 overrides.overridestatus) |
16515
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
45 entry = extensions.wrapfunction(hgsubrepo, 'status', |
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
46 overrides.overridestatusfn) |
12dabc22de77
largefiles: fix status -S reporting of subrepos (issue3231)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16449
diff
changeset
|
47 |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
48 entry = extensions.wrapcommand(commands.table, 'log', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
49 overrides.overridelog) |
15168 | 50 entry = extensions.wrapcommand(commands.table, 'rollback', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
51 overrides.overriderollback) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
52 entry = extensions.wrapcommand(commands.table, 'verify', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
53 overrides.overrideverify) |
15168 | 54 |
55 verifyopt = [('', 'large', None, _('verify largefiles')), | |
56 ('', 'lfa', None, | |
57 _('verify all revisions of largefiles not just current')), | |
58 ('', 'lfc', None, | |
59 _('verify largefile contents not just existence'))] | |
60 entry[1].extend(verifyopt) | |
61 | |
62 entry = extensions.wrapcommand(commands.table, 'outgoing', | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
63 overrides.overrideoutgoing) |
15168 | 64 outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
65 entry[1].extend(outgoingopt) | |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
66 entry = extensions.wrapcommand(commands.table, 'summary', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
67 overrides.overridesummary) |
15168 | 68 summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
69 entry[1].extend(summaryopt) | |
70 | |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
71 entry = extensions.wrapcommand(commands.table, 'update', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
72 overrides.overrideupdate) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
73 entry = extensions.wrapcommand(commands.table, 'pull', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
74 overrides.overridepull) |
16692
b9969574540a
largefiles: add --all-largefiles flag to pull
Na'Tosha Bard <natosha@unity3d.com>
parents:
16644
diff
changeset
|
75 pullopt = [('', 'all-largefiles', None, |
b9969574540a
largefiles: add --all-largefiles flag to pull
Na'Tosha Bard <natosha@unity3d.com>
parents:
16644
diff
changeset
|
76 _('download all pulled versions of largefiles'))] |
b9969574540a
largefiles: add --all-largefiles flag to pull
Na'Tosha Bard <natosha@unity3d.com>
parents:
16644
diff
changeset
|
77 entry[1].extend(pullopt) |
16644
98a9266db803
largefiles: add --all-largefiles flag to clone (issue3188)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16578
diff
changeset
|
78 entry = extensions.wrapcommand(commands.table, 'clone', |
98a9266db803
largefiles: add --all-largefiles flag to clone (issue3188)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16578
diff
changeset
|
79 overrides.overrideclone) |
98a9266db803
largefiles: add --all-largefiles flag to clone (issue3188)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16578
diff
changeset
|
80 cloneopt = [('', 'all-largefiles', None, |
98a9266db803
largefiles: add --all-largefiles flag to clone (issue3188)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16578
diff
changeset
|
81 _('download all versions of all largefiles'))] |
17601
6e2ab601be3f
largefiles: delegate to the wrapped clone command
Matt Harbison <matt_harbison@yahoo.com>
parents:
17192
diff
changeset
|
82 entry[1].extend(cloneopt) |
6e2ab601be3f
largefiles: delegate to the wrapped clone command
Matt Harbison <matt_harbison@yahoo.com>
parents:
17192
diff
changeset
|
83 entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone) |
16644
98a9266db803
largefiles: add --all-largefiles flag to clone (issue3188)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16578
diff
changeset
|
84 |
16439
290850e7aa43
largefiles: fix cat for largefiles (issue3352)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16247
diff
changeset
|
85 entry = extensions.wrapcommand(commands.table, 'cat', |
290850e7aa43
largefiles: fix cat for largefiles (issue3352)
Na'Tosha Bard <natosha@unity3d.com>
parents:
16247
diff
changeset
|
86 overrides.overridecat) |
16093
7e30f5f2285f
merge: refactor unknown file conflict checking
Matt Mackall <mpm@selenic.com>
parents:
15944
diff
changeset
|
87 entry = extensions.wrapfunction(merge, '_checkunknownfile', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
88 overrides.overridecheckunknownfile) |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
89 entry = extensions.wrapfunction(merge, 'manifestmerge', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
90 overrides.overridemanifestmerge) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
91 entry = extensions.wrapfunction(filemerge, 'filemerge', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
92 overrides.overridefilemerge) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
93 entry = extensions.wrapfunction(cmdutil, 'copy', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
94 overrides.overridecopy) |
15168 | 95 |
16516
597ddcb41b32
largefiles: notice dirty large files in a subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
16515
diff
changeset
|
96 # Summary calls dirty on the subrepos |
597ddcb41b32
largefiles: notice dirty large files in a subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
16515
diff
changeset
|
97 entry = extensions.wrapfunction(hgsubrepo, 'dirty', |
597ddcb41b32
largefiles: notice dirty large files in a subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
16515
diff
changeset
|
98 overrides.overridedirty) |
597ddcb41b32
largefiles: notice dirty large files in a subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
16515
diff
changeset
|
99 |
15168 | 100 # Backout calls revert so we need to override both the command and the |
101 # function | |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
102 entry = extensions.wrapcommand(commands.table, 'revert', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
103 overrides.overriderevert) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
104 entry = extensions.wrapfunction(commands, 'revert', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
105 overrides.overriderevert) |
15168 | 106 |
107 # clone uses hg._update instead of hg.update even though they are the | |
108 # same function... so wrap both of them) | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
109 extensions.wrapfunction(hg, 'update', overrides.hgupdate) |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
110 extensions.wrapfunction(hg, '_update', overrides.hgupdate) |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
111 extensions.wrapfunction(hg, 'clean', overrides.hgclean) |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
112 extensions.wrapfunction(hg, 'merge', overrides.hgmerge) |
15168 | 113 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
114 extensions.wrapfunction(archival, 'archive', overrides.overridearchive) |
16578
43fb170a23bd
largefiles: make archive -S store largefiles instead of standins
Matt Harbison <matt_harbison@yahoo.com>
parents:
16516
diff
changeset
|
115 extensions.wrapfunction(hgsubrepo, 'archive', overrides.hgsubrepoarchive) |
15349
63455eb771af
largefiles: drop more unnecessary compatibility checks
Greg Ward <greg@gerg.ca>
parents:
15295
diff
changeset
|
116 extensions.wrapfunction(cmdutil, 'bailifchanged', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
117 overrides.overridebailifchanged) |
15168 | 118 |
119 # create the new wireproto commands ... | |
120 wireproto.commands['putlfile'] = (proto.putlfile, 'sha') | |
121 wireproto.commands['getlfile'] = (proto.getlfile, 'sha') | |
122 wireproto.commands['statlfile'] = (proto.statlfile, 'sha') | |
123 | |
124 # ... and wrap some existing ones | |
125 wireproto.commands['capabilities'] = (proto.capabilities, '') | |
126 wireproto.commands['heads'] = (proto.heads, '') | |
127 wireproto.commands['lheads'] = (wireproto.heads, '') | |
128 | |
15254
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15252
diff
changeset
|
129 # make putlfile behave the same as push and {get,stat}lfile behave |
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15252
diff
changeset
|
130 # the same as pull w.r.t. permissions checks |
15168 | 131 hgweb_mod.perms['putlfile'] = 'push' |
132 hgweb_mod.perms['getlfile'] = 'pull' | |
133 hgweb_mod.perms['statlfile'] = 'pull' | |
134 | |
16449
874a680a3e23
largefiles: hide .hglf/ prefix for largefiles in hgweb
Martin Geisler <mg@lazybytes.net>
parents:
16439
diff
changeset
|
135 extensions.wrapfunction(webcommands, 'decodepath', overrides.decodepath) |
874a680a3e23
largefiles: hide .hglf/ prefix for largefiles in hgweb
Martin Geisler <mg@lazybytes.net>
parents:
16439
diff
changeset
|
136 |
15168 | 137 # the hello wireproto command uses wireproto.capabilities, so it won't see |
138 # our largefiles capability unless we replace the actual function as well. | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
139 proto.capabilitiesorig = wireproto.capabilities |
15168 | 140 wireproto.capabilities = proto.capabilities |
141 | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15188
diff
changeset
|
142 # these let us reject non-largefiles clients and make them display |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15188
diff
changeset
|
143 # our error messages |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
144 protocol.webproto.refuseclient = proto.webprotorefuseclient |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
145 sshserver.sshserver.refuseclient = proto.sshprotorefuseclient |
15168 | 146 |
147 # can't do this in reposetup because it needs to have happened before | |
148 # wirerepo.__init__ is called | |
17192
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
16692
diff
changeset
|
149 proto.ssholdcallstream = sshpeer.sshpeer._callstream |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
16692
diff
changeset
|
150 proto.httpoldcallstream = httppeer.httppeer._callstream |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
16692
diff
changeset
|
151 sshpeer.sshpeer._callstream = proto.sshrepocallstream |
1ac628cd7113
peer: introduce real peer classes
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
16692
diff
changeset
|
152 httppeer.httppeer._callstream = proto.httprepocallstream |
15168 | 153 |
154 # don't die on seeing a repo with the largefiles requirement | |
155 localrepo.localrepository.supported |= set(['largefiles']) | |
156 | |
157 # override some extensions' stuff as well | |
158 for name, module in extensions.extensions(): | |
159 if name == 'fetch': | |
160 extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
161 overrides.overridefetch) |
15168 | 162 if name == 'purge': |
163 extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
164 overrides.overridepurge) |
15168 | 165 if name == 'rebase': |
166 extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
167 overrides.overriderebase) |
15383
155d0f8fb7e5
largefiles: fix bad bug where transplanting a changeset with a largefile will result in an old largefile being comitted later on
Na'Tosha Bard <natosha@unity3d.com>
parents:
15356
diff
changeset
|
168 if name == 'transplant': |
155d0f8fb7e5
largefiles: fix bad bug where transplanting a changeset with a largefile will result in an old largefile being comitted later on
Na'Tosha Bard <natosha@unity3d.com>
parents:
15356
diff
changeset
|
169 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
170 overrides.overridetransplant) |