Changeset 9e5f67217e8e…
Parent 53d9e75793ca…
by Andrew Pritchard <andrewp@fogcreek.com>
Changes to 2 files · Browse files at 9e5f67217e8e Showing diff from parent 53d9e75793ca Diff from another changeset...
@@ -399,34 +399,20 @@ continue
if os.path.exists(repo.wjoin(lfutil.standin(lfile + '.orig'))):
shutil.copyfile(repo.wjoin(lfile), repo.wjoin(lfile + '.orig'))
- expectedhash = repo[None][lfutil.standin(lfile)].data().strip()
+ expectedhash = lfutil.readstandin(repo, lfile)
mode = os.stat(repo.wjoin(lfutil.standin(lfile))).st_mode
if not os.path.exists(repo.wjoin(lfile)) or expectedhash != \
- lfutil.hashfile(repo.wjoin(lfile)):
- path = lfutil.findfile(repo, expectedhash)
- if path is not None:
- util.makedirs(os.path.dirname(repo.wjoin(lfile)))
- shutil.copy(path, repo.wjoin(lfile))
- os.chmod(repo.wjoin(lfile), mode)
- if lfutil.standin(lfile) not in repo['.']:
- lfdirstate.add(lfutil.unixpath(lfile))
- elif expectedhash == repo['.'][lfutil.standin(lfile)] \
- .data().strip():
- lfdirstate.normal(lfutil.unixpath(lfile))
- else:
- lfutil.dirstate_normaldirty(lfdirstate,
- lfutil.unixpath(lfile))
- elif os.path.exists(repo.wjoin(lfile)) and mode != \
+ lfutil.hashrepofile(repo, lfile):
+ lfutil.copyfromcache(repo, expectedhash, lfile)
+ if os.path.exists(repo.wjoin(lfile)) and mode != \
os.stat(repo.wjoin(lfile)).st_mode:
os.chmod(repo.wjoin(lfile), mode)
- if lfutil.standin(lfile) not in repo['.']:
- lfdirstate.add(lfutil.unixpath(lfile))
- elif expectedhash == \
- repo['.'][lfutil.standin(lfile)].data().strip():
- lfdirstate.normal(lfutil.unixpath(lfile))
- else:
- lfutil.dirstate_normaldirty(lfdirstate,
- lfutil.unixpath(lfile))
+ if lfutil.standin(lfile) not in repo['.']:
+ lfdirstate.add(lfile)
+ elif expectedhash == lfutil.readstandin(repo, lfile, '.'):
+ lfdirstate.normal(lfile)
+ else:
+ lfutil.dirstate_normaldirty(lfdirstate, lfile)
removed = 0
for lfile in lfdirstate:
@@ -436,9 +422,9 @@ os.unlink(repo.wjoin(lfile))
removed += 1
if lfutil.standin(lfile) in repo['.']:
- lfdirstate.remove(lfutil.unixpath(lfile))
+ lfdirstate.remove(lfile)
else:
- lfdirstate.forget(lfutil.unixpath(lfile))
+ lfdirstate.forget(lfile)
else:
state = repo.dirstate[lfutil.standin(lfile)]
if state == 'n':
|
@@ -97,7 +97,7 @@ dirstate._map[f] = ('n', 0, -2, -1)
if f in dirstate._copymap:
del dirstate._copymap[f]
- normaldirty(file)
+ normaldirty(unixpath(file))
def findoutgoing(repo, remote, force):
# First attempt is for Mercurial <= 1.5 second is for >= 1.6
@@ -159,6 +159,16 @@ return systemcachepath(repo.ui, hash)
return None
+class largefiles_dirstate(dirstate.dirstate):
+ def normal(self, f):
+ return super(largefiles_dirstate, self).normal(unixpath(f))
+ def remove(self, f):
+ return super(largefiles_dirstate, self).remove(unixpath(f))
+ def add(self, f):
+ return super(largefiles_dirstate, self).add(unixpath(f))
+ def drop(self, f):
+ return super(largefiles_dirstate, self).drop(unixpath(f))
+
def openlfdirstate(ui, repo):
'''
Return a dirstate object that tracks big files: i.e. its root is the
@@ -172,10 +182,10 @@ # Mercurial <= 1.8
opener = util.opener(admin)
if hasattr(repo.dirstate, '_validate'):
- lfdirstate = dirstate.dirstate(opener, ui, repo.root,
+ lfdirstate = largefiles_dirstate(opener, ui, repo.root,
repo.dirstate._validate)
else:
- lfdirstate = dirstate.dirstate(opener, ui, repo.root)
+ lfdirstate = largefiles_dirstate(opener, ui, repo.root)
# If the lfiles dirstate does not exist, populate and create it. This
# ensures that we create it on the first meaningful largefiles operation in
@@ -252,6 +262,18 @@def cachepath(repo, hash):
return repo.join(os.path.join(longname, hash))
+def copyfromcache(repo, hash, filename):
+ '''copyfromcache copies the specified largefile from the repo or system
+ cache to the specified location in the repository. It will not throw an
+ exception on failure, as it is meant to be called only after ensuring that
+ the needed largefile exists in the cache.'''
+ path = findfile(repo, hash)
+ if path is None:
+ return False
+ util.makedirs(os.path.dirname(repo.wjoin(filename)))
+ shutil.copy(path, repo.wjoin(filename))
+ return True
+
def copytocache(repo, rev, file, uploaded=False):
hash = readstandin(repo, file)
if incache(repo, hash):
|
Loading...