Commits

Sheng Mao  committed 9de22d3

due to prectxcommit happends before the transaction finishes, thus, commit hook
should be used. however, by the time, changeset is not add, so exception is
thrown. luckily, it works except for the exception.

  • Participants
  • Parent commits 615bbfa

Comments (0)

Files changed (1)

File issue-lit.py

 '''
 
 #imports
+# Tortoisehg uses an internal python.exe, so import the system's
+import sys, os
+sys.path.append(os.environ['PYTHONLIB'])
 from mercurial import hg, commands, node, cmdutil, util
 from mercurial import commands
 
         self.status = status
 
 # hook
-def pretxncommithook(ui, repo, **args):
+def commit_hook(ui, repo, **args):
     ctx = repo[args['node']]
     if not ctx:
         raise LookupNodeError('no node %s' % args['node'])
         id = log[pos+len(issue_anchor):pos_line]
         iss = find_issue(issues, id)
         if not iss:
+            print 'here'
             raise LookupNodeError('no issue %s' % id)
         iss.status = status
         serialize_issues(issues)
+        log_msg = log_template % (id, verb)
+        repo_status = repo.status()
+        if issue_file_name in repo_status[0]:
+            commands.commit(ui, repo, issue_file_name,
+                            message=log_msg, addremove=True)
 
 def reposetup(ui, repo):
     # Repository-specific hooks can be configured here. These include
     # the update hook.
-    ui.setconfig("hooks", "pretxncommit", pretxncommithook)
-    # Tortoisehg uses an internal python.exe, so import the system's
-    import sys, os
-    sys.path.append(os.environ['PYTHONLIB'])
+    ui.setconfig("hooks", "commit", commit_hook)
 
 # functions
 def issue(ui, repo, arg = None, **opts):