2009-12-08 3 views
11

~/.hgrc 및 ~/.hgrc.local - "표준"설정 (예 : username)을 가진 것, 다른 하나는 컴퓨터 특정 설정 (예 : 설정 그래픽 병합 도구)..hgrc 파일을 여러 개로드하십시오. 즉, 일부 컴퓨터 관련 설정이 있습니까?

hg로 어떻게 할 수 있습니까?

는 예를 들어, 내가 빔 함께 할 방법은 다음과 같습니다 그런

# ~/.vimrc 
syntax enable 
source ~/.vimrc.local 

:

# ~/.vimrc.local 
let work_code = 'code/work/.*' 
if expand('%:p:h') =~ work_code ... fi 

답변

20

나중에 수은 1.3에서하지-자주 사용 %include 지시어가있다 .

+0

경외감 - 그게 내가 찾고 있던 바로 그거야. 감사. –

+0

와우, 나는 그 존재를 전혀 몰랐다. 좋은. –

+0

Hrm, 정말 멋지 네요 ...하지만 hg 1.3.1 또는 1.4.1에서는 작동하지 않습니다 ... 그리고 '% import'에 대한 hg 소스 트리 (1.4.1 + 7-4ddfad7ebd98)를 grepping하면 바뀌지 않습니다 어떤 것도. 그래서 ... 그걸 어디서 발견 했니? –

0

의욕이 hgrc 파일에 대해 여러 다른 위치에 모양과 존재하는 경우를로드합니다. 시스템 전체 구성의 경우 표준 (UNIX의 경우)은 /etc/mercurial/hgrc입니다.

자세한 내용은 files section of the hgrc man page을 참조하십시오. man hgrc에서

:

A line of the form %include file will include file into the current 
    configuration file. The inclusion is recursive, which means that 
    included files can include other files. Filenames are relative to the 
    configuration file in which the %include directive is found. 

그렇게 갈 :

%include ~/.hgrc.local 

당신이 갈 수 있어야한다

+0

그것은 몇 가지 다른 장소에서 보이는 ...하지만 내 컴퓨터에 루트가 없기 때문에 ~에서 두 설정 파일을 모두 가져야합니다. –

+0

실제 정보를 추가하지 않고 매뉴얼을 바꾸어 말하기 위해 downvoted. 당신은 더 잘할 수 있습니다 :) – NicDumZ

5

비슷한 방법으로 모든 "도트 파일"에 대해이 문제를 해결합니다. 로그인시 쉘은 파일 목록 (hgrc, vimrc, ....)을 확인하고 그 중 하나가 ${that_name}.global 또는 ${that_name}.local보다 오래된 지 확인합니다. - cat ${that_name}.{global,local} > ${that_name} 인 경우 단순하고 지금까지 큰 작품. "더 나은"방법 (%include 사용)이 있지만 설정 파일을 수동으로 처리 할 때 장점이 있습니다. 예를 들어 수은 이전 1.3 버전에서 작동합니다.

+0

아, 그거 좋은 생각이에요. 감사! –

4

Mercurial은 특정 우선 순위를 가진 여러 구성 파일을 확인합니다. 이렇게하면 전역, 사용자 별 및 저장소 별 설정을 가질 수 있습니다.

$ hg help config 
Configuration Files 

    Mercurial reads configuration data from several files, if they exist. Below we list the most specific file first. 

    On Windows, these configuration files are read: 

    - "<repo>\.hg\hgrc" 
    - "%USERPROFILE%\.hgrc" 
    - "%USERPROFILE%\Mercurial.ini" 
    - "%HOME%\.hgrc" 
    - "%HOME%\Mercurial.ini" 
    - "C:\Mercurial\Mercurial.ini" 
    - "HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial" 
    - "<install-dir>\Mercurial.ini" 

    On Unix, these files are read: 

    - "<repo>/.hg/hgrc" 
    - "$HOME/.hgrc" 
    - "/etc/mercurial/hgrc" 
    - "/etc/mercurial/hgrc.d/*.rc" 
    - "<install-root>/etc/mercurial/hgrc" 
    - "<install-root>/etc/mercurial/hgrc.d/*.rc" 

    The configuration files for Mercurial use a simple ini-file format. A configuration file consists of sections, led by a "[section]" header and followed by 
    "name = value" entries: 

     [ui] 
     username = Firstname Lastname <[email protected]> 
     verbose = True 

    This above entries will be referred to as "ui.username" and "ui.verbose", respectively. Please see the hgrc man page for a full description of the possible 
    configuration values: 

    - on Unix-like systems: "man hgrc" 
    - online: http://www.selenic.com/mercurial/hgrc.5.html 

당신은 hg showconfig와 현재 설정을 나열 할 수 있습니다 : 의욕 버전> = 1.4 좋은 개요이를 설명하는 hg help config 명령이 있습니다.

+0

불행히도 나는 그것을 보았습니다 ... 그리고 그것은 질문에 대답하지 않습니다. –

+1

답변이 100 % 답변에 포함되지 않는다고 동의합니다. 그러나 투표가 끝났습니까? 어서. – Paidhi

+0

도와주세요. 나는 당신을 투표 할거야! – user37078