Fork me on GitHub

2009/08/18


このエントリーをはてなブックマークに追加
だいたいに10分くらいだと思う。
まずtinytinyhttpd(tthttpd)とmercurialは既に入っている事として

1. リポジトリを作る

# cd /path/to/repo
# hg init

2. hgwebdir.cgiを用意する

mercurialに含まれるhgwebdir.cgiを配置する。
# cd /path/to/web
# cp /path/to/hgwebdir.cgi .
mercurialのソースパッケージに入ってる

3. hgweb.configを用意する

hgwebdir.cgi用の設定ファイルを書く。
[paths]
repo = /path/to/repo

4. hgrcを作る

.hg/hgrcを作る(もしくは修正する)。
[web]
name = repo
description = my private repo
contact = mattn@example.com
push_ssl = false
allow_push = mattn iratqq hasegawa
allow_pull = *
allow_read = *
allow_archive = bz2, gz, zip
encoding = utf-8

5. パスワードファイルを書く

mattn:ggrks
iratqq:kkrkr
hasegawa:xss
プレインテキストなので要注意

6. tthttpdの設定ファイルを書く

Windowsならば
[global]
port=8080
root=c:/path/to/repo
indexpages=hgwebdir.cgi

[mime/types]
cgi=@c:/python26/python.exe

[authentication]
/=POST,Admin!,c:/path/to/passwd
Unixならば
[global]
port=8080
root=/path/to/repo
indexpages=hgwebdir.cgi
spawn_executable=on

[authentication]
/=POST,Admin!,/path/to/passwd
こんな感じ。

7. tthttpdを起動する

設定ファイルを指定して起動
# tthttpd -vvv -c repo.conf
tthttpd-hgweb1
うごいた。

8. clone/pushしてみる

# hg clone http://localhost:8080/hgwebdir.cgi/repo
destination directory: repo
no changes found
updating working directory
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# cat > README

^D

# hg add README
# hg commit -m "first import"
# hg push
pushing to http://localhost:8080/hgwebdir.cgi/repo
searching for changes
http authorization required
realm: Admin!
user: mattn
password:
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files

tthttpd-hgweb2
うごいた。
最新版のtinytinyhttpdでしか動きません。

tthttpd.exeを含んだリポジトリフォルダごと持って歩けば、どこでもmercurialサーバになるね。
Posted at 14:27 in ソフトウェア::lang::c
Tagged as: mercurial, tinytinyhttpd
Bookmarks: add to hatena add to hatena | add to delicious.com | add to livedoor.clip add to livedoor.clip

2008/11/10


このエントリーをはてなブックマークに追加
さらにちょこっと弄ってset-branch/commitが使える様にした。
Ditz の Mercurial プラグイン - ursmの日記

例によって Mercurial のはないみたいだったので、Git のものをちょちょいと手直しして作ってみました。

http://d.hatena.ne.jp/ursm/20080729/1217345141
これまたgit.rbからパクっただけですが...
--- mercurial.rb.orig   2008-11-10 12:30:03.015625000 +0900
+++ mercurial.rb    2008-11-10 12:30:04.921875000 +0900
@@ -2,6 +2,7 @@
  
 module Ditz
   class Issue
+    field :hg_branch, :ask => false
     def hg_commits
       return @hg_commits if @hg_commits
       output = `hg log --template '{date|rfc822date}\t{author}\t{node|short}\t{desc|firstline}\n' #{pathname}`
@@ -45,5 +46,51 @@
 EOS
     end
   end
+  class Operator
+    operation :set_branch, "Set the hg feature branch of an issue", :issue, :maybe_string
+    def set_branch project, config, issue, maybe_string
+      puts "Issue #{issue.name} currently " + if issue.hg_branch
+        "assigned to hg branch #{issue.hg_branch.inspect}."
+      else
+        "not assigned to any hg branch."
 end
 
+      branch = maybe_string || ask("Mercurial feature branch name:")
+      return unless branch
+  
+      if branch == issue.hg_branch
+        raise Error, "issue #{issue.name} already assigned to branch #{issue.hg_branch.inspect}"
+      end
+  
+      puts "Assigning to branch #{branch.inspect}."
+      issue.hg_branch = branch
+    end
+  
+    operation :commit, "Runs hg-commit and auto-fills the issue name in the commit message", :issue do
+      opt :all, "commit all changed files", :short => "-a", :default => false
+      opt :verbose, "show diff between HEAD and what would be committed", \
+        :short => "-v", :default => false
+      opt :message, "Use the given <s> as the commit message.", \
+        :short => "-m", :type => :string
+    end
+  
+    def commit project, config, opts, issue
+  
+      args = {
+        :verbose => "--verbose",
+        :all => "--all",
+      }.map { |k, v| opts[k] ? v : "" }.join(" ")
+  
+      comment = "# #{issue.name}: #{issue.title}"
+      tag = "Ditz-issue: #{issue.id}"
+      message = if opts[:message]
+        "#{opts[:message]}\n\n#{tag}"
+      else
+        "#{comment}\n#{tag}"
+      end
+  
+      message = message.gsub("\"", "\\\"")
+      exec "hg commit #{args} --message=\"#{message}\""
+    end
+  end
+end
ちなみにmercurialとditzを使った開発方法はおおよそ以下の様な感じ。
# cd /path/to/my/repos/example
まず初期設定
# ditz init
# echo '- mercurial' >> .ditz-plugins
# cat > .ditz-config
--- !ditz.rubyforge.org,2008-03-06/config
mercurial_commit_url_prefix: .
^D
# ditz reconfigure
issueを追加
# ditz add
Title: 'foo' is not found in README.
Description (ctrl-d, ., or /stop to stop, /edit to edit, /reset to reset):
> need to add 'foo'
> .
Is this a (b)ugfix, a (f)eature, or a (t)ask? t
Issue creator (enter for "mattn <mattn.jp@gmail.com>"):
Comments (ctrl-d, ., or /stop to stop, /edit to edit, /reset to reset):
> .
Added issue example-1.
You may have to inform your SCM that the following files have been added:
  .ditz/issue-5486bdc5eeb7c4f6c2fc784a4a7c41d949d0791e.yaml

ソースを修正する
# echo 'foo' >> README
# ditz close example-1
Closing issue example-1: 'foo' is not found in README..
Choose a disposition:
  1) fixed
  2) won't fix
  3) reorganized
Disposition (1--3): 1
Comments (ctrl-d, ., or /stop to stop, /edit to edit, /reset to reset):
> added 'foo'
> .
Closed issue test2-2 with disposition fixed.
You may have to inform your SCM that the following files have been modified:
  .ditz/issue-5486bdc5eeb7c4f6c2fc784a4a7c41d949d0791e.yaml

コミットする
# ditz commit
summary付でコミットされている
# hg log
changeset:   6:720dc3bf4ef9
tag:         tip
user:        mattn <mattn.jp@gmail.com>
date:        Mon Nov 10 12:43:21 2008 +0900
summary:     # example-1: 'foo' is not found in README.
ditzの場合は、.ditzフォルダや.ditz-configもリポジトリに格納するのが通常の使い方みたいですね。

ところでditzってバッチっぽく動く様になればいろんなツールが出始めると思うのに勿体無い気がするなぁ。
Posted at 12:51 in ソフトウェア
Tagged as: ditz, mercurial
Bookmarks: add to hatena add to hatena | add to delicious.com | add to livedoor.clip add to livedoor.clip