author | Matt Mackall <mpm@selenic.com> |
Fri, 16 Dec 2011 19:05:59 -0600 | |
changeset 15674 | 7b7f03502b5a |
parent 15627 | 9d7a83a42f8c |
parent 15663 | 9036c7d106bf |
child 15944 | f19d5c852f9b |
permissions | -rw-r--r-- |
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, \ |
|
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
12 |
httprepo, localrepo, merge, sshrepo, sshserver, wireproto |
15168 | 13 |
from mercurial.i18n import _ |
14 |
from mercurial.hgweb import hgweb_mod, protocol |
|
15 |
||
16 |
import overrides |
|
17 |
import proto |
|
18 |
||
19 |
def uisetup(ui): |
|
20 |
# Disable auto-status for some commands which assume that all |
|
21 |
# files in the result are under Mercurial's control |
|
22 |
||
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
23 |
entry = extensions.wrapcommand(commands.table, 'add', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
24 |
overrides.override_add) |
15168 | 25 |
addopt = [('', 'large', None, _('add as largefile')), |
15627
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
26 |
('', 'lfsize', '', _('add all files above this size ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
27 |
'(in megabytes) as largefiles ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
28 |
'(default: 10)'))] |
15168 | 29 |
entry[1].extend(addopt) |
30 |
||
31 |
entry = extensions.wrapcommand(commands.table, 'addremove', |
|
32 |
overrides.override_addremove) |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
33 |
entry = extensions.wrapcommand(commands.table, 'remove', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
34 |
overrides.override_remove) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
35 |
entry = extensions.wrapcommand(commands.table, 'forget', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
36 |
overrides.override_forget) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
37 |
entry = extensions.wrapcommand(commands.table, 'status', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
38 |
overrides.override_status) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
39 |
entry = extensions.wrapcommand(commands.table, 'log', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
40 |
overrides.override_log) |
15168 | 41 |
entry = extensions.wrapcommand(commands.table, 'rollback', |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
42 |
overrides.override_rollback) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
43 |
entry = extensions.wrapcommand(commands.table, 'verify', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
44 |
overrides.override_verify) |
15168 | 45 |
|
46 |
verifyopt = [('', 'large', None, _('verify largefiles')), |
|
47 |
('', 'lfa', None, |
|
48 |
_('verify all revisions of largefiles not just current')), |
|
49 |
('', 'lfc', None, |
|
50 |
_('verify largefile contents not just existence'))] |
|
51 |
entry[1].extend(verifyopt) |
|
52 |
||
53 |
entry = extensions.wrapcommand(commands.table, 'outgoing', |
|
54 |
overrides.override_outgoing) |
|
55 |
outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
|
56 |
entry[1].extend(outgoingopt) |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
57 |
entry = extensions.wrapcommand(commands.table, 'summary', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
58 |
overrides.override_summary) |
15168 | 59 |
summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
60 |
entry[1].extend(summaryopt) |
|
61 |
||
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
62 |
entry = extensions.wrapcommand(commands.table, 'update', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
63 |
overrides.override_update) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
64 |
entry = extensions.wrapcommand(commands.table, 'pull', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
65 |
overrides.override_pull) |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
66 |
entry = extensions.wrapfunction(merge, '_checkunknown', |
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
67 |
overrides.override_checkunknown) |
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
68 |
entry = extensions.wrapfunction(merge, 'manifestmerge', |
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
69 |
overrides.override_manifestmerge) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
70 |
entry = extensions.wrapfunction(filemerge, 'filemerge', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
71 |
overrides.override_filemerge) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
72 |
entry = extensions.wrapfunction(cmdutil, 'copy', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
73 |
overrides.override_copy) |
15168 | 74 |
|
75 |
# Backout calls revert so we need to override both the command and the |
|
76 |
# function |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
77 |
entry = extensions.wrapcommand(commands.table, 'revert', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
78 |
overrides.override_revert) |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
79 |
entry = extensions.wrapfunction(commands, 'revert', |
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
80 |
overrides.override_revert) |
15168 | 81 |
|
82 |
# clone uses hg._update instead of hg.update even though they are the |
|
83 |
# same function... so wrap both of them) |
|
84 |
extensions.wrapfunction(hg, 'update', overrides.hg_update) |
|
85 |
extensions.wrapfunction(hg, '_update', overrides.hg_update) |
|
86 |
extensions.wrapfunction(hg, 'clean', overrides.hg_clean) |
|
87 |
extensions.wrapfunction(hg, 'merge', overrides.hg_merge) |
|
88 |
||
89 |
extensions.wrapfunction(archival, 'archive', overrides.override_archive) |
|
15349
63455eb771af
largefiles: drop more unnecessary compatibility checks
Greg Ward <greg@gerg.ca>
parents:
15295
diff
changeset
|
90 |
extensions.wrapfunction(cmdutil, 'bailifchanged', |
63455eb771af
largefiles: drop more unnecessary compatibility checks
Greg Ward <greg@gerg.ca>
parents:
15295
diff
changeset
|
91 |
overrides.override_bailifchanged) |
15168 | 92 |
|
93 |
# create the new wireproto commands ... |
|
94 |
wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
95 |
wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
|
96 |
wireproto.commands['statlfile'] = (proto.statlfile, 'sha') |
|
97 |
||
98 |
# ... and wrap some existing ones |
|
99 |
wireproto.commands['capabilities'] = (proto.capabilities, '') |
|
100 |
wireproto.commands['heads'] = (proto.heads, '') |
|
101 |
wireproto.commands['lheads'] = (wireproto.heads, '') |
|
102 |
||
15254
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15252
diff
changeset
|
103 |
# 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
|
104 |
# the same as pull w.r.t. permissions checks |
15168 | 105 |
hgweb_mod.perms['putlfile'] = 'push' |
106 |
hgweb_mod.perms['getlfile'] = 'pull' |
|
107 |
hgweb_mod.perms['statlfile'] = 'pull' |
|
108 |
||
109 |
# the hello wireproto command uses wireproto.capabilities, so it won't see |
|
110 |
# our largefiles capability unless we replace the actual function as well. |
|
111 |
proto.capabilities_orig = wireproto.capabilities |
|
112 |
wireproto.capabilities = proto.capabilities |
|
113 |
||
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15188
diff
changeset
|
114 |
# 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
|
115 |
# our error messages |
15168 | 116 |
protocol.webproto.refuseclient = proto.webproto_refuseclient |
117 |
sshserver.sshserver.refuseclient = proto.sshproto_refuseclient |
|
118 |
||
119 |
# can't do this in reposetup because it needs to have happened before |
|
120 |
# wirerepo.__init__ is called |
|
121 |
proto.ssh_oldcallstream = sshrepo.sshrepository._callstream |
|
122 |
proto.http_oldcallstream = httprepo.httprepository._callstream |
|
123 |
sshrepo.sshrepository._callstream = proto.sshrepo_callstream |
|
124 |
httprepo.httprepository._callstream = proto.httprepo_callstream |
|
125 |
||
126 |
# don't die on seeing a repo with the largefiles requirement |
|
127 |
localrepo.localrepository.supported |= set(['largefiles']) |
|
128 |
||
129 |
# override some extensions' stuff as well |
|
130 |
for name, module in extensions.extensions(): |
|
131 |
if name == 'fetch': |
|
132 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', |
|
133 |
overrides.override_fetch) |
|
134 |
if name == 'purge': |
|
135 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', |
|
136 |
overrides.override_purge) |
|
137 |
if name == 'rebase': |
|
138 |
extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', |
|
139 |
overrides.override_rebase) |
|
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
|
140 |
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
|
141 |
extensions.wrapcommand(getattr(module, 'cmdtable'), '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
|
142 |
overrides.override_transplant) |