Show More
@@ -16,7 +16,6 b' import time' | |||||
16 |
|
16 | |||
17 | from .i18n import _ |
|
17 | from .i18n import _ | |
18 | from .node import ( |
|
18 | from .node import ( | |
19 | bin, |
|
|||
20 | hex, |
|
19 | hex, | |
21 | nullid, |
|
20 | nullid, | |
22 | nullrev, |
|
21 | nullrev, | |
@@ -1861,117 +1860,6 b' def copy(ui, repo, *pats, **opts):' | |||||
1861 | with repo.wlock(False): |
|
1860 | with repo.wlock(False): | |
1862 | return cmdutil.copy(ui, repo, pats, opts) |
|
1861 | return cmdutil.copy(ui, repo, pats, opts) | |
1863 |
|
1862 | |||
1864 | @command('debugobsolete', |
|
|||
1865 | [('', 'flags', 0, _('markers flag')), |
|
|||
1866 | ('', 'record-parents', False, |
|
|||
1867 | _('record parent information for the precursor')), |
|
|||
1868 | ('r', 'rev', [], _('display markers relevant to REV')), |
|
|||
1869 | ('', 'index', False, _('display index of the marker')), |
|
|||
1870 | ('', 'delete', [], _('delete markers specified by indices')), |
|
|||
1871 | ] + commitopts2 + formatteropts, |
|
|||
1872 | _('[OBSOLETED [REPLACEMENT ...]]')) |
|
|||
1873 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
|
|||
1874 | """create arbitrary obsolete marker |
|
|||
1875 |
|
||||
1876 | With no arguments, displays the list of obsolescence markers.""" |
|
|||
1877 |
|
||||
1878 | def parsenodeid(s): |
|
|||
1879 | try: |
|
|||
1880 | # We do not use revsingle/revrange functions here to accept |
|
|||
1881 | # arbitrary node identifiers, possibly not present in the |
|
|||
1882 | # local repository. |
|
|||
1883 | n = bin(s) |
|
|||
1884 | if len(n) != len(nullid): |
|
|||
1885 | raise TypeError() |
|
|||
1886 | return n |
|
|||
1887 | except TypeError: |
|
|||
1888 | raise error.Abort('changeset references must be full hexadecimal ' |
|
|||
1889 | 'node identifiers') |
|
|||
1890 |
|
||||
1891 | if opts.get('delete'): |
|
|||
1892 | indices = [] |
|
|||
1893 | for v in opts.get('delete'): |
|
|||
1894 | try: |
|
|||
1895 | indices.append(int(v)) |
|
|||
1896 | except ValueError: |
|
|||
1897 | raise error.Abort(_('invalid index value: %r') % v, |
|
|||
1898 | hint=_('use integers for indices')) |
|
|||
1899 |
|
||||
1900 | if repo.currenttransaction(): |
|
|||
1901 | raise error.Abort(_('cannot delete obsmarkers in the middle ' |
|
|||
1902 | 'of transaction.')) |
|
|||
1903 |
|
||||
1904 | with repo.lock(): |
|
|||
1905 | n = repair.deleteobsmarkers(repo.obsstore, indices) |
|
|||
1906 | ui.write(_('deleted %i obsolescence markers\n') % n) |
|
|||
1907 |
|
||||
1908 | return |
|
|||
1909 |
|
||||
1910 | if precursor is not None: |
|
|||
1911 | if opts['rev']: |
|
|||
1912 | raise error.Abort('cannot select revision when creating marker') |
|
|||
1913 | metadata = {} |
|
|||
1914 | metadata['user'] = opts['user'] or ui.username() |
|
|||
1915 | succs = tuple(parsenodeid(succ) for succ in successors) |
|
|||
1916 | l = repo.lock() |
|
|||
1917 | try: |
|
|||
1918 | tr = repo.transaction('debugobsolete') |
|
|||
1919 | try: |
|
|||
1920 | date = opts.get('date') |
|
|||
1921 | if date: |
|
|||
1922 | date = util.parsedate(date) |
|
|||
1923 | else: |
|
|||
1924 | date = None |
|
|||
1925 | prec = parsenodeid(precursor) |
|
|||
1926 | parents = None |
|
|||
1927 | if opts['record_parents']: |
|
|||
1928 | if prec not in repo.unfiltered(): |
|
|||
1929 | raise error.Abort('cannot used --record-parents on ' |
|
|||
1930 | 'unknown changesets') |
|
|||
1931 | parents = repo.unfiltered()[prec].parents() |
|
|||
1932 | parents = tuple(p.node() for p in parents) |
|
|||
1933 | repo.obsstore.create(tr, prec, succs, opts['flags'], |
|
|||
1934 | parents=parents, date=date, |
|
|||
1935 | metadata=metadata) |
|
|||
1936 | tr.close() |
|
|||
1937 | except ValueError as exc: |
|
|||
1938 | raise error.Abort(_('bad obsmarker input: %s') % exc) |
|
|||
1939 | finally: |
|
|||
1940 | tr.release() |
|
|||
1941 | finally: |
|
|||
1942 | l.release() |
|
|||
1943 | else: |
|
|||
1944 | if opts['rev']: |
|
|||
1945 | revs = scmutil.revrange(repo, opts['rev']) |
|
|||
1946 | nodes = [repo[r].node() for r in revs] |
|
|||
1947 | markers = list(obsolete.getmarkers(repo, nodes=nodes)) |
|
|||
1948 | markers.sort(key=lambda x: x._data) |
|
|||
1949 | else: |
|
|||
1950 | markers = obsolete.getmarkers(repo) |
|
|||
1951 |
|
||||
1952 | markerstoiter = markers |
|
|||
1953 | isrelevant = lambda m: True |
|
|||
1954 | if opts.get('rev') and opts.get('index'): |
|
|||
1955 | markerstoiter = obsolete.getmarkers(repo) |
|
|||
1956 | markerset = set(markers) |
|
|||
1957 | isrelevant = lambda m: m in markerset |
|
|||
1958 |
|
||||
1959 | fm = ui.formatter('debugobsolete', opts) |
|
|||
1960 | for i, m in enumerate(markerstoiter): |
|
|||
1961 | if not isrelevant(m): |
|
|||
1962 | # marker can be irrelevant when we're iterating over a set |
|
|||
1963 | # of markers (markerstoiter) which is bigger than the set |
|
|||
1964 | # of markers we want to display (markers) |
|
|||
1965 | # this can happen if both --index and --rev options are |
|
|||
1966 | # provided and thus we need to iterate over all of the markers |
|
|||
1967 | # to get the correct indices, but only display the ones that |
|
|||
1968 | # are relevant to --rev value |
|
|||
1969 | continue |
|
|||
1970 | fm.startitem() |
|
|||
1971 | ind = i if opts.get('index') else None |
|
|||
1972 | cmdutil.showmarker(fm, m, index=ind) |
|
|||
1973 | fm.end() |
|
|||
1974 |
|
||||
1975 | @command('debugpathcomplete', |
|
1863 | @command('debugpathcomplete', | |
1976 | [('f', 'full', None, _('complete an entire path')), |
|
1864 | [('f', 'full', None, _('complete an entire path')), | |
1977 | ('n', 'normal', None, _('show only normal files')), |
|
1865 | ('n', 'normal', None, _('show only normal files')), |
@@ -41,6 +41,7 b' from . import (' | |||||
41 | localrepo, |
|
41 | localrepo, | |
42 | lock as lockmod, |
|
42 | lock as lockmod, | |
43 | merge as mergemod, |
|
43 | merge as mergemod, | |
|
44 | obsolete, | |||
44 | policy, |
|
45 | policy, | |
45 | pycompat, |
|
46 | pycompat, | |
46 | repair, |
|
47 | repair, | |
@@ -1237,6 +1238,117 b' def debugnamecomplete(ui, repo, *args):' | |||||
1237 | ui.write('\n'.join(sorted(completions))) |
|
1238 | ui.write('\n'.join(sorted(completions))) | |
1238 | ui.write('\n') |
|
1239 | ui.write('\n') | |
1239 |
|
1240 | |||
|
1241 | @command('debugobsolete', | |||
|
1242 | [('', 'flags', 0, _('markers flag')), | |||
|
1243 | ('', 'record-parents', False, | |||
|
1244 | _('record parent information for the precursor')), | |||
|
1245 | ('r', 'rev', [], _('display markers relevant to REV')), | |||
|
1246 | ('', 'index', False, _('display index of the marker')), | |||
|
1247 | ('', 'delete', [], _('delete markers specified by indices')), | |||
|
1248 | ] + commands.commitopts2 + commands.formatteropts, | |||
|
1249 | _('[OBSOLETED [REPLACEMENT ...]]')) | |||
|
1250 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): | |||
|
1251 | """create arbitrary obsolete marker | |||
|
1252 | ||||
|
1253 | With no arguments, displays the list of obsolescence markers.""" | |||
|
1254 | ||||
|
1255 | def parsenodeid(s): | |||
|
1256 | try: | |||
|
1257 | # We do not use revsingle/revrange functions here to accept | |||
|
1258 | # arbitrary node identifiers, possibly not present in the | |||
|
1259 | # local repository. | |||
|
1260 | n = bin(s) | |||
|
1261 | if len(n) != len(nullid): | |||
|
1262 | raise TypeError() | |||
|
1263 | return n | |||
|
1264 | except TypeError: | |||
|
1265 | raise error.Abort('changeset references must be full hexadecimal ' | |||
|
1266 | 'node identifiers') | |||
|
1267 | ||||
|
1268 | if opts.get('delete'): | |||
|
1269 | indices = [] | |||
|
1270 | for v in opts.get('delete'): | |||
|
1271 | try: | |||
|
1272 | indices.append(int(v)) | |||
|
1273 | except ValueError: | |||
|
1274 | raise error.Abort(_('invalid index value: %r') % v, | |||
|
1275 | hint=_('use integers for indices')) | |||
|
1276 | ||||
|
1277 | if repo.currenttransaction(): | |||
|
1278 | raise error.Abort(_('cannot delete obsmarkers in the middle ' | |||
|
1279 | 'of transaction.')) | |||
|
1280 | ||||
|
1281 | with repo.lock(): | |||
|
1282 | n = repair.deleteobsmarkers(repo.obsstore, indices) | |||
|
1283 | ui.write(_('deleted %i obsolescence markers\n') % n) | |||
|
1284 | ||||
|
1285 | return | |||
|
1286 | ||||
|
1287 | if precursor is not None: | |||
|
1288 | if opts['rev']: | |||
|
1289 | raise error.Abort('cannot select revision when creating marker') | |||
|
1290 | metadata = {} | |||
|
1291 | metadata['user'] = opts['user'] or ui.username() | |||
|
1292 | succs = tuple(parsenodeid(succ) for succ in successors) | |||
|
1293 | l = repo.lock() | |||
|
1294 | try: | |||
|
1295 | tr = repo.transaction('debugobsolete') | |||
|
1296 | try: | |||
|
1297 | date = opts.get('date') | |||
|
1298 | if date: | |||
|
1299 | date = util.parsedate(date) | |||
|
1300 | else: | |||
|
1301 | date = None | |||
|
1302 | prec = parsenodeid(precursor) | |||
|
1303 | parents = None | |||
|
1304 | if opts['record_parents']: | |||
|
1305 | if prec not in repo.unfiltered(): | |||
|
1306 | raise error.Abort('cannot used --record-parents on ' | |||
|
1307 | 'unknown changesets') | |||
|
1308 | parents = repo.unfiltered()[prec].parents() | |||
|
1309 | parents = tuple(p.node() for p in parents) | |||
|
1310 | repo.obsstore.create(tr, prec, succs, opts['flags'], | |||
|
1311 | parents=parents, date=date, | |||
|
1312 | metadata=metadata) | |||
|
1313 | tr.close() | |||
|
1314 | except ValueError as exc: | |||
|
1315 | raise error.Abort(_('bad obsmarker input: %s') % exc) | |||
|
1316 | finally: | |||
|
1317 | tr.release() | |||
|
1318 | finally: | |||
|
1319 | l.release() | |||
|
1320 | else: | |||
|
1321 | if opts['rev']: | |||
|
1322 | revs = scmutil.revrange(repo, opts['rev']) | |||
|
1323 | nodes = [repo[r].node() for r in revs] | |||
|
1324 | markers = list(obsolete.getmarkers(repo, nodes=nodes)) | |||
|
1325 | markers.sort(key=lambda x: x._data) | |||
|
1326 | else: | |||
|
1327 | markers = obsolete.getmarkers(repo) | |||
|
1328 | ||||
|
1329 | markerstoiter = markers | |||
|
1330 | isrelevant = lambda m: True | |||
|
1331 | if opts.get('rev') and opts.get('index'): | |||
|
1332 | markerstoiter = obsolete.getmarkers(repo) | |||
|
1333 | markerset = set(markers) | |||
|
1334 | isrelevant = lambda m: m in markerset | |||
|
1335 | ||||
|
1336 | fm = ui.formatter('debugobsolete', opts) | |||
|
1337 | for i, m in enumerate(markerstoiter): | |||
|
1338 | if not isrelevant(m): | |||
|
1339 | # marker can be irrelevant when we're iterating over a set | |||
|
1340 | # of markers (markerstoiter) which is bigger than the set | |||
|
1341 | # of markers we want to display (markers) | |||
|
1342 | # this can happen if both --index and --rev options are | |||
|
1343 | # provided and thus we need to iterate over all of the markers | |||
|
1344 | # to get the correct indices, but only display the ones that | |||
|
1345 | # are relevant to --rev value | |||
|
1346 | continue | |||
|
1347 | fm.startitem() | |||
|
1348 | ind = i if opts.get('index') else None | |||
|
1349 | cmdutil.showmarker(fm, m, index=ind) | |||
|
1350 | fm.end() | |||
|
1351 | ||||
1240 | @command('debugupgraderepo', [ |
|
1352 | @command('debugupgraderepo', [ | |
1241 | ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
|
1353 | ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), | |
1242 | ('', 'run', False, _('performs an upgrade')), |
|
1354 | ('', 'run', False, _('performs an upgrade')), |
General Comments 0
You need to be logged in to leave comments.
Login now