From: Eric S. Raymond Date: Tue, 2 Oct 2012 18:25:44 +0000 (-0400) Subject: Second step in Mercurial support merge. X-Git-Tag: 1.5~26 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=e2d87b11effac82abfff300bcfda173c128046db;p=irker.git Second step in Mercurial support merge. --- diff --git a/irkerhook.py b/irkerhook.py index 5ed90e1..0ecef84 100755 --- a/irkerhook.py +++ b/irkerhook.py @@ -294,7 +294,7 @@ class HgExtractor(GenericExtractor): if arguments and type(arguments[0]) == type(()): # Called from hg_hook function - ui, repo, self.node = arguments[0] + ui, repo, node = arguments[0] # Extract global values from the hg configuration file(s) self.project = ui.config('irker', 'project') @@ -354,15 +354,20 @@ if __name__ == "__main__": # Determine the repository type. Default to git unless user has pointed # us at a repo with identifiable internals. vcs = "git" - if repository and os.path.exists(os.path.join(repository, "format")): + if repository and os.path.exists(os.path.join(repository, ".hg")): + vcs = "hg" + elif repository and os.path.exists(os.path.join(repository, "format")): vcs = "svn" # Someday we'll have extractors for several version-control systems if vcs == "svn": - if repository is None or not commits: - sys.stderr.write("irkerhook: svn requires a repository and a commit.") - sys.exit(1) extractor = SvnExtractor(sys.argv[1:]) + if not commits: + commits = ['HEAD'] + elif vcs == "hg": + extractor = HgExtractor(sys.argv[1:]) + if not commits: + commits = ['-1'] else: extractor = GitExtractor(sys.argv[1:]) if not commits: diff --git a/irkerhook.xml b/irkerhook.xml index b09a745..c6a4696 100644 --- a/irkerhook.xml +++ b/irkerhook.xml @@ -217,8 +217,8 @@ may have the following values: Subversion Under Subversion, irkerhook.py -requires two arguments: "repository=" (the absolute pathname of the -Subversion repository) and "commit=" (the numeric revision level of +requires a --repository option with value (the absolute pathname of the +Subversion repository) and a commit argument (the numeric revision level of the commit). The values must be the two arguments that Subversion gives its post-commit hook. Thus, a typical invocation in the post-commit script will look like this: @@ -263,7 +263,14 @@ this will be fixed in the next release. Under Mercurial, irkerhook.py can be invoked in two ways: either as a Python hook (preferred) or as a -script. As for git, in both cases all variables may be set in the repo +script. + +When called as a script, the hook requires a --repository option +with value (the absolute pathname of the Subversion repository) and can take a +commit argument (the Mercurial hash ID of the commit or a reference to it). +The default commit argument is '-1', designating the current tip commit. + +As for git, in both cases all variables may be set in the repo hgrc file in an [irker] section. Command-line variable=value arguments are accepted but not required for script invocation. No attempt is made to interpret an