2009-12-08 7 views
11

मैं दो ~/.hgrc फ़ाइलों को रखना चाहता हूं: ~/.hgrc और ~/.hgrc.local - "मानक" सेटिंग्स के साथ एक (उदाहरण के लिए, username), दूसरा मशीन-विशिष्ट सेटिंग्स (उदाहरण के लिए, सेटिंग एक ग्राफिकल विलय उपकरण)।एकाधिक .hgrc फ़ाइलों को लोड करें - यानी, कुछ मशीन-विशिष्ट सेटिंग्स के साथ?

मैं एचजी के साथ ऐसा कैसे कर सकता हूं?

उदाहरण के लिए, यह कैसे मैं इसे विम के साथ क्या है:

# ~/.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

एचआरएम, तो यह वास्तव में अच्छा होगा ... लेकिन यह एचजी 1.3.1 या 1.4.1 के साथ काम नहीं करता है ... और '% आयात' के लिए एचजी स्रोत पेड़ (1.4.1 + 7-4ddfad7ebd98) grepping नहीं करता है कुछ भी ऊपर तो ... तुमने उसे कहाँ पाया? –

0

मर्क्युरियल hgrc फ़ाइलों के लिए कई अलग अलग स्थानों में दिखेगा और वर्तमान अगर उन्हें लोड होगा। सिस्टम-व्यापी विन्यास के लिए मानक (यूनिक्स पर) /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

वास्तविक जानकारी जोड़ने के बिना मैनुअल paraphrasing के लिए downvoted। आप बेहतर कर सकते हैं :) – NicDumZ

5

मैं इस समस्या को मेरी सभी "डॉट फाइलों" के लिए इसी तरह हल करता हूं। लॉगिन पर मेरा खोल फाइलों की सूची (एचजीआरसी, वीमआरसी, ....) की जांच करता है और चेक करता है कि उनमें से कोई भी ${that_name}.global या ${that_name}.local से बड़ा है। यदि यह है - cat ${that_name}.{global,local} > ${that_name}। सरल और अब तक महान काम करता है। जबकि "बेहतर" तरीका है (%include का उपयोग करके) कभी-कभी कॉन्फ़िगरेशन फ़ाइलों को प्रोसेस करने के लिए मैन्युअल रूप से फायदे होते हैं - उदाहरण के लिए यह Mercurial pre-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