Programing

Mercurial 이동이 새로운 지점으로 변경

lottogame 2020. 7. 10. 08:15
반응형

Mercurial 이동이 새로운 지점으로 변경


로컬 리포지토리에 많은 변경 사항이 있지만 아직 푸시되지 않았습니다. 기능이 예상보다 오래 걸리므로 푸시하기 전에 이러한 변경 사항을 명명 된 분기로 바꾸고 싶습니다. 어떻게해야합니까?


Mark가 제안한 것처럼 MqExtension 은 문제를 해결하는 한 가지 솔루션입니다. 보다 간단한 워크 플로우는 rebase 확장 을 사용하는 것 입니다. 다음과 같은 역사가 있다고 가정하십시오.

@  changeset:   2:81b92083cb1d
|  tag:         tip
|  summary:     my new feature: edit file a
|
o  changeset:   1:8bdc4508ac7b
|  summary:     my new feature: add file b
|
o  changeset:   0:d554afd54164
   summary:     initial

즉, 개정 0은 기능에 대한 작업을 시작한 기초입니다. 이제 1-2명명 된 브랜치에 대한 수정을 원합니다 my-feature. 개정 0하고 해당 분기를 작성하려면 다음을 수행하십시오.

$ hg up 0
$ hg branch my-feature
$ hg ci -m "start new branch my-feature"

역사는 이제 다음과 같습니다 :

@  changeset:   3:b5939750b911
|  branch:      my-feature
|  tag:         tip
|  parent:      0:d554afd54164
|  summary:     start new branch my-feature
|
| o  changeset:   2:81b92083cb1d
| |  summary:     my new feature: edit file a
| |
| o  changeset:   1:8bdc4508ac7b
|/   summary:     my new feature: add file b
|
o  changeset:   0:d554afd54164
   summary:     initial

rebase명령을 사용하여 개정판 1-2을 개정판 으로 이동 하십시오 3.

$ hg rebase -s 1 -d 3

결과는 다음과 같습니다.

@  changeset:   3:88a90f9bbde7
|  branch:      my-feature
|  tag:         tip
|  summary:     my new feature: edit file a
|
o  changeset:   2:38f5adf2cf4b
|  branch:      my-feature
|  summary:     my new feature: add file b
|
o  changeset:   1:b5939750b911
|  branch:      my-feature
|  summary:     start new branch my-feature
|
o  changeset:   0:d554afd54164
   summary:     initial

그게 .. Mark의 답변에 대한 의견에서 언급했듯이, 이미 추진 한 변경 세트를 이동하는 것은 일반적으로 역사 조작을 의사 소통하고 시행 할 수있는 작은 팀에서 일하지 않는 한 나쁜 생각입니다.


MqExtension을 사용할 수 있습니다 . 이동할 변경 집합이 개정 1-3이라고 가정 해 봅시다.

hg qimport -r 1:3    # convert revisions to patches
hg qpop -a           # remove all them from history
hg branch new        # start a new branch
hg qpush -a          # push them all back into history
hg qfin -a           # finalize the patches

나는 패치 솔루션은 설명 선호 여기에 마크 Tolonen에 의해

내가 가진 것 :

hg log -G

#default branch
@  changeset:   3:cb292fcdbde1
|
o  changeset:   2:e746dceba503
|
o  changeset:   1:2d50c7ab6b8f
|
o  changeset:   0:c22be856358b

내가 원하는 것 :

  @  changeset:   3:0e85ae268e35
  |  branch:      feature/my_feature
  |
  o  changeset:   2:1450cb9ec349
  |  branch:      feature/my_feature
  |
  o  changeset:   1:7b9836f25f28
  |  branch:      feature/my_feature
  |
 /
|
o  changeset:   0:c22be856358b

수은 명령 :

hg export -o feature.diff 1 2 3
hg update 0
hg branch feature/my_feature
hg import feature.diff

내 로컬 저장소의 상태는 다음과 같습니다.

@  changeset:   6:0e85ae268e35
|  branch:      feature/my_feature
|
o  changeset:   5:1450cb9ec349
|  branch:      feature/my_feature
|
o  changeset:   4:7b9836f25f28
|  branch:      feature/my_feature
|
| o  changeset:   3:cb292fcdbde1
| |
| o  changeset:   2:e746dceba503
| |
| o  changeset:   1:2d50c7ab6b8f
|/
|
o  changeset:   0:c22be856358b

이제 기본 분기에서 개정 1 2와 3을 삭제해야합니다. mq의 확장자에서 strip 명령 으로이 작업을 수행 할 수 있습니다. hg strip저장소에서 변경 세트와 모든 하위 항목을 제거합니다.

Enable the extension by adding following lines to your configuration file (.hgrc or Mercurial.ini):

vim ~/.hgrc and add :

[extensions]
mq =

And now strip this repository on revision 1.

hg strip 1

and here we are

@  changeset:   3:0e85ae268e35
|  branch:      feature/my_feature
|
o  changeset:   2:1450cb9ec349
|  branch:      feature/my_feature
|
o  changeset:   1:7b9836f25f28
|  branch:      feature/my_feature
|
o  changeset:   0:c22be856358b

note: changesets are different but revisions are the same


For those inclined to use GUI

  1. Go to Tortoise Hg -> File -> Settings then tick rebase .

enter image description here

  1. Restart tortoise UI

  2. Create new branch where you will be moving changes. Click on current branch name -> choose Open a new named branch -> choose branch name.

enter image description here

  1. If changes you want to move have not been made public (e.g draft) go to 5. (If changes have already been published and you are not a senior dev you should talk to someone senior (get a scapegoat) as you might screw things up big time, I don't take any responsibility :) ).

Go to View -> Show Console (or Ctrl + L) then write in console hg phase -f -d 2 - where 2 is lowest revision you will be moving to new branch.

  1. Go to branch and revision (should be topmost revision if you are moving changes to new branch created in step 3.) Right Mouse -> Update

  2. Go to branch and revsion you will be moving changes from Right Mouse -> Modify History -> Rebase

enter image description here

  1. Click Rebase and pray there are no conflicts, merge if you must.

  2. Push changes, at this point all revisions should still be draft.

  3. Go to topmost revision in branch you were moving changes to Right Mouse -> Change Phase to -> Public.

enter image description here

Hope this saves you some time.

참고URL : https://stackoverflow.com/questions/4665549/mercurial-move-changes-to-a-new-branch

반응형