##// END OF EJS Templates
phabricator: handle local:commits time being string or int...
phabricator: handle local:commits time being string or int When setting local:commits arcanist has different behaviour depending on whether the repo is git or hg. With hg it sets the time as a number, since it calls PHP's strtotime on the value, but with git it sets it as a string. Normally this wouldn't be an issue since phabread wouldn't be interacting with Phabricator Revisions for git repos, but Mozilla has a secondary workflow for git users that uses the git-cinnabar tool to interact with their hg repos. When a git-cinnabar user uses the moz-phab tool to submit patches for mozilla-central it makes use of Mozilla's fork of arcanist, which works with their local git version of m-c, and thus sets the local:commit time as a string, and then translates the commit hashes. Currently when encountering such DREVS phabread dies with "TypeError: %d format: a number is required, not str". phabsend also used to set it as a string but wouldn't have encountered the issue with its own DREVs since it would read hg:meta first. Differential Revision: https://phab.mercurial-scm.org/D6650

File last commit:

r30180:736f92c4 default
r42824:c9be100e default
Show More
localstore.py
68 lines | 2.4 KiB | text/x-python | PythonLexer
various
hgext: add largefiles extension...
r15168 # Copyright 2009-2010 Gregory P. Ward
# Copyright 2009-2010 Intelerad Medical Systems Incorporated
# Copyright 2010-2011 Fog Creek Software
# Copyright 2010-2011 Unity Technologies
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
Greg Ward
largefiles: improve comments, internal docstrings...
r15252 '''store class for local filesystem'''
liscju
py3: make largefiles/localstore.py use absolute_import
r29310 from __future__ import absolute_import
various
hgext: add largefiles extension...
r15168
from mercurial.i18n import _
Mads Kiilerich
largefiles: always use filechunkiter when iterating files...
r30180 from mercurial import util
various
hgext: add largefiles extension...
r15168
liscju
py3: make largefiles/localstore.py use absolute_import
r29310 from . import (
basestore,
lfutil,
)
various
hgext: add largefiles extension...
r15168
class localstore(basestore.basestore):
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 '''localstore first attempts to grab files out of the store in the remote
Mads Kiilerich
fix trivial spelling errors
r17424 Mercurial repository. Failing that, it attempts to grab the files from
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 the user cache.'''
various
hgext: add largefiles extension...
r15168
def __init__(self, ui, repo, remote):
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 self.remote = remote.local()
Mads Kiilerich
largefiles: cleanup of warnings on errors getting largefiles...
r18155 super(localstore, self).__init__(ui, repo, self.remote.url())
various
hgext: add largefiles extension...
r15168
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 def put(self, source, hash):
if lfutil.instore(self.remote, hash):
return
Mads Kiilerich
largefiles: 'put' should store 'source' file in under 'hash', also in localstore
r19007 lfutil.link(source, lfutil.storepath(self.remote, hash))
various
hgext: add largefiles extension...
r15168
Matt Harbison
largefiles: adjust localstore to handle batch statlfile requests (issue3583)...
r17411 def exists(self, hashes):
retval = {}
for hash in hashes:
retval[hash] = lfutil.instore(self.remote, hash)
return retval
various
hgext: add largefiles extension...
r15168 def _getfile(self, tmpfile, filename, hash):
Mads Kiilerich
largefiles: refactoring - use findfile in localstore._getfile
r19000 path = lfutil.findfile(self.remote, hash)
if not path:
Mads Kiilerich
largefiles: cleanup of warnings on errors getting largefiles...
r18155 raise basestore.StoreError(filename, hash, self.url,
Martin Geisler
largefiles: lowercase messages
r16928 _("can't get file locally"))
Bryan O'Sullivan
largefiles: use a context manager in _getfile
r27769 with open(path, 'rb') as fd:
Mads Kiilerich
largefiles: always use filechunkiter when iterating files...
r30180 return lfutil.copyandhash(
util.filechunkiter(fd), tmpfile)
various
hgext: add largefiles extension...
r15168
liscju
largefiles: change basestore._verifyfile to take list of files to check...
r29067 def _verifyfiles(self, contents, filestocheck):
failed = False
for cset, filename, expectedhash in filestocheck:
liscju
largefiles: check file in the repo store before checking remotely (issue5257)...
r29421 storepath, exists = lfutil.findstorepath(self.repo, expectedhash)
if not exists:
storepath, exists = lfutil.findstorepath(
self.remote, expectedhash)
liscju
largefiles: change basestore._verifyfile to take list of files to check...
r29067 if not exists:
various
hgext: add largefiles extension...
r15168 self.ui.warn(
liscju
largefiles: change basestore._verifyfile to take list of files to check...
r29067 _('changeset %s: %s references missing %s\n')
Mads Kiilerich
largefiles: report localstore errors with single line warnings messages...
r18545 % (cset, filename, storepath))
liscju
largefiles: change basestore._verifyfile to take list of files to check...
r29067 failed = True
elif contents:
actualhash = lfutil.hashfile(storepath)
if actualhash != expectedhash:
self.ui.warn(
_('changeset %s: %s references corrupted %s\n')
% (cset, filename, storepath))
failed = True
return failed