view tests/test-absorb-edit-lines.t @ 39548:7ce9dea3a14a

localrepo: move repo creation logic out of localrepository.__init__ (API) It has long bothered me that local repository creation is handled as part of localrepository.__init__. Upcoming changes I want to make around how repositories are initialized and instantiated will make the continued existence of repository creation code in localrepository.__init__ even more awkward. localrepository instances are almost never constructed directly: instead, callers are supposed to go through hg.repository() to obtain a handle on a repository. And hg.repository() calls localrepo.instance() to return a new repo instance. This commit teaches localrepo.instance() to handle the create=True logic. Most of the code for repo construction has been moved to a standalone function. This allows extensions to monkeypatch the function to further customize freshly-created repositories. A few calls to localrepo.localrepository.__init__ that were passing create=True were converted to call localrepo.instance(). .. api:: local repo creation moved out of constructor ``localrepo.localrepository.__init__`` no longer accepts a ``create`` argument to create a new repository. New repository creation is now performed as part of ``localrepo.instance()`` and the bulk of the work is performed by ``localrepo.createrepository()``. Differential Revision: https://phab.mercurial-scm.org/D4534
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 11 Sep 2018 13:46:59 -0700
parents 5111d11b8719
children 31dfa7dac4c9
line wrap: on
line source

  $ cat >> $HGRCPATH << EOF
  > [extensions]
  > absorb=
  > EOF

  $ hg init repo1
  $ cd repo1

Make some commits:

  $ for i in 1 2 3; do
  >   echo $i >> a
  >   hg commit -A a -m "commit $i" -q
  > done

absorb --edit-lines will run the editor if filename is provided:

  $ hg absorb --edit-lines
  nothing applied
  [1]
  $ HGEDITOR=cat hg absorb --edit-lines a
  HG: editing a
  HG: "y" means the line to the right exists in the changeset to the top
  HG:
  HG: /---- 4ec16f85269a commit 1
  HG: |/--- 5c5f95224a50 commit 2
  HG: ||/-- 43f0a75bede7 commit 3
  HG: |||
      yyy : 1
       yy : 2
        y : 3
  nothing applied
  [1]

Edit the file using --edit-lines:

  $ cat > editortext << EOF
  >       y : a
  >      yy :  b
  >      y  : c
  >     yy  : d  
  >     y y : e
  >     y   : f
  >     yyy : g
  > EOF
  $ HGEDITOR='cat editortext >' hg absorb -q --edit-lines a
  $ hg cat -r 0 a
  d  
  e
  f
  g
  $ hg cat -r 1 a
   b
  c
  d  
  g
  $ hg cat -r 2 a
  a
   b
  e
  g