1347 fm.startitem() |
1347 fm.startitem() |
1348 ind = i if opts.get('index') else None |
1348 ind = i if opts.get('index') else None |
1349 cmdutil.showmarker(fm, m, index=ind) |
1349 cmdutil.showmarker(fm, m, index=ind) |
1350 fm.end() |
1350 fm.end() |
1351 |
1351 |
|
1352 @command('debugpathcomplete', |
|
1353 [('f', 'full', None, _('complete an entire path')), |
|
1354 ('n', 'normal', None, _('show only normal files')), |
|
1355 ('a', 'added', None, _('show only added files')), |
|
1356 ('r', 'removed', None, _('show only removed files'))], |
|
1357 _('FILESPEC...')) |
|
1358 def debugpathcomplete(ui, repo, *specs, **opts): |
|
1359 '''complete part or all of a tracked path |
|
1360 |
|
1361 This command supports shells that offer path name completion. It |
|
1362 currently completes only files already known to the dirstate. |
|
1363 |
|
1364 Completion extends only to the next path segment unless |
|
1365 --full is specified, in which case entire paths are used.''' |
|
1366 |
|
1367 def complete(path, acceptable): |
|
1368 dirstate = repo.dirstate |
|
1369 spec = os.path.normpath(os.path.join(pycompat.getcwd(), path)) |
|
1370 rootdir = repo.root + pycompat.ossep |
|
1371 if spec != repo.root and not spec.startswith(rootdir): |
|
1372 return [], [] |
|
1373 if os.path.isdir(spec): |
|
1374 spec += '/' |
|
1375 spec = spec[len(rootdir):] |
|
1376 fixpaths = pycompat.ossep != '/' |
|
1377 if fixpaths: |
|
1378 spec = spec.replace(pycompat.ossep, '/') |
|
1379 speclen = len(spec) |
|
1380 fullpaths = opts['full'] |
|
1381 files, dirs = set(), set() |
|
1382 adddir, addfile = dirs.add, files.add |
|
1383 for f, st in dirstate.iteritems(): |
|
1384 if f.startswith(spec) and st[0] in acceptable: |
|
1385 if fixpaths: |
|
1386 f = f.replace('/', pycompat.ossep) |
|
1387 if fullpaths: |
|
1388 addfile(f) |
|
1389 continue |
|
1390 s = f.find(pycompat.ossep, speclen) |
|
1391 if s >= 0: |
|
1392 adddir(f[:s]) |
|
1393 else: |
|
1394 addfile(f) |
|
1395 return files, dirs |
|
1396 |
|
1397 acceptable = '' |
|
1398 if opts['normal']: |
|
1399 acceptable += 'nm' |
|
1400 if opts['added']: |
|
1401 acceptable += 'a' |
|
1402 if opts['removed']: |
|
1403 acceptable += 'r' |
|
1404 cwd = repo.getcwd() |
|
1405 if not specs: |
|
1406 specs = ['.'] |
|
1407 |
|
1408 files, dirs = set(), set() |
|
1409 for spec in specs: |
|
1410 f, d = complete(spec, acceptable or 'nmar') |
|
1411 files.update(f) |
|
1412 dirs.update(d) |
|
1413 files.update(dirs) |
|
1414 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
|
1415 ui.write('\n') |
|
1416 |
1352 @command('debugupgraderepo', [ |
1417 @command('debugupgraderepo', [ |
1353 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
1418 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
1354 ('', 'run', False, _('performs an upgrade')), |
1419 ('', 'run', False, _('performs an upgrade')), |
1355 ]) |
1420 ]) |
1356 def debugupgraderepo(ui, repo, run=False, optimize=None): |
1421 def debugupgraderepo(ui, repo, run=False, optimize=None): |