mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
07292913da
Summary: move p4fastimport under hgext3rd as that's where it belongs. Also has the benefit that we package it up. Test Plan: rt test-p4* Reviewers: #mercurial, quark Reviewed By: quark Subscribers: mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5056664 Signature: t1:5056664:1494631758:4892f47922d8fbbd2c1f7793f3f29ee73fa8fa42
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
# (c) 2017-present Facebook Inc.
|
|
from __future__ import absolute_import
|
|
|
|
import collections
|
|
import os
|
|
|
|
from mercurial import worker
|
|
|
|
def localpath(p):
|
|
return p.lstrip('/')
|
|
|
|
def storepath(b, p, ci=False):
|
|
p = os.path.join(b, p)
|
|
if ci:
|
|
p = p.lower()
|
|
return p
|
|
|
|
def caseconflict(filelist):
|
|
temp = {}
|
|
conflicts = []
|
|
for this in filelist:
|
|
if this.lower() in temp:
|
|
other = temp[this.lower()]
|
|
if this != other:
|
|
conflicts.append(sorted([this, other]))
|
|
temp[this.lower()] = this
|
|
return sorted(conflicts)
|
|
|
|
def decodefileflags(json):
|
|
r = collections.defaultdict(dict)
|
|
for changelist, flag in json.items():
|
|
r[int(changelist)] = flag.encode('ascii')
|
|
return r
|
|
|
|
def lastcl(node):
|
|
if node:
|
|
assert node.extra().get('p4changelist')
|
|
return int(node.extra()['p4changelist']) + 1
|
|
return None
|
|
|
|
def runworker(ui, fn, wargs, items):
|
|
# 0.4 is the cost per argument. So if we have at least 100 files
|
|
# on a 4 core machine than our linear cost outweights the
|
|
# drawback of spwaning. We are overwritign this if we force a
|
|
# worker to run with a ridiculous high number.
|
|
weight = 0.0 # disable worker
|
|
if ui.config('p4fastimport', 'useworker', None) == 'force':
|
|
weight = 100000.0 # force worker
|
|
elif ui.configbool('p4fastimport', 'useworker', False):
|
|
weight = 0.04 # normal weight
|
|
|
|
# Fix duplicated messages before
|
|
# https://www.mercurial-scm.org/repo/hg-committed/rev/9d3d56aa1a9f
|
|
ui.flush()
|
|
return worker.worker(ui, weight, fn, wargs, items)
|
|
|