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() {
|
_hg_cmd_commit() {
|
||||||
_arguments -s -w : $_hg_global_opts $_hg_pat_opts \
|
_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:' \
|
'(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
|
||||||
'(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_file -g \*.txt' \
|
'(--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:' \
|
'(--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):
|
def docopy(ui, repo, pats, opts, wlock):
|
||||||
# called with the repo lock held
|
# 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()
|
cwd = repo.getcwd()
|
||||||
errors = 0
|
errors = 0
|
||||||
copied = []
|
copied = []
|
||||||
targets = {}
|
targets = {}
|
||||||
|
|
||||||
|
# abs: hgsep
|
||||||
|
# rel: ossep
|
||||||
|
# return: hgsep
|
||||||
def okaytocopy(abs, rel, exact):
|
def okaytocopy(abs, rel, exact):
|
||||||
reasons = {'?': _('is not managed'),
|
reasons = {'?': _('is not managed'),
|
||||||
'a': _('has been marked for add'),
|
'a': _('has been marked for add'),
|
||||||
@ -458,13 +464,18 @@ def docopy(ui, repo, pats, opts, wlock):
|
|||||||
else:
|
else:
|
||||||
return abs
|
return abs
|
||||||
|
|
||||||
|
# origsrc: hgsep
|
||||||
|
# abssrc: hgsep
|
||||||
|
# relsrc: ossep
|
||||||
|
# target: ossep
|
||||||
def copy(origsrc, abssrc, relsrc, target, exact):
|
def copy(origsrc, abssrc, relsrc, target, exact):
|
||||||
abstarget = util.canonpath(repo.root, cwd, target)
|
abstarget = util.canonpath(repo.root, cwd, target)
|
||||||
reltarget = util.pathto(cwd, abstarget)
|
reltarget = util.pathto(cwd, abstarget)
|
||||||
prevsrc = targets.get(abstarget)
|
prevsrc = targets.get(abstarget)
|
||||||
if prevsrc is not None:
|
if prevsrc is not None:
|
||||||
ui.warn(_('%s: not overwriting - %s collides with %s\n') %
|
ui.warn(_('%s: not overwriting - %s collides with %s\n') %
|
||||||
(reltarget, abssrc, prevsrc))
|
(reltarget, util.localpath(abssrc),
|
||||||
|
util.localpath(prevsrc)))
|
||||||
return
|
return
|
||||||
if (not opts['after'] and os.path.exists(reltarget) or
|
if (not opts['after'] and os.path.exists(reltarget) or
|
||||||
opts['after'] and repo.dirstate.state(abstarget) not in '?r'):
|
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)
|
repo.copy(origsrc, abstarget, wlock)
|
||||||
copied.append((abssrc, relsrc, exact))
|
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):
|
def targetpathfn(pat, dest, srcs):
|
||||||
if os.path.isdir(pat):
|
if os.path.isdir(pat):
|
||||||
abspfx = util.canonpath(repo.root, cwd, pat)
|
abspfx = util.canonpath(repo.root, cwd, pat)
|
||||||
|
abspfx = util.localpath(abspfx)
|
||||||
if destdirexists:
|
if destdirexists:
|
||||||
striplen = len(os.path.split(abspfx)[0])
|
striplen = len(os.path.split(abspfx)[0])
|
||||||
else:
|
else:
|
||||||
striplen = len(abspfx)
|
striplen = len(abspfx)
|
||||||
if striplen:
|
if striplen:
|
||||||
striplen += len(os.sep)
|
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:
|
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:
|
else:
|
||||||
res = lambda p: dest
|
res = lambda p: dest
|
||||||
return res
|
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):
|
def targetpathafterfn(pat, dest, srcs):
|
||||||
if util.patkind(pat, None)[0]:
|
if util.patkind(pat, None)[0]:
|
||||||
# a mercurial pattern
|
# 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:
|
else:
|
||||||
abspfx = util.canonpath(repo.root, cwd, pat)
|
abspfx = util.canonpath(repo.root, cwd, pat)
|
||||||
if len(abspfx) < len(srcs[0][0]):
|
if len(abspfx) < len(srcs[0][0]):
|
||||||
@ -535,11 +557,12 @@ def docopy(ui, repo, pats, opts, wlock):
|
|||||||
def evalpath(striplen):
|
def evalpath(striplen):
|
||||||
score = 0
|
score = 0
|
||||||
for s in srcs:
|
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):
|
if os.path.exists(t):
|
||||||
score += 1
|
score += 1
|
||||||
return score
|
return score
|
||||||
|
|
||||||
|
abspfx = util.localpath(abspfx)
|
||||||
striplen = len(abspfx)
|
striplen = len(abspfx)
|
||||||
if striplen:
|
if striplen:
|
||||||
striplen += len(os.sep)
|
striplen += len(os.sep)
|
||||||
@ -550,11 +573,13 @@ def docopy(ui, repo, pats, opts, wlock):
|
|||||||
striplen1 += len(os.sep)
|
striplen1 += len(os.sep)
|
||||||
if evalpath(striplen1) > score:
|
if evalpath(striplen1) > score:
|
||||||
striplen = striplen1
|
striplen = striplen1
|
||||||
res = lambda p: os.path.join(dest, p[striplen:])
|
res = lambda p: os.path.join(dest,
|
||||||
|
util.localpath(p)[striplen:])
|
||||||
else:
|
else:
|
||||||
# a file
|
# a file
|
||||||
if destdirexists:
|
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:
|
else:
|
||||||
res = lambda p: dest
|
res = lambda p: dest
|
||||||
return res
|
return res
|
||||||
|
@ -32,7 +32,11 @@ class dirstate(object):
|
|||||||
def getcwd(self):
|
def getcwd(self):
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
if cwd == self.root: return ''
|
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):
|
def hgignore(self):
|
||||||
'''return the contents of .hgignore files as a list of patterns.
|
'''return the contents of .hgignore files as a list of patterns.
|
||||||
|
@ -324,16 +324,18 @@ class localrepository(repo.repository):
|
|||||||
partial = {}
|
partial = {}
|
||||||
try:
|
try:
|
||||||
f = self.opener("branches.cache")
|
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)
|
last, lrev = bin(last), int(lrev)
|
||||||
if (lrev < self.changelog.count() and
|
if (lrev < self.changelog.count() and
|
||||||
self.changelog.node(lrev) == last): # sanity check
|
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)
|
node, label = l.rstrip().split(" ", 1)
|
||||||
partial[label] = bin(node)
|
partial[label] = bin(node)
|
||||||
else: # invalidate the cache
|
else: # invalidate the cache
|
||||||
last, lrev = nullid, nullrev
|
last, lrev = nullid, nullrev
|
||||||
f.close()
|
|
||||||
except IOError:
|
except IOError:
|
||||||
last, lrev = nullid, nullrev
|
last, lrev = nullid, nullrev
|
||||||
return partial, last, lrev
|
return partial, last, lrev
|
||||||
@ -581,12 +583,13 @@ class localrepository(repo.repository):
|
|||||||
|
|
||||||
def commit(self, files=None, text="", user=None, date=None,
|
def commit(self, files=None, text="", user=None, date=None,
|
||||||
match=util.always, force=False, lock=None, wlock=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 = []
|
commit = []
|
||||||
remove = []
|
remove = []
|
||||||
changed = []
|
changed = []
|
||||||
use_dirstate = (p1 is None) # not rawcommit
|
use_dirstate = (p1 is None) # not rawcommit
|
||||||
|
extra = extra.copy()
|
||||||
|
|
||||||
if use_dirstate:
|
if use_dirstate:
|
||||||
if files:
|
if files:
|
||||||
@ -693,7 +696,6 @@ class localrepository(repo.repository):
|
|||||||
if not lines:
|
if not lines:
|
||||||
return None
|
return None
|
||||||
text = '\n'.join(lines)
|
text = '\n'.join(lines)
|
||||||
extra = {}
|
|
||||||
if branchname:
|
if branchname:
|
||||||
extra["branch"] = branchname
|
extra["branch"] = branchname
|
||||||
n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
|
n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
|
||||||
|
@ -207,9 +207,12 @@ _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
|
|||||||
|
|
||||||
def pathto(n1, n2):
|
def pathto(n1, n2):
|
||||||
'''return the relative path from one place to another.
|
'''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)
|
if not n1: return localpath(n2)
|
||||||
a, b = n1.split('/'), n2.split('/')
|
a, b = n1.split(os.sep), n2.split('/')
|
||||||
a.reverse()
|
a.reverse()
|
||||||
b.reverse()
|
b.reverse()
|
||||||
while a and b and a[-1] == b[-1]:
|
while a and b and a[-1] == b[-1]:
|
||||||
|
Loading…
Reference in New Issue
Block a user