Mercurial > hg
annotate hgext/largefiles/lfutil.py @ 18300:745bc16ccef2
largefiles: fix update from a merge with removed files
A situation with this case could happen after interrupting an update. Update
would fail with:
abort: No such file or directory: $TESTTMP/f/.hglf/sub2/large6
Update from a merge without using clean is not possible anyway, so this patch
takes a step in the right direction so it gets as far as reporting the right
error.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 11 Jan 2013 16:30:29 +0100 |
parents | a7a88a458a4c |
children | 877f80599df0 |
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 '''largefiles utility code: must not import other modules in this package.''' | |
10 | |
11 import os | |
12 import errno | |
15320
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
13 import platform |
15168 | 14 import shutil |
15 import stat | |
16 | |
15226
2223ea21c98f
largefiles: cleanup import, now that we can assume > 1.9 for bundled extension
Na'Tosha Bard <natosha@unity3d.com>
parents:
15224
diff
changeset
|
17 from mercurial import dirstate, httpconnection, match as match_, util, scmutil |
15168 | 18 from mercurial.i18n import _ |
19 | |
20 shortname = '.hglf' | |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
21 shortnameslash = shortname + '/' |
15168 | 22 longname = 'largefiles' |
23 | |
24 | |
25 # -- Private worker functions ------------------------------------------ | |
26 | |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
27 def getminsize(ui, assumelfiles, opt, default=10): |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
28 lfsize = opt |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
29 if not lfsize and assumelfiles: |
15304
9aa9d4bb3d88
largefiles: rename config setting 'size' to 'minsize'
Greg Ward <greg@gerg.ca>
parents:
15255
diff
changeset
|
30 lfsize = ui.config(longname, 'minsize', default=default) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
31 if lfsize: |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
32 try: |
15228
ee625de3541e
largefiles: allow minimum size to be a float
Greg Ward <greg@gerg.ca>
parents:
15227
diff
changeset
|
33 lfsize = float(lfsize) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
34 except ValueError: |
15228
ee625de3541e
largefiles: allow minimum size to be a float
Greg Ward <greg@gerg.ca>
parents:
15227
diff
changeset
|
35 raise util.Abort(_('largefiles: size must be number (not %s)\n') |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
36 % lfsize) |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
37 if lfsize is None: |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
38 raise util.Abort(_('minimum size for largefiles must be specified')) |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
39 return lfsize |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
40 |
15168 | 41 def link(src, dest): |
42 try: | |
15206
f85c76b16f27
largefiles: fix commit of specified file on non-windows
Na'Tosha Bard <natosha@unity3d.com>
parents:
15188
diff
changeset
|
43 util.oslink(src, dest) |
15168 | 44 except OSError: |
15572
926bc23d0b6a
largefiles: copy files into .hg/largefiles atomically
Martin Geisler <mg@aragost.com>
parents:
15571
diff
changeset
|
45 # if hardlinks fail, fallback on atomic copy |
926bc23d0b6a
largefiles: copy files into .hg/largefiles atomically
Martin Geisler <mg@aragost.com>
parents:
15571
diff
changeset
|
46 dst = util.atomictempfile(dest) |
15699
84e55467093c
largefiles: copy files in binary mode (issue3164)
Matt Mackall <mpm@selenic.com>
parents:
15658
diff
changeset
|
47 for chunk in util.filechunkiter(open(src, 'rb')): |
15572
926bc23d0b6a
largefiles: copy files into .hg/largefiles atomically
Martin Geisler <mg@aragost.com>
parents:
15571
diff
changeset
|
48 dst.write(chunk) |
926bc23d0b6a
largefiles: copy files into .hg/largefiles atomically
Martin Geisler <mg@aragost.com>
parents:
15571
diff
changeset
|
49 dst.close() |
15168 | 50 os.chmod(dest, os.stat(src).st_mode) |
51 | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
52 def usercachepath(ui, hash): |
15350
8b8dd13295db
largefiles: use ui.configpath() where appropriate
Greg Ward <greg@gerg.ca>
parents:
15349
diff
changeset
|
53 path = ui.configpath(longname, 'usercache', None) |
15168 | 54 if path: |
55 path = os.path.join(path, hash) | |
56 else: | |
57 if os.name == 'nt': | |
15255
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
58 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
59 if appdata: |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
60 path = os.path.join(appdata, longname, hash) |
15320
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
61 elif platform.system() == 'Darwin': |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
62 home = os.getenv('HOME') |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
63 if home: |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
64 path = os.path.join(home, 'Library', 'Caches', |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
65 longname, hash) |
15168 | 66 elif os.name == 'posix': |
15320
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
67 path = os.getenv('XDG_CACHE_HOME') |
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
68 if path: |
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
69 path = os.path.join(path, longname, hash) |
681267a5f491
largefiles: use XDG and OS X-specific cache locations by default (issue3067)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15319
diff
changeset
|
70 else: |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
71 home = os.getenv('HOME') |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
72 if home: |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
73 path = os.path.join(home, '.cache', longname, hash) |
15168 | 74 else: |
15253
67d010779907
largefiles: improve error reporting
Greg Ward <greg@gerg.ca>
parents:
15252
diff
changeset
|
75 raise util.Abort(_('unknown operating system: %s\n') % os.name) |
15168 | 76 return path |
77 | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
78 def inusercache(ui, hash): |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
79 path = usercachepath(ui, hash) |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
80 return path and os.path.exists(path) |
15168 | 81 |
82 def findfile(repo, hash): | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
83 if instore(repo, hash): |
16928
73b9286e667c
largefiles: lowercase messages
Martin Geisler <mg@aragost.com>
parents:
16247
diff
changeset
|
84 repo.ui.note(_('found %s in store\n') % hash) |
15913
c35dcde25174
largefiles: refactor lfutil.findfiles to be more logical
Na'Tosha Bard <natosha@unity3d.com>
parents:
15796
diff
changeset
|
85 return storepath(repo, hash) |
15317
41f371150ccb
largefiles: make the store primary, and the user cache secondary
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15316
diff
changeset
|
86 elif inusercache(repo.ui, hash): |
16928
73b9286e667c
largefiles: lowercase messages
Martin Geisler <mg@aragost.com>
parents:
16247
diff
changeset
|
87 repo.ui.note(_('found %s in system cache\n') % hash) |
15408
db8b0ee74025
largefiles: ensure destination directory exists before findfile links to there
Hao Lian <hao@fogcreek.com>
parents:
15392
diff
changeset
|
88 path = storepath(repo, hash) |
db8b0ee74025
largefiles: ensure destination directory exists before findfile links to there
Hao Lian <hao@fogcreek.com>
parents:
15392
diff
changeset
|
89 util.makedirs(os.path.dirname(path)) |
db8b0ee74025
largefiles: ensure destination directory exists before findfile links to there
Hao Lian <hao@fogcreek.com>
parents:
15392
diff
changeset
|
90 link(usercachepath(repo.ui, hash), path) |
15913
c35dcde25174
largefiles: refactor lfutil.findfiles to be more logical
Na'Tosha Bard <natosha@unity3d.com>
parents:
15796
diff
changeset
|
91 return path |
c35dcde25174
largefiles: refactor lfutil.findfiles to be more logical
Na'Tosha Bard <natosha@unity3d.com>
parents:
15796
diff
changeset
|
92 return None |
15168 | 93 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
94 class largefilesdirstate(dirstate.dirstate): |
15168 | 95 def __getitem__(self, key): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
96 return super(largefilesdirstate, self).__getitem__(unixpath(key)) |
15168 | 97 def normal(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
98 return super(largefilesdirstate, self).normal(unixpath(f)) |
15168 | 99 def remove(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
100 return super(largefilesdirstate, self).remove(unixpath(f)) |
15168 | 101 def add(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
102 return super(largefilesdirstate, self).add(unixpath(f)) |
15168 | 103 def drop(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
104 return super(largefilesdirstate, self).drop(unixpath(f)) |
15168 | 105 def forget(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
106 return super(largefilesdirstate, self).forget(unixpath(f)) |
15793
3ef07ecdb0d5
largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents:
15700
diff
changeset
|
107 def normallookup(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
108 return super(largefilesdirstate, self).normallookup(unixpath(f)) |
18148
bf6252d12c34
largefiles: simplify lfdirstate ignore handling - it is only for tracking .hglf
Mads Kiilerich <madski@unity3d.com>
parents:
18147
diff
changeset
|
109 def _ignore(self): |
bf6252d12c34
largefiles: simplify lfdirstate ignore handling - it is only for tracking .hglf
Mads Kiilerich <madski@unity3d.com>
parents:
18147
diff
changeset
|
110 return False |
15168 | 111 |
17659
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
112 def openlfdirstate(ui, repo, create=True): |
15168 | 113 ''' |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
114 Return a dirstate object that tracks largefiles: i.e. its root is |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
115 the repo root, but it is saved in .hg/largefiles/dirstate. |
15168 | 116 ''' |
18147
79f2493198e1
largefiles: rename 'admin' to more descriptive 'lfstoredir'
Mads Kiilerich <madski@unity3d.com>
parents:
18146
diff
changeset
|
117 lfstoredir = repo.join(longname) |
79f2493198e1
largefiles: rename 'admin' to more descriptive 'lfstoredir'
Mads Kiilerich <madski@unity3d.com>
parents:
18146
diff
changeset
|
118 opener = scmutil.opener(lfstoredir) |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
119 lfdirstate = largefilesdirstate(opener, ui, repo.root, |
15349
63455eb771af
largefiles: drop more unnecessary compatibility checks
Greg Ward <greg@gerg.ca>
parents:
15347
diff
changeset
|
120 repo.dirstate._validate) |
15168 | 121 |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
122 # If the largefiles dirstate does not exist, populate and create |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
123 # it. This ensures that we create it on the first meaningful |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
124 # largefiles operation in a new clone. |
18147
79f2493198e1
largefiles: rename 'admin' to more descriptive 'lfstoredir'
Mads Kiilerich <madski@unity3d.com>
parents:
18146
diff
changeset
|
125 if create and not os.path.exists(os.path.join(lfstoredir, 'dirstate')): |
79f2493198e1
largefiles: rename 'admin' to more descriptive 'lfstoredir'
Mads Kiilerich <madski@unity3d.com>
parents:
18146
diff
changeset
|
126 util.makedirs(lfstoredir) |
15168 | 127 matcher = getstandinmatcher(repo) |
18154
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
128 for standin in repo.dirstate.walk(matcher, [], False, False): |
15168 | 129 lfile = splitstandin(standin) |
130 hash = readstandin(repo, lfile) | |
131 lfdirstate.normallookup(lfile) | |
132 try: | |
15553
e89385e4ef8d
largefiles: file storage should be relative to repo, not relative to cwd
Mads Kiilerich <mads@kiilerich.com>
parents:
15548
diff
changeset
|
133 if hash == hashfile(repo.wjoin(lfile)): |
15168 | 134 lfdirstate.normal(lfile) |
15548
f76584098c88
largefiles: fix 'hg clone . ../foo' OSError abort
Martin Geisler <mg@lazybytes.net>
parents:
15408
diff
changeset
|
135 except OSError, err: |
15168 | 136 if err.errno != errno.ENOENT: |
137 raise | |
138 return lfdirstate | |
139 | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
140 def lfdirstatestatus(lfdirstate, repo, rev): |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
141 match = match_.always(repo.root, repo.getcwd()) |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
142 s = lfdirstate.status(match, [], False, False, False) |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
143 unsure, modified, added, removed, missing, unknown, ignored, clean = s |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
144 for lfile in unsure: |
18299
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
145 try: |
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
146 fctx = repo[rev][standin(lfile)] |
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
147 except LookupError: |
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
148 fctx = None |
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
149 if not fctx or fctx.data().strip() != hashfile(repo.wjoin(lfile)): |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
150 modified.append(lfile) |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
151 else: |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
152 clean.append(lfile) |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
153 lfdirstate.normal(lfile) |
15168 | 154 return (modified, added, removed, missing, unknown, ignored, clean) |
155 | |
156 def listlfiles(repo, rev=None, matcher=None): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
157 '''return a list of largefiles in the working copy or the |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
158 specified changeset''' |
15168 | 159 |
160 if matcher is None: | |
161 matcher = getstandinmatcher(repo) | |
162 | |
163 # ignore unknown files in working directory | |
15255
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
164 return [splitstandin(f) |
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
165 for f in repo[rev].walk(matcher) |
15168 | 166 if rev is not None or repo.dirstate[f] != '?'] |
167 | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
168 def instore(repo, hash): |
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
169 return os.path.exists(storepath(repo, hash)) |
15168 | 170 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
171 def storepath(repo, hash): |
15168 | 172 return repo.join(os.path.join(longname, hash)) |
173 | |
174 def copyfromcache(repo, hash, filename): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
175 '''Copy the specified largefile from the repo or system cache to |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
176 filename in the repository. Return true on success or false if the |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
177 file was not found in either cache (which should not happened: |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
178 this is meant to be called only after ensuring that the needed |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
179 largefile exists in the cache).''' |
15168 | 180 path = findfile(repo, hash) |
181 if path is None: | |
182 return False | |
183 util.makedirs(os.path.dirname(repo.wjoin(filename))) | |
15570
0f208626d503
largefiles: add comment about non-atomic working directory
Martin Geisler <mg@aragost.com>
parents:
15553
diff
changeset
|
184 # The write may fail before the file is fully written, but we |
0f208626d503
largefiles: add comment about non-atomic working directory
Martin Geisler <mg@aragost.com>
parents:
15553
diff
changeset
|
185 # don't use atomic writes in the working copy. |
15168 | 186 shutil.copy(path, repo.wjoin(filename)) |
187 return True | |
188 | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
189 def copytostore(repo, rev, file, uploaded=False): |
17877
92bbb21d4b13
largefiles: respect the rev when reading standins in copytostore() (issue3630)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17794
diff
changeset
|
190 hash = readstandin(repo, file, rev) |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
191 if instore(repo, hash): |
15168 | 192 return |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
193 copytostoreabsolute(repo, repo.wjoin(file), hash) |
15168 | 194 |
15796
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
195 def copyalltostore(repo, node): |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
196 '''Copy all largefiles in a given revision to the store''' |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
197 |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
198 ctx = repo[node] |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
199 for filename in ctx.files(): |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
200 if isstandin(filename) and filename in ctx.manifest(): |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
201 realfile = splitstandin(filename) |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
202 copytostore(repo, ctx.node(), realfile) |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
203 |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
204 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
205 def copytostoreabsolute(repo, file, hash): |
15371
f26ed4ea46d8
largefiles: remove lfutil.createdir, replace calls with util.makedirs
Hao Lian <hao@fogcreek.com>
parents:
15350
diff
changeset
|
206 util.makedirs(os.path.dirname(storepath(repo, hash))) |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
207 if inusercache(repo.ui, hash): |
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
208 link(usercachepath(repo.ui, hash), storepath(repo, hash)) |
17878
d1d0140287b8
largefiles: don't copy largefiles from working dir to the store while converting
Matt Harbison <matt_harbison@yahoo.com>
parents:
17877
diff
changeset
|
209 elif not getattr(repo, "_isconverting", False): |
16153
05197f9fd1f3
largefiles: use repo.store.createmode for new files in .hg/largefiles
Martin Geisler <mg@aragost.com>
parents:
16103
diff
changeset
|
210 dst = util.atomictempfile(storepath(repo, hash), |
05197f9fd1f3
largefiles: use repo.store.createmode for new files in .hg/largefiles
Martin Geisler <mg@aragost.com>
parents:
16103
diff
changeset
|
211 createmode=repo.store.createmode) |
15699
84e55467093c
largefiles: copy files in binary mode (issue3164)
Matt Mackall <mpm@selenic.com>
parents:
15658
diff
changeset
|
212 for chunk in util.filechunkiter(open(file, 'rb')): |
15571
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
15570
diff
changeset
|
213 dst.write(chunk) |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
15570
diff
changeset
|
214 dst.close() |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
215 linktousercache(repo, hash) |
15168 | 216 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
217 def linktousercache(repo, hash): |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
218 path = usercachepath(repo.ui, hash) |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
219 if path: |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
220 util.makedirs(os.path.dirname(path)) |
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
221 link(storepath(repo, hash), path) |
15168 | 222 |
223 def getstandinmatcher(repo, pats=[], opts={}): | |
224 '''Return a match object that applies pats to the standin directory''' | |
18150
14e31a631e41
largefiles: use plain wjoin instead of the complex pathto
Mads Kiilerich <madski@unity3d.com>
parents:
18148
diff
changeset
|
225 standindir = repo.wjoin(shortname) |
15168 | 226 if pats: |
227 # patterns supplied: search standin directory relative to current dir | |
228 cwd = repo.getcwd() | |
229 if os.path.isabs(cwd): | |
230 # cwd is an absolute path for hg -R <reponame> | |
231 # work relative to the repository root in this case | |
232 cwd = '' | |
233 pats = [os.path.join(standindir, cwd, pat) for pat in pats] | |
234 elif os.path.isdir(standindir): | |
235 # no patterns: relative to repo root | |
236 pats = [standindir] | |
237 else: | |
238 # no patterns and no standin dir: return matcher that matches nothing | |
18146
819c7e10d60d
largefiles: simplify lfutil.getstandinmatcher by inlining getmatcher
Mads Kiilerich <madski@unity3d.com>
parents:
18143
diff
changeset
|
239 return match_.match(repo.root, None, [], exact=True) |
15168 | 240 |
18146
819c7e10d60d
largefiles: simplify lfutil.getstandinmatcher by inlining getmatcher
Mads Kiilerich <madski@unity3d.com>
parents:
18143
diff
changeset
|
241 # no warnings about missing files or directories |
15224
7c604d8c7e83
largefiles: remove pre-1.9 code from extension first bundled with 1.9
Na'Tosha Bard <natosha@unity3d.com>
parents:
15206
diff
changeset
|
242 match = scmutil.match(repo[None], pats, opts) |
18146
819c7e10d60d
largefiles: simplify lfutil.getstandinmatcher by inlining getmatcher
Mads Kiilerich <madski@unity3d.com>
parents:
18143
diff
changeset
|
243 match.bad = lambda f, msg: None |
15168 | 244 return match |
245 | |
246 def composestandinmatcher(repo, rmatcher): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
247 '''Return a matcher that accepts standins corresponding to the |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
248 files accepted by rmatcher. Pass the list of files in the matcher |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
249 as the paths specified by the user.''' |
15168 | 250 smatcher = getstandinmatcher(repo, rmatcher.files()) |
251 isstandin = smatcher.matchfn | |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
252 def composedmatchfn(f): |
15168 | 253 return isstandin(f) and rmatcher.matchfn(splitstandin(f)) |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
254 smatcher.matchfn = composedmatchfn |
15168 | 255 |
256 return smatcher | |
257 | |
258 def standin(filename): | |
259 '''Return the repo-relative path to the standin for the specified big | |
260 file.''' | |
261 # Notes: | |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17270
diff
changeset
|
262 # 1) Some callers want an absolute path, but for instance addlargefiles |
18154
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
263 # needs it repo-relative so it can be passed to repo[None].add(). So |
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
264 # leave it up to the caller to use repo.wjoin() to get an absolute path. |
15168 | 265 # 2) Join with '/' because that's what dirstate always uses, even on |
266 # Windows. Change existing separator to '/' first in case we are | |
267 # passed filenames from an external source (like the command line). | |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
268 return shortnameslash + util.pconvert(filename) |
15168 | 269 |
270 def isstandin(filename): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
271 '''Return true if filename is a big file standin. filename must be |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
272 in Mercurial's internal form (slash-separated).''' |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
273 return filename.startswith(shortnameslash) |
15168 | 274 |
275 def splitstandin(filename): | |
276 # Split on / because that's what dirstate always uses, even on Windows. | |
277 # Change local separator to / first just in case we are passed filenames | |
278 # from an external source (like the command line). | |
16066
6a42846cf769
i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15915
diff
changeset
|
279 bits = util.pconvert(filename).split('/', 1) |
15168 | 280 if len(bits) == 2 and bits[0] == shortname: |
281 return bits[1] | |
282 else: | |
283 return None | |
284 | |
285 def updatestandin(repo, standin): | |
286 file = repo.wjoin(splitstandin(standin)) | |
287 if os.path.exists(file): | |
288 hash = hashfile(file) | |
289 executable = getexecutable(file) | |
290 writestandin(repo, standin, hash, executable) | |
291 | |
292 def readstandin(repo, filename, node=None): | |
293 '''read hex hash from standin for filename at given node, or working | |
294 directory if no node is given''' | |
295 return repo[node][standin(filename)].data().strip() | |
296 | |
297 def writestandin(repo, standin, hash, executable): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
298 '''write hash to <repo.root>/<standin>''' |
15168 | 299 writehash(hash, repo.wjoin(standin), executable) |
300 | |
301 def copyandhash(instream, outfile): | |
302 '''Read bytes from instream (iterable) and write them to outfile, | |
303 computing the SHA-1 hash of the data along the way. Close outfile | |
304 when done and return the binary hash.''' | |
305 hasher = util.sha1('') | |
306 for data in instream: | |
307 hasher.update(data) | |
308 outfile.write(data) | |
309 | |
310 # Blecch: closing a file that somebody else opened is rude and | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
311 # wrong. But it's so darn convenient and practical! After all, |
15168 | 312 # outfile was opened just to copy and hash. |
313 outfile.close() | |
314 | |
315 return hasher.digest() | |
316 | |
317 def hashrepofile(repo, file): | |
318 return hashfile(repo.wjoin(file)) | |
319 | |
320 def hashfile(file): | |
321 if not os.path.exists(file): | |
322 return '' | |
323 hasher = util.sha1('') | |
324 fd = open(file, 'rb') | |
325 for data in blockstream(fd): | |
326 hasher.update(data) | |
327 fd.close() | |
328 return hasher.hexdigest() | |
329 | |
330 class limitreader(object): | |
331 def __init__(self, f, limit): | |
332 self.f = f | |
333 self.limit = limit | |
334 | |
335 def read(self, length): | |
336 if self.limit == 0: | |
337 return '' | |
338 length = length > self.limit and self.limit or length | |
339 self.limit -= length | |
340 return self.f.read(length) | |
341 | |
342 def close(self): | |
343 pass | |
344 | |
345 def blockstream(infile, blocksize=128 * 1024): | |
346 """Generator that yields blocks of data from infile and closes infile.""" | |
347 while True: | |
348 data = infile.read(blocksize) | |
349 if not data: | |
350 break | |
351 yield data | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
352 # same blecch as copyandhash() above |
15168 | 353 infile.close() |
354 | |
355 def writehash(hash, filename, executable): | |
356 util.makedirs(os.path.dirname(filename)) | |
15574
c9328c829cd9
largefiles: simplify lfutil.writehash
Martin Geisler <mg@aragost.com>
parents:
15572
diff
changeset
|
357 util.writefile(filename, hash + '\n') |
c9328c829cd9
largefiles: simplify lfutil.writehash
Martin Geisler <mg@aragost.com>
parents:
15572
diff
changeset
|
358 os.chmod(filename, getmode(executable)) |
15168 | 359 |
360 def getexecutable(filename): | |
361 mode = os.stat(filename).st_mode | |
15255
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
362 return ((mode & stat.S_IXUSR) and |
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
363 (mode & stat.S_IXGRP) and |
7ab05d752405
largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents:
15253
diff
changeset
|
364 (mode & stat.S_IXOTH)) |
15168 | 365 |
366 def getmode(executable): | |
367 if executable: | |
368 return 0755 | |
369 else: | |
370 return 0644 | |
371 | |
372 def urljoin(first, second, *arg): | |
373 def join(left, right): | |
374 if not left.endswith('/'): | |
375 left += '/' | |
376 if right.startswith('/'): | |
377 right = right[1:] | |
378 return left + right | |
379 | |
380 url = join(first, second) | |
381 for a in arg: | |
382 url = join(url, a) | |
383 return url | |
384 | |
385 def hexsha1(data): | |
386 """hexsha1 returns the hex-encoded sha1 sum of the data in the file-like | |
387 object data""" | |
15347
799e56609ef6
largefiles: use util.sha1() instead of hashlib.sha1() everywhere
Thomas Arendsen Hein <thomas@intevation.de>
parents:
15333
diff
changeset
|
388 h = util.sha1() |
15168 | 389 for chunk in util.filechunkiter(data): |
390 h.update(chunk) | |
391 return h.hexdigest() | |
392 | |
393 def httpsendfile(ui, filename): | |
15224
7c604d8c7e83
largefiles: remove pre-1.9 code from extension first bundled with 1.9
Na'Tosha Bard <natosha@unity3d.com>
parents:
15206
diff
changeset
|
394 return httpconnection.httpsendfile(ui, filename, 'rb') |
15168 | 395 |
396 def unixpath(path): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
397 '''Return a version of path normalized for use with the lfdirstate.''' |
16066
6a42846cf769
i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15915
diff
changeset
|
398 return util.pconvert(os.path.normpath(path)) |
15168 | 399 |
400 def islfilesrepo(repo): | |
17659
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
401 if ('largefiles' in repo.requirements and |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
402 util.any(shortnameslash in f[0] for f in repo.store.datafiles())): |
17659
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
403 return True |
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
404 |
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
405 return util.any(openlfdirstate(repo.ui, repo, False)) |
15168 | 406 |
15333
f37b71fec602
largefiles: py2.4 doesn't have BaseException
Matt Mackall <mpm@selenic.com>
parents:
15320
diff
changeset
|
407 class storeprotonotcapable(Exception): |
15168 | 408 def __init__(self, storetypes): |
409 self.storetypes = storetypes | |
16103
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
410 |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
411 def getcurrentheads(repo): |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
412 branches = repo.branchmap() |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
413 heads = [] |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
414 for branch in branches: |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
415 newheads = repo.branchheads(branch) |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
416 heads = heads + newheads |
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
417 return heads |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
418 |
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
419 def getstandinsstate(repo): |
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
420 standins = [] |
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
421 matcher = getstandinmatcher(repo) |
18154
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
422 for standin in repo.dirstate.walk(matcher, [], False, False): |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
423 lfile = splitstandin(standin) |
18300
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
424 try: |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
425 hash = readstandin(repo, lfile) |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
426 except IOError: |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
427 hash = None |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
428 standins.append((lfile, hash)) |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
429 return standins |
16245
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
430 |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
431 def getlfilestoupdate(oldstandins, newstandins): |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
432 changedstandins = set(oldstandins).symmetric_difference(set(newstandins)) |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
433 filelist = [] |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
434 for f in changedstandins: |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
435 if f[0] not in filelist: |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
436 filelist.append(f[0]) |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
437 return filelist |