mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
Merge with crew.
This commit is contained in:
commit
55e3c776d7
@ -377,7 +377,7 @@ _hg_cmd_clone() {
|
||||
|
||||
_hg_cmd_commit() {
|
||||
_arguments -s -w : $_hg_global_opts $_hg_pat_opts \
|
||||
'(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]'
|
||||
'(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
|
||||
'(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
|
||||
'(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_file -g \*.txt' \
|
||||
'(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
|
||||
|
@ -437,11 +437,17 @@ def commit(ui, repo, *pats, **opts):
|
||||
|
||||
def docopy(ui, repo, pats, opts, wlock):
|
||||
# called with the repo lock held
|
||||
#
|
||||
# hgsep => pathname that uses "/" to separate directories
|
||||
# ossep => pathname that uses os.sep to separate directories
|
||||
cwd = repo.getcwd()
|
||||
errors = 0
|
||||
copied = []
|
||||
targets = {}
|
||||
|
||||
# abs: hgsep
|
||||
# rel: ossep
|
||||
# return: hgsep
|
||||
def okaytocopy(abs, rel, exact):
|
||||
reasons = {'?': _('is not managed'),
|
||||
'a': _('has been marked for add'),
|
||||
@ -458,13 +464,18 @@ def docopy(ui, repo, pats, opts, wlock):
|
||||
else:
|
||||
return abs
|
||||
|
||||
# origsrc: hgsep
|
||||
# abssrc: hgsep
|
||||
# relsrc: ossep
|
||||
# target: ossep
|
||||
def copy(origsrc, abssrc, relsrc, target, exact):
|
||||
abstarget = util.canonpath(repo.root, cwd, target)
|
||||
reltarget = util.pathto(cwd, abstarget)
|
||||
prevsrc = targets.get(abstarget)
|
||||
if prevsrc is not None:
|
||||
ui.warn(_('%s: not overwriting - %s collides with %s\n') %
|
||||
(reltarget, abssrc, prevsrc))
|
||||
(reltarget, util.localpath(abssrc),
|
||||
util.localpath(prevsrc)))
|
||||
return
|
||||
if (not opts['after'] and os.path.exists(reltarget) or
|
||||
opts['after'] and repo.dirstate.state(abstarget) not in '?r'):
|
||||
@ -507,26 +518,37 @@ def docopy(ui, repo, pats, opts, wlock):
|
||||
repo.copy(origsrc, abstarget, wlock)
|
||||
copied.append((abssrc, relsrc, exact))
|
||||
|
||||
# pat: ossep
|
||||
# dest ossep
|
||||
# srcs: list of (hgsep, hgsep, ossep, bool)
|
||||
# return: function that takes hgsep and returns ossep
|
||||
def targetpathfn(pat, dest, srcs):
|
||||
if os.path.isdir(pat):
|
||||
abspfx = util.canonpath(repo.root, cwd, pat)
|
||||
abspfx = util.localpath(abspfx)
|
||||
if destdirexists:
|
||||
striplen = len(os.path.split(abspfx)[0])
|
||||
else:
|
||||
striplen = len(abspfx)
|
||||
if striplen:
|
||||
striplen += len(os.sep)
|
||||
res = lambda p: os.path.join(dest, p[striplen:])
|
||||
res = lambda p: os.path.join(dest, util.localpath(p)[striplen:])
|
||||
elif destdirexists:
|
||||
res = lambda p: os.path.join(dest, os.path.basename(p))
|
||||
res = lambda p: os.path.join(dest,
|
||||
os.path.basename(util.localpath(p)))
|
||||
else:
|
||||
res = lambda p: dest
|
||||
return res
|
||||
|
||||
# pat: ossep
|
||||
# dest ossep
|
||||
# srcs: list of (hgsep, hgsep, ossep, bool)
|
||||
# return: function that takes hgsep and returns ossep
|
||||
def targetpathafterfn(pat, dest, srcs):
|
||||
if util.patkind(pat, None)[0]:
|
||||
# a mercurial pattern
|
||||
res = lambda p: os.path.join(dest, os.path.basename(p))
|
||||
res = lambda p: os.path.join(dest,
|
||||
os.path.basename(util.localpath(p)))
|
||||
else:
|
||||
abspfx = util.canonpath(repo.root, cwd, pat)
|
||||
if len(abspfx) < len(srcs[0][0]):
|
||||
@ -535,11 +557,12 @@ def docopy(ui, repo, pats, opts, wlock):
|
||||
def evalpath(striplen):
|
||||
score = 0
|
||||
for s in srcs:
|
||||
t = os.path.join(dest, s[0][striplen:])
|
||||
t = os.path.join(dest, util.localpath(s[0])[striplen:])
|
||||
if os.path.exists(t):
|
||||
score += 1
|
||||
return score
|
||||
|
||||
abspfx = util.localpath(abspfx)
|
||||
striplen = len(abspfx)
|
||||
if striplen:
|
||||
striplen += len(os.sep)
|
||||
@ -550,11 +573,13 @@ def docopy(ui, repo, pats, opts, wlock):
|
||||
striplen1 += len(os.sep)
|
||||
if evalpath(striplen1) > score:
|
||||
striplen = striplen1
|
||||
res = lambda p: os.path.join(dest, p[striplen:])
|
||||
res = lambda p: os.path.join(dest,
|
||||
util.localpath(p)[striplen:])
|
||||
else:
|
||||
# a file
|
||||
if destdirexists:
|
||||
res = lambda p: os.path.join(dest, os.path.basename(p))
|
||||
res = lambda p: os.path.join(dest,
|
||||
os.path.basename(util.localpath(p)))
|
||||
else:
|
||||
res = lambda p: dest
|
||||
return res
|
||||
|
@ -32,7 +32,11 @@ class dirstate(object):
|
||||
def getcwd(self):
|
||||
cwd = os.getcwd()
|
||||
if cwd == self.root: return ''
|
||||
return cwd[len(self.root) + 1:]
|
||||
# self.root ends with a path separator if self.root is '/' or 'C:\'
|
||||
common_prefix_len = len(self.root)
|
||||
if not self.root.endswith(os.sep):
|
||||
common_prefix_len += 1
|
||||
return cwd[common_prefix_len:]
|
||||
|
||||
def hgignore(self):
|
||||
'''return the contents of .hgignore files as a list of patterns.
|
||||
|
@ -324,16 +324,18 @@ class localrepository(repo.repository):
|
||||
partial = {}
|
||||
try:
|
||||
f = self.opener("branches.cache")
|
||||
last, lrev = f.readline().rstrip().split(" ", 1)
|
||||
lines = f.read().split('\n')
|
||||
f.close()
|
||||
last, lrev = lines.pop(0).rstrip().split(" ", 1)
|
||||
last, lrev = bin(last), int(lrev)
|
||||
if (lrev < self.changelog.count() and
|
||||
self.changelog.node(lrev) == last): # sanity check
|
||||
for l in f:
|
||||
for l in lines:
|
||||
if not l: continue
|
||||
node, label = l.rstrip().split(" ", 1)
|
||||
partial[label] = bin(node)
|
||||
else: # invalidate the cache
|
||||
last, lrev = nullid, nullrev
|
||||
f.close()
|
||||
except IOError:
|
||||
last, lrev = nullid, nullrev
|
||||
return partial, last, lrev
|
||||
@ -581,12 +583,13 @@ class localrepository(repo.repository):
|
||||
|
||||
def commit(self, files=None, text="", user=None, date=None,
|
||||
match=util.always, force=False, lock=None, wlock=None,
|
||||
force_editor=False, p1=None, p2=None):
|
||||
force_editor=False, p1=None, p2=None, extra={}):
|
||||
|
||||
commit = []
|
||||
remove = []
|
||||
changed = []
|
||||
use_dirstate = (p1 is None) # not rawcommit
|
||||
extra = extra.copy()
|
||||
|
||||
if use_dirstate:
|
||||
if files:
|
||||
@ -693,7 +696,6 @@ class localrepository(repo.repository):
|
||||
if not lines:
|
||||
return None
|
||||
text = '\n'.join(lines)
|
||||
extra = {}
|
||||
if branchname:
|
||||
extra["branch"] = branchname
|
||||
n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
|
||||
|
@ -207,9 +207,12 @@ _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
|
||||
|
||||
def pathto(n1, n2):
|
||||
'''return the relative path from one place to another.
|
||||
this returns a path in the form used by the local filesystem, not hg.'''
|
||||
n1 should use os.sep to separate directories
|
||||
n2 should use "/" to separate directories
|
||||
returns an os.sep-separated path.
|
||||
'''
|
||||
if not n1: return localpath(n2)
|
||||
a, b = n1.split('/'), n2.split('/')
|
||||
a, b = n1.split(os.sep), n2.split('/')
|
||||
a.reverse()
|
||||
b.reverse()
|
||||
while a and b and a[-1] == b[-1]:
|
||||
|
Loading…
Reference in New Issue
Block a user