author | Bryan O'Sullivan <bryano@fb.com> |
Thu, 12 Apr 2012 15:21:54 -0700 | |
changeset 16404 | 9fca5b056c0a |
parent 16247 | d87d9d8a8e03 |
child 16439 | 290850e7aa43 |
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', |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
24 |
overrides.overrideadd) |
15168 | 25 |
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
|
26 |
('', 'normal', None, _('add as normal file')), |
15627
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
27 |
('', 'lfsize', '', _('add all files above this size ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
28 |
'(in megabytes) as largefiles ' |
9d7a83a42f8c
largefiles: fix indentation
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
29 |
'(default: 10)'))] |
15168 | 30 |
entry[1].extend(addopt) |
31 |
||
32 |
entry = extensions.wrapcommand(commands.table, 'addremove', |
|
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
33 |
overrides.overrideaddremove) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
34 |
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
|
35 |
overrides.overrideremove) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
36 |
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
|
37 |
overrides.overrideforget) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
38 |
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
|
39 |
overrides.overridestatus) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
40 |
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
|
41 |
overrides.overridelog) |
15168 | 42 |
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
|
43 |
overrides.overriderollback) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
44 |
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
|
45 |
overrides.overrideverify) |
15168 | 46 |
|
47 |
verifyopt = [('', 'large', None, _('verify largefiles')), |
|
48 |
('', 'lfa', None, |
|
49 |
_('verify all revisions of largefiles not just current')), |
|
50 |
('', 'lfc', None, |
|
51 |
_('verify largefile contents not just existence'))] |
|
52 |
entry[1].extend(verifyopt) |
|
53 |
||
54 |
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
|
55 |
overrides.overrideoutgoing) |
15168 | 56 |
outgoingopt = [('', 'large', None, _('display outgoing largefiles'))] |
57 |
entry[1].extend(outgoingopt) |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
58 |
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
|
59 |
overrides.overridesummary) |
15168 | 60 |
summaryopt = [('', 'large', None, _('display outgoing largefiles'))] |
61 |
entry[1].extend(summaryopt) |
|
62 |
||
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
63 |
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
|
64 |
overrides.overrideupdate) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
65 |
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
|
66 |
overrides.overridepull) |
16093
7e30f5f2285f
merge: refactor unknown file conflict checking
Matt Mackall <mpm@selenic.com>
parents:
15944
diff
changeset
|
67 |
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
|
68 |
overrides.overridecheckunknownfile) |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15383
diff
changeset
|
69 |
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
|
70 |
overrides.overridemanifestmerge) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
71 |
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
|
72 |
overrides.overridefilemerge) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
73 |
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
|
74 |
overrides.overridecopy) |
15168 | 75 |
|
76 |
# Backout calls revert so we need to override both the command and the |
|
77 |
# function |
|
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
78 |
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
|
79 |
overrides.overriderevert) |
15170
c1a4a3220711
largefiles: fix over-long lines
Matt Mackall <mpm@selenic.com>
parents:
15169
diff
changeset
|
80 |
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
|
81 |
overrides.overriderevert) |
15168 | 82 |
|
83 |
# clone uses hg._update instead of hg.update even though they are the |
|
84 |
# 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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
extensions.wrapfunction(hg, 'merge', overrides.hgmerge) |
15168 | 89 |
|
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
90 |
extensions.wrapfunction(archival, 'archive', overrides.overridearchive) |
15349
63455eb771af
largefiles: drop more unnecessary compatibility checks
Greg Ward <greg@gerg.ca>
parents:
15295
diff
changeset
|
91 |
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
|
92 |
overrides.overridebailifchanged) |
15168 | 93 |
|
94 |
# create the new wireproto commands ... |
|
95 |
wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
96 |
wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
|
97 |
wireproto.commands['statlfile'] = (proto.statlfile, 'sha') |
|
98 |
||
99 |
# ... and wrap some existing ones |
|
100 |
wireproto.commands['capabilities'] = (proto.capabilities, '') |
|
101 |
wireproto.commands['heads'] = (proto.heads, '') |
|
102 |
wireproto.commands['lheads'] = (wireproto.heads, '') |
|
103 |
||
15254
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15252
diff
changeset
|
104 |
# 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
|
105 |
# the same as pull w.r.t. permissions checks |
15168 | 106 |
hgweb_mod.perms['putlfile'] = 'push' |
107 |
hgweb_mod.perms['getlfile'] = 'pull' |
|
108 |
hgweb_mod.perms['statlfile'] = 'pull' |
|
109 |
||
110 |
# the hello wireproto command uses wireproto.capabilities, so it won't see |
|
111 |
# 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
|
112 |
proto.capabilitiesorig = wireproto.capabilities |
15168 | 113 |
wireproto.capabilities = proto.capabilities |
114 |
||
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15188
diff
changeset
|
115 |
# 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
|
116 |
# our error messages |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
117 |
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
|
118 |
sshserver.sshserver.refuseclient = proto.sshprotorefuseclient |
15168 | 119 |
|
120 |
# can't do this in reposetup because it needs to have happened before |
|
121 |
# wirerepo.__init__ is called |
|
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
122 |
proto.ssholdcallstream = sshrepo.sshrepository._callstream |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
123 |
proto.httpoldcallstream = httprepo.httprepository._callstream |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
124 |
sshrepo.sshrepository._callstream = proto.sshrepocallstream |
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16093
diff
changeset
|
125 |
httprepo.httprepository._callstream = proto.httprepocallstream |
15168 | 126 |
|
127 |
# don't die on seeing a repo with the largefiles requirement |
|
128 |
localrepo.localrepository.supported |= set(['largefiles']) |
|
129 |
||
130 |
# override some extensions' stuff as well |
|
131 |
for name, module in extensions.extensions(): |
|
132 |
if name == 'fetch': |
|
133 |
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
|
134 |
overrides.overridefetch) |
15168 | 135 |
if name == 'purge': |
136 |
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
|
137 |
overrides.overridepurge) |
15168 | 138 |
if name == 'rebase': |
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
overrides.overridetransplant) |