mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
merge with mpm
This commit is contained in:
commit
3e789a3783
@ -162,22 +162,24 @@ def colorqseries(orig, ui, repo, *dummy, **opts):
|
||||
_patch_effects = { 'applied': ['blue', 'bold', 'underline'],
|
||||
'missing': ['red', 'bold'],
|
||||
'unapplied': ['black', 'bold'], }
|
||||
def colorwrap(orig, s):
|
||||
def colorwrap(orig, *args):
|
||||
'''wrap ui.write for colored diff output'''
|
||||
lines = s.split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
stripline = line
|
||||
if line and line[0] in '+-':
|
||||
# highlight trailing whitespace, but only in changed lines
|
||||
stripline = line.rstrip()
|
||||
for prefix, style in _diff_prefixes:
|
||||
if stripline.startswith(prefix):
|
||||
lines[i] = render_effects(stripline, _diff_effects[style])
|
||||
break
|
||||
if line != stripline:
|
||||
lines[i] += render_effects(
|
||||
line[len(stripline):], _diff_effects['trailingwhitespace'])
|
||||
orig('\n'.join(lines))
|
||||
def _colorize(s):
|
||||
lines = s.split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
stripline = line
|
||||
if line and line[0] in '+-':
|
||||
# highlight trailing whitespace, but only in changed lines
|
||||
stripline = line.rstrip()
|
||||
for prefix, style in _diff_prefixes:
|
||||
if stripline.startswith(prefix):
|
||||
lines[i] = render_effects(stripline, _diff_effects[style])
|
||||
break
|
||||
if line != stripline:
|
||||
lines[i] += render_effects(
|
||||
line[len(stripline):], _diff_effects['trailingwhitespace'])
|
||||
return '\n'.join(lines)
|
||||
orig(*[_colorize(s) for s in args])
|
||||
|
||||
def colorshowpatch(orig, self, node):
|
||||
'''wrap cmdutil.changeset_printer.showpatch with colored output'''
|
||||
@ -234,6 +236,13 @@ def uisetup(ui):
|
||||
# The mq extension is not enabled
|
||||
pass
|
||||
|
||||
try:
|
||||
rec = extensions.find('record')
|
||||
_setupcmd(ui, 'record', rec.cmdtable, colordiff, _diff_effects)
|
||||
except KeyError:
|
||||
# The record extension is not enabled
|
||||
pass
|
||||
|
||||
def _setupcmd(ui, cmd, table, func, effectsmap):
|
||||
'''patch in command to command table and load effect map'''
|
||||
def nocolor(orig, *args, **opts):
|
||||
|
1486
i18n/da.po
1486
i18n/da.po
File diff suppressed because it is too large
Load Diff
3555
i18n/de.po
3555
i18n/de.po
File diff suppressed because it is too large
Load Diff
2507
i18n/pt_BR.po
2507
i18n/pt_BR.po
File diff suppressed because it is too large
Load Diff
9006
i18n/sv.po
Normal file
9006
i18n/sv.po
Normal file
File diff suppressed because it is too large
Load Diff
@ -652,9 +652,8 @@ class changeset_printer(object):
|
||||
return
|
||||
|
||||
log = self.repo.changelog
|
||||
changes = log.read(changenode)
|
||||
date = util.datestr(changes[2])
|
||||
extra = changes[5]
|
||||
date = util.datestr(ctx.date())
|
||||
extra = ctx.extra()
|
||||
branch = extra.get("branch")
|
||||
|
||||
hexfunc = self.ui.debugflag and hex or short
|
||||
@ -674,9 +673,10 @@ class changeset_printer(object):
|
||||
self.ui.write(_("parent: %d:%s\n") % parent)
|
||||
|
||||
if self.ui.debugflag:
|
||||
mnode = ctx.manifestnode()
|
||||
self.ui.write(_("manifest: %d:%s\n") %
|
||||
(self.repo.manifest.rev(changes[0]), hex(changes[0])))
|
||||
self.ui.write(_("user: %s\n") % changes[1])
|
||||
(self.repo.manifest.rev(mnode), hex(mnode)))
|
||||
self.ui.write(_("user: %s\n") % ctx.user())
|
||||
self.ui.write(_("date: %s\n") % date)
|
||||
|
||||
if self.ui.debugflag:
|
||||
@ -685,8 +685,8 @@ class changeset_printer(object):
|
||||
files):
|
||||
if value:
|
||||
self.ui.write("%-12s %s\n" % (key, " ".join(value)))
|
||||
elif changes[3] and self.ui.verbose:
|
||||
self.ui.write(_("files: %s\n") % " ".join(changes[3]))
|
||||
elif ctx.files() and self.ui.verbose:
|
||||
self.ui.write(_("files: %s\n") % " ".join(ctx.files()))
|
||||
if copies and self.ui.verbose:
|
||||
copies = ['%s (%s)' % c for c in copies]
|
||||
self.ui.write(_("copies: %s\n") % ' '.join(copies))
|
||||
@ -696,7 +696,7 @@ class changeset_printer(object):
|
||||
self.ui.write(_("extra: %s=%s\n")
|
||||
% (key, value.encode('string_escape')))
|
||||
|
||||
description = changes[4].strip()
|
||||
description = ctx.description().strip()
|
||||
if description:
|
||||
if self.ui.verbose:
|
||||
self.ui.write(_("description:\n"))
|
||||
|
@ -299,6 +299,7 @@ class filectx(object):
|
||||
def files(self): return self._changectx.files()
|
||||
def description(self): return self._changectx.description()
|
||||
def branch(self): return self._changectx.branch()
|
||||
def extra(self): return self._changectx.extra()
|
||||
def manifest(self): return self._changectx.manifest()
|
||||
def changectx(self): return self._changectx
|
||||
|
||||
|
@ -13,6 +13,7 @@ posixfile = open
|
||||
nulldev = '/dev/null'
|
||||
normpath = os.path.normpath
|
||||
samestat = os.path.samestat
|
||||
rename = os.rename
|
||||
expandglobs = False
|
||||
|
||||
umask = os.umask(0)
|
||||
|
@ -16,7 +16,7 @@ hide platform-specific details from the core.
|
||||
from i18n import _
|
||||
import error, osutil, encoding
|
||||
import cStringIO, errno, re, shutil, sys, tempfile, traceback
|
||||
import os, stat, time, calendar, random, textwrap
|
||||
import os, stat, time, calendar, textwrap
|
||||
import imp
|
||||
|
||||
# Python compatibility
|
||||
@ -399,44 +399,6 @@ def lexists(filename):
|
||||
return False
|
||||
return True
|
||||
|
||||
def rename(src, dst):
|
||||
"""forcibly rename a file"""
|
||||
try:
|
||||
os.rename(src, dst)
|
||||
except OSError, err: # FIXME: check err (EEXIST ?)
|
||||
|
||||
# On windows, rename to existing file is not allowed, so we
|
||||
# must delete destination first. But if a file is open, unlink
|
||||
# schedules it for delete but does not delete it. Rename
|
||||
# happens immediately even for open files, so we rename
|
||||
# destination to a temporary name, then delete that. Then
|
||||
# rename is safe to do.
|
||||
# The temporary name is chosen at random to avoid the situation
|
||||
# where a file is left lying around from a previous aborted run.
|
||||
# The usual race condition this introduces can't be avoided as
|
||||
# we need the name to rename into, and not the file itself. Due
|
||||
# to the nature of the operation however, any races will at worst
|
||||
# lead to the rename failing and the current operation aborting.
|
||||
|
||||
def tempname(prefix):
|
||||
for tries in xrange(10):
|
||||
temp = '%s-%08x' % (prefix, random.randint(0, 0xffffffff))
|
||||
if not os.path.exists(temp):
|
||||
return temp
|
||||
raise IOError, (errno.EEXIST, "No usable temporary filename found")
|
||||
|
||||
temp = tempname(dst)
|
||||
os.rename(dst, temp)
|
||||
try:
|
||||
os.unlink(temp)
|
||||
except:
|
||||
# Some rude AV-scanners on Windows may cause the unlink to
|
||||
# fail. Not aborting here just leaks the temp file, whereas
|
||||
# aborting at this point may leave serious inconsistencies.
|
||||
# Ideally, we would notify the user here.
|
||||
pass
|
||||
os.rename(src, dst)
|
||||
|
||||
def unlink(f):
|
||||
"""unlink and remove the directory if it is empty"""
|
||||
os.unlink(f)
|
||||
@ -1259,6 +1221,11 @@ def termwidth():
|
||||
return array.array('h', arri)[1]
|
||||
except ValueError:
|
||||
pass
|
||||
except IOError, e:
|
||||
if e[0] == errno.EINVAL:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
except ImportError:
|
||||
pass
|
||||
return 80
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
from i18n import _
|
||||
import osutil, error
|
||||
import errno, msvcrt, os, re, sys
|
||||
import errno, msvcrt, os, re, sys, random
|
||||
|
||||
nulldev = 'NUL:'
|
||||
umask = 002
|
||||
@ -283,6 +283,44 @@ def unlink(f):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def rename(src, dst):
|
||||
'''atomically rename file src to dst, replacing dst if it exists'''
|
||||
try:
|
||||
os.rename(src, dst)
|
||||
except OSError, err: # FIXME: check err (EEXIST ?)
|
||||
|
||||
# On windows, rename to existing file is not allowed, so we
|
||||
# must delete destination first. But if a file is open, unlink
|
||||
# schedules it for delete but does not delete it. Rename
|
||||
# happens immediately even for open files, so we rename
|
||||
# destination to a temporary name, then delete that. Then
|
||||
# rename is safe to do.
|
||||
# The temporary name is chosen at random to avoid the situation
|
||||
# where a file is left lying around from a previous aborted run.
|
||||
# The usual race condition this introduces can't be avoided as
|
||||
# we need the name to rename into, and not the file itself. Due
|
||||
# to the nature of the operation however, any races will at worst
|
||||
# lead to the rename failing and the current operation aborting.
|
||||
|
||||
def tempname(prefix):
|
||||
for tries in xrange(10):
|
||||
temp = '%s-%08x' % (prefix, random.randint(0, 0xffffffff))
|
||||
if not os.path.exists(temp):
|
||||
return temp
|
||||
raise IOError, (errno.EEXIST, "No usable temporary filename found")
|
||||
|
||||
temp = tempname(dst)
|
||||
os.rename(dst, temp)
|
||||
try:
|
||||
os.unlink(temp)
|
||||
except:
|
||||
# Some rude AV-scanners on Windows may cause the unlink to
|
||||
# fail. Not aborting here just leaks the temp file, whereas
|
||||
# aborting at this point may leave serious inconsistencies.
|
||||
# Ideally, we would notify the user here.
|
||||
pass
|
||||
os.rename(src, dst)
|
||||
|
||||
try:
|
||||
# override functions with win32 versions if possible
|
||||
from win32 import *
|
||||
|
Loading…
Reference in New Issue
Block a user