[darcs-devel] darcs patch

Juliusz Chroboczek jch at pps.jussieu.fr
Mon Jun 28 12:10:03 PDT 2004


--aaack


Mon Jun 28 21:07:20 CEST 2004  Juliusz Chroboczek <jch at pps.jussieu.fr>
  * Use lock directory for temporary lock file.
  This avoids lock creation failing with EXDEV when the repository
  directory and _darcs are not on the same filesystem (e.g. _darcs is
  softlinked).  I hate users.


--aaack
Content-Type: text/x-darcs-patch
Content-Description: A darcs patch for your repository!


New patches:

[Use lock directory for temporary lock file.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040628190720
 This avoids lock creation failing with EXDEV when the repository
 directory and _darcs are not on the same filesystem (e.g. _darcs is
 softlinked).  I hate users.
] {
hunk ./compat.c 43
+/* memrchr is a GNU extension, and rindex is BSD.  Roll our own. */
+
+static void *
+my_memrchr(const void *s, int c, int n)
+{
+    const char *ss = (const char *)s;
+    int i = n - 1;
+
+    while(i >= 0) {
+        if(ss[i] == c)
+            return (void*)(ss + i);
+        i--;
+    }
+    return NULL;
+}
+
hunk ./compat.c 70
-#define FILENAME_SIZE 11 + 15 + 8 + 1
-    char filename[FILENAME_SIZE];
+#define FILENAME_SIZE (11 + 15 + 8 + 1)
+    char *filename;
+    char *lastslash;
+    int dirlen;
hunk ./compat.c 79
+        /* POSIX guarantees 65 is enough. */
hunk ./compat.c 82
-            fprintf(stderr, "Error reading hostname on locking.\n");
-            return -1;
+            fprintf(stderr, "Error reading hostname when locking.\n");
+            strcpy(hostname, "kremvax");
hunk ./compat.c 91
+    lastslash = my_memrchr(p, '/', strlen(p));
+    if(lastslash == NULL)
+        dirlen = 0;
+    else
+        dirlen = lastslash - p + 1;
+
+    filename = malloc(dirlen + FILENAME_SIZE);
+    if(filename == NULL)
+        return -1;
+
+    if(dirlen > 0)
+        memcpy(filename, p, dirlen);
+    filename[dirlen] = '\0';
+
hunk ./compat.c 107
-    rc = snprintf(filename, FILENAME_SIZE, "darcs_lock_%s%04x%04x",
+    rc = snprintf(filename + dirlen, FILENAME_SIZE, "darcs_lock_%s%04x%04x",
hunk ./compat.c 109
-                  ((unsigned int)(now.tv_usec ^ (now.tv_usec << 4))) & 0xFFFF);
+                  ((unsigned)(now.tv_usec ^ (now.tv_usec << 4))) & 0xFFFF);
hunk ./compat.c 111
-        fprintf(stderr, "Error writing to lock filename. (%d)\n", rc);
-        return -1;
+        fprintf(stderr, "Error writing to lock filename (%d)\n", 
+                rc < 0 ? errno : 0);
+        goto fail2;
hunk ./compat.c 118
-        return -1;
+        goto fail2;
hunk ./compat.c 120
-    /* This should cause a correctly implemented NFS client to flush
-       its metadata cache. */
+    /* Paranoia: should cause the client to flush its metadata cache. */
hunk ./compat.c 123
-        fprintf(stderr, "Error closing file %s. (%d)\n", filename, rc);
+        fprintf(stderr, "Error closing file %s. (%d)\n", filename, errno);
hunk ./compat.c 134
+        free(filename);
hunk ./compat.c 144
-        fprintf(stderr, "Couldn't stat %s! (%d)\n", filename, rc);
hunk ./compat.c 149
-        fprintf(stderr, "Wrong number of links to %s! (%d != 2)\n",
-                filename, sb.st_nlink);
hunk ./compat.c 154
+    free(filename);
hunk ./compat.c 161
+ fail2:
+    free(filename);
}



Context:

[support --context option in send.
David Roundy <droundy at abridgegame.org>**20040628102624] 
[add support for a --last option to specify last N changes.
David Roundy <droundy at abridgegame.org>**20040628095805
 This has only been tested so far with diff and changes...
] 
[update and reprioritize TODO.
David Roundy <droundy at abridgegame.org>**20040628091216] 
[Merge debian/ directory with 0.9.22
Gabriel Ebner <ge at gabrielebner.at>**20040627212437] 
[correction on send help.
David Roundy <droundy at abridgegame.org>**20040627093056] 
[Add warning to 'darcs remove' help
Jim Marshall <jmarshall99 at qwest.net>**20040626220417] 
[Small 'command -h' typo fixes and clarifications.
Jim Marshall <jmarshall99 at qwest.net>**20040626212642] 
[fix happy-forwarding to not include nasty long header.
droundy at civet.berkeley.edu**20040627121954
 The catch is that all headers are lost now when the mail is resent, so this
 may make it harder to track down what went wrong if something does go
 wrong.
] 
[Minor doc fixes
Nigel Rowe <rho at swiftdsl.com.au>**20040627035455] 
[work around stupid bug in old autoconfs.
droundy at civet.berkeley.edu**20040627104351] 
[fix up happ-forwarding (hopefully).
David Roundy <droundy at abridgegame.org>**20040627092644] 
[increase laziness of diff_from_empty.
David Roundy <droundy at abridgegame.org>**20040626140020
 I believe this reduces the memory usage of initial records (or whenever
 lots of files are added) and optimize --checkpoint by about a factor of
 four, although I haven't yet tested it on a seriously large repository.
] 
[TAG 0.9.22
David Roundy <droundy at abridgegame.org>**20040626123533] 

Patch bundle hash:
35a6a08e4953eab39ed6a2f872f5d3ee245d5af9

--aaack

--aaack--





More information about the darcs-devel mailing list