assorted-commits Mailing List for Assorted projects (Page 34)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2008-11-30 22:22:25
|
Revision: 1077 http://assorted.svn.sourceforge.net/assorted/?rev=1077&view=rev Author: yangzhang Date: 2008-11-30 21:34:08 +0000 (Sun, 30 Nov 2008) Log Message: ----------- - added nullptr - delegates - added swallow - removed exception handling from run_function0 - st - updated stfd - cleaned up st_tcp_listen - split st_tcp_connect into overloads - added st_lock, st_join, st_mutex, st_cond, st_bool, st_channel, st_intr_hub, st_intr_cond, st_intr_bool, st_intr, st_group_join_exception, st_joining, st_thread_group - sockets - cleaned up casts - updated tcp_listen signature - check - added checkerr, checknnegerr, checkeqnneg - added some comments on how to revamp check.h Modified Paths: -------------- cpp-commons/trunk/src/commons/boost/delegates.h cpp-commons/trunk/src/commons/check.h cpp-commons/trunk/src/commons/sockets.h cpp-commons/trunk/src/commons/st/st.h Added Paths: ----------- cpp-commons/trunk/src/commons/nullptr.h Modified: cpp-commons/trunk/src/commons/boost/delegates.h =================================================================== --- cpp-commons/trunk/src/commons/boost/delegates.h 2008-11-29 07:51:27 UTC (rev 1076) +++ cpp-commons/trunk/src/commons/boost/delegates.h 2008-11-30 21:34:08 UTC (rev 1077) @@ -3,12 +3,20 @@ #include <boost/function.hpp> #include <boost/scoped_ptr.hpp> +#include <iostream> // for cerr namespace commons { using namespace boost; + using namespace std; + void + swallow(const function0<void> f) { + try { f(); } + catch (exception &ex) { cerr << ex.what() << endl; } + } + /** * Delegate for running a 0-ary void function. */ @@ -16,8 +24,7 @@ run_function0(void *p) { scoped_ptr< const function0<void> > pf((const function0<void>*) p); - try { (*pf)(); } - catch (exception ex) { cerr << ex.what() << endl; } + (*pf)(); } /** @@ -30,6 +37,17 @@ return NULL; } + // TODO: is there a way to do this? +// /** +// * Exception-returning delegate for running a 0-ary void function. +// */ +// void* +// run_function0_ex(void* p) +// { +// try { run_function0(p); } +// catch (exception &ex) { return exception(ex); } +// } + } #endif Modified: cpp-commons/trunk/src/commons/check.h =================================================================== --- cpp-commons/trunk/src/commons/check.h 2008-11-29 07:51:27 UTC (rev 1076) +++ cpp-commons/trunk/src/commons/check.h 2008-11-30 21:34:08 UTC (rev 1077) @@ -1,16 +1,32 @@ #ifndef COMMONS_CHECK_H #define COMMONS_CHECK_H -#define buflen 4096 - #include <exception> #include <sstream> #include <string> #include <commons/die.h> +// TODO: rename: +// - chk(x): verifies and return x; if not, throw strerror +// - chk(x, msg...): prepend "$msg: " to strerror +// - chk(x, false): don't use errno/strerror +// - chk(x, false, msg...) +// - chknoret(x): doesn't return x and doesn't use strerror +// - chk0(x): verifies !x; if not, throw strerror +// - same overloads as chk +// - chkpos(x): returns x; if not positive, throw strerror +// - same overloads as chk +// - chknneg(x): returns x; if negative, throw strerror +// - same overloads as chk +// - chkeq(x,y): if x!=y, throw; if x<0, throw strerror +// +// - chkr(): same as chk but returns -1 instead of throwing + namespace commons { + enum { buflen = 4096 }; + // TODO: deal with va args // TODO: provide strerror in other functions too // TODO: better way to deal with errno? (rather than resetting it) @@ -22,7 +38,7 @@ public: check_exception(const string & name) : name(name) {} virtual ~check_exception() throw() {} - const char *what() const throw() { return name.c_str(); } + virtual const char *what() const throw() { return name.c_str(); } private: const string name; }; @@ -38,7 +54,6 @@ vsnprintf(buf, buflen, fmt, ap); ss << buf; } - ss << endl; throw check_exception(ss.str()); } } @@ -72,6 +87,28 @@ return x; } + template<typename T> inline T + _checknnegerr(T x, const char *file, int line) + { + if (x < 0) { + int e = errno; + errno = 0; + _check(x, file, line, "expecting >=0, got %d: %s", x, strerror(e)); + } + return x; + } + + template<typename T> inline T + _checkerr(T x, const char *file, int line) + { + if (!x) { + int e = errno; + errno = 0; + _check(x, file, line, "expecting !=0, got %d: %s", x, strerror(e)); + } + return x; + } + template<typename T> inline void _check0(T x, const char *file, int line) { @@ -97,6 +134,19 @@ } } + template<typename T, typename U> inline void + _checkeqnneg(T l, U r, const char *file, int line) + { + if (l < 0) { + int e = errno; + errno = 0; + _check(l == r, file, line, + "expecting %d, got %d: %s", r, l, strerror(e)); + } else { + _checkeq(l, r, file, line); + } + } + } /** @@ -117,11 +167,21 @@ #define checkpass(expr, msg...) _checkpass(expr, __FILE__, __LINE__, ## msg) /** + * Same as checkpass(), but includes the strerror message in the exception. + */ +#define checkerr(expr) _checkerr(expr, __FILE__, __LINE__) + +/** * Checks that the value is non-negative. */ #define checknneg(expr, msg...) _checknneg(expr, __FILE__, __LINE__, ## msg) /** + * Same as checknneg, but include the strerror in the exception. + */ +#define checknnegerr(expr) _checknnegerr(expr, __FILE__, __LINE__) + +/** * Checks that the value is 0. Same as check0(), but throws an error rather * than return. Also clears the errno on error. The resulting exception * includes the strerror(). @@ -134,6 +194,13 @@ */ #define checkeq(l, r, msg...) _checkeq(l, r, __FILE__, __LINE__, ## msg) +/** + * Like checkeq, but if the left value is negative, then interpret that as a + * sign of error, and include the errorstr in the exception message. + */ +#define checkeqnneg(l, r, msg...) \ + _checkeqnneg(l, r, __FILE__, __LINE__, ## msg) + #if 0 #define checkmsg(cond, msg) \ bool b__ = cond; \ Added: cpp-commons/trunk/src/commons/nullptr.h =================================================================== --- cpp-commons/trunk/src/commons/nullptr.h (rev 0) +++ cpp-commons/trunk/src/commons/nullptr.h 2008-11-30 21:34:08 UTC (rev 1077) @@ -0,0 +1,28 @@ +#ifndef COMMONS_NULLPTR_H +#define COMMONS_NULLPTR_H + +// From <http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr> + +namespace commons +{ + + const // It is a const object... + class nullptr_t + { + public: + template<class T> + operator T*() const // convertible to any type of null non-member pointer... + { return 0; } + + template<class C, class T> + operator T C::*() const // or any type of null member pointer... + { return 0; } + + private: + void operator&() const; // Can't take address of nullptr + + } nullptr = {}; + +} + +#endif Modified: cpp-commons/trunk/src/commons/sockets.h =================================================================== --- cpp-commons/trunk/src/commons/sockets.h 2008-11-29 07:51:27 UTC (rev 1076) +++ cpp-commons/trunk/src/commons/sockets.h 2008-11-30 21:34:08 UTC (rev 1077) @@ -6,6 +6,8 @@ #include <netinet/in.h> #include <strings.h> #include <sys/socket.h> +#include <sys/types.h> +#include <fcntl.h> #include <unistd.h> #include <commons/check.h> @@ -20,7 +22,7 @@ * \return The server socket. */ int - server_socket(int port, bool nb = false) + server_socket(uint16_t port, bool nb = false) { // Create the socket. int fd = checknneg(socket(PF_INET, SOCK_STREAM, 0)); @@ -28,8 +30,8 @@ try { // Configure the socket. int n = 1; - check0x(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&n, - sizeof(n))); + check0x(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast<char *>(&n), sizeof(n))); // Make our socket non-blocking if desired. if (nb) { @@ -37,14 +39,14 @@ } // Create the local socket address. - struct sockaddr_in sa; + sockaddr_in sa; bzero(&sa, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_port = htons(port); sa.sin_addr.s_addr = htonl(INADDR_ANY); // Bind the socket to the local socket address. - check0x(bind(fd, (struct sockaddr*) &sa, sizeof(struct sockaddr_in))); + check0x(bind(fd, (sockaddr*) &sa, sizeof sa)); return fd; } catch (...) { @@ -60,7 +62,7 @@ * \return The listener socket. */ int - tcp_listen(int port, bool nb = false) + tcp_listen(uint16_t port, bool nb = false) { int fd = server_socket(port, nb); try { Modified: cpp-commons/trunk/src/commons/st/st.h =================================================================== --- cpp-commons/trunk/src/commons/st/st.h 2008-11-29 07:51:27 UTC (rev 1076) +++ cpp-commons/trunk/src/commons/st/st.h 2008-11-30 21:34:08 UTC (rev 1077) @@ -1,12 +1,22 @@ #ifndef COMMONS_ST_ST_H #define COMMONS_ST_ST_H +#include <exception> +#include <map> +#include <queue> +#include <set> +#include <sstream> #include <st.h> #include <stx.h> +#include <commons/nullptr.h> +// delegates.h must be included after sockets.h due to bind() conflicts. #include <commons/sockets.h> #include <commons/boost/delegates.h> +#include <boost/foreach.hpp> #include <boost/function.hpp> +#define foreach BOOST_FOREACH + namespace commons { using namespace boost; @@ -28,20 +38,32 @@ }; /** - * non-copyable. - * \todo remove? this seems to be bad if it closes the file! + * \todo Make non-copyable. */ class stfd { public: stfd(st_netfd_t fd) : fd_(fd), sclose(fd) {} - const st_netfd_t fd() const { return fd_; } + st_netfd_t fd() const { return fd_; } + operator st_netfd_t() const { return fd_; } private: const st_netfd_t fd_; st_closing sclose; }; /** + * RAII to acquire and release a st_mutex_t. Non-copyable. + */ + class st_lock + { + public: + st_lock(st_mutex_t mx) : mx_(mx) { check0x(st_mutex_lock(mx)); } + ~st_lock() { check0x(st_mutex_unlock(mx_)); } + private: + st_mutex_t mx_; + }; + + /** * Run a function in pthread. * \return The new pthread_t on success, 0 on failure. * \todo Is it safe to treat the pthread_t as a pointer? @@ -55,36 +77,35 @@ default_stack_size); } + void + st_join(st_thread_t t) + { + check0x(st_thread_join(t, nullptr)); + } + /** * Connect to a TCP socket address. - * \param[in] host Either an IP address or hostname. + * \param[in] host An IP address. * \param[in] port The destination port. - * \param[in] timeout The timeout for each of the DNS lookup and the connect - * operation. - * \todo Create variants that take or return the sockaddr. + * \param[in] timeout The timeout for the connect operation. */ st_netfd_t - st_tcp_connect(char *host, int port, st_utime_t timeout) + st_tcp_connect(in_addr host, uint16_t port, st_utime_t timeout) { // Create remote socket address. struct sockaddr_in sa; bzero(&sa, sizeof sa); sa.sin_family = AF_INET; sa.sin_port = htons(port); + sa.sin_addr = host; - // First try to parse as IP address. Note: inet_addr() is obsolete. - if (inet_aton(host, &sa.sin_addr) != 0) { - // Then look up by hostname. - check0x(stx_dns_getaddr(host, &sa.sin_addr, timeout)); - } - // Create the socket. int sfd = checknneg(socket(PF_INET, SOCK_STREAM, 0)); st_netfd_t nfd = st_netfd_open_socket(sfd); // Connect. try { - check0x(st_connect(nfd, (struct sockaddr*) &sa, sizeof sa, timeout)); + check0x(st_connect(nfd, (sockaddr*) &sa, sizeof sa, timeout)); return nfd; } catch (...) { st_netfd_close(nfd); @@ -93,26 +114,261 @@ } /** + * Connect to a TCP socket address. + * \param[in] host Either an IP address or hostname. + * \param[in] port The destination port. + * \param[in] timeout The timeout for each of the DNS lookup and the connect + * operation. + * \todo Create variants that take and/or return sockaddr_in's. + */ + st_netfd_t + st_tcp_connect(const char *host, uint16_t port, st_utime_t timeout) + { + in_addr ipaddr; + + // First try to parse as IP address. Note: inet_addr() is obsolete. Note: + // inet_aton returns 0 if address is invalid. + if (inet_aton(host, &ipaddr) == 0) { + // Then look up by hostname. + check0x(stx_dns_getaddr(host, &ipaddr, timeout)); + } + + return st_tcp_connect(ipaddr, port, timeout); + } + + /** * Create a listener st_netfd_t. * \param[in] port The port to listen on. * \return The st_netfd_t. */ st_netfd_t - st_tcp_listen(int port) + st_tcp_listen(uint16_t port) { int sfd = tcp_listen(port); try { // Create a net file descriptor around a listener socket. - st_netfd_t nfd = st_netfd_open_socket(sfd); - checkpass(nfd); - //st_netfd_t nfd = checkpass(st_netfd_open_socket(sfd)); - return nfd; + return checkpass(st_netfd_open_socket(sfd)); } catch (...) { close(sfd); throw; } } + /** + * Wraps st_cond_* errno-functions with exceptions and cleans up on + * destruction. + */ + class st_cond + { + public: + st_cond() : c(checkerr(st_cond_new())) {} + ~st_cond() { check0x(st_cond_destroy(c)); } + void wait() { check0x(st_cond_wait(c)); } + void wait(st_utime_t t) { check0x(st_cond_timedwait(c, t)); } + void signal() { st_cond_signal(c); } + void bcast() { st_cond_broadcast(c); } + private: + st_cond_t c; + }; + + /** + * Synchronized boolean. + */ + class st_bool + { + public: + st_bool(bool init = false) : b(init) {} + void set() { b = true; c.bcast(); } + void reset() { b = false; c.bcast(); } + void waitset() { if (!b) c.wait(); } + void waitreset() { if (b) c.wait(); } + operator bool() { return b; } + private: + st_cond c; + bool b; + }; + + /** + * Wraps st_mutex_* errno-functions with exceptions and cleans up on + * destruction. + */ + class st_mutex + { + public: + st_mutex() : m(checkerr(st_mutex_new())) {} + ~st_mutex() { check0x(st_mutex_destroy(m)); } + void lock() { check0x(st_mutex_lock(m)); } + bool trylock() { + int res = st_mutex_trylock(m); + if (res == 0) return true; + else if (errno == EBUSY) return false; + else check0x(res); + } + void unlock() { check0x(st_mutex_unlock(m)); } + private: + st_mutex_t m; + }; + + /** + * An unbounded FIFO queue. ST threads can wait on this until elements have + * been pushed in (resulting in a waking signal). + */ + template <typename T> + class st_channel + { + public: + void push(const T &x) { + q_.push(x); + empty_.signal(); + } + T take() { + while (q_.empty()) + empty_.wait(); + T x = front(); + q_.pop(); + return x; + } + const T& front() const { return q_.front(); } + bool empty() const { return q_.empty(); } + void pop() { q_.pop(); } + void clear() { while (!q_.empty()) q_.pop(); } + const std::queue<T> &queue() const { return q_; } + private: + std::queue<T> q_; + st_cond empty_; + }; + + /** + * A hub is a single point to signal to wake up a set of threads. Threads + * join the hub before calling a blocking operation if they want to make + * themselves interruptible on this hub. + */ + class st_intr_hub + { + public: + virtual void insert(st_thread_t t) = 0; + virtual void erase(st_thread_t t) = 0; + }; + + /** + * The simplest hub, which only interrupts those who are currently joined in + * the hub (like a condition variable broadcast). + */ + class st_intr_cond : public st_intr_hub + { + public: + void insert(st_thread_t t) { threads.insert(t); } + void erase(st_thread_t t) { threads.erase(t); } + void signal() { + foreach (st_thread_t t, threads) { + st_thread_interrupt(t); + } + threads.clear(); + } + private: + set<st_thread_t> threads; + }; + + /** + * Like st_intr_cond, but a bool instead, so there's state; newly joining + * threads may immediately be interrupted. Interruption occurs when this is + * set to true. + */ + class st_intr_bool : public st_intr_hub + { + public: + void insert(st_thread_t t) { + if (b) st_thread_interrupt(t); + else threads.insert(t); + } + void erase(st_thread_t t) { threads.erase(t); } + void set() { + b = true; + foreach (st_thread_t t, threads) { + st_thread_interrupt(t); + } + threads.clear(); + } + void reset() { + // If b is true, then any threads that join are immediately + // interrupted, so the set must be empty. + assert(!b || threads.empty()); + b = false; + } + operator bool() const { return b; } + private: + std::set<st_thread_t> threads; + bool b; + }; + + /** + * RAII for making the current thread interruptible on a certain hub. + */ + class st_intr + { + public: + st_intr(st_intr_hub &hub) : hub_(hub) { hub.insert(st_thread_self()); } + ~st_intr() { hub_.erase(st_thread_self()); } + private: + st_intr_hub &hub_; + }; + + class st_group_join_exception : public exception + { + public: + st_group_join_exception(const map<st_thread_t, exception> &th2ex) : + th2ex_(th2ex) {} + virtual ~st_group_join_exception() throw() {} + virtual const char *what() const throw() { + if (!th2ex_.empty() && s == "") { + bool first = true; + stringstream ss; + typedef pair<st_thread_t, exception> p; + foreach (p p, th2ex_) { + ss << (first ? "" : ", ") << p.first << " -> " << p.second.what(); + first = false; + } + const_cast<string&>(s) = ss.str(); + } + return s.c_str(); + } + private: + map<st_thread_t, exception> th2ex_; + string s; + }; + + /** + * RAII for joining on a single thread. + */ + class st_joining + { + public: + st_joining(st_thread_t t) : t_(t) {} + ~st_joining() { st_join(t_); } + private: + st_thread_t t_; + }; + + /** + * RAII for joining on all contained threads. Warning: st_join may throw + * exceptions. + */ + class st_thread_group + { + public: + ~st_thread_group() { + map<st_thread_t, exception> th2ex; + foreach (st_thread_t t, ts) { + try { st_join(t); } + catch (exception &ex) { th2ex[t] = ex; } + } + if (!th2ex.empty()) throw st_group_join_exception(th2ex); + } + void insert(st_thread_t t) { ts.insert(t); } + private: + set<st_thread_t> ts; + }; + } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-29 07:51:31
|
Revision: 1076 http://assorted.svn.sourceforge.net/assorted/?rev=1076&view=rev Author: yangzhang Date: 2008-11-29 07:51:27 +0000 (Sat, 29 Nov 2008) Log Message: ----------- updated readme Modified Paths: -------------- google-file-search/trunk/README Modified: google-file-search/trunk/README =================================================================== --- google-file-search/trunk/README 2008-11-29 07:50:42 UTC (rev 1075) +++ google-file-search/trunk/README 2008-11-29 07:51:27 UTC (rev 1076) @@ -1,2 +1,2 @@ -A simple web frontend to Google for finding files in web directory listings, -especially media files (mp3s). +A simple web frontend to Google for finding files hosted by services like +Rapidshare and Megaupload. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-29 07:50:55
|
Revision: 1075 http://assorted.svn.sourceforge.net/assorted/?rev=1075&view=rev Author: yangzhang Date: 2008-11-29 07:50:42 +0000 (Sat, 29 Nov 2008) Log Message: ----------- updated to provide searches over file hosts like rapidshare and megaupload Modified Paths: -------------- google-file-search/trunk/src/gfs.php Modified: google-file-search/trunk/src/gfs.php =================================================================== --- google-file-search/trunk/src/gfs.php 2008-11-21 01:37:44 UTC (rev 1074) +++ google-file-search/trunk/src/gfs.php 2008-11-29 07:50:42 UTC (rev 1075) @@ -1,11 +1,10 @@ <?php +$services = explode( + ' ', + 'megaupload rapidshare zshare yousendit mediafire badongo' +); if ($_POST['query']) { - $query = urlencode( - 'intitle:"index of" +"last modified" +"parent directory" ' . - '+(mp3|wma|ogg) -inurl:htm -inurl:html -inurl:php -inurl:asp ' . - //'-site:openpirate.com ' . - $_POST['query'] - ); + $query = urlencode(implode(' | ', $services) . ' ' . $_POST['query']); header('Location: http://www.google.com/search?q=' . $query); exit; } @@ -15,7 +14,13 @@ <title>Google File Search</title> </head> <body> -<form method="post" action="gfs.php"> +<p>Currently searches:</p> +<ul> +<? foreach ($services as $service): ?> +<li><?=htmlentities($service)?></li> +<? endforeach ?> +</ul> +<form method="post" action="index.php"> <input name="query" style="width: 100%" /> </form> </body> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-21 01:39:37
|
Revision: 1074 http://assorted.svn.sourceforge.net/assorted/?rev=1074&view=rev Author: yangzhang Date: 2008-11-21 01:37:44 +0000 (Fri, 21 Nov 2008) Log Message: ----------- initial commit of ydb! Added Paths: ----------- ydb/ ydb/trunk/ ydb/trunk/src/ ydb/trunk/src/Makefile ydb/trunk/src/main.lzz ydb/trunk/src/ydb.proto ydb/trunk/src/ydb.thrift Added: ydb/trunk/src/Makefile =================================================================== --- ydb/trunk/src/Makefile (rev 0) +++ ydb/trunk/src/Makefile 2008-11-21 01:37:44 UTC (rev 1074) @@ -0,0 +1,59 @@ +TARGET := ydb + +LZZS := $(wildcard *.lzz) +LZZHDRS := $(foreach lzz,$(LZZS),$(patsubst %.lzz,%.hh,$(lzz))) +LZZSRCS := $(foreach lzz,$(LZZS),$(patsubst %.lzz,%.cc,$(lzz))) +LZZOBJS := $(foreach lzz,$(LZZS),$(patsubst %.lzz,%.o,$(lzz))) + +PBS := $(wildcard *.proto) +PBHDRS := $(foreach pb,$(PBS),$(patsubst %.proto,%.pb.h,$(pb))) +PBSRCS := $(foreach pb,$(PBS),$(patsubst %.proto,%.pb.cc,$(pb))) +PBOBJS := $(foreach pb,$(PBS),$(patsubst %.proto,%.o,$(pb))) + +GENHDRS := $(LZZHDRS) $(PBHDRS) +GENSRCS := $(LZZSRCS) $(PBSRCS) +GENOBJS := $(LZZOBJS) $(PBOBJS) + +HDRS := $(GENHDRS) +SRCS := $(GENSRCS) +OBJS := $(GENOBJS) + +LDFLAGS := -lstx -lst -lresolv -lpthread -lprotobuf +CXXFLAGS := -g3 -Wall -Werror -Wextra -Woverloaded-virtual -Wconversion \ + -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \ + -Winit-self -Wno-sign-compare -Wno-unused-parameter -Wc++0x-compat \ + -Wparentheses +PBCXXFLAGS := -g3 -Wall -Werror + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CXX) -o $@ $^ $(LDFLAGS) + +%.o: %.cc $(PBHDRS) + wtf $(CXX) $(CXXFLAGS) -c -o $@ $< + +%.o: %.pb.cc %.pb.h + wtf $(CXX) $(PBCXXFLAGS) -c -o $@ $< + +%.cc: %.lzz + lzz -hx hh -sx cc -hl -sl -hd -sd $< + +%.hh: %.lzz + lzz -hx hh -sx cc -hl -sl -hd -sd $< + +%.pb.cc: %.proto + protoc --cpp_out=. $< + +%.pb.h: %.proto + protoc --cpp_out=. $< + +clean: + rm -f $(GENSRCS) $(GENHDRS) $(OBJS) $(TARGET) + +doc: $(SRCS) $(HDRS) + doxygen + +.PHONY: clean + +.SECONDARY: $(SRCS) $(HDRS) $(OBJS) Added: ydb/trunk/src/main.lzz =================================================================== --- ydb/trunk/src/main.lzz (rev 0) +++ ydb/trunk/src/main.lzz 2008-11-21 01:37:44 UTC (rev 1074) @@ -0,0 +1,328 @@ +// TODO +// - how does replication affect overhead? +// - implement other recovery schemes (disk-based) +// - verify correctness of the simple recovery scheme + +#hdr +#include <boost/bind.hpp> +#include <boost/foreach.hpp> +#include <commons/nullptr.h> +#include <commons/st/st.h> +#include <cstdio> +#include <cstdlib> +#include <iostream> +#include <map> +#include <sstream> +#include <vector> +#include "ydb.pb.h" +#define foreach BOOST_FOREACH +using namespace boost; +using namespace commons; +using namespace std; +#end + +extern int chkpt = 1000; +extern const st_utime_t timeout = 1000000; +extern const bool verbose = false; + +/** + * Send a message to some destinations (sequentially). + */ +template<typename T> +void +bcastmsg(const vector<st_netfd_t> &dsts, const T & msg) +{ + // Serialize message to a buffer. + string s; + check(msg.SerializeToString(&s)); + const char *buf = s.c_str(); + + // Prefix the message with a four-byte length. + uint32_t len = htonl(static_cast<uint32_t>(s.size())); + + // Broadcast the length-prefixed message to replicas. + foreach (st_netfd_t dst, dsts) { + checkeqnneg(st_write(dst, static_cast<void*>(&len), sizeof len, timeout), + static_cast<int>(sizeof len)); + checkeqnneg(st_write(dst, buf, s.size(), timeout), + static_cast<int>(s.size())); + } +} + +/** + * Send a message to a single recipient. + */ +template<typename T> +void +sendmsg(st_netfd_t dst, const T &msg) +{ + vector<st_netfd_t> dsts(1, dst); + bcastmsg(dsts, msg); +} + +/** + * Read a message. + */ +template <typename T> +void +readmsg(st_netfd_t src, T & msg) +{ + // Read the message length. + uint32_t len; + checkeqnneg(st_read_fully(src, static_cast<void*>(&len), sizeof len, + ST_UTIME_NO_TIMEOUT), + static_cast<int>(sizeof len)); + len = ntohl(len); + + // Parse the message body. + char buf[len]; + checkeqnneg(st_read_fully(src, buf, len, timeout), (int) len); + check(msg.ParseFromArray(buf, len)); +} + +inline int +rand32(int max = RAND_MAX) +{ + return static_cast<int>( random() / ( RAND_MAX / max ) ); +} + +/** + * Keep issuing transactions to the replicas. + */ +void +issue_txns(const vector<st_netfd_t> &replicas) +{ + Op_OpType types[] = {Op::read, Op::write, Op::del}; + size_t lastsize = replicas.size(); + cout << "replicas = " << &replicas << endl; + int i = 0; + while (true) { + if (replicas.size() != lastsize) { + cout << "size changed from " << lastsize << " to " << replicas.size() + << endl; + lastsize = replicas.size(); + } + // Generate a random transaction. + Txn txn; + int count = rand32(5) + 1; + for (int o = 0; o < count; o++) { + Op *op = txn.add_op(); + int rtype = rand32(3), rkey = rand32(), rvalue = rand32(); + op->set_type(types[rtype]); + op->set_key(rkey); + op->set_value(rvalue); + } + bcastmsg(replicas, txn); + if (++i % chkpt == 0) { + if (verbose) cout << "issued txn " << i << endl; + st_sleep(0); + } + } +} + +/** + * Keep swallowing replica responses. + */ +void +handle_responses(st_netfd_t replica) +{ + int i = 0; + while (true) { + Response res; + readmsg(replica, res); + if (++i % chkpt == 0) { + if (verbose) + cout << "got response " << i << " from " << replica << " of size " + << res.result_size() << endl; + st_sleep(0); + } + } +} + +/** + * Actually do the work of executing a transaction and sending back the reply. + */ +void +process_txns(st_netfd_t leader, map<int, int> &map) +{ + int i = 0; + while (true) { + Txn txn; + readmsg(leader, txn); + + Response res; + for (int o = 0; o < txn.op_size(); o++) { + const Op &op = txn.op(o); + switch (op.type()) { + case Op::read: + res.add_result(map[op.key()]); + break; + case Op::write: + map[op.key()] = op.value(); + break; + case Op::del: + map.erase(op.key()); + break; + } + } + sendmsg(leader, res); + + if (++i % chkpt == 0) { + if (verbose) cout << "processed txn " << i << endl; + st_sleep(0); + } + } +} + +/** + * Help the recovering node. + */ +void +recover_joiner(st_netfd_t listener, const map<int, int> &map) +{ + st_netfd_t joiner = checkpass(st_accept(listener, nullptr, nullptr, + ST_UTIME_NO_TIMEOUT)); + cout << "got the joiner! " << joiner << endl; + Recovery recovery; + typedef pair<int, int> pii; + foreach (pii p, map) { + Recovery_Pair *pair = recovery.add_pair(); + pair->set_key(p.first); + pair->set_value(p.second); + } + sendmsg(joiner, recovery); +} + +int +main(int argc, char **argv) +{ + check0x(st_init()); + if (argc < 2) + die("leader: ydb <nreplicas>\n" + "replica: ydb <leaderhost> <leaderport> <listenport>\n" + "joiner: ydb <leaderhost> <leaderport>\n"); + bool is_leader = argc == 2; + bool is_joiner = argc == 3; + if (is_leader) { + cout << "starting as leader" << endl; + + // Wait until all replicas have joined. + st_netfd_t listener = st_tcp_listen(7654); + vector<st_netfd_t> replicas; + for (int i = 1; i < atoi(argv[1]); i++) { + replicas.push_back(checkpass( + st_accept(listener, nullptr, nullptr, ST_UTIME_NO_TIMEOUT))); + } + + // Construct the initialization message. + Init init; + foreach (st_netfd_t r, replicas) { + // Get socket addresses. + + sockaddr_in sa; + socklen_t salen = sizeof sa; + check0x(getpeername(st_netfd_fileno(r), reinterpret_cast<sockaddr*>(&sa), &salen)); + + SockAddr *psa = init.add_node(); + psa->set_host(sa.sin_addr.s_addr); + psa->set_port(sa.sin_port); + } + + bcastmsg(replicas, init); + + // Start dispatching queries. + const function0<void> f = bind(issue_txns, ref(replicas)); + st_thread_t t = st_spawn(bind(swallow, f)); + + // Start handling responses. + vector<st_thread_t> handlers(replicas.size()); + foreach (st_netfd_t r, replicas) { + handlers.push_back(st_spawn(bind(handle_responses, r))); + } + + // Accept the recovering node, and tell it about the online replicas. + st_netfd_t joiner = checkpass(st_accept(listener, nullptr, nullptr, + ST_UTIME_NO_TIMEOUT)); + sendmsg(joiner, init); + + // Bring the new guy "back" into action. + Ready ready; + readmsg(joiner, ready); + cout << "the prodigal son has returned" << endl; + cout << "replicas = " << &replicas << endl; + replicas.push_back(joiner); + handlers.push_back(st_spawn(bind(handle_responses, joiner))); + + // Wait on other threads. + check0x(st_thread_join(t, nullptr)); + + // Cleanly close all connections. + foreach (st_netfd_t r, replicas) { + check0x(st_netfd_close(r)); + } + check0x(st_netfd_close(listener)); + } else { + map<int, int> map; + + // Connect to the leader. + char *host = argv[1]; + uint16_t port = static_cast<uint16_t>(atoi(argv[2])); + + if (!is_joiner) { + // Listen for then talk to the joiner. + st_netfd_t listener = + st_tcp_listen(static_cast<uint16_t>(atoi(argv[3]))); + st_spawn(bind(recover_joiner, listener, ref(map))); + } + + st_sleep(0); + cout << "here" << endl; + st_netfd_t leader = st_tcp_connect(host, port, timeout); + cout << "there" << endl; + + // Read the initialization message. + Init init; + readmsg(leader, init); + + // Display the info. + cout << "hosts:" << endl; + vector<st_netfd_t> replicas; + for (uint16_t i = 0; i < init.node_size(); i++) { + const SockAddr &sa = init.node(i); + char buf[INET_ADDRSTRLEN]; + in_addr host; + host.s_addr = sa.host(); + cout << checkpass(inet_ntop(AF_INET, &host, buf, INET_ADDRSTRLEN)) + << ':' << sa.port() << endl; + if (is_joiner) + replicas.push_back(st_tcp_connect(host, static_cast<uint16_t>(7655+i), + timeout)); + } + + if (is_joiner) { + // Read the recovery message. + Recovery recovery; + readmsg(replicas[0], recovery); + for (int i = 0; i < recovery.pair_size(); i++) { + const Recovery_Pair &p = recovery.pair(i); + map[p.key()] = p.value(); + } + cout << "recovered." << endl; + + // Notify the leader. + Ready ready; + sendmsg(leader, ready); + } + + // Process txns. + st_thread_t t = st_spawn(bind(process_txns, leader, ref(map))); + check0x(st_thread_join(t, nullptr)); + + foreach (st_netfd_t r, replicas) { + check0x(st_netfd_close(r)); + } + check0x(st_netfd_close(leader)); + } + + return 0; +} Added: ydb/trunk/src/ydb.proto =================================================================== --- ydb/trunk/src/ydb.proto (rev 0) +++ ydb/trunk/src/ydb.proto 2008-11-21 01:37:44 UTC (rev 1074) @@ -0,0 +1,33 @@ +message SockAddr { + required int32 host = 1; + required int32 port = 2; +} +message Init { + repeated SockAddr node = 1; +} +message Op { + enum OpType { + read = 0; + write = 1; + del = 2; + } + required OpType type = 1; + required int32 key = 2; + optional int32 value = 3; +} +message Txn { + repeated Op op = 1; +} +message Response { + repeated int32 result = 1; +} +message Ready { + optional int32 ready = 1; +} +message Recovery { + message Pair { + required int32 key = 1; + required int32 value = 2; + } + repeated Pair pair = 1; +} Added: ydb/trunk/src/ydb.thrift =================================================================== --- ydb/trunk/src/ydb.thrift (rev 0) +++ ydb/trunk/src/ydb.thrift 2008-11-21 01:37:44 UTC (rev 1074) @@ -0,0 +1,9 @@ +enum op_type { read, write, rm } +struct sock_addr { i32 host, i16 port } +struct init { list<sock_addr> node } +struct op { op_type type, i32 key, optional i32 value } +struct txn { list<op> op } +struct response { list<i32> results } +struct ready {} +struct pair { i32 key, i32 value } +struct recovery { list<pair> pairs } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-11 18:49:21
|
Revision: 1073 http://assorted.svn.sourceforge.net/assorted/?rev=1073&view=rev Author: yangzhang Date: 2008-11-11 18:49:10 +0000 (Tue, 11 Nov 2008) Log Message: ----------- adding more barnowl config Modified Paths: -------------- configs/trunk/setup-yang.bash configs/trunk/src/owl/startup Added Paths: ----------- configs/trunk/src/owl/modules/ configs/trunk/src/owl/modules/ColorUtils.par Modified: configs/trunk/setup-yang.bash =================================================================== --- configs/trunk/setup-yang.bash 2008-11-07 21:11:32 UTC (rev 1072) +++ configs/trunk/setup-yang.bash 2008-11-11 18:49:10 UTC (rev 1073) @@ -19,7 +19,7 @@ install .inputrc inputrc install .gitconfig gitconfig install .gitignore gitignore -install .owl/ owl/startup +install .owl owl install .pythonrc.py pythonrc.py install .screenrc screenrc install .signature signature Added: configs/trunk/src/owl/modules/ColorUtils.par =================================================================== (Binary files differ) Property changes on: configs/trunk/src/owl/modules/ColorUtils.par ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: configs/trunk/src/owl/startup =================================================================== --- configs/trunk/src/owl/startup 2008-11-07 21:11:32 UTC (rev 1072) +++ configs/trunk/src/owl/startup 2008-11-11 18:49:10 UTC (rev 1073) @@ -1,2 +1,10 @@ -set logging on -set classlogging on +set logging +set classlogging +unset fancylines + +# colors +viewclass xvm +filter class-xvm -c blue +viewclass sipb +filter class-sipb -c cyan +view all This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 21:11:38
|
Revision: 1072 http://assorted.svn.sourceforge.net/assorted/?rev=1072&view=rev Author: yangzhang Date: 2008-11-07 21:11:32 +0000 (Fri, 07 Nov 2008) Log Message: ----------- renamed hstore to voltdb Modified Paths: -------------- personal-site/trunk/src/index.txt Modified: personal-site/trunk/src/index.txt =================================================================== --- personal-site/trunk/src/index.txt 2008-11-07 21:10:30 UTC (rev 1071) +++ personal-site/trunk/src/index.txt 2008-11-07 21:11:32 UTC (rev 1072) @@ -56,8 +56,8 @@ Here are the non-confidential projects in which I've been involved. More details when I have time! -- [H-Store]: a distributed main-memory relational database management system - for on-line transaction processing workloads. +- [VoltDB] (formerly H-Store): a distributed main-memory relational database + management system for on-line transaction processing workloads. - Invirt: [SIPB]'s virtual machine management system. The name of the MIT instance of this service is [XVM]. - Corey: an exokernel operating system for many-core architectures. @@ -96,7 +96,7 @@ [SIPB]: http://sipb.mit.edu/ [XVM]: http://xvm.mit.edu/ -[H-Store]: http://db.cs.yale.edu/hstore/ +[VoltDB]: http://db.cs.yale.edu/hstore/ [WebTables]: slides/webtables-presentation-google07.pdf [Scalable Resilient Overlay Networks]: http://nms.csail.mit.edu/ron/ @@ -135,12 +135,16 @@ del.icio.us - [JSamp]: a simple sampling profiler for Java - [Simple Publications Manager]: publication management web application -- [ICFPC 2008 entry]: with Kwon An, Chris Lesniewski-Laas, and Greg Little +- [ICFPC 2008 entry]: with Byoung Kwon An, Chris Lesniewski-Laas, and Greg + Little - [BattleCode 2008 entry]: with Greg Little +- [ICFPC 2007 entry]: with Christophe Poucet, Dmitry Astapov, David + Himmelstrup, Per Vognsen, Johannes Ahlmann, and Cale Gibbard [Assorted Projects]: http://assorted.sf.net/ [BattleCode 2008 entry]: http://www.assembla.com/spaces/battlecode2008 [ICFPC 2008 entry]: http://www.assembla.com/spaces/icfpc08-csail +[ICFPC 2007 entry]: http://downloads.sourceforge.net/assorted/icfpc2007-lazybottoms.tgz [JSamp]: http://jsamp.googlecode.com/ [Simple Publications Manager]: http://pubmgr.sf.net/ [gbookmark2delicious]: http://gbookmark2delicious.googlecode.com/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 21:10:35
|
Revision: 1071 http://assorted.svn.sourceforge.net/assorted/?rev=1071&view=rev Author: yangzhang Date: 2008-11-07 21:10:30 +0000 (Fri, 07 Nov 2008) Log Message: ----------- added a note Modified Paths: -------------- sandbox/trunk/src/nix/backtrace/run.bash Modified: sandbox/trunk/src/nix/backtrace/run.bash =================================================================== --- sandbox/trunk/src/nix/backtrace/run.bash 2008-11-07 21:09:26 UTC (rev 1070) +++ sandbox/trunk/src/nix/backtrace/run.bash 2008-11-07 21:10:30 UTC (rev 1071) @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# TODO: write a demo of how to get more informative backtraces from a shared +# library. (I.e.: is relocation problematic?) + rdynamic=-rdynamic rdynamic= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 21:09:28
|
Revision: 1070 http://assorted.svn.sourceforge.net/assorted/?rev=1070&view=rev Author: yangzhang Date: 2008-11-07 21:09:26 +0000 (Fri, 07 Nov 2008) Log Message: ----------- demo of how to get a backtrace Added Paths: ----------- sandbox/trunk/src/nix/backtrace/ sandbox/trunk/src/nix/backtrace/plain.c sandbox/trunk/src/nix/backtrace/resolving.c sandbox/trunk/src/nix/backtrace/run.bash Added: sandbox/trunk/src/nix/backtrace/plain.c =================================================================== --- sandbox/trunk/src/nix/backtrace/plain.c (rev 0) +++ sandbox/trunk/src/nix/backtrace/plain.c 2008-11-07 21:09:26 UTC (rev 1070) @@ -0,0 +1,36 @@ +// Demo of how to get a basic backtrace. + +#include <execinfo.h> // backtrace, backtrace_symbols_fd +#include <stddef.h> // size_t +#include <unistd.h> // STDOUT_FILENO + +enum { max_frames = 20 }; + +void +foo(int x) +{ + void *a[max_frames]; + size_t sz = backtrace(a, sizeof a / sizeof *a); + backtrace_symbols_fd(a, sz, STDOUT_FILENO); +} + +void +bar() +{ + foo(0); +} + +int +main() +{ + bar(); + return 0; +} + +// Output: +// +// ./demo(foo+0x22)[0x4007ca] +// ./demo(bar+0xe)[0x4007f7] +// ./demo(main+0xe)[0x400807] +// /lib/libc.so.6(__libc_start_main+0xf4)[0x7fbe5b02c1c4] +// ./demo[0x400719] Added: sandbox/trunk/src/nix/backtrace/resolving.c =================================================================== --- sandbox/trunk/src/nix/backtrace/resolving.c (rev 0) +++ sandbox/trunk/src/nix/backtrace/resolving.c 2008-11-07 21:09:26 UTC (rev 1070) @@ -0,0 +1,73 @@ +// Demo of how to get a backtrace along with file and line numbers. + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <dlfcn.h> +#include <execinfo.h> +#include <signal.h> +#include <bfd.h> +#include <unistd.h> + +#define MAX_FRAMES (20) + +/* globals retained across calls to resolve. */ +static bfd* abfd = 0; +static asymbol **syms = 0; +static asection *text = 0; + +static void resolve(char *address) { + if (!abfd) { + char ename[1024]; + int l = readlink("/proc/self/exe",ename,sizeof(ename)); + if (l == -1) { + perror("failed to find executable\n"); + return; + } + ename[l] = 0; + + bfd_init(); + + abfd = bfd_openr(ename, 0); + if (!abfd) { + perror("bfd_openr failed: "); + return; + } + /* oddly, this is required for it to work... */ + bfd_check_format(abfd,bfd_object); + + unsigned storage_needed = bfd_get_symtab_upper_bound(abfd); + syms = (asymbol **) malloc(storage_needed); + unsigned cSymbols = bfd_canonicalize_symtab(abfd, syms); + + text = bfd_get_section_by_name(abfd, ".text"); + } + long offset = ((long)address) - text->vma; + if (offset > 0) { + const char *file; + const char *func; + unsigned line; + if (bfd_find_nearest_line(abfd, text, syms, offset, &file, &func, &line) && file) + printf("file: %s, line: %u, func %s\n",file,line,func); + } +} + +static void print_trace() { + void *array[MAX_FRAMES]; + size_t size; + size_t i; + void *approx_text_end = (void*) ((128+100) * 2<<20); + + size = backtrace (array, MAX_FRAMES); + printf ("Obtained %zd stack frames.\n", size); + for (i = 0; i < size; i++) { + if (array[i] < approx_text_end) { + resolve(array[i]); + } + } +} + +int main() { + print_trace(); + return 0; +} Added: sandbox/trunk/src/nix/backtrace/run.bash =================================================================== --- sandbox/trunk/src/nix/backtrace/run.bash (rev 0) +++ sandbox/trunk/src/nix/backtrace/run.bash 2008-11-07 21:09:26 UTC (rev 1070) @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +rdynamic=-rdynamic +rdynamic= + +# -g and -rdynamic are not necessary. +gcc $rdynamic -o plain plain.c +./plain | head -1 | sed 's/.*\[//; s/\]$//' + +echo + +# -rdynamic still necessary if it was there before. +gcc -g $rdynamic -o plain2 plain.c +addr2line --demangle --functions -e plain2 \ + "$(./plain | head -1 | sed 's/.*\[//; s/\]$//')" + +echo + +# -g necessary. +gcc -g -fPIC -lbfd -o resolving resolving.c +./resolving Property changes on: sandbox/trunk/src/nix/backtrace/run.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 21:06:44
|
Revision: 1069 http://assorted.svn.sourceforge.net/assorted/?rev=1069&view=rev Author: yangzhang Date: 2008-11-07 21:06:33 +0000 (Fri, 07 Nov 2008) Log Message: ----------- added showcmd Modified Paths: -------------- configs/trunk/src/vim/plugin/_yang.vim Modified: configs/trunk/src/vim/plugin/_yang.vim =================================================================== --- configs/trunk/src/vim/plugin/_yang.vim 2008-11-07 20:55:53 UTC (rev 1068) +++ configs/trunk/src/vim/plugin/_yang.vim 2008-11-07 21:06:33 UTC (rev 1069) @@ -150,6 +150,7 @@ set shiftwidth=2 set showmatch set nosmartindent " TODO ??? +set showcmd " show the partial command; in visual mode, show num lines selected set switchbuf=useopen " TODO ??? set tabstop=2 set updatetime=500 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 20:56:08
|
Revision: 1068 http://assorted.svn.sourceforge.net/assorted/?rev=1068&view=rev Author: yangzhang Date: 2008-11-07 20:55:53 +0000 (Fri, 07 Nov 2008) Log Message: ----------- added nop, updated overload_new Modified Paths: -------------- sandbox/trunk/src/cc/overload_new.cc Added Paths: ----------- sandbox/trunk/src/c/nop.c Added: sandbox/trunk/src/c/nop.c =================================================================== --- sandbox/trunk/src/c/nop.c (rev 0) +++ sandbox/trunk/src/c/nop.c 2008-11-07 20:55:53 UTC (rev 1068) @@ -0,0 +1 @@ +int main() { return 0; } Modified: sandbox/trunk/src/cc/overload_new.cc =================================================================== --- sandbox/trunk/src/cc/overload_new.cc 2008-11-07 20:02:47 UTC (rev 1067) +++ sandbox/trunk/src/cc/overload_new.cc 2008-11-07 20:55:53 UTC (rev 1068) @@ -63,13 +63,23 @@ // You can add extra parameters to operator new. void * -operator new(std::size_t sz, const char file[16], int line) +operator new(std::size_t sz, const char *file, int line) throw(std::bad_alloc) { std::cout << "calling operator new at " << file << ':' << line << std::endl; return operator new(sz); } +// Don't forget to do the same for arrays! + +void * +operator new[](std::size_t sz, const char *file, int line) +throw(std::bad_alloc) +{ + std::cout << "calling operator new[] at " << file << ':' << line << std::endl; + return operator new(sz); +} + class D { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 20:02:57
|
Revision: 1067 http://assorted.svn.sourceforge.net/assorted/?rev=1067&view=rev Author: yangzhang Date: 2008-11-07 20:02:47 +0000 (Fri, 07 Nov 2008) Log Message: ----------- forgot to update setup-yang.bash Modified Paths: -------------- configs/trunk/setup-yang.bash Modified: configs/trunk/setup-yang.bash =================================================================== --- configs/trunk/setup-yang.bash 2008-11-07 20:02:28 UTC (rev 1066) +++ configs/trunk/setup-yang.bash 2008-11-07 20:02:47 UTC (rev 1067) @@ -18,6 +18,7 @@ install .devscripts devscripts install .inputrc inputrc install .gitconfig gitconfig +install .gitignore gitignore install .owl/ owl/startup install .pythonrc.py pythonrc.py install .screenrc screenrc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-07 20:02:41
|
Revision: 1066 http://assorted.svn.sourceforge.net/assorted/?rev=1066&view=rev Author: yangzhang Date: 2008-11-07 20:02:28 +0000 (Fri, 07 Nov 2008) Log Message: ----------- added .gitignore; added more aliases to .gitconfig Modified Paths: -------------- configs/trunk/src/gitconfig Added Paths: ----------- configs/trunk/src/gitignore Modified: configs/trunk/src/gitconfig =================================================================== --- configs/trunk/src/gitconfig 2008-11-06 22:12:00 UTC (rev 1065) +++ configs/trunk/src/gitconfig 2008-11-07 20:02:28 UTC (rev 1066) @@ -2,6 +2,10 @@ b = branch ci = commit -a co = checkout + com = commit h = help + pr = pull --rebase llog = log --date=local st = status +[core] + excludesfile = /home/yang/.gitignore Added: configs/trunk/src/gitignore =================================================================== --- configs/trunk/src/gitignore (rev 0) +++ configs/trunk/src/gitignore 2008-11-07 20:02:28 UTC (rev 1066) @@ -0,0 +1,21 @@ +tags +cscope.* +*.aux +*.aux +*.elc +*.ml[io] +*.hi +.*.sw? +*.class +*.pyc +*.o +*.lo +*.la +#*# +.*.rej +*.rej +.*~ +*~ +.#* +.DS_Store +.project.vim This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 22:12:05
|
Revision: 1065 http://assorted.svn.sourceforge.net/assorted/?rev=1065&view=rev Author: yangzhang Date: 2008-11-06 22:12:00 +0000 (Thu, 06 Nov 2008) Log Message: ----------- cleaned and extended the test suite Modified Paths: -------------- sandbox/trunk/src/git/gitsvn.bash Modified: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash 2008-11-06 19:56:45 UTC (rev 1064) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-06 22:12:00 UTC (rev 1065) @@ -3,8 +3,10 @@ # Demo of how git svn and cloning that would work. Run this with e.g.: # ./gitsvn.bash /tmp/test -set -o errexit -o nounset +set -o errexit -o nounset -o xtrace +shownormal=false showfailure=false shownofailure=true + fail=false if $fail then rebase= @@ -16,204 +18,141 @@ mkdir -p $basedir cd $basedir +munge() { + local i=$1 dir=$2 + sed -i s/line$i\$/Line$i/ $dir/myfile +} + +svnci() { + local i=$1 + munge $i svn + svn ci -q -m "munge line$i in svn" svn/ +} + +gitci() { + local i=$1 + munge $i gitsvn + (cd gitsvn; git commit -q -a -m "munge line$i in git") +} + +cloci() { + local i=$1 + munge $i gitsvn2 + (cd gitsvn2; git commit -q -a -m "munge line$i in clo") +} + +svn2git() { + (cd gitsvn; git svn -q rebase) +} + +clo2git() { + (cd gitsvn; git pull $rebase -q file://$basedir/gitsvn2) +} + +gitst() { + if false + then (cd gitsvn; git log --pretty='format:%h... %ar by %an: %s') + fi +} + +clost() { + if false + then (cd gitsvn; git log --pretty='format:%h... %ar by %an: %s') + fi +} + # set up an svn repo mkdir svnrepo svnadmin create svnrepo # add something to the repo svn co -q file://$basedir/svnrepo svn -echo -e 'line1\nline2\nline3\nline4' > svn/myfile +seq 90 | xargs -I_ echo line_ > svn/myfile svn add -q svn/myfile svn ci -q -m 'added myfile' svn/ -# git clone it -# s +# clone the svn repo and commit there git svn -q clone file://$basedir/svnrepo gitsvn +gitci 30 -# make some more changes to svn and mirror those to gitsvn -# s--s -echo -e 'line5\nline6\nline7\nline8' >> svn/myfile -svn ci -q -m 'added more lines' svn/ -(cd gitsvn; git svn -q rebase) +# clone the git repo and commit there +git clone -q file://$basedir/gitsvn gitsvn2 +cloci 60 -# make concurrent changes to both svn and git -# s--s--s -# `-g -# ==> -# s--s--s -# `-g -sed -i s/line1/Line1/ svn/myfile -sed -i s/line5/Line5/ gitsvn/myfile -svn ci -q -m 'munge line1' svn/ -(cd gitsvn; git commit -a -m 'munge line5'; git svn -q rebase) -# clone the git repo elsewhere and commit something there -# s--s--s -# `-g -# `-G -git clone -q file://$basedir/gitsvn gitsvn2 -sed -i s/line8/Line8/ gitsvn2/myfile -(cd gitsvn2; git commit -q -a -m 'munge line8') -# make concurrent change to svn, and original git repo -# s--s--s--s -# `-g--g -# `-G -# ==> -# s--s--s--s -# `-g--g -# `-g -# `-G -sed -i s/line2/Line2/ svn/myfile -svn ci -q -m 'munge line2' svn/ -(cd gitsvn; git svn -q rebase) +if $shownormal ; then -# make another concurrent change to svn, then pull (merge) gitsvn2 changes into -# the original git repo, then update gitsvn from svn -# s--s--s--s--s -# `-g--g -# `-g -# `-G -# ==> -# s--s--s--s--s -# `-g--g--g -# `-g -# `-G-------' -# ==> -# CONFLICT -sed -i s/line3/Line3/ svn/myfile -svn ci -q -m 'munge line3' svn/ -# XXX problem here -( - cd gitsvn - git pull $rebase -q file://$basedir/gitsvn2 - git svn -q rebase || git diff -) + # commit to svn then pull to git + svnci 1 + svn2git + gitst -# Output: + # make another concurrent change to svn, then pull (merge) gitsvn2 changes into + # the original git repo, then update gitsvn from svn + svnci 3 + clo2git + gitst + svn2git + gitst + + # make any number of changes at any site before pulling in + + svnci 10 + svnci 12 + svnci 14 + + gitci 40 + gitci 42 + gitci 44 + + cloci 70 + cloci 72 + cloci 74 + + # either direction works + clo2git + svn2git + +fi + +# everything above was "commutative" + +if $showfailure ; then + + # these work + svnci 10 + gitci 11 + svnci 12 + gitci 13 + svnci 14 + gitci 15 + svn2git + +fi + +if $shownofailure ; then + + gitci 10 + cloci 11 + gitci 12 + cloci 13 + gitci 14 + cloci 15 + clo2git + +fi + +# What's actually happening? # -# $ bash -x ./gitsvn.bash /tmp/t4 -# + set -o errexit -o nounset -# + fail=false -# + false -# + rebase=--rebase -# + basedir=/tmp/t4 -# + mkdir -p /tmp/t4 -# + cd /tmp/t4 -# + mkdir svnrepo -# + svnadmin create svnrepo -# + svn co -q file:///tmp/t4/svnrepo svn -# + echo -e 'line1\nline2\nline3\nline4' -# + svn add -q svn/myfile -# + svn ci -q -m 'added myfile' svn/ -# + git svn -q clone file:///tmp/t4/svnrepo gitsvn -# Initialized empty Git repository in .git/ -# r1 = f39dddf518003f497e89b08c7d9ce03cb0834a5e (git-svn) -# Checked out HEAD: -# file:///tmp/t4/svnrepo r1 -# + echo -e 'line5\nline6\nline7\nline8' -# + svn ci -q -m 'added more lines' svn/ -# + cd gitsvn -# + git svn -q rebase -# r2 = 4eb6330c853563989930ebac27165fd613dca81b (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 4eb6330... added more lines -# Fast-forwarded master to refs/remotes/git-svn. -# + sed -i s/line1/Line1/ svn/myfile -# + sed -i s/line5/Line5/ gitsvn/myfile -# + svn ci -q -m 'munge line1' svn/ -# + cd gitsvn -# + git commit -a -m 'munge line5' -# Created commit 1da2513: munge line5 -# 1 files changed, 1 insertions(+), 1 deletions(-) -# + git svn -q rebase -# r3 = 89c2629a7bc6e67e90e28e143b32ae0cf9c82d3a (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 89c2629... munge line1 -# Applying munge line5 -# + git clone -q file:///tmp/t4/gitsvn gitsvn2 -# remote: Counting objects: 12, done. -# remote: Compressing objects: 100% (4/4), done. -# remote: Total 12 (delta 1), reused 0 (delta 0) -# + sed -i s/line8/Line8/ gitsvn2/myfile -# + cd gitsvn2 -# + git commit -q -a -m 'munge line8' -# + sed -i s/line2/Line2/ svn/myfile -# + svn ci -q -m 'munge line2' svn/ -# + cd gitsvn -# + git svn -q rebase -# r4 = 3073ef827c94d15a1f4b6c1187ba97cac5128241 (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 3073ef8... munge line2 -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# + sed -i s/line3/Line3/ svn/myfile -# + svn ci -q -m 'munge line3' svn/ -# + cd gitsvn -# + git pull --rebase -q file:///tmp/t4/gitsvn2 -# remote: Counting objects: 8, done. -# remote: Compressing objects: 100% (2/2), done. -# remote: Total 6 (delta 0), reused 3 (delta 0) -# Unpacking objects: 100% (6/6), done. -# First, rewinding head to replay your work on top of it... -# HEAD is now at 9cfe5a5... munge line8 -# Applying munge line2 -# error: patch failed: myfile:1 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# No changes -- Patch already applied. -# + git svn -q rebase -# r5 = aafbc408b0567d24e25eb96a940b69a5c20bd9cc (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at aafbc40... munge line3 -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# Applying munge line8 -# Applying munge line2 -# error: patch failed: myfile:1 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# CONFLICT (content): Merge conflict in myfile -# Failed to merge in the changes. -# Patch failed at 0003. -# -# When you have resolved this problem run "git rebase --continue". -# If you would prefer to skip this patch, instead run "git rebase --skip". -# To restore the original branch and stop rebasing run "git rebase --abort". -# -# rebase refs/remotes/git-svn: command returned error: 1 -# -# + git diff -# diff --cc myfile -# index 2560a81,3813bf9..0000000 -# --- a/myfile -# +++ b/myfile -# @@@ -1,6 -1,6 +1,10 @@@ -# Line1 -# Line2 -# ++<<<<<<< HEAD:myfile -# +Line3 -# ++======= -# + line3 -# ++>>>>>>> munge line2:myfile -# line4 -# Line5 -# line6 +# When you do a git pull --rebase, it puts all your local changes after the +# remote changes. +# +# So when you do git svn rebase, changes from the main git repo and its clone +# come after the svn changes. +# +# And when you do git pull --rebase from the clone, changes from the main git +# repo and svn come after the clone changes. +# +# Rebasing in general requires your changes to be "portable" (not sure if +# "commutative" is accurate) so that changes can be moved around/reordered. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 19:57:08
|
Revision: 1064 http://assorted.svn.sourceforge.net/assorted/?rev=1064&view=rev Author: yangzhang Date: 2008-11-06 19:56:45 +0000 (Thu, 06 Nov 2008) Log Message: ----------- trying git pull --rebase instead; still running into issues Modified Paths: -------------- sandbox/trunk/src/git/gitsvn.bash Modified: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash 2008-11-06 09:20:08 UTC (rev 1063) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-06 19:56:45 UTC (rev 1064) @@ -5,6 +5,12 @@ set -o errexit -o nounset +fail=false +if $fail +then rebase= +else rebase=--rebase +fi + # this is where the experiment will take place basedir=$1 mkdir -p $basedir @@ -15,141 +21,171 @@ svnadmin create svnrepo # add something to the repo -svn co file://$basedir/svnrepo svn -echo -e 'line1\nline2\nline3' > svn/myfile -svn add svn/myfile -svn ci -m 'added myfile' svn/ +svn co -q file://$basedir/svnrepo svn +echo -e 'line1\nline2\nline3\nline4' > svn/myfile +svn add -q svn/myfile +svn ci -q -m 'added myfile' svn/ # git clone it -git svn clone file://$basedir/svnrepo gitsvn +# s +git svn -q clone file://$basedir/svnrepo gitsvn # make some more changes to svn and mirror those to gitsvn -echo -e 'line4\nline5\nline6' >> svn/myfile -svn ci -m 'added more lines' svn/ -(cd gitsvn; git svn rebase) +# s--s +echo -e 'line5\nline6\nline7\nline8' >> svn/myfile +svn ci -q -m 'added more lines' svn/ +(cd gitsvn; git svn -q rebase) # make concurrent changes to both svn and git +# s--s--s +# `-g +# ==> +# s--s--s +# `-g sed -i s/line1/Line1/ svn/myfile -sed -i s/line4/Line4/ gitsvn/myfile -svn ci -m 'munge line1' svn/ -(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) +sed -i s/line5/Line5/ gitsvn/myfile +svn ci -q -m 'munge line1' svn/ +(cd gitsvn; git commit -a -m 'munge line5'; git svn -q rebase) # clone the git repo elsewhere and commit something there -git clone file://$basedir/gitsvn gitsvn2 -sed -i s/line6/Line6/ gitsvn2/myfile -(cd gitsvn2; git commit -a -m 'munge line6') +# s--s--s +# `-g +# `-G +git clone -q file://$basedir/gitsvn gitsvn2 +sed -i s/line8/Line8/ gitsvn2/myfile +(cd gitsvn2; git commit -q -a -m 'munge line8') # make concurrent change to svn, and original git repo +# s--s--s--s +# `-g--g +# `-G +# ==> +# s--s--s--s +# `-g--g +# `-g +# `-G sed -i s/line2/Line2/ svn/myfile -svn ci -m 'munge line2' svn/ -(cd gitsvn; git svn rebase) +svn ci -q -m 'munge line2' svn/ +(cd gitsvn; git svn -q rebase) -# make another concurrent change to svn, then pull gitsvn2 changes into the -# original git repo, then update gitsvn from svn +# make another concurrent change to svn, then pull (merge) gitsvn2 changes into +# the original git repo, then update gitsvn from svn +# s--s--s--s--s +# `-g--g +# `-g +# `-G +# ==> +# s--s--s--s--s +# `-g--g--g +# `-g +# `-G-------' +# ==> +# CONFLICT sed -i s/line3/Line3/ svn/myfile -svn ci -m 'munge line3' svn/ -(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) # XXX problem here! +svn ci -q -m 'munge line3' svn/ +# XXX problem here +( + cd gitsvn + git pull $rebase -q file://$basedir/gitsvn2 + git svn -q rebase || git diff +) +# Output: +# +# $ bash -x ./gitsvn.bash /tmp/t4 # + set -o errexit -o nounset -# + basedir=/tmp/test2 -# + mkdir -p /tmp/test2 -# + cd /tmp/test2 +# + fail=false +# + false +# + rebase=--rebase +# + basedir=/tmp/t4 +# + mkdir -p /tmp/t4 +# + cd /tmp/t4 # + mkdir svnrepo # + svnadmin create svnrepo -# + svn co file:///tmp/test2/svnrepo svn -# Checked out revision 0. -# + echo -e 'line1\nline2\nline3' -# + svn add svn/myfile -# A svn/myfile -# + svn ci -m 'added myfile' svn/ -# Adding svn/myfile -# Transmitting file data . -# Committed revision 1. -# + git svn clone file:///tmp/test2/svnrepo gitsvn +# + svn co -q file:///tmp/t4/svnrepo svn +# + echo -e 'line1\nline2\nline3\nline4' +# + svn add -q svn/myfile +# + svn ci -q -m 'added myfile' svn/ +# + git svn -q clone file:///tmp/t4/svnrepo gitsvn # Initialized empty Git repository in .git/ -# A myfile -# r1 = e03653693de0cfebfcfb1ed7d9d3db896421ee7a (git-svn) +# r1 = f39dddf518003f497e89b08c7d9ce03cb0834a5e (git-svn) # Checked out HEAD: -# file:///tmp/test2/svnrepo r1 -# + echo -e 'line4\nline5\nline6' -# + svn ci -m 'added more lines' svn/ -# Sending svn/myfile -# Transmitting file data . -# Committed revision 2. +# file:///tmp/t4/svnrepo r1 +# + echo -e 'line5\nline6\nline7\nline8' +# + svn ci -q -m 'added more lines' svn/ # + cd gitsvn -# + git svn rebase -# M myfile -# r2 = c8f7e4bc4a623abcabf27d34c6716c1f13c37da2 (git-svn) +# + git svn -q rebase +# r2 = 4eb6330c853563989930ebac27165fd613dca81b (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at c8f7e4b... added more lines +# HEAD is now at 4eb6330... added more lines # Fast-forwarded master to refs/remotes/git-svn. # + sed -i s/line1/Line1/ svn/myfile -# + sed -i s/line4/Line4/ gitsvn/myfile -# + svn ci -m 'munge line1' svn/ -# Sending svn/myfile -# Transmitting file data . -# Committed revision 3. +# + sed -i s/line5/Line5/ gitsvn/myfile +# + svn ci -q -m 'munge line1' svn/ # + cd gitsvn -# + git commit -a -m 'munge line4' -# Created commit 4efa529: munge line4 +# + git commit -a -m 'munge line5' +# Created commit 1da2513: munge line5 # 1 files changed, 1 insertions(+), 1 deletions(-) -# + git svn rebase -# M myfile -# r3 = 76ffe8259f02910393f7f03fdfd0c81b12cfbcee (git-svn) +# + git svn -q rebase +# r3 = 89c2629a7bc6e67e90e28e143b32ae0cf9c82d3a (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at 76ffe82... munge line1 -# Applying munge line4 -# error: patch failed: myfile:1 +# HEAD is now at 89c2629... munge line1 +# Applying munge line5 +# + git clone -q file:///tmp/t4/gitsvn gitsvn2 +# remote: Counting objects: 12, done. +# remote: Compressing objects: 100% (4/4), done. +# remote: Total 12 (delta 1), reused 0 (delta 0) +# + sed -i s/line8/Line8/ gitsvn2/myfile +# + cd gitsvn2 +# + git commit -q -a -m 'munge line8' +# + sed -i s/line2/Line2/ svn/myfile +# + svn ci -q -m 'munge line2' svn/ +# + cd gitsvn +# + git svn -q rebase +# r4 = 3073ef827c94d15a1f4b6c1187ba97cac5128241 (git-svn) +# First, rewinding head to replay your work on top of it... +# HEAD is now at 3073ef8... munge line2 +# Applying munge line5 +# error: patch failed: myfile:2 # error: myfile: patch does not apply # Using index info to reconstruct a base tree... # Falling back to patching base and 3-way merge... # Auto-merged myfile -# + git clone file:///tmp/test2/gitsvn gitsvn2 -# Initialized empty Git repository in /tmp/test2/gitsvn2/.git/ -# + sed -i s/line6/Line6/ gitsvn2/myfile -# + cd gitsvn2 -# + git commit -a -m 'munge line6' -# Created commit 33eebd0: munge line6 -# 1 files changed, 1 insertions(+), 1 deletions(-) -# + sed -i s/line2/Line2/ svn/myfile -# + svn ci -m 'munge line2' svn/ -# Sending svn/myfile -# Transmitting file data . -# Committed revision 4. +# + sed -i s/line3/Line3/ svn/myfile +# + svn ci -q -m 'munge line3' svn/ # + cd gitsvn -# + git svn rebase -# M myfile -# r4 = 3923d574137132addd9f32ca40170f62aae0c456 (git-svn) +# + git pull --rebase -q file:///tmp/t4/gitsvn2 +# remote: Counting objects: 8, done. +# remote: Compressing objects: 100% (2/2), done. +# remote: Total 6 (delta 0), reused 3 (delta 0) +# Unpacking objects: 100% (6/6), done. # First, rewinding head to replay your work on top of it... -# HEAD is now at 3923d57... munge line2 -# Applying munge line4 +# HEAD is now at 9cfe5a5... munge line8 +# Applying munge line2 # error: patch failed: myfile:1 # error: myfile: patch does not apply # Using index info to reconstruct a base tree... # Falling back to patching base and 3-way merge... # Auto-merged myfile -# + sed -i s/line3/Line3/ svn/myfile -# + svn ci -m 'munge line3' svn/ -# Sending svn/myfile -# Transmitting file data . -# Committed revision 5. -# + cd gitsvn -# + git pull file:///tmp/test2/gitsvn2 -# remote: Counting objects: 8, done.[K -# remote: Compressing objects: 50% (1/2) [K -remote: Compressing objects: 100% (2/2) [K -remote: Compressing objects: 100% (2/2[K)remote: , done.[K -# remote: Total 6 (delta 0), reused 3 (delta 0)[K +# Applying munge line5 +# error: patch failed: myfile:2 +# error: myfile: patch does not apply +# Using index info to reconstruct a base tree... +# Falling back to patching base and 3-way merge... # Auto-merged myfile -# Merge made by recursive. -# myfile | 2 +- -# 1 files changed, 1 insertions(+), 1 deletions(-) -# + git svn rebase -# M myfile -# r5 = c90dcc08fb3cc07f714662d6e1d1054ba1678b75 (git-svn) +# No changes -- Patch already applied. +# + git svn -q rebase +# r5 = aafbc408b0567d24e25eb96a940b69a5c20bd9cc (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at c90dcc0... munge line3 -# Applying munge line4 +# HEAD is now at aafbc40... munge line3 +# Applying munge line5 +# error: patch failed: myfile:2 +# error: myfile: patch does not apply +# Using index info to reconstruct a base tree... +# Falling back to patching base and 3-way merge... +# Auto-merged myfile +# Applying munge line8 +# Applying munge line2 # error: patch failed: myfile:1 # error: myfile: patch does not apply # Using index info to reconstruct a base tree... @@ -157,7 +193,7 @@ # Auto-merged myfile # CONFLICT (content): Merge conflict in myfile # Failed to merge in the changes. -# Patch failed at 0001. +# Patch failed at 0003. # # When you have resolved this problem run "git rebase --continue". # If you would prefer to skip this patch, instead run "git rebase --skip". @@ -165,3 +201,19 @@ # # rebase refs/remotes/git-svn: command returned error: 1 # +# + git diff +# diff --cc myfile +# index 2560a81,3813bf9..0000000 +# --- a/myfile +# +++ b/myfile +# @@@ -1,6 -1,6 +1,10 @@@ +# Line1 +# Line2 +# ++<<<<<<< HEAD:myfile +# +Line3 +# ++======= +# + line3 +# ++>>>>>>> munge line2:myfile +# line4 +# Line5 +# line6 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 09:20:18
|
Revision: 1063 http://assorted.svn.sourceforge.net/assorted/?rev=1063&view=rev Author: yangzhang Date: 2008-11-06 09:20:08 +0000 (Thu, 06 Nov 2008) Log Message: ----------- oops Modified Paths: -------------- sandbox/trunk/src/nix/btmalloc/btmalloc.c Modified: sandbox/trunk/src/nix/btmalloc/btmalloc.c =================================================================== --- sandbox/trunk/src/nix/btmalloc/btmalloc.c 2008-11-06 09:16:47 UTC (rev 1062) +++ sandbox/trunk/src/nix/btmalloc/btmalloc.c 2008-11-06 09:20:08 UTC (rev 1063) @@ -1,4 +1,4 @@ -#include "backtrace.c" +#include "backtrace.h" #define _GNU_SOURCE #include <stdio.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 09:16:57
|
Revision: 1062 http://assorted.svn.sourceforge.net/assorted/?rev=1062&view=rev Author: yangzhang Date: 2008-11-06 09:16:47 +0000 (Thu, 06 Nov 2008) Log Message: ----------- added the btmalloc debugging tool Added Paths: ----------- sandbox/trunk/src/nix/btmalloc/ sandbox/trunk/src/nix/btmalloc/backtrace.h sandbox/trunk/src/nix/btmalloc/btmalloc.c sandbox/trunk/src/nix/btmalloc/run.bash sandbox/trunk/src/nix/btmalloc/test.cc Added: sandbox/trunk/src/nix/btmalloc/backtrace.h =================================================================== --- sandbox/trunk/src/nix/btmalloc/backtrace.h (rev 0) +++ sandbox/trunk/src/nix/btmalloc/backtrace.h 2008-11-06 09:16:47 UTC (rev 1062) @@ -0,0 +1,65 @@ +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <dlfcn.h> +#include <execinfo.h> +#include <signal.h> +#include <bfd.h> +#include <unistd.h> + +#define MAX_FRAMES (20) + +/* globals retained across calls to resolve. */ +static bfd* abfd = 0; +static asymbol **syms = 0; +static asection *text = 0; + +static void resolve(char *address) { + if (!abfd) { + char ename[1024]; + int l = readlink("/proc/self/exe",ename,sizeof(ename)); + if (l == -1) { + perror("failed to find executable\n"); + return; + } + ename[l] = 0; + + bfd_init(); + + abfd = bfd_openr(ename, 0); + if (!abfd) { + perror("bfd_openr failed: "); + return; + } + /* oddly, this is required for it to work... */ + bfd_check_format(abfd,bfd_object); + + unsigned storage_needed = bfd_get_symtab_upper_bound(abfd); + syms = (asymbol **) malloc(storage_needed); + + text = bfd_get_section_by_name(abfd, ".text"); + } + long offset = ((long)address) - text->vma; + if (offset > 0) { + const char *file; + const char *func; + unsigned line; + if (bfd_find_nearest_line(abfd, text, syms, offset, &file, &func, &line) && file) + printf("file: %s, line: %u, func %s\n",file,line,func); + } +} + +static void print_trace() { + void *array[MAX_FRAMES]; + size_t size; + size_t i; + void *approx_text_end = (void*) ((128+100) * 2<<20); + + size = backtrace (array, MAX_FRAMES); + printf ("Obtained %zd stack frames.\n", size); + for (i = 0; i < size; i++) { + if (array[i] < approx_text_end) { + resolve(array[i]); + } + } +} Copied: sandbox/trunk/src/nix/btmalloc/btmalloc.c (from rev 1061, sandbox/trunk/src/nix/preload/interposer.c) =================================================================== --- sandbox/trunk/src/nix/btmalloc/btmalloc.c (rev 0) +++ sandbox/trunk/src/nix/btmalloc/btmalloc.c 2008-11-06 09:16:47 UTC (rev 1062) @@ -0,0 +1,24 @@ +#include "backtrace.c" + +#define _GNU_SOURCE +#include <stdio.h> +#include <dlfcn.h> + +void * +malloc(size_t sz) +{ + // Find and cache the next malloc (in our example it should be the "real" + // malloc). + static void * (*func)(); + if (!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "malloc"); + + void *p = func(sz); + + if (!p) { + printf("malloc failed!\n"); + print_trace(); + } + + return p; +} Added: sandbox/trunk/src/nix/btmalloc/run.bash =================================================================== --- sandbox/trunk/src/nix/btmalloc/run.bash (rev 0) +++ sandbox/trunk/src/nix/btmalloc/run.bash 2008-11-06 09:16:47 UTC (rev 1062) @@ -0,0 +1,3 @@ +g++ -Wall -g3 -o test test.cc +gcc -Wall -lbfd -ldl -fPIC -shared -o btmalloc.so btmalloc.c #backtrace.c +LD_PRELOAD=./btmalloc.so ./test Property changes on: sandbox/trunk/src/nix/btmalloc/run.bash ___________________________________________________________________ Added: svn:executable + * Added: sandbox/trunk/src/nix/btmalloc/test.cc =================================================================== --- sandbox/trunk/src/nix/btmalloc/test.cc (rev 0) +++ sandbox/trunk/src/nix/btmalloc/test.cc 2008-11-06 09:16:47 UTC (rev 1062) @@ -0,0 +1,3 @@ +void foo() { operator new(-1); } +void bar() { foo(); } +int main() { bar(); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 09:06:47
|
Revision: 1061 http://assorted.svn.sourceforge.net/assorted/?rev=1061&view=rev Author: yangzhang Date: 2008-11-06 09:06:41 +0000 (Thu, 06 Nov 2008) Log Message: ----------- added demo of LD_PRELOAD Added Paths: ----------- sandbox/trunk/src/nix/preload/ sandbox/trunk/src/nix/preload/interposer.c sandbox/trunk/src/nix/preload/run.bash sandbox/trunk/src/nix/preload/test.c sandbox/trunk/src/nix/preload/test.cc Added: sandbox/trunk/src/nix/preload/interposer.c =================================================================== --- sandbox/trunk/src/nix/preload/interposer.c (rev 0) +++ sandbox/trunk/src/nix/preload/interposer.c 2008-11-06 09:06:41 UTC (rev 1061) @@ -0,0 +1,30 @@ +#define _GNU_SOURCE +#include <stdio.h> +#include <dlfcn.h> + +void * +malloc(size_t sz) +{ + // Find and cache the next malloc (in our example it should be the "real" + // malloc). + static void * (*func)(); + if (!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "malloc"); + + // Do our thang. +#ifdef VERBOSE + printf("malloc(%u) is called\n", sz); +#endif + + // Call real malloc. + void *p = func(sz); + + // Do our thang. +#ifdef VERBOSE + printf("malloc returned %p\n", p); +#endif + if (!p) + printf("malloc failed!\n"); + + return p; +} Added: sandbox/trunk/src/nix/preload/run.bash =================================================================== --- sandbox/trunk/src/nix/preload/run.bash (rev 0) +++ sandbox/trunk/src/nix/preload/run.bash 2008-11-06 09:06:41 UTC (rev 1061) @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset + +gcc -Wall -o testc test.c +g++ -Wall -o testcc test.cc +gcc -Wall -shared -fPIC -ldl -o interposer.so interposer.c +LD_PRELOAD=./interposer.so ./testc +LD_PRELOAD=./interposer.so ./testcc || true Property changes on: sandbox/trunk/src/nix/preload/run.bash ___________________________________________________________________ Added: svn:executable + * Added: sandbox/trunk/src/nix/preload/test.c =================================================================== --- sandbox/trunk/src/nix/preload/test.c (rev 0) +++ sandbox/trunk/src/nix/preload/test.c 2008-11-06 09:06:41 UTC (rev 1061) @@ -0,0 +1,11 @@ +#include <stdlib.h> +#include <stdio.h> + +int +main() +{ + char *msg = (char*) malloc(16); + snprintf(msg, 16, "hello!\n"); + printf("%s", msg); + return 0; +} Added: sandbox/trunk/src/nix/preload/test.cc =================================================================== --- sandbox/trunk/src/nix/preload/test.cc (rev 0) +++ sandbox/trunk/src/nix/preload/test.cc 2008-11-06 09:06:41 UTC (rev 1061) @@ -0,0 +1,7 @@ +// Intentionally fail. + +int +main() { + operator new(-1); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 08:43:15
|
Revision: 1060 http://assorted.svn.sourceforge.net/assorted/?rev=1060&view=rev Author: yangzhang Date: 2008-11-06 08:43:12 +0000 (Thu, 06 Nov 2008) Log Message: ----------- added overloading of operator new Modified Paths: -------------- sandbox/trunk/src/cc/overload_new.cc Modified: sandbox/trunk/src/cc/overload_new.cc =================================================================== --- sandbox/trunk/src/cc/overload_new.cc 2008-11-06 08:42:43 UTC (rev 1059) +++ sandbox/trunk/src/cc/overload_new.cc 2008-11-06 08:43:12 UTC (rev 1060) @@ -60,17 +60,57 @@ } }; +// You can add extra parameters to operator new. + +void * +operator new(std::size_t sz, const char file[16], int line) +throw(std::bad_alloc) +{ + std::cout << "calling operator new at " << file << ':' << line << std::endl; + return operator new(sz); +} + +class D +{ + public: + int x; +}; + int main() { // You can actually call operator new directly anywhere. void *p = operator new(1024); - C *c = new C; + std::cout << std::endl; + + // Use C's operator new. + C *a = new C; + std::cout << std::endl; + + // This won't work since we didn't extend C's operator new. + // C *b = new(__FILE__, __LINE__) C; + + // Use the extended operator new. + D *b = new(__FILE__, __LINE__) D; + std::cout << std::endl; + + // Permanently change what 'new' means. +#define new new(__FILE__, __LINE__) + D *c = new D; + std::cout << std::endl; + return 0; } // Output: // // calling operator new that throws exceptions +// // calling C::operator new // calling operator new that throws exceptions +// +// calling operator new at overload_new.cc:94 +// calling operator new that throws exceptions +// +// calling operator new at overload_new.cc:99 +// calling operator new that throws exceptions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 08:42:48
|
Revision: 1059 http://assorted.svn.sourceforge.net/assorted/?rev=1059&view=rev Author: yangzhang Date: 2008-11-06 08:42:43 +0000 (Thu, 06 Nov 2008) Log Message: ----------- demo writing stdin Added Paths: ----------- sandbox/trunk/src/c/write_stdin.c Added: sandbox/trunk/src/c/write_stdin.c =================================================================== --- sandbox/trunk/src/c/write_stdin.c (rev 0) +++ sandbox/trunk/src/c/write_stdin.c 2008-11-06 08:42:43 UTC (rev 1059) @@ -0,0 +1,12 @@ +// What happens if we try writing to stdin? + +#include <unistd.h> + +int +main() +{ + char msg[] = "hello, world!\n"; + // This will actually print something out to the console! + write(0, msg, sizeof msg); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-06 05:10:02
|
Revision: 1058 http://assorted.svn.sourceforge.net/assorted/?rev=1058&view=rev Author: yangzhang Date: 2008-11-06 05:09:46 +0000 (Thu, 06 Nov 2008) Log Message: ----------- added demo of overloading new Added Paths: ----------- sandbox/trunk/src/cc/overload_new.cc Added: sandbox/trunk/src/cc/overload_new.cc =================================================================== --- sandbox/trunk/src/cc/overload_new.cc (rev 0) +++ sandbox/trunk/src/cc/overload_new.cc 2008-11-06 05:09:46 UTC (rev 1058) @@ -0,0 +1,76 @@ +// Great thread: http://bytes.com/forum/thread521533.html +// +// - "operator new" != "new operator" +// - "new operator" consists of (1) allocation and (2) construction +// - "operator new" is the (1) allocation in "new operator" +// +// See also: man g++, search for -fcheck-new + +// #include <cstddef> // size_t +#include <new> // bad_alloc, size_t +#include <cstdlib> // malloc +#include <iostream> // cout, endl + +// You can globally *replace* operator new. There are two ways to replace +// operator new. + +#if 1 + +// Option 1: You can throw an exception when something goes awry. + +void * +operator new(std::size_t sz) throw(std::bad_alloc) +{ + std::cout << "calling operator new that throws exceptions" << std::endl; + // If you uncomment this line, the compiler will complain. + // return NULL; + void *p = malloc(sz); + if (!p) throw std::bad_alloc(); + return p; +} + +#else + +// Option 2: You can return NULL when something goes awry. + +void * +operator new(std::size_t sz) throw() +{ + std::cout << "calling operator new that returns NULL" << std::endl; + return malloc(sz); +} + +#endif + +// You can also *overload* operator new for a specific class. As with global +// replacement, you can either go with a NULL-returning new or an +// exception-throwing new. + +class C +{ + public: + int x; + + void * + operator new(std::size_t sz) throw(std::bad_alloc) + { + std::cout << "calling C::operator new" << std::endl; + // Must use ::, otherwise will recurse into self infinitely. + return ::operator new(sz); + } +}; + +int +main() +{ + // You can actually call operator new directly anywhere. + void *p = operator new(1024); + C *c = new C; + return 0; +} + +// Output: +// +// calling operator new that throws exceptions +// calling C::operator new +// calling operator new that throws exceptions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-05 19:07:32
|
Revision: 1057 http://assorted.svn.sourceforge.net/assorted/?rev=1057&view=rev Author: yangzhang Date: 2008-11-05 19:07:18 +0000 (Wed, 05 Nov 2008) Log Message: ----------- showing the real problem Modified Paths: -------------- sandbox/trunk/src/git/gitsvn.bash Modified: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash 2008-11-05 18:50:30 UTC (rev 1056) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-05 19:07:18 UTC (rev 1057) @@ -32,30 +32,31 @@ sed -i s/line1/Line1/ svn/myfile sed -i s/line4/Line4/ gitsvn/myfile svn ci -m 'munge line1' svn/ -(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) # XXX problem here +(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) # clone the git repo elsewhere and commit something there git clone file://$basedir/gitsvn gitsvn2 sed -i s/line6/Line6/ gitsvn2/myfile (cd gitsvn2; git commit -a -m 'munge line6') -# make concurrent change to svn +# make concurrent change to svn, and original git repo sed -i s/line2/Line2/ svn/myfile svn ci -m 'munge line2' svn/ +(cd gitsvn; git svn rebase) -# pull those changes back into the original git repo -(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) # XXX problem here +# make another concurrent change to svn, then pull gitsvn2 changes into the +# original git repo, then update gitsvn from svn +sed -i s/line3/Line3/ svn/myfile +svn ci -m 'munge line3' svn/ +(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) # XXX problem here! -# Sample output: -# -# $ bash -x gitsvn.bash /tmp/test # + set -o errexit -o nounset -# + basedir=/tmp/test -# + mkdir -p /tmp/test -# + cd /tmp/test +# + basedir=/tmp/test2 +# + mkdir -p /tmp/test2 +# + cd /tmp/test2 # + mkdir svnrepo # + svnadmin create svnrepo -# + svn co file:///tmp/test/svnrepo svn +# + svn co file:///tmp/test2/svnrepo svn # Checked out revision 0. # + echo -e 'line1\nline2\nline3' # + svn add svn/myfile @@ -64,12 +65,12 @@ # Adding svn/myfile # Transmitting file data . # Committed revision 1. -# + git svn clone file:///tmp/test/svnrepo gitsvn +# + git svn clone file:///tmp/test2/svnrepo gitsvn # Initialized empty Git repository in .git/ # A myfile -# r1 = f9c96692b0244e1793f14de0cf6cb3d72efac32a (git-svn) +# r1 = e03653693de0cfebfcfb1ed7d9d3db896421ee7a (git-svn) # Checked out HEAD: -# file:///tmp/test/svnrepo r1 +# file:///tmp/test2/svnrepo r1 # + echo -e 'line4\nline5\nline6' # + svn ci -m 'added more lines' svn/ # Sending svn/myfile @@ -78,9 +79,9 @@ # + cd gitsvn # + git svn rebase # M myfile -# r2 = 141185b6945d81b866db2258a902d5bdc5d6c8a4 (git-svn) +# r2 = c8f7e4bc4a623abcabf27d34c6716c1f13c37da2 (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at 141185b... added more lines +# HEAD is now at c8f7e4b... added more lines # Fast-forwarded master to refs/remotes/git-svn. # + sed -i s/line1/Line1/ svn/myfile # + sed -i s/line4/Line4/ gitsvn/myfile @@ -90,25 +91,25 @@ # Committed revision 3. # + cd gitsvn # + git commit -a -m 'munge line4' -# Created commit 82a13bf: munge line4 +# Created commit 4efa529: munge line4 # 1 files changed, 1 insertions(+), 1 deletions(-) # + git svn rebase # M myfile -# r3 = 22e5d634f29dbfa70e4586a8d7e958e01489a8ff (git-svn) +# r3 = 76ffe8259f02910393f7f03fdfd0c81b12cfbcee (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at 22e5d63... munge line1 +# HEAD is now at 76ffe82... munge line1 # Applying munge line4 # error: patch failed: myfile:1 # error: myfile: patch does not apply # Using index info to reconstruct a base tree... # Falling back to patching base and 3-way merge... # Auto-merged myfile -# + git clone file:///tmp/test/gitsvn gitsvn2 -# Initialized empty Git repository in /tmp/test/gitsvn2/.git/ +# + git clone file:///tmp/test2/gitsvn gitsvn2 +# Initialized empty Git repository in /tmp/test2/gitsvn2/.git/ # + sed -i s/line6/Line6/ gitsvn2/myfile # + cd gitsvn2 # + git commit -a -m 'munge line6' -# Created commit 8f8a660: munge line6 +# Created commit 33eebd0: munge line6 # 1 files changed, 1 insertions(+), 1 deletions(-) # + sed -i s/line2/Line2/ svn/myfile # + svn ci -m 'munge line2' svn/ @@ -116,22 +117,51 @@ # Transmitting file data . # Committed revision 4. # + cd gitsvn -# + git pull file:///tmp/test/gitsvn2 -# remote: Counting objects: 5, done.[K -# remote: Total 3 (delta 0), reused 0 (delta 0)[K -# Updating fd0dc9b..8f8a660 -# Fast forward +# + git svn rebase +# M myfile +# r4 = 3923d574137132addd9f32ca40170f62aae0c456 (git-svn) +# First, rewinding head to replay your work on top of it... +# HEAD is now at 3923d57... munge line2 +# Applying munge line4 +# error: patch failed: myfile:1 +# error: myfile: patch does not apply +# Using index info to reconstruct a base tree... +# Falling back to patching base and 3-way merge... +# Auto-merged myfile +# + sed -i s/line3/Line3/ svn/myfile +# + svn ci -m 'munge line3' svn/ +# Sending svn/myfile +# Transmitting file data . +# Committed revision 5. +# + cd gitsvn +# + git pull file:///tmp/test2/gitsvn2 +# remote: Counting objects: 8, done.[K +# remote: Compressing objects: 50% (1/2) [K +remote: Compressing objects: 100% (2/2) [K +remote: Compressing objects: 100% (2/2[K)remote: , done.[K +# remote: Total 6 (delta 0), reused 3 (delta 0)[K +# Auto-merged myfile +# Merge made by recursive. # myfile | 2 +- # 1 files changed, 1 insertions(+), 1 deletions(-) # + git svn rebase # M myfile -# r4 = 22f9c8564ccbd4195c3c609c8149ef7bf33eec64 (git-svn) +# r5 = c90dcc08fb3cc07f714662d6e1d1054ba1678b75 (git-svn) # First, rewinding head to replay your work on top of it... -# HEAD is now at 22f9c85... munge line2 +# HEAD is now at c90dcc0... munge line3 # Applying munge line4 # error: patch failed: myfile:1 # error: myfile: patch does not apply # Using index info to reconstruct a base tree... # Falling back to patching base and 3-way merge... # Auto-merged myfile -# Applying munge line6 +# CONFLICT (content): Merge conflict in myfile +# Failed to merge in the changes. +# Patch failed at 0001. +# +# When you have resolved this problem run "git rebase --continue". +# If you would prefer to skip this patch, instead run "git rebase --skip". +# To restore the original branch and stop rebasing run "git rebase --abort". +# +# rebase refs/remotes/git-svn: command returned error: 1 +# This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-05 18:50:32
|
Revision: 1056 http://assorted.svn.sourceforge.net/assorted/?rev=1056&view=rev Author: yangzhang Date: 2008-11-05 18:50:30 +0000 (Wed, 05 Nov 2008) Log Message: ----------- added some sample output; removed extraneous git svn rebase Modified Paths: -------------- sandbox/trunk/src/git/gitsvn.bash Modified: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash 2008-11-05 18:45:41 UTC (rev 1055) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-05 18:50:30 UTC (rev 1056) @@ -32,16 +32,106 @@ sed -i s/line1/Line1/ svn/myfile sed -i s/line4/Line4/ gitsvn/myfile svn ci -m 'munge line1' svn/ -(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) +(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) # XXX problem here # clone the git repo elsewhere and commit something there git clone file://$basedir/gitsvn gitsvn2 sed -i s/line6/Line6/ gitsvn2/myfile -(cd gitsvn2; git commit -a -m 'munge line6'; git svn rebase) +(cd gitsvn2; git commit -a -m 'munge line6') # make concurrent change to svn sed -i s/line2/Line2/ svn/myfile svn ci -m 'munge line2' svn/ # pull those changes back into the original git repo -(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) +(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) # XXX problem here + +# Sample output: +# +# $ bash -x gitsvn.bash /tmp/test +# + set -o errexit -o nounset +# + basedir=/tmp/test +# + mkdir -p /tmp/test +# + cd /tmp/test +# + mkdir svnrepo +# + svnadmin create svnrepo +# + svn co file:///tmp/test/svnrepo svn +# Checked out revision 0. +# + echo -e 'line1\nline2\nline3' +# + svn add svn/myfile +# A svn/myfile +# + svn ci -m 'added myfile' svn/ +# Adding svn/myfile +# Transmitting file data . +# Committed revision 1. +# + git svn clone file:///tmp/test/svnrepo gitsvn +# Initialized empty Git repository in .git/ +# A myfile +# r1 = f9c96692b0244e1793f14de0cf6cb3d72efac32a (git-svn) +# Checked out HEAD: +# file:///tmp/test/svnrepo r1 +# + echo -e 'line4\nline5\nline6' +# + svn ci -m 'added more lines' svn/ +# Sending svn/myfile +# Transmitting file data . +# Committed revision 2. +# + cd gitsvn +# + git svn rebase +# M myfile +# r2 = 141185b6945d81b866db2258a902d5bdc5d6c8a4 (git-svn) +# First, rewinding head to replay your work on top of it... +# HEAD is now at 141185b... added more lines +# Fast-forwarded master to refs/remotes/git-svn. +# + sed -i s/line1/Line1/ svn/myfile +# + sed -i s/line4/Line4/ gitsvn/myfile +# + svn ci -m 'munge line1' svn/ +# Sending svn/myfile +# Transmitting file data . +# Committed revision 3. +# + cd gitsvn +# + git commit -a -m 'munge line4' +# Created commit 82a13bf: munge line4 +# 1 files changed, 1 insertions(+), 1 deletions(-) +# + git svn rebase +# M myfile +# r3 = 22e5d634f29dbfa70e4586a8d7e958e01489a8ff (git-svn) +# First, rewinding head to replay your work on top of it... +# HEAD is now at 22e5d63... munge line1 +# Applying munge line4 +# error: patch failed: myfile:1 +# error: myfile: patch does not apply +# Using index info to reconstruct a base tree... +# Falling back to patching base and 3-way merge... +# Auto-merged myfile +# + git clone file:///tmp/test/gitsvn gitsvn2 +# Initialized empty Git repository in /tmp/test/gitsvn2/.git/ +# + sed -i s/line6/Line6/ gitsvn2/myfile +# + cd gitsvn2 +# + git commit -a -m 'munge line6' +# Created commit 8f8a660: munge line6 +# 1 files changed, 1 insertions(+), 1 deletions(-) +# + sed -i s/line2/Line2/ svn/myfile +# + svn ci -m 'munge line2' svn/ +# Sending svn/myfile +# Transmitting file data . +# Committed revision 4. +# + cd gitsvn +# + git pull file:///tmp/test/gitsvn2 +# remote: Counting objects: 5, done.[K +# remote: Total 3 (delta 0), reused 0 (delta 0)[K +# Updating fd0dc9b..8f8a660 +# Fast forward +# myfile | 2 +- +# 1 files changed, 1 insertions(+), 1 deletions(-) +# + git svn rebase +# M myfile +# r4 = 22f9c8564ccbd4195c3c609c8149ef7bf33eec64 (git-svn) +# First, rewinding head to replay your work on top of it... +# HEAD is now at 22f9c85... munge line2 +# Applying munge line4 +# error: patch failed: myfile:1 +# error: myfile: patch does not apply +# Using index info to reconstruct a base tree... +# Falling back to patching base and 3-way merge... +# Auto-merged myfile +# Applying munge line6 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-05 18:45:50
|
Revision: 1055 http://assorted.svn.sourceforge.net/assorted/?rev=1055&view=rev Author: yangzhang Date: 2008-11-05 18:45:41 +0000 (Wed, 05 Nov 2008) Log Message: ----------- added git svn demo Added Paths: ----------- sandbox/trunk/src/git/gitsvn.bash Added: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash (rev 0) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-05 18:45:41 UTC (rev 1055) @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Demo of how git svn and cloning that would work. Run this with e.g.: +# ./gitsvn.bash /tmp/test + +set -o errexit -o nounset + +# this is where the experiment will take place +basedir=$1 +mkdir -p $basedir +cd $basedir + +# set up an svn repo +mkdir svnrepo +svnadmin create svnrepo + +# add something to the repo +svn co file://$basedir/svnrepo svn +echo -e 'line1\nline2\nline3' > svn/myfile +svn add svn/myfile +svn ci -m 'added myfile' svn/ + +# git clone it +git svn clone file://$basedir/svnrepo gitsvn + +# make some more changes to svn and mirror those to gitsvn +echo -e 'line4\nline5\nline6' >> svn/myfile +svn ci -m 'added more lines' svn/ +(cd gitsvn; git svn rebase) + +# make concurrent changes to both svn and git +sed -i s/line1/Line1/ svn/myfile +sed -i s/line4/Line4/ gitsvn/myfile +svn ci -m 'munge line1' svn/ +(cd gitsvn; git commit -a -m 'munge line4'; git svn rebase) + +# clone the git repo elsewhere and commit something there +git clone file://$basedir/gitsvn gitsvn2 +sed -i s/line6/Line6/ gitsvn2/myfile +(cd gitsvn2; git commit -a -m 'munge line6'; git svn rebase) + +# make concurrent change to svn +sed -i s/line2/Line2/ svn/myfile +svn ci -m 'munge line2' svn/ + +# pull those changes back into the original git repo +(cd gitsvn; git pull file://$basedir/gitsvn2; git svn rebase) Property changes on: sandbox/trunk/src/git/gitsvn.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-05 18:41:06
|
Revision: 1054 http://assorted.svn.sourceforge.net/assorted/?rev=1054&view=rev Author: yangzhang Date: 2008-11-05 18:40:55 +0000 (Wed, 05 Nov 2008) Log Message: ----------- added git sandbox Added Paths: ----------- sandbox/trunk/src/git/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-11-04 00:57:27
|
Revision: 1053 http://assorted.svn.sourceforge.net/assorted/?rev=1053&view=rev Author: yangzhang Date: 2008-11-04 00:57:18 +0000 (Tue, 04 Nov 2008) Log Message: ----------- forward krb tickets to linerva Modified Paths: -------------- configs/trunk/src/ssh/config Modified: configs/trunk/src/ssh/config =================================================================== --- configs/trunk/src/ssh/config 2008-11-04 00:55:45 UTC (rev 1052) +++ configs/trunk/src/ssh/config 2008-11-04 00:57:18 UTC (rev 1053) @@ -125,6 +125,7 @@ HostName linerva.mit.edu User y_z ForwardX11 yes + GSSAPIDelegateCredentials yes Host athcs HostName athena.csail.mit.edu This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |