undo.patch

joelkp, 03/29/2009 02:50 PM

Download (3.13 KB)

View differences:

undo/undo.1 2009-03-29 14:05:56 +0000
107 107
Transaction ids always start with "0x".
108 108
A simple index may be
109 109
specified instead of a transaction id where 0 indicates the latest version
110
and increasing values indicate older versions.
110
and increasing values indicate older versions, or where -0 indicates the oldest version and decreasing values indicate newer versions.
111 111
.El
112 112
.Sh EXAMPLES
113 113
.Li "undo -d mytextfile"
undo/undo.c 2009-03-29 14:21:53 +0000
281 281
		 * Find entry if tid set to placeholder index
282 282
		 */
283 283
		if (flags & UNDO_FLAG_SETTID1){
284
			tse1 = RB_MAX(undo_hist_entry_rb_tree, &tse_tree);
285
			while (tse1 && ts1.tid--) {
286
				tse1 = RB_PREV(undo_hist_entry_rb_tree,
287
					       &tse_tree, tse1);
284
			if ((int64_t)ts1.tid >= 0) {
285
				tse1 = RB_MAX(undo_hist_entry_rb_tree,
286
				              &tse_tree);
287
				while (tse1 && ts1.tid--) {
288
					tse1 = RB_PREV(undo_hist_entry_rb_tree,
289
						       &tse_tree, tse1);
290
				}
291
			} else {
292
				tse1 = RB_MIN(undo_hist_entry_rb_tree,
293
				              &tse_tree);
294
				while (tse1 && ++ts1.tid) {
295
					tse1 = RB_NEXT(undo_hist_entry_rb_tree,
296
						       &tse_tree, tse1);
297
				}
288 298
			}
289 299
			if (tse1)
290 300
				ts1 = tse1->tse;
......
292 302
				ts1.tid = 0;
293 303
		}
294 304
		if (flags & UNDO_FLAG_SETTID2){
295
			tse2 = RB_MAX(undo_hist_entry_rb_tree, &tse_tree);
296
			while (tse2 && ts2.tid--) {
297
				tse2 = RB_PREV(undo_hist_entry_rb_tree,
298
					       &tse_tree, tse2);
305
			if ((int64_t)ts2.tid >= 0) {
306
				tse2 = RB_MAX(undo_hist_entry_rb_tree,
307
				              &tse_tree);
308
				while (tse2 && ts2.tid--) {
309
					tse2 = RB_PREV(undo_hist_entry_rb_tree,
310
						       &tse_tree, tse2);
311
				}
312
			} else {
313
				tse2 = RB_MIN(undo_hist_entry_rb_tree,
314
				              &tse_tree);
315
				while (tse2 && ++ts2.tid) {
316
					tse2 = RB_NEXT(undo_hist_entry_rb_tree,
317
						       &tse_tree, tse2);
318
				}
299 319
			}
300 320
			if (tse2)
301 321
				ts2 = tse2->tse;
......
626 646
parse_delta_time(const char *timeStr, int *flags, int ind_flag)
627 647
{
628 648
	hammer_tid_t tid;
649
	int adj;
629 650

  
630 651
	tid = strtoull(timeStr, NULL, 0);
631
	if (timeStr[0] == '+')
652
	adj = 0;
653
	if (timeStr[0] == '+') {
654
		++timeStr;
655
	} else if (timeStr[0] == '-') {
632 656
		++timeStr;
633
	if (timeStr[0] >= '0' && timeStr[0] <= '9' && timeStr[1] != 'x')
657
		adj = 1;
658
	}
659
	if (timeStr[0] >= '0' && timeStr[0] <= '9' && timeStr[1] != 'x') {
634 660
		*flags |= ind_flag;
661
		if (adj)
662
			--tid;
663
	}
635 664
	return(tid);
636 665
}
637 666

  
......
715 744
			"    -t TID   Retrieve as of transaction-id, TID\n"
716 745
			"             (a second `-t TID' to diff two)\n"
717 746
			"    transaction ids must be prefixed with 0x, and\n"
718
			"    otherwise may specify an index starting at 0\n"
719
			"    and iterating backwards through the history.\n"
747
			"    otherwise may specify a positive index starting\n"
748
			"    at 0 and iterating backwards through the\n"
749
			"    history, or a negative index starting at -0 and\n"
750
			"    iterating forwards through the history.\n"
720 751
	);
721 752
	exit(1);
722 753
}