view tests/test-dispatch.t @ 39270:37e56607cbb9

lfs: add a progress bar when searching for blobs to upload The search itself can take an extreme amount of time if there are a lot of revisions involved. I've got a local repo that took 6 minutes to push 1850 commits, and 60% of that time was spent here (there are ~70K files): \ 58.1% wrapper.py: extractpointers line 297: pointers = extractpointers(... | 57.7% wrapper.py: pointersfromctx line 352: for p in pointersfromctx(ct... | 57.4% wrapper.py: pointerfromctx line 397: p = pointerfromctx(ctx, f, ... \ 38.7% context.py: __contains__ line 368: if f not in ctx: | 38.7% util.py: __get__ line 82: return key in self._manifest | 38.7% context.py: _manifest line 1416: result = self.func(obj) | 38.7% manifest.py: read line 472: return self._manifestctx.re... \ 25.6% revlog.py: revision line 1562: text = rl.revision(self._node) \ 12.8% revlog.py: _chunks line 2217: bins = self._chunks(chain, ... | 12.0% revlog.py: decompressline 2112: ladd(decomp(buffer(data, ch... \ 7.8% revlog.py: checkhash line 2232: self.checkhash(text, node, ... | 7.8% revlog.py: hash line 2315: if node != self.hash(text, ... | 7.8% revlog.py: hash line 2242: return hash(text, p1, p2) \ 12.0% manifest.py: __init__ line 1565: self._data = manifestdict(t... \ 16.8% context.py: filenode line 378: if not _islfs(fctx.filelog(... | 15.7% util.py: __get__ line 706: return self._filelog | 14.8% context.py: _filelog line 1416: result = self.func(obj) | 14.8% localrepo.py: file line 629: return self._repo.file(self... | 14.8% filelog.py: __init__ line 1134: return filelog.filelog(self... | 14.5% revlog.py: __init__ line 24: censorable=True)
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 24 Aug 2018 17:45:46 -0400
parents 4441705b7111
children 0d703063d0c8
line wrap: on
line source

test command parsing and dispatch

  $ hg init a
  $ cd a

Redundant options used to crash (issue436):
  $ hg -v log -v
  $ hg -v log -v x

  $ echo a > a
  $ hg ci -Ama
  adding a

Missing arg:

  $ hg cat
  hg cat: invalid arguments
  hg cat [OPTION]... FILE...
  
  output the current or given revision of files
  
  options ([+] can be repeated):
  
   -o --output FORMAT       print output to file with formatted name
   -r --rev REV             print the given revision
      --decode              apply any matching decode filter
   -I --include PATTERN [+] include names matching the given patterns
   -X --exclude PATTERN [+] exclude names matching the given patterns
  
  (use 'hg cat -h' to show more help)
  [255]

Missing parameter for early option:

  $ hg log -R 2>&1 | grep 'hg log'
  hg log: option -R requires argument
  hg log [OPTION]... [FILE]
  (use 'hg log -h' to show more help)

"--" may be an option value:

  $ hg -R -- log
  abort: repository -- not found!
  [255]
  $ hg log -R --
  abort: repository -- not found!
  [255]
  $ hg log -T --
  -- (no-eol)
  $ hg log -T -- -k nomatch

Parsing of early options should stop at "--":

  $ hg cat -- --config=hooks.pre-cat=false
  --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
  [1]
  $ hg cat -- --debugger
  --debugger: no such file in rev cb9a9f314b8b
  [1]

Unparsable form of early options:

  $ hg cat --debugg
  abort: option --debugger may not be abbreviated!
  [255]

Parsing failure of early options should be detected before executing the
command:

  $ hg log -b '--config=hooks.pre-log=false' default
  abort: option --config may not be abbreviated!
  [255]
  $ hg log -b -R. default
  abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
  [255]
  $ hg log --cwd .. -b --cwd=. default
  abort: option --cwd may not be abbreviated!
  [255]

However, we can't prevent it from loading extensions and configs:

  $ cat <<EOF > bad.py
  > raise Exception('bad')
  > EOF
  $ hg log -b '--config=extensions.bad=bad.py' default
  *** failed to import extension bad from bad.py: bad
  abort: option --config may not be abbreviated!
  [255]

  $ mkdir -p badrepo/.hg
  $ echo 'invalid-syntax' > badrepo/.hg/hgrc
  $ hg log -b -Rbadrepo default
  hg: parse error at badrepo/.hg/hgrc:1: invalid-syntax
  [255]

  $ hg log -b --cwd=inexistent default
  abort: $ENOENT$: 'inexistent'
  [255]

  $ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback'
  Traceback (most recent call last):
  $ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample
  Sample count: .*|No samples recorded\. (re)

Early options can't be specified in [aliases] and [defaults] because they are
applied before the command name is resolved:

  $ hg log -b '--config=alias.log=log --config=hooks.pre-log=false'
  hg log: option -b not recognized
  error in definition for alias 'log': --config may only be given on the command
  line
  [255]

  $ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
  abort: option --config may not be abbreviated!
  [255]

Shell aliases bypass any command parsing rules but for the early one:

  $ hg log -b '--config=alias.log=!echo howdy'
  howdy

Early options must come first if HGPLAIN=+strictflags is specified:
(BUG: chg cherry-picks early options to pass them as a server command)

#if no-chg
  $ HGPLAIN=+strictflags hg log -b --config='hooks.pre-log=false' default
  abort: unknown revision '--config=hooks.pre-log=false'!
  [255]
  $ HGPLAIN=+strictflags hg log -b -R. default
  abort: unknown revision '-R.'!
  [255]
  $ HGPLAIN=+strictflags hg log -b --cwd=. default
  abort: unknown revision '--cwd=.'!
  [255]
#endif
  $ HGPLAIN=+strictflags hg log -b --debugger default
  abort: unknown revision '--debugger'!
  [255]
  $ HGPLAIN=+strictflags hg log -b --config='alias.log=!echo pwned' default
  abort: unknown revision '--config=alias.log=!echo pwned'!
  [255]

  $ HGPLAIN=+strictflags hg log --config='hooks.pre-log=false' -b default
  abort: option --config may not be abbreviated!
  [255]
  $ HGPLAIN=+strictflags hg log -q --cwd=.. -b default
  abort: option --cwd may not be abbreviated!
  [255]
  $ HGPLAIN=+strictflags hg log -q -R . -b default
  abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
  [255]

  $ HGPLAIN=+strictflags hg --config='hooks.pre-log=false' log -b default
  abort: pre-log hook exited with status 1
  [255]
  $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
  0:cb9a9f314b8b
  $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
  0:cb9a9f314b8b
  $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
  0:cb9a9f314b8b

For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN:

  $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
  abort: pre-log hook exited with status 1
  [255]
  $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
  0:cb9a9f314b8b

[defaults]

  $ hg cat a
  a
  $ cat >> $HGRCPATH <<EOF
  > [defaults]
  > cat = -r null
  > EOF
  $ hg cat a
  a: no such file in rev 000000000000
  [1]

  $ cd "$TESTTMP"

OSError "No such file or directory" / "The system cannot find the path
specified" should include filename even when it is empty

  $ hg -R a archive ''
  abort: *: '' (glob)
  [255]

#if no-outer-repo

No repo:

  $ hg cat
  abort: no repository found in '$TESTTMP' (.hg not found)!
  [255]

#endif

#if rmcwd

Current directory removed:

  $ mkdir $TESTTMP/repo1
  $ cd $TESTTMP/repo1
  $ rm -rf $TESTTMP/repo1

The output could be one of the following and something else:
 chg: abort: failed to getcwd (errno = *) (glob)
 abort: error getting current working directory: * (glob)
 sh: 0: getcwd() failed: $ENOENT$
Since the exact behavior depends on the shell, only check it returns non-zero.
  $ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
  [1]

#endif