sapling/tests/test-amend-previous.t
Jun Wu ac7e07dbdf commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.

This diff adds various aliases to "roughly" keep the command prefix matching
behavior.

The list of aliases are obtained by this script in `hg dbsh`:

  def unique(prefix, names):
    m = __import__('edenscm.mercurial').mercurial
    try:
      return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
    except:
      return False

  nameslist=sorted([i.replace('^','') for i in m.commands.table])
  aliases = {}

  for names in nameslist:
    names = names.split('|')
    for name in names:
      if name.startswith('debug'):
        continue
      for prefix in [name[:i] for i in xrange(1, len(name))]:
        if unique(prefix, names):
          aliases.setdefault(name, []).append(prefix)

Debug commands, and commands that are rarely used are not changed, including:

  'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
  'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
  'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
  'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
  'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
  'clone': ['clon'],
  'cloud': ['clou'],
  'convert': ['conv', 'conve', 'conver'],
  'copy': ['cop'],
  'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
  'fold': ['fol'],
  'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
  'histgrep': ['histg', 'histgr', 'histgre'],
  'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
  'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
  'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
  'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
  'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
  'prune': ['pru', 'prun'],
  'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
  'rage': ['ra', 'rag'],
  'record': ['recor'],
  'recover': ['recov', 'recove'],
  'redo': ['red'],
  'repack': ['rep', 'repa', 'repac'],
  'reset': ['rese'],
  'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
  'root': ['roo'],
  'serve': ['se', 'ser', 'serv'],
  'share': ['sha', 'shar'],
  'sparse': ['spa', 'spar', 'spars'],
  'svn': ['sv'],
  'undo': ['und'],
  'unshare': ['unsha', 'unshar'],
  'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],

Reviewed By: sfilipco

Differential Revision: D17644676

fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 09:45:59 -07:00

138 lines
4.0 KiB
Perl

Set up test environment.
$ cat >> $HGRCPATH << EOF
> [extensions]
> amend=
> rebase=
> [experimental]
> evolution = createmarkers
> [ui]
> disallowemptyupdate = True
> EOF
$ hg init amendprevious && cd amendprevious
Check help text for new options and removal of unsupported options.
$ hg previous --help
hg previous [OPTIONS]... [STEPS]
aliases: prev
check out the parent commit
Options:
--newest always pick the newest parent when a changeset has
multiple parents
--bottom update to the lowest non-public ancestor of the
current changeset
--bookmark update to the first ancestor with a bookmark
--no-activate-bookmark do not activate the bookmark on the destination
changeset
-C --clean discard uncommitted changes (no backup)
-B --move-bookmark move active bookmark
-m --merge merge uncommitted changes
(some details hidden, use --verbose to show complete help)
Create stack of commits and go to the top.
$ hg debugbuilddag --mergeable-file +6
$ hg up tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg book top
Test invalid argument combinations.
$ hg previous --bottom 1
abort: cannot use both number and --bottom
[255]
$ hg previous --bookmark 1
abort: cannot use both number and --bookmark
[255]
$ hg previous --bottom --bookmark
abort: cannot use both --bottom and --bookmark
[255]
Test basic usage.
$ hg previous
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark top)
[*] r4 (glob)
With positional argument.
$ hg previous 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[*] r2 (glob)
Overshoot bottom of repo.
$ hg previous 5
reached root changeset
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[*] r0 (glob)
Test --bottom flag.
$ hg up top
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark top)
$ hg previous --bottom
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark top)
[*] r0 (glob)
Test bookmark navigation.
$ hg book -r 0 root
$ hg book -r 2 bookmark
$ hg up top
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark top)
$ hg previous --bookmark
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark top)
[*] (bookmark) r2 (glob)
(activating bookmark bookmark)
$ hg previous --bookmark
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark bookmark)
[*] (root) r0 (glob)
(activating bookmark root)
Test bookmark activation.
$ hg up top
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark top)
$ hg previous 3
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark top)
[*] (bookmark) r2 (glob)
(activating bookmark bookmark)
$ hg previous 2 --no-activate-bookmark
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark bookmark)
[*] (root) r0 (glob)
Test dirty working copy and --merge.
$ hg up top
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark top)
$ echo "test" >> mf
$ hg st
M mf
$ hg previous
abort: uncommitted changes
(use --clean to discard uncommitted changes or --merge to bring them along)
[255]
$ hg previous --merge
merging mf
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(leaving bookmark top)
[*] r4 (glob)
$ hg st
M mf
Test dirty working copy and --clean.
$ hg previous
abort: uncommitted changes
(use --clean to discard uncommitted changes or --merge to bring them along)
[255]
$ hg previous --clean
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[*] r3 (glob)
$ hg st