comparison hgext/largefiles/lfutil.py @ 18154:93c697d9c158

largefiles: remove trivial portability wrappers
author Mads Kiilerich <madski@unity3d.com>
date Thu, 13 Dec 2012 19:19:06 +0100
parents 51837a31b425
children a7a88a458a4c
comparison
equal deleted inserted replaced
18153:51837a31b425 18154:93c697d9c158
19 19
20 shortname = '.hglf' 20 shortname = '.hglf'
21 shortnameslash = shortname + '/' 21 shortnameslash = shortname + '/'
22 longname = 'largefiles' 22 longname = 'largefiles'
23 23
24
25 # -- Portability wrappers ----------------------------------------------
26
27 def dirstatewalk(dirstate, matcher, unknown=False, ignored=False):
28 return dirstate.walk(matcher, [], unknown, ignored)
29
30 def repoadd(repo, list):
31 add = repo[None].add
32 return add(list)
33
34 def repoforget(repo, list):
35 forget = repo[None].forget
36 return forget(list)
37 24
38 # -- Private worker functions ------------------------------------------ 25 # -- Private worker functions ------------------------------------------
39 26
40 def getminsize(ui, assumelfiles, opt, default=10): 27 def getminsize(ui, assumelfiles, opt, default=10):
41 lfsize = opt 28 lfsize = opt
136 # it. This ensures that we create it on the first meaningful 123 # it. This ensures that we create it on the first meaningful
137 # largefiles operation in a new clone. 124 # largefiles operation in a new clone.
138 if create and not os.path.exists(os.path.join(lfstoredir, 'dirstate')): 125 if create and not os.path.exists(os.path.join(lfstoredir, 'dirstate')):
139 util.makedirs(lfstoredir) 126 util.makedirs(lfstoredir)
140 matcher = getstandinmatcher(repo) 127 matcher = getstandinmatcher(repo)
141 for standin in dirstatewalk(repo.dirstate, matcher): 128 for standin in repo.dirstate.walk(matcher, [], False, False):
142 lfile = splitstandin(standin) 129 lfile = splitstandin(standin)
143 hash = readstandin(repo, lfile) 130 hash = readstandin(repo, lfile)
144 lfdirstate.normallookup(lfile) 131 lfdirstate.normallookup(lfile)
145 try: 132 try:
146 if hash == hashfile(repo.wjoin(lfile)): 133 if hash == hashfile(repo.wjoin(lfile)):
268 def standin(filename): 255 def standin(filename):
269 '''Return the repo-relative path to the standin for the specified big 256 '''Return the repo-relative path to the standin for the specified big
270 file.''' 257 file.'''
271 # Notes: 258 # Notes:
272 # 1) Some callers want an absolute path, but for instance addlargefiles 259 # 1) Some callers want an absolute path, but for instance addlargefiles
273 # needs it repo-relative so it can be passed to repoadd(). So leave 260 # needs it repo-relative so it can be passed to repo[None].add(). So
274 # it up to the caller to use repo.wjoin() to get an absolute path. 261 # leave it up to the caller to use repo.wjoin() to get an absolute path.
275 # 2) Join with '/' because that's what dirstate always uses, even on 262 # 2) Join with '/' because that's what dirstate always uses, even on
276 # Windows. Change existing separator to '/' first in case we are 263 # Windows. Change existing separator to '/' first in case we are
277 # passed filenames from an external source (like the command line). 264 # passed filenames from an external source (like the command line).
278 return shortnameslash + util.pconvert(filename) 265 return shortnameslash + util.pconvert(filename)
279 266
427 return heads 414 return heads
428 415
429 def getstandinsstate(repo): 416 def getstandinsstate(repo):
430 standins = [] 417 standins = []
431 matcher = getstandinmatcher(repo) 418 matcher = getstandinmatcher(repo)
432 for standin in dirstatewalk(repo.dirstate, matcher): 419 for standin in repo.dirstate.walk(matcher, [], False, False):
433 lfile = splitstandin(standin) 420 lfile = splitstandin(standin)
434 standins.append((lfile, readstandin(repo, lfile))) 421 standins.append((lfile, readstandin(repo, lfile)))
435 return standins 422 return standins
436 423
437 def getlfilestoupdate(oldstandins, newstandins): 424 def getlfilestoupdate(oldstandins, newstandins):