Show More
@@ -11,7 +11,6 b' import difflib' | |||||
11 | import errno |
|
11 | import errno | |
12 | import os |
|
12 | import os | |
13 | import re |
|
13 | import re | |
14 | import socket |
|
|||
15 | import string |
|
14 | import string | |
16 | import time |
|
15 | import time | |
17 |
|
16 | |||
@@ -1862,78 +1861,6 b' def copy(ui, repo, *pats, **opts):' | |||||
1862 | with repo.wlock(False): |
|
1861 | with repo.wlock(False): | |
1863 | return cmdutil.copy(ui, repo, pats, opts) |
|
1862 | return cmdutil.copy(ui, repo, pats, opts) | |
1864 |
|
1863 | |||
1865 | @command('debuglocks', |
|
|||
1866 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
|
|||
1867 | ('W', 'force-wlock', None, |
|
|||
1868 | _('free the working state lock (DANGEROUS)'))], |
|
|||
1869 | _('[OPTION]...')) |
|
|||
1870 | def debuglocks(ui, repo, **opts): |
|
|||
1871 | """show or modify state of locks |
|
|||
1872 |
|
||||
1873 | By default, this command will show which locks are held. This |
|
|||
1874 | includes the user and process holding the lock, the amount of time |
|
|||
1875 | the lock has been held, and the machine name where the process is |
|
|||
1876 | running if it's not local. |
|
|||
1877 |
|
||||
1878 | Locks protect the integrity of Mercurial's data, so should be |
|
|||
1879 | treated with care. System crashes or other interruptions may cause |
|
|||
1880 | locks to not be properly released, though Mercurial will usually |
|
|||
1881 | detect and remove such stale locks automatically. |
|
|||
1882 |
|
||||
1883 | However, detecting stale locks may not always be possible (for |
|
|||
1884 | instance, on a shared filesystem). Removing locks may also be |
|
|||
1885 | blocked by filesystem permissions. |
|
|||
1886 |
|
||||
1887 | Returns 0 if no locks are held. |
|
|||
1888 |
|
||||
1889 | """ |
|
|||
1890 |
|
||||
1891 | if opts.get('force_lock'): |
|
|||
1892 | repo.svfs.unlink('lock') |
|
|||
1893 | if opts.get('force_wlock'): |
|
|||
1894 | repo.vfs.unlink('wlock') |
|
|||
1895 | if opts.get('force_lock') or opts.get('force_lock'): |
|
|||
1896 | return 0 |
|
|||
1897 |
|
||||
1898 | now = time.time() |
|
|||
1899 | held = 0 |
|
|||
1900 |
|
||||
1901 | def report(vfs, name, method): |
|
|||
1902 | # this causes stale locks to get reaped for more accurate reporting |
|
|||
1903 | try: |
|
|||
1904 | l = method(False) |
|
|||
1905 | except error.LockHeld: |
|
|||
1906 | l = None |
|
|||
1907 |
|
||||
1908 | if l: |
|
|||
1909 | l.release() |
|
|||
1910 | else: |
|
|||
1911 | try: |
|
|||
1912 | stat = vfs.lstat(name) |
|
|||
1913 | age = now - stat.st_mtime |
|
|||
1914 | user = util.username(stat.st_uid) |
|
|||
1915 | locker = vfs.readlock(name) |
|
|||
1916 | if ":" in locker: |
|
|||
1917 | host, pid = locker.split(':') |
|
|||
1918 | if host == socket.gethostname(): |
|
|||
1919 | locker = 'user %s, process %s' % (user, pid) |
|
|||
1920 | else: |
|
|||
1921 | locker = 'user %s, process %s, host %s' \ |
|
|||
1922 | % (user, pid, host) |
|
|||
1923 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
|
|||
1924 | return 1 |
|
|||
1925 | except OSError as e: |
|
|||
1926 | if e.errno != errno.ENOENT: |
|
|||
1927 | raise |
|
|||
1928 |
|
||||
1929 | ui.write(("%-6s free\n") % (name + ":")) |
|
|||
1930 | return 0 |
|
|||
1931 |
|
||||
1932 | held += report(repo.svfs, "lock", repo.lock) |
|
|||
1933 | held += report(repo.vfs, "wlock", repo.wlock) |
|
|||
1934 |
|
||||
1935 | return held |
|
|||
1936 |
|
||||
1937 | @command('debugobsolete', |
|
1864 | @command('debugobsolete', | |
1938 | [('', 'flags', 0, _('markers flag')), |
|
1865 | [('', 'flags', 0, _('markers flag')), | |
1939 | ('', 'record-parents', False, |
|
1866 | ('', 'record-parents', False, |
@@ -7,11 +7,14 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | import errno | |||
10 | import operator |
|
11 | import operator | |
11 | import os |
|
12 | import os | |
12 | import random |
|
13 | import random | |
|
14 | import socket | |||
13 | import sys |
|
15 | import sys | |
14 | import tempfile |
|
16 | import tempfile | |
|
17 | import time | |||
15 |
|
18 | |||
16 | from .i18n import _ |
|
19 | from .i18n import _ | |
17 | from .node import ( |
|
20 | from .node import ( | |
@@ -1043,6 +1046,78 b' def debuglabelcomplete(ui, repo, *args):' | |||||
1043 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' |
|
1046 | '''backwards compatibility with old bash completion scripts (DEPRECATED)''' | |
1044 | commands.debugnamecomplete(ui, repo, *args) |
|
1047 | commands.debugnamecomplete(ui, repo, *args) | |
1045 |
|
1048 | |||
|
1049 | @command('debuglocks', | |||
|
1050 | [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), | |||
|
1051 | ('W', 'force-wlock', None, | |||
|
1052 | _('free the working state lock (DANGEROUS)'))], | |||
|
1053 | _('[OPTION]...')) | |||
|
1054 | def debuglocks(ui, repo, **opts): | |||
|
1055 | """show or modify state of locks | |||
|
1056 | ||||
|
1057 | By default, this command will show which locks are held. This | |||
|
1058 | includes the user and process holding the lock, the amount of time | |||
|
1059 | the lock has been held, and the machine name where the process is | |||
|
1060 | running if it's not local. | |||
|
1061 | ||||
|
1062 | Locks protect the integrity of Mercurial's data, so should be | |||
|
1063 | treated with care. System crashes or other interruptions may cause | |||
|
1064 | locks to not be properly released, though Mercurial will usually | |||
|
1065 | detect and remove such stale locks automatically. | |||
|
1066 | ||||
|
1067 | However, detecting stale locks may not always be possible (for | |||
|
1068 | instance, on a shared filesystem). Removing locks may also be | |||
|
1069 | blocked by filesystem permissions. | |||
|
1070 | ||||
|
1071 | Returns 0 if no locks are held. | |||
|
1072 | ||||
|
1073 | """ | |||
|
1074 | ||||
|
1075 | if opts.get('force_lock'): | |||
|
1076 | repo.svfs.unlink('lock') | |||
|
1077 | if opts.get('force_wlock'): | |||
|
1078 | repo.vfs.unlink('wlock') | |||
|
1079 | if opts.get('force_lock') or opts.get('force_lock'): | |||
|
1080 | return 0 | |||
|
1081 | ||||
|
1082 | now = time.time() | |||
|
1083 | held = 0 | |||
|
1084 | ||||
|
1085 | def report(vfs, name, method): | |||
|
1086 | # this causes stale locks to get reaped for more accurate reporting | |||
|
1087 | try: | |||
|
1088 | l = method(False) | |||
|
1089 | except error.LockHeld: | |||
|
1090 | l = None | |||
|
1091 | ||||
|
1092 | if l: | |||
|
1093 | l.release() | |||
|
1094 | else: | |||
|
1095 | try: | |||
|
1096 | stat = vfs.lstat(name) | |||
|
1097 | age = now - stat.st_mtime | |||
|
1098 | user = util.username(stat.st_uid) | |||
|
1099 | locker = vfs.readlock(name) | |||
|
1100 | if ":" in locker: | |||
|
1101 | host, pid = locker.split(':') | |||
|
1102 | if host == socket.gethostname(): | |||
|
1103 | locker = 'user %s, process %s' % (user, pid) | |||
|
1104 | else: | |||
|
1105 | locker = 'user %s, process %s, host %s' \ | |||
|
1106 | % (user, pid, host) | |||
|
1107 | ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) | |||
|
1108 | return 1 | |||
|
1109 | except OSError as e: | |||
|
1110 | if e.errno != errno.ENOENT: | |||
|
1111 | raise | |||
|
1112 | ||||
|
1113 | ui.write(("%-6s free\n") % (name + ":")) | |||
|
1114 | return 0 | |||
|
1115 | ||||
|
1116 | held += report(repo.svfs, "lock", repo.lock) | |||
|
1117 | held += report(repo.vfs, "wlock", repo.wlock) | |||
|
1118 | ||||
|
1119 | return held | |||
|
1120 | ||||
1046 | @command('debugmergestate', [], '') |
|
1121 | @command('debugmergestate', [], '') | |
1047 | def debugmergestate(ui, repo, *args): |
|
1122 | def debugmergestate(ui, repo, *args): | |
1048 | """print merge state |
|
1123 | """print merge state |
General Comments 0
You need to be logged in to leave comments.
Login now