Skip to content
Snippets Groups Projects
  • Yuya Nishihara's avatar
    5e27afeddaee
    subrepo: add config option to reject any subrepo operations (SEC) · 5e27afeddaee
    Yuya Nishihara authored
    This is an alternative workaround for the issue5730.
    
    Perhaps this is the simplest way of disabling subrepo operations. It does
    nothing clever, but just aborts if Mercurial starts accessing to a subrepo.
    
    I think Greg's patch is more useful since it allows us to at least check
    out the parent repository. However, that would be confusing if the default
    is flipped to checkout=False and subrepos are silently ignored.
    
    I don't like the config name 'allowed', but I couldn't get any better name.
    5e27afeddaee
    History
    subrepo: add config option to reject any subrepo operations (SEC)
    Yuya Nishihara authored
    This is an alternative workaround for the issue5730.
    
    Perhaps this is the simplest way of disabling subrepo operations. It does
    nothing clever, but just aborts if Mercurial starts accessing to a subrepo.
    
    I think Greg's patch is more useful since it allows us to at least check
    out the parent repository. However, that would be confusing if the default
    is flipped to checkout=False and subrepos are silently ignored.
    
    I don't like the config name 'allowed', but I couldn't get any better name.
test-subrepo.t 49.96 KiB
Let commit recurse into subrepos by default to match pre-2.0 behavior:

  $ echo "[ui]" >> $HGRCPATH
  $ echo "commitsubrepos = Yes" >> $HGRCPATH

  $ hg init t
  $ cd t

first revision, no sub

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

add first sub

  $ echo s = s > .hgsub
  $ hg add .hgsub
  $ hg init s
  $ echo a > s/a

Issue2232: committing a subrepo without .hgsub

  $ hg ci -mbad s
  abort: can't commit subrepos without .hgsub
  [255]

  $ hg -R s add s/a
  $ hg files -S
  .hgsub
  a
  s/a (glob)

  $ hg -R s ci -Ams0
  $ hg sum
  parent: 0:f7b1eb17ad24 tip
   0
  branch: default
  commit: 1 added, 1 subrepos
  update: (current)
  phases: 1 draft
  $ hg ci -m1

test handling .hgsubstate "added" explicitly.

  $ hg parents --template '{node}\n{files}\n'
  7cf8cfea66e410e8e3336508dfeec07b3192de51
  .hgsub .hgsubstate
  $ hg rollback -q
  $ hg add .hgsubstate
  $ hg ci -m1
  $ hg parents --template '{node}\n{files}\n'
  7cf8cfea66e410e8e3336508dfeec07b3192de51
  .hgsub .hgsubstate

Subrepopath which overlaps with filepath, does not change warnings in remove()

  $ mkdir snot
  $ touch snot/file
  $ hg remove -S snot/file
  not removing snot/file: file is untracked (glob)
  [1]
  $ hg cat snot/filenot
  snot/filenot: no such file in rev 7cf8cfea66e4 (glob)
  [1]
  $ rm -r snot

Revert subrepo and test subrepo fileset keyword:

  $ echo b > s/a