11 |
11 |
12 This contains helper routines that are independent of the SCM core and |
12 This contains helper routines that are independent of the SCM core and |
13 hide platform-specific details from the core. |
13 hide platform-specific details from the core. |
14 """ |
14 """ |
15 |
15 |
16 import i18n |
16 from __future__ import absolute_import |
17 _ = i18n._ |
17 |
18 import error, osutil, encoding, parsers |
18 import bz2 |
19 import errno, shutil, sys, tempfile, traceback |
19 import calendar |
|
20 import collections |
|
21 import datetime |
|
22 import errno |
|
23 import gc |
|
24 import hashlib |
|
25 import imp |
|
26 import os |
20 import re as remod |
27 import re as remod |
21 import os, time, datetime, calendar, textwrap, signal, collections |
28 import shutil |
22 import imp, socket, urllib |
29 import signal |
23 import gc |
30 import socket |
24 import bz2 |
31 import subprocess |
|
32 import sys |
|
33 import tempfile |
|
34 import textwrap |
|
35 import time |
|
36 import traceback |
|
37 import urllib |
25 import zlib |
38 import zlib |
26 import hashlib |
39 |
|
40 from . import ( |
|
41 encoding, |
|
42 error, |
|
43 i18n, |
|
44 osutil, |
|
45 parsers, |
|
46 ) |
27 |
47 |
28 if os.name == 'nt': |
48 if os.name == 'nt': |
29 import windows as platform |
49 from . import windows as platform |
30 else: |
50 else: |
31 import posix as platform |
51 from . import posix as platform |
32 |
52 |
33 md5 = hashlib.md5 |
53 md5 = hashlib.md5 |
34 sha1 = hashlib.sha1 |
54 sha1 = hashlib.sha1 |
35 sha512 = hashlib.sha512 |
55 sha512 = hashlib.sha512 |
|
56 _ = i18n._ |
36 |
57 |
37 cachestat = platform.cachestat |
58 cachestat = platform.cachestat |
38 checkexec = platform.checkexec |
59 checkexec = platform.checkexec |
39 checklink = platform.checklink |
60 checklink = platform.checklink |
40 copymode = platform.copymode |
61 copymode = platform.copymode |
198 return sliceable[offset:] |
219 return sliceable[offset:] |
199 else: |
220 else: |
200 def buffer(sliceable, offset=0): |
221 def buffer(sliceable, offset=0): |
201 return memoryview(sliceable)[offset:] |
222 return memoryview(sliceable)[offset:] |
202 |
223 |
203 import subprocess |
|
204 closefds = os.name == 'posix' |
224 closefds = os.name == 'posix' |
205 |
225 |
206 _chunksize = 4096 |
226 _chunksize = 4096 |
207 |
227 |
208 class bufferedinputpipe(object): |
228 class bufferedinputpipe(object): |
324 return p.stdin, p.stdout, p.stderr, p |
344 return p.stdin, p.stdout, p.stderr, p |
325 |
345 |
326 def version(): |
346 def version(): |
327 """Return version information if available.""" |
347 """Return version information if available.""" |
328 try: |
348 try: |
329 import __version__ |
349 from . import __version__ |
330 return __version__.version |
350 return __version__.version |
331 except ImportError: |
351 except ImportError: |
332 return 'unknown' |
352 return 'unknown' |
333 |
353 |
334 def versiontuple(v=None, n=4): |
354 def versiontuple(v=None, n=4): |