Commits

Yuya Nishihara committed d27a16d

hg qq, etc.

  • Participants
  • Parent commits 5081265

Comments (0)

Files changed (3)

makeinstall.diff

-makefile: add rule to install executable
-
-diff --git a/Makefile b/Makefile
---- a/Makefile
-+++ b/Makefile
-@@ -29,3 +29,10 @@ check-all: check check-git
- 
- clean:
- 	rm -f $(objects) vcprompt
-+
-+DESTDIR =
-+PREFIX = /usr/local
-+.PHONY: install
-+install: vcprompt
-+	install -d $(DESTDIR)$(PREFIX)/bin
-+	install -m 755 -t $(DESTDIR)$(PREFIX)/bin vcprompt
-diff --git a/README.txt b/README.txt
---- a/README.txt
-+++ b/README.txt
-@@ -19,7 +19,7 @@ To compile vcprompt:
- 
- To install it:
- 
--  cp -p vcprompt ~/bin
-+  make install PREFIX=$HOME
- 
- To use it with bash, just call it in PS1:
- 
 # HG changeset patch
-# Parent 5dcd5518f833c9a96f278e9c01e8f0bbce25e31c
+# Parent d2bc4f950765e2e655bdbdc9abfa2641c00dc7eb
 hg: add support for multiple patch queues, introduced at Mercurial 1.6
 
-TODO: snprintf
+ % hg qqueue -c foo
+ % cat .hg/patches.queue
+ foo
+ % hg qnew bar
+ % ls .hg/patches-foo
+ bar  series  status
 
 diff --git a/src/hg.c b/src/hg.c
 --- a/src/hg.c
 +++ b/src/hg.c
-@@ -104,12 +104,21 @@ static csinfo_t get_csinfo(const char* n
+@@ -113,12 +113,22 @@ static csinfo_t get_csinfo(const char* n
  static size_t get_mq_patchname(char* str, const char* nodeid, size_t n)
  {
      char buf[1024];
-+    char status_file_name[1024] = ".hg/patches/status";
++    char status_file_name[256] = ".hg/patches/status";
++    static const char QQ_STATUS_FILE_PAT[] = ".hg/patches-%s/status";
++    static const size_t MAX_QQ_NAME = sizeof(status_file_name)
++        - (sizeof(QQ_STATUS_FILE_PAT) - 2 - 1);  // - "%s" - '\0'
  
 -    if (read_last_line(".hg/patches/status", buf, 1024)) {
-+    // multiple patch queues, since mercurial 1.6
-+    if (read_first_line(".hg/patches.queue", buf, 1024) && buf[0]) {
++    // multiple patch queues, introduced at mercurial 1.6
++    if (read_first_line(".hg/patches.queue", buf, MAX_QQ_NAME) && buf[0]) {
 +        debug("read first line from .hg/patches.queue: '%s'", buf);
-+        // TODO: snprintf isn't portable
-+        snprintf(status_file_name, sizeof(status_file_name),
-+                 ".hg/patches-%s/status", buf);
++        sprintf(status_file_name, QQ_STATUS_FILE_PAT, buf);
 +    }
 +
 +    if (read_last_line(status_file_name, buf, 1024)) {
 diff --git a/tests/test-simple b/tests/test-simple
 --- a/tests/test-simple
 +++ b/tests/test-simple
-@@ -166,7 +166,15 @@ test_simple_hg_mq ()
+@@ -130,7 +130,15 @@ test_simple_hg_mq ()
      printf 'a123456789abcdefghij\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' \
          > .hg/dirstate
      echo '613132333435363738396162636465666768696a:baz.diff' >> .hg/patches/status
 multi-mq.diff #+experimental
-makeinstall.diff
 debian-skel.diff
 debian-unused.diff
 debian-rules.diff