program story

Mercurial 저장소 기록에서 삭제 된 파일을 신속하게 찾으십니까?

inputbox 2020. 12. 7. 08:07
반응형

Mercurial 저장소 기록에서 삭제 된 파일을 신속하게 찾으십니까?


hg grep을 사용할 수 있지만 모든 파일의 내용을 검색합니다.

삭제 된 파일 이름 만 검색하여 복구하려면 어떻게해야합니까?

hg grep -I 파일 이름 패턴 패턴을 시도했지만 결과가 반환되지 않는 것 같습니다.


템플릿 사용 은 간단합니다 .

$ hg log --template "{rev}: {file_dels}\n"

Mercurial 1.6 업데이트

이것에도 revsets사용할 수 있습니다 .

hg log -r "removes('**')"

( 편집 : 이중 참고 *- 하나 하나의 저장소 만의 루트에서 제거를 감지합니다 .)


편집 : 마티유 Longtin에서 알 수 있듯이,이은과 결합 될 수 템플릿 에서 DFA의 대답은 당신을 보여 하는 나열된 각 개정을 제거합니다 파일 :

hg log -r "removes('**')" --template "{rev}: {file_dels}\n"

그것은 한 줄에 하나의 개정판을 나열하는 (기계 가독성을 위해) 미덕이 있지만 %삭제 목록의 각 항목을 형식화 하는 데를 사용하여 사람에게 더 예쁘게 출력 할 수 있습니다 .

hg log -r "removes('**')" --template "{rev}:\n{file_dels % '{file}\n'}\n"

TortoiseHg 워크 벤치를 사용하는 경우 편리한 방법은 개정 필터를 사용하는 것입니다. ctrl+s누른 다음 입력하십시오.

removes("**/FileYouWantToFind.txt")

**/저장소에서 재귀 적으로 검색하려고 함을 나타냅니다. *파일 이름에도 와일드 카드를 사용할 수 있습니다 . and, or연산자를 사용하여이 쿼리를 다른 개정 세트와 결합 할 수 있습니다 .

이 고급 쿼리 편집기도 있습니다. 여기에 이미지 설명 입력


효율적으로 삭제 한 특정 파일을 검색하고 결과를 멋지게 형식화하십시오.

hg log --template "File(s) deleted in rev {rev}: {file_dels % '\n  {file}'}\n\n" -r 'removes("**/FileYouWantToFind.txt")'

샘플 출력 :

File(s) deleted in rev 33336: 
  class/WebEngineX/Database/RawSql.php

File(s) deleted in rev 34468: 
  class/PdoPlus/AccessDeniedException.php
  class/PdoPlus/BulkInsert.php
  class/PdoPlus/BulkInsertInfo.php
  class/PdoPlus/CannotAddForeignKeyException.php
  class/PdoPlus/DuplicateEntryException.php
  class/PdoPlus/Escaper.php
  class/PdoPlus/MsPdo.php
  class/PdoPlus/MyPdo.php
  class/PdoPlus/MyPdoException.php
  class/PdoPlus/NoSuchTableException.php
  class/PdoPlus/PdoPlus.php
  class/PdoPlus/PdoPlusException.php
  class/PdoPlus/PdoPlusStatement.php
  class/PdoPlus/RawSql.php

다른 답변을 받아 개선했습니다.

"--no-merges"를 추가했습니다. 개발 팀이있는 대규모 프로젝트에서는 많은 병합이 발생합니다. --no-merger는 로그 노이즈를 필터링합니다.

변경 removes("**")sort(removes("**"), -rev). 10 만 개가 넘는 변경 세트가있는 대규모 프로젝트의 경우 제거 된 최신 파일을 훨씬 빨리 얻을 수 있습니다. 이것은 rev 0에서 시작하여 대신 tip에서 시작하는 순서를 반대로합니다.

출력에 {author} 및 {desc}를 추가했습니다. 이렇게하면 로그 주석을 표시하여 파일이 제거 된 이유와 누가이를 수행했는지에 대한 컨텍스트를 제공합니다.

그래서 제 사용 사례의 경우 hg log --template "File(s) deleted in rev {rev}: {author} \n {desc}\n {file_dels % '\n {file}'}\n\n" -r 'sort(removes("**"), -rev)' --no-merges

샘플 출력 :

File(s) deleted in rev 52363: Ansariel 
 STORM-2141: Fix various inventory floater related issues:
* Opening new inventory via Control-Shift-I shortcut uses legacy and potentinally dangerous code path
* Closing new inventory windows don't release memory
* During shutdown legacy and inoperable code for inventory window cleanup is called
* Remove old and unused inventory legacy code

  indra/newview/llfloaterinventory.cpp
  indra/newview/llfloaterinventory.h

File(s) deleted in rev 51951: Ansariel 
 Remove readme.md file - again...

  README.md

File(s) deleted in rev 51856: Brad Payne (Vir Linden) <vir@lindenlab.com> 
 SL-276 WIP - removed avatar_skeleton_spine_joints.xml

  indra/newview/character/avatar_skeleton_spine_joints.xml

File(s) deleted in rev 51821: Brad Payne (Vir Linden) <vir@lindenlab.com> 
 SL-276 WIP - removed avatar_XXX_orig.xml files.

  indra/newview/character/avatar_lad_orig.xml
  indra/newview/character/avatar_skeleton_orig.xml

프로젝트 루트에서

hg status . | grep "\!" >> /tmp/filesmissinginrepo.txt

참고 URL : https://stackoverflow.com/questions/1013550/find-deleted-files-in-mercurial-repository-history-quickly

반응형