Fossil

Check-in [e8efbc31]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reworked the code determining the parent of the currently committed changeset. It should now handle the transition from vendor branch to trunk correctly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e8efbc317a008a6c94465099784ac1213a5174eb
User & Date: aku 2008-02-01 05:25:03
Context
2008-02-01
05:29
Made remove_from_argv public for use by the upcoming test-import-manifest command. Fixed description of verify_all_options. Initialized variable to silence gcc warning. check-in: da4f0c26 user: aku tags: trunk
05:25
Reworked the code determining the parent of the currently committed changeset. It should now handle the transition from vendor branch to trunk correctly. check-in: e8efbc31 user: aku tags: trunk
2008-01-31
07:14
Added high-verbosity (level 11) logging to trace the application of rcs patches. check-in: e5ae612c user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/cvs2fossil/lib/c2f_prev.tcl.

398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413

414
415
416
417
418
419
420
421
...
442
443
444
445
446
447
448
449
450

451
452
453
454
455

456
457

458
459
460

461
462
463
464


465
466
467
468
469
470
471
472





473
474






475

















476
477
478
479
480
481
482
483
484

485
486
487
















488


489



490
491
492





493
494
495
496
497
498
499
	#
	# Data needed:
	# - Commit message               (-- mysrcid -> repository meta)
	# - User doing the commit        (s.a.)
	#
	# - Timestamp of when committed  (command argument)
	#
	# - The parent changeset, if any. If there is no parent use
	#   the empty base revision as parent.
	#
	# - List of the file revisions in the changeset.

	struct::list assign [$myproject getmeta $mysrcid] __ branch user message
	struct::list assign $branch __ lodname

	# Perform the import. As part of that convert the list of

	# items in the changeset into uuids and printable data.

	set uuid [Updatestate state $lodname \
		      [$repository importrevision [$self str] \
			   $user $message $date \
			   [Getparent state $lodname $myproject] \
			   [Getrevisioninfo $myitems]]]

................................................................................
	}
	return $revisions
    }

    proc Getparent {sv lodname project} {
	upvar 1 $sv state

	# The parent is determined via the line-of-development (LOD)
	# information of each changeset, and the history of

	# imports. The last changeset committed to the same LOD is
	# taken as the parent of the current changeset. If the
	# changeset is the first on that LOD it can be either spawned
	# from another LOD, or detached. For the first case we
	# retrieve the parent LOD of the current LOD symbol (*) and

	# recheck for a committed changeset. The second case is taken
	# if that lookup fails as well.

	#
	# (*) And this parent was found in previous passes when
	#     determining the prefered parents of all the symbols.


	# NOTE: The above is incomplete and buggy. Vendor-branches and
	#       the various possibilities of its interaction with the
	#       trunk are not fully handled.



	if {[info exists state($lodname)]} {
	    # LOD exists and has already been committed to.
	    return $state($lodname)
	}

	# LOD has not been committed to before, this is the first
	# time. Determine the name of the parent LOD.






	set lodname [[[$project getsymbol $lodname] parent] name]
























	if {[info exists state($lodname)]} {
	    # The parental LOD has been committed to, take that last
	    # changeset as the spawnpoint for the new LOD.
	    return $state($lodname)
	}

	# The parental LOD is not defined (yet). This LOD is
	# detached. We choose as our parent the automatic empty root
	# baseline of the target repository.

	return {}
    }

















    proc Updatestate {sv lodname uuid} {


	# Remember the imported changeset in the state, under our LOD.




	upvar 1 $sv state
	set state($lodname) $uuid





	return $uuid
    }

    typemethod split {cset args} {
	# As part of the creation of the new changesets specified in
	# ARGS as sets of items, all subsets of CSET's item set, CSET
	# will be dropped from all databases, in and out of memory,







|
|






|
>
|







 







|
<
>
|
|
|
|
<
>
|
|
>
|
<
|
>

<
|
|
>
>


<



<
|
>
>
>
>
>

<
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
<



<
<
<
>
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
|
>
>
>

<

>
>
>
>
>







398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
443
444
445
446
447
448
449
450

451
452
453
454
455

456
457
458
459
460

461
462
463

464
465
466
467
468
469

470
471
472

473
474
475
476
477
478
479

480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504


505
506
507



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535

536
537
538
539
540
541
542
543
544
545
546
547
548
	#
	# Data needed:
	# - Commit message               (-- mysrcid -> repository meta)
	# - User doing the commit        (s.a.)
	#
	# - Timestamp of when committed  (command argument)
	#
	# - The parent changeset, if any. If there is no parent fossil
	#   will use the empty base revision as parent.
	#
	# - List of the file revisions in the changeset.

	struct::list assign [$myproject getmeta $mysrcid] __ branch user message
	struct::list assign $branch __ lodname

	# Perform the import. As part of that we determine the parent
	# we need, and convert the list of items in the changeset into
	# uuids and printable data.

	set uuid [Updatestate state $lodname \
		      [$repository importrevision [$self str] \
			   $user $message $date \
			   [Getparent state $lodname $myproject] \
			   [Getrevisioninfo $myitems]]]

................................................................................
	}
	return $revisions
    }

    proc Getparent {sv lodname project} {
	upvar 1 $sv state

	struct::list assign [Getisdefault $myitems] isdefault lastdefaultontrunk


	# See (a) below, we have to remember if the changeset is last
	# on vendor branch also belonging to trunk even if we find a
	# parent in the state. The caller will later (after import)
	# make us the first trunk changeset in the state (See (**)).


	if {$lastdefaultontrunk} {
	    set state(:vendor:last:) .
	}


	# The state array holds for each line-of-development (LOD) the
	# last committed changeset belonging to that LOD.


	# (*) Standard handling if in-LOD changesets. If the LOD of
	#     the current changeset exists in the state (= has been
	#     committed to) then the stored changeset is the parent we
	#     are looking for.

	if {[info exists state($lodname)]} {

	    return $state($lodname)
	}


	# If the LOD is not yet known the current changeset can either
	# be
	# (a) the root of a vendor branch,
	# (b) the root of the trunk LOD, or
	# (c) the first changeset in a new LOD which was spawned from
	#     an existing LOD.


	if {$isdefault} {
	    # In case of (a) the changeset has no parent, signaled by
	    # the empty string. We do remember if the changeset is
	    # last on the vendor branch still belonging to trunk, for
	    # the trunk root.
	    return {}
	}

	if {$lodname eq ":trunk:"} {
	    # This is case (b), and we also can be sure that there is
	    # no vendor branch changeset which could be our
	    # parent. That was already dealt with through the
	    # :vendor:last: signal and code in the caller (setting
	    # such a changeset up as parent in the state, causing the
	    # standard LOD handler at (*) to kick in. So, no parent
	    # here at all.
	    return {}
	}

	# Case (c). We find the parent LOD of our LOD and take the
	# last changeset committed to that as our parent. If that
	# doesn't exist we have an error on our hands.

	set lodname [[[$project getsymbol $lodname] parent] name]
	if {[info exists state($lodname)]} {


	    return $state($lodname)
	}




	trouble internal {Unable to determine changeset parent}
	return
    }

    proc Getisdefault {revisions} {
	set theset ('[join $revisions {','}]')

	struct::list assign [state run [subst -nocommands -nobackslashes {
	    SELECT R.isdefault, R.dbchild
	    FROM   revision R
	    WHERE  R.rid IN $theset  -- All specified revisions
	    LIMIT 1
	}]] def last

	# TODO/CHECK: look for changesets where isdefault/dbchild is
	# ambigous.

	return [list $def [expr {$last ne ""}]]
    }

    proc Updatestate {sv lodname uuid} {
	upvar 1 $sv state

	# Remember the imported changeset in the state, under our
	# LOD. (**) And if the :vendor:last: signal is present then
	# the revision is also the actual root of the :trunk:, so
	# remember it as such.


	set state($lodname) $uuid
	if {[info exists state(:vendor:last:)]} {
	    unset state(:vendor:last:)
	    set state(:trunk:) $uuid
	}

	return $uuid
    }

    typemethod split {cset args} {
	# As part of the creation of the new changesets specified in
	# ARGS as sets of items, all subsets of CSET's item set, CSET
	# will be dropped from all databases, in and out of memory,