मुझे Mercurial के लिए सरल हुक की आवश्यकता है जो पैटर्न का उपयोग करके टिप्पणी प्रतिबद्ध करता है। यहां मेरा हुक है:टोर्टोइज एचजी लॉग विंडो में हुक आउटपुट कैसे दिखाएं?
#!/usr/bin/env python
#
# save as .hg/check_whitespace.py and make executable
import re
def check_comment(comment):
#
print 'Checking comment...'
pattern = '^((Issue \d+:)|(No Issue:)).+'
if re.match(pattern, comment, flags=re.IGNORECASE):
return 1
else:
print >> sys.stderr, 'Comment does not match pattern. You must start it with "Issue 12323:" or "No Issue:"'
return 0
if __name__ == '__main__':
import os, sys
comment=os.popen('hg tip --template "{desc}"').read()
if not check_comment(comment):
sys.exit(1)
sys.exit(0)
यह काम करता है। जब मैं कंसोल से प्रतिबद्ध करता हूं तो यह त्रुटि संदेश 'Comment does not match pattern. You must start it with "Issue 12323:" or "No Issue:"'
भी दिखाता है। लेकिन जब मैं कछुए एचजी वर्कबेंच से प्रतिबद्ध करने की कोशिश करता हूं, केवल सिस्टम संदेश दिखाया जाता है: abort: pretxncommit.check_comment hook exited with status 1
।
मुझे उपयोगकर्ता को सूचित करने की आवश्यकता है कि क्या गलत है। क्या हुक से आउटपुट दिखाने के लिए कछुए एचजी को मजबूर करने का कोई तरीका है?
बस एक अनुमान है, लेकिन क्या आपने sys.err के बजाय sys.out पर लिखने की कोशिश की है? – bbaja42
हां। यह मदद नहीं की। –