Mercurial > hg
annotate hgext/largefiles/reposetup.py @ 24276:2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
We're soon going to add an alternative manifest class
(treemanifest). Rather than extending both those classes by
largesfiles versions, let's replace the method on the manifest
instances.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 09 Mar 2015 17:13:22 -0700 |
parents | d8e0c591781c |
children | f78252429e0a |
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 repositories: reposetup''' | |
10 import copy | |
11 import os | |
12 | |
24276
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
13 from mercurial import error, match as match_, util |
15168 | 14 from mercurial.i18n import _ |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
15 from mercurial import scmutil, localrepo |
15168 | 16 |
17 import lfcommands | |
18 import lfutil | |
19 | |
20 def reposetup(ui, repo): | |
20858
bc56ec9e64df
hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20177
diff
changeset
|
21 # wire repositories should be given new wireproto functions |
bc56ec9e64df
hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20177
diff
changeset
|
22 # by "proto.wirereposetup()" via "hg.wirepeersetupfuncs" |
15168 | 23 if not repo.local(): |
20858
bc56ec9e64df
hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20177
diff
changeset
|
24 return |
15168 | 25 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
26 class lfilesrepo(repo.__class__): |
24158
d414c28db84d
largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23958
diff
changeset
|
27 # the mark to examine whether "repo" object enables largefiles or not |
d414c28db84d
largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23958
diff
changeset
|
28 _largefilesenabled = True |
d414c28db84d
largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23958
diff
changeset
|
29 |
15168 | 30 lfstatus = False |
31 def status_nolfiles(self, *args, **kwargs): | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
32 return super(lfilesrepo, self).status(*args, **kwargs) |
15168 | 33 |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
34 # When lfstatus is set, return a context that gives the names |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
35 # of largefiles instead of their corresponding standins and |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
36 # identifies the largefiles as always binary, regardless of |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
37 # their actual contents. |
15168 | 38 def __getitem__(self, changeid): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
39 ctx = super(lfilesrepo, self).__getitem__(changeid) |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
40 if self.lfstatus: |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
41 class lfilesctx(ctx.__class__): |
15168 | 42 def files(self): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
43 filenames = super(lfilesctx, self).files() |
15628
2b40513384ca
largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents:
15626
diff
changeset
|
44 return [lfutil.splitstandin(f) or f for f in filenames] |
15168 | 45 def manifest(self): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
46 man1 = super(lfilesctx, self).manifest() |
24276
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
47 orig = man1.__contains__ |
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
48 def __contains__(self, filename): |
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
49 return (orig(filename) or |
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
50 orig(lfutil.standin(filename))) |
2720f967a7b1
largefiles: replace manifestdict.__contains__, don't extend class
Martin von Zweigbergk <martinvonz@google.com>
parents:
24180
diff
changeset
|
51 man1.__contains__ = __contains__.__get__(man1) |
15168 | 52 return man1 |
53 def filectx(self, path, fileid=None, filelog=None): | |
22517
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
54 orig = super(lfilesctx, self).filectx |
15168 | 55 try: |
16141
f346de4dff57
largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
16110
diff
changeset
|
56 if filelog is not None: |
22517
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
57 result = orig(path, fileid, filelog) |
16141
f346de4dff57
largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
16110
diff
changeset
|
58 else: |
22517
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
59 result = orig(path, fileid) |
15168 | 60 except error.LookupError: |
61 # Adding a null character will cause Mercurial to | |
62 # identify this as a binary file. | |
16141
f346de4dff57
largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
16110
diff
changeset
|
63 if filelog is not None: |
22517
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
64 result = orig(lfutil.standin(path), fileid, |
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
65 filelog) |
16141
f346de4dff57
largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
16110
diff
changeset
|
66 else: |
22517
e54a001ace06
largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22516
diff
changeset
|
67 result = orig(lfutil.standin(path), fileid) |
15168 | 68 olddata = result.data |
69 result.data = lambda: olddata() + '\0' | |
70 return result | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
71 ctx.__class__ = lfilesctx |
15168 | 72 return ctx |
73 | |
74 # Figure out the status of big files and insert them into the | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
75 # appropriate list in the result. Also removes standin files |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
76 # from the listing. Revert to the original status if |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15250
diff
changeset
|
77 # self.lfstatus is False. |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
78 # XXX large file status is buggy when used on repo proxy. |
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
79 # XXX this needs to be investigated. |
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
80 @localrepo.unfilteredmethod |
15168 | 81 def status(self, node1='.', node2=None, match=None, ignored=False, |
82 clean=False, unknown=False, listsubrepos=False): | |
83 listignored, listclean, listunknown = ignored, clean, unknown | |
22518
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
84 orig = super(lfilesrepo, self).status |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
85 if not self.lfstatus: |
22518
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
86 return orig(node1, node2, match, listignored, listclean, |
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
87 listunknown, listsubrepos) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
88 |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
89 # some calls in this function rely on the old version of status |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
90 self.lfstatus = False |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
91 ctx1 = self[node1] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
92 ctx2 = self[node2] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
93 working = ctx2.rev() is None |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
94 parentworking = working and ctx1 == self['.'] |
15168 | 95 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
96 if match is None: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
97 match = match_.always(self.root, self.getcwd()) |
15168 | 98 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
99 wlock = None |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
100 try: |
19056
ac41bb76c737
largefiles: wlock in status before lfdirstate.write()
Mads Kiilerich <madski@unity3d.com>
parents:
18969
diff
changeset
|
101 try: |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
102 # updating the dirstate is optional |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
103 # so we don't wait on the lock |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
104 wlock = self.wlock(False) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
105 except error.LockError: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
106 pass |
15653
93c77d5b9752
largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents:
15630
diff
changeset
|
107 |
23146
5311de37b86f
largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents:
23139
diff
changeset
|
108 # First check if paths or patterns were specified on the |
5311de37b86f
largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents:
23139
diff
changeset
|
109 # command line. If there were, and they don't match any |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
110 # largefiles, we should just bail here and let super |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
111 # handle it -- thus gaining a big performance boost. |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
112 lfdirstate = lfutil.openlfdirstate(ui, self) |
23146
5311de37b86f
largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents:
23139
diff
changeset
|
113 if not match.always(): |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
114 for f in lfdirstate: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
115 if match(f): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
116 break |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
117 else: |
22518
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
118 return orig(node1, node2, match, listignored, listclean, |
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
119 listunknown, listsubrepos) |
15168 | 120 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
121 # Create a copy of match that matches standins instead |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
122 # of largefiles. |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
123 def tostandins(files): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
124 if not working: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
125 return files |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
126 newfiles = [] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
127 dirstate = self.dirstate |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
128 for f in files: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
129 sf = lfutil.standin(f) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
130 if sf in dirstate: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
131 newfiles.append(sf) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
132 elif sf in dirstate.dirs(): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
133 # Directory entries could be regular or |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
134 # standin, check both |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
135 newfiles.extend((f, sf)) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
136 else: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
137 newfiles.append(f) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
138 return newfiles |
18149
2dcc3653b361
largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents:
18148
diff
changeset
|
139 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
140 m = copy.copy(match) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
141 m._files = tostandins(m._files) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
142 |
22518
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
143 result = orig(node1, node2, m, ignored, clean, unknown, |
52dd6e25121f
largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22517
diff
changeset
|
144 listsubrepos) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
145 if working: |
15617
74e691b141c4
largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents:
15385
diff
changeset
|
146 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
147 def sfindirstate(f): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
148 sf = lfutil.standin(f) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
149 dirstate = self.dirstate |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
150 return sf in dirstate or sf in dirstate.dirs() |
18149
2dcc3653b361
largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents:
18148
diff
changeset
|
151 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
152 match._files = [f for f in match._files |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
153 if sfindirstate(f)] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
154 # Don't waste time getting the ignored and unknown |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
155 # files from lfdirstate |
22911
509e2cbee679
dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22525
diff
changeset
|
156 unsure, s = lfdirstate.status(match, [], False, listclean, |
509e2cbee679
dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22525
diff
changeset
|
157 False) |
22919
1982bdb7e2cc
largefiles: access status fields by name rather than index
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
158 (modified, added, removed, clean) = (s.modified, s.added, |
1982bdb7e2cc
largefiles: access status fields by name rather than index
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
159 s.removed, s.clean) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
160 if parentworking: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
161 for lfile in unsure: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
162 standin = lfutil.standin(lfile) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
163 if standin not in ctx1: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
164 # from second parent |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
165 modified.append(lfile) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
166 elif ctx1[standin].data().strip() \ |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
167 != lfutil.hashfile(self.wjoin(lfile)): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
168 modified.append(lfile) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
169 else: |
22523
8cd91f481ffd
largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22518
diff
changeset
|
170 if listclean: |
8cd91f481ffd
largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22518
diff
changeset
|
171 clean.append(lfile) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
172 lfdirstate.normal(lfile) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
173 else: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
174 tocheck = unsure + modified + added + clean |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
175 modified, added, clean = [], [], [] |
23383
7f8d27e1f862
largefiles: avoid exec-bit examination on the platform being unaware of it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23090
diff
changeset
|
176 checkexec = self.dirstate._checkexec |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
177 |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
178 for lfile in tocheck: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
179 standin = lfutil.standin(lfile) |
23043
244dbb646ab7
largefiles: inline redundant inctx function in status
Mads Kiilerich <madski@unity3d.com>
parents:
22919
diff
changeset
|
180 if standin in ctx1: |
23090
24600c9d7f4e
largefiles: add examination of exec bit in "hg status --rev REV" case
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23089
diff
changeset
|
181 abslfile = self.wjoin(lfile) |
24600c9d7f4e
largefiles: add examination of exec bit in "hg status --rev REV" case
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23089
diff
changeset
|
182 if ((ctx1[standin].data().strip() != |
24600c9d7f4e
largefiles: add examination of exec bit in "hg status --rev REV" case
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23089
diff
changeset
|
183 lfutil.hashfile(abslfile)) or |
23383
7f8d27e1f862
largefiles: avoid exec-bit examination on the platform being unaware of it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23090
diff
changeset
|
184 (checkexec and |
7f8d27e1f862
largefiles: avoid exec-bit examination on the platform being unaware of it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23090
diff
changeset
|
185 ('x' in ctx1.flags(standin)) != |
23090
24600c9d7f4e
largefiles: add examination of exec bit in "hg status --rev REV" case
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23089
diff
changeset
|
186 bool(lfutil.getexecutable(abslfile)))): |
15168 | 187 modified.append(lfile) |
22523
8cd91f481ffd
largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22518
diff
changeset
|
188 elif listclean: |
15168 | 189 clean.append(lfile) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
190 else: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
191 added.append(lfile) |
15168 | 192 |
23089
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
193 # at this point, 'removed' contains largefiles |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
194 # marked as 'R' in the working context. |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
195 # then, largefiles not managed also in the target |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
196 # context should be excluded from 'removed'. |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
197 removed = [lfile for lfile in removed |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
198 if lfutil.standin(lfile) in ctx1] |
197dc4580da2
largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23044
diff
changeset
|
199 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
200 # Standins no longer found in lfdirstate has been |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
201 # removed |
22525
764127f58903
largefiles: simplify iteration over standins
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22524
diff
changeset
|
202 for standin in ctx1.walk(lfutil.getstandinmatcher(self)): |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
203 lfile = lfutil.splitstandin(standin) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
204 if not match(lfile): |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
205 continue |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
206 if lfile not in lfdirstate: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
207 removed.append(lfile) |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15629
diff
changeset
|
208 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
209 # Filter result lists |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
210 result = list(result) |
19056
ac41bb76c737
largefiles: wlock in status before lfdirstate.write()
Mads Kiilerich <madski@unity3d.com>
parents:
18969
diff
changeset
|
211 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
212 # Largefiles are not really removed when they're |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
213 # still in the normal dirstate. Likewise, normal |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
214 # files are not really removed if they are still in |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
215 # lfdirstate. This happens in merges where files |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
216 # change type. |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
217 removed = [f for f in removed |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
218 if f not in self.dirstate] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
219 result[2] = [f for f in result[2] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
220 if f not in lfdirstate] |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15629
diff
changeset
|
221 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
222 lfiles = set(lfdirstate._map) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
223 # Unknown files |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
224 result[4] = set(result[4]).difference(lfiles) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
225 # Ignored files |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
226 result[5] = set(result[5]).difference(lfiles) |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
227 # combine normal files and largefiles |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
228 normals = [[fn for fn in filelist |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
229 if not lfutil.isstandin(fn)] |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
230 for filelist in result] |
22919
1982bdb7e2cc
largefiles: access status fields by name rather than index
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
231 lfstatus = (modified, added, removed, s.deleted, [], [], |
22524
8c8fe120670f
largefiles: avoid using 'lfiles' variable for two purposes
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22523
diff
changeset
|
232 clean) |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
233 result = [sorted(list1 + list2) |
22524
8c8fe120670f
largefiles: avoid using 'lfiles' variable for two purposes
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22523
diff
changeset
|
234 for (list1, list2) in zip(normals, lfstatus)] |
23044
075f55a9c488
largefiles: inline redundant toname function in status
Mads Kiilerich <madski@unity3d.com>
parents:
23043
diff
changeset
|
235 else: # not against working directory |
075f55a9c488
largefiles: inline redundant toname function in status
Mads Kiilerich <madski@unity3d.com>
parents:
23043
diff
changeset
|
236 result = [[lfutil.splitstandin(f) or f for f in items] |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
237 for items in result] |
15663
9036c7d106bf
largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents:
15629
diff
changeset
|
238 |
22515
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
239 if wlock: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
240 lfdirstate.write() |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
241 |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
242 finally: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
243 if wlock: |
b4e251b7e9a8
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22514
diff
changeset
|
244 wlock.release() |
15168 | 245 |
23958
df463ca0adef
largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents:
23923
diff
changeset
|
246 self.lfstatus = True |
22914
c95db3208a33
status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22911
diff
changeset
|
247 return scmutil.status(*result) |
15168 | 248 |
23184
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
249 def commitctx(self, ctx, *args, **kwargs): |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
250 node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs) |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
251 class lfilesctx(ctx.__class__): |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
252 def markcommitted(self, node): |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
253 orig = super(lfilesctx, self).markcommitted |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
254 return lfutil.markcommitted(orig, self, node) |
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23147
diff
changeset
|
255 ctx.__class__ = lfilesctx |
15168 | 256 return node |
257 | |
15254
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
258 # Before commit, largefile standins have not had their |
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
259 # contents updated to reflect the hash of their largefile. |
dd03d3a9f888
largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
260 # Do that here. |
15168 | 261 def commit(self, text="", user=None, date=None, match=None, |
262 force=False, editor=False, extra={}): | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
263 orig = super(lfilesrepo, self).commit |
15168 | 264 |
17803
1479572db256
largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17424
diff
changeset
|
265 wlock = self.wlock() |
15168 | 266 try: |
23186
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
267 lfcommithook = self._lfcommithooks[-1] |
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
268 match = lfcommithook(self, match) |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
269 result = orig(text=text, user=user, date=date, match=match, |
15168 | 270 force=force, editor=editor, extra=extra) |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
271 return result |
15168 | 272 finally: |
273 wlock.release() | |
274 | |
275 def push(self, remote, force=False, revs=None, newbranch=False): | |
19779
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
276 if remote.local(): |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
277 missing = set(self.requirements) - remote.local().supported |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
278 if missing: |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
279 msg = _("required features are not" |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
280 " supported in the destination:" |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
281 " %s") % (', '.join(sorted(missing))) |
fb6e87d93948
largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19570
diff
changeset
|
282 raise util.Abort(msg) |
20177
c5f0574034ef
largefiles: call super class method with proper kwargs to respect API
Long Vu <long@tlvu.ca>
parents:
19779
diff
changeset
|
283 return super(lfilesrepo, self).push(remote, force=force, revs=revs, |
c5f0574034ef
largefiles: call super class method with proper kwargs to respect API
Long Vu <long@tlvu.ca>
parents:
19779
diff
changeset
|
284 newbranch=newbranch) |
15168 | 285 |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
286 # TODO: _subdirlfs should be moved into "lfutil.py", because |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
287 # it is referred only from "lfutil.updatestandinsbymatch" |
18064
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
288 def _subdirlfs(self, files, lfiles): |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
289 ''' |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
290 Adjust matched file list |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23394
diff
changeset
|
291 If we pass a directory to commit whose only committable files |
18064
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
292 are largefiles, the core commit code aborts before finding |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
293 the largefiles. |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
294 So we do the following: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
295 For directories that only have largefiles as matches, |
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18182
diff
changeset
|
296 we explicitly add the largefiles to the match list and remove |
18064
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
297 the directory. |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
298 In other cases, we leave the match list unmodified. |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
299 ''' |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
300 actualfiles = [] |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
301 dirs = [] |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
302 regulars = [] |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
303 |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
304 for f in files: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
305 if lfutil.isstandin(f + '/'): |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
306 raise util.Abort( |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
307 _('file "%s" is a largefile standin') % f, |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
308 hint=('commit the largefile itself instead')) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
309 # Scan directories |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
310 if os.path.isdir(self.wjoin(f)): |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
311 dirs.append(f) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
312 else: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
313 regulars.append(f) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
314 |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
315 for f in dirs: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
316 matcheddir = False |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
317 d = self.dirstate.normalize(f) + '/' |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
318 # Check for matched normal files |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
319 for mf in regulars: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
320 if self.dirstate.normalize(mf).startswith(d): |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
321 actualfiles.append(f) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
322 matcheddir = True |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
323 break |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
324 if not matcheddir: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
325 # If no normal match, manually append |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
326 # any matching largefiles |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
327 for lf in lfiles: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
328 if self.dirstate.normalize(lf).startswith(d): |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
329 actualfiles.append(lf) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
330 if not matcheddir: |
23923
ab6fd3205dad
largefiles: fix commit of a directory with no largefile changes (issue4330)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23660
diff
changeset
|
331 # There may still be normal files in the dir, so |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24163
diff
changeset
|
332 # add a directory to the list, which |
24007
240343e13c4d
largefiles: update _subdirlfs() comment
Matt Harbison <matt_harbison@yahoo.com>
parents:
23958
diff
changeset
|
333 # forces status/dirstate to walk all files and |
240343e13c4d
largefiles: update _subdirlfs() comment
Matt Harbison <matt_harbison@yahoo.com>
parents:
23958
diff
changeset
|
334 # call the match function on the matcher, even |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24163
diff
changeset
|
335 # on case sensitive filesystems. |
23923
ab6fd3205dad
largefiles: fix commit of a directory with no largefile changes (issue4330)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23660
diff
changeset
|
336 actualfiles.append('.') |
18064
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
337 matcheddir = True |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
338 # Nothing in dir, so readd it |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
339 # and let commit reject it |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
340 if not matcheddir: |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
341 actualfiles.append(f) |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
342 |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
343 # Always add normal files |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
344 actualfiles += regulars |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
345 return actualfiles |
7e2b9f6a2cd0
largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents:
17803
diff
changeset
|
346 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16141
diff
changeset
|
347 repo.__class__ = lfilesrepo |
15168 | 348 |
23186
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
349 # stack of hooks being executed before committing. |
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
350 # only last element ("_lfcommithooks[-1]") is used for each committing. |
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
351 repo._lfcommithooks = [lfutil.updatestandinsbymatch] |
6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
352 |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23186
diff
changeset
|
353 # Stack of status writer functions taking "*msg, **opts" arguments |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23394
diff
changeset
|
354 # like "ui.status()". Only last element ("_lfstatuswriters[-1]") |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23186
diff
changeset
|
355 # is used to write status out. |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23186
diff
changeset
|
356 repo._lfstatuswriters = [ui.status] |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23186
diff
changeset
|
357 |
21044
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
358 def prepushoutgoinghook(local, remote, outgoing): |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
359 if outgoing.missing: |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
360 toupload = set() |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
361 addfunc = lambda fn, lfhash: toupload.add(lfhash) |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
362 lfutil.getlfilestoupload(local, outgoing.missing, addfunc) |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
363 lfcommands.uploadlfiles(ui, local, remote, toupload) |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
364 repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook) |
52a5eabf1f2f
largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21042
diff
changeset
|
365 |
15168 | 366 def checkrequireslfiles(ui, repo, **kwargs): |
15319
9da7e96cd5c2
largefiles: remove redundant any_ function
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15316
diff
changeset
|
367 if 'largefiles' not in repo.requirements and util.any( |
15168 | 368 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()): |
15312
8d862e7b96d4
largefiles: remove 1.9 compat code
Eli Carter <eli.carter@tektronix.com>
parents:
15305
diff
changeset
|
369 repo.requirements.add('largefiles') |
15168 | 370 repo._writerequirements() |
371 | |
20790
49f2d5644f04
config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents:
20177
diff
changeset
|
372 ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles, |
49f2d5644f04
config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents:
20177
diff
changeset
|
373 'largefiles') |
49f2d5644f04
config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents:
20177
diff
changeset
|
374 ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles') |