[RFC][PATCH] New style of revision id

Goffredo Baroncelli kreijack at alice.it
Wed Oct 25 22:13:52 BST 2006


Hi all,

I hacked a bit bazaar and now I added the support for revision-id with 
checksum ( as git and/or hgweb ). John made some suggestions and now that is 
the result.


****
NOTE 
This is an experimental version, the revision-id format can change (and will), 
so please don't use it in production.
****

The new revision-id is in the form:

<user>@<host>-<yyyymmddhhmmss>-<sha1sum>

The checksum is computed on the testament without the revision-id. In fact the 
following field are evaluated [*]:

- commiter
- comment
- revision-properties
- timestamp/timezone
- parents
- inventory ( path, file_id, kind, sha1 for the text or the target for the
  symlink )


I added two command ( verify-repo and verify-branch ) which verify  all the 
revision of a repository/branch. 
I added a property to the revision in order to record if and which method was 
used for the checksum ( the property is named "chksum_testament", and the 
actual value is "sha1/strict3" ). That will permit an evolution of the 
checksum method

During the commit my code perform an addition check between the checksum 
stored in the inventory and the ones computed during the creation of the 
inventory-id ( in order to avoid a race condition in case that a file is 
changed ).

The source can be pulled from
  http://goffredo-baroncelli.homelinux.net/bazaar/repo/bzr-sha1
and can be browsed at
  http://goffredo-baroncelli.homelinux.net/bazaar/bzr-sha1


Comments are welcomes


Below an example of use

$ mkdir repo
repo$ bzr init-repo --tree .
repo$ mkdir a
repo$ mkdir b
repo$ cd a
/repo/a$ echo 1 >>a ; bzr init . ; bzr add a; bzr ci -m "a added"
added a
added a
Committed revision 1.
repo/a$ bzr log --show-ids
------------------------------------------------------------
revno: 1
revision-id: 
ghigo at venice-20061025202916-9f472a5cfbc5fc77de3a39c5cecc0d09326d3e86
committer: ghigo <ghigo at venice>
branch nick: a
timestamp: Wed 2006-10-25 22:29:16 +0200
message:
  a added
repo/a$ cd ../b
repo/b$ echo 1 >>a ; bzr init . ; bzr add a; bzr ci -m "a added"
added a
added a
Committed revision 1.
/repo/b$ bzr log --show-ids
------------------------------------------------------------
revno: 1
revision-id: 
ghigo at venice-20061025202938-7af3994189708d60284471bc77f6996db5edf6a7
committer: ghigo <ghigo at venice>
branch nick: b
timestamp: Wed 2006-10-25 22:29:38 +0200
message:
  a added
repo/b$ cd ..
repo$ bzr verify-repo
ghigo at venice-20061025202938-7af3994189708d60284471bc77f6996db5edf6a7: OK
ghigo at venice-20061025202916-9f472a5cfbc5fc77de3a39c5cecc0d09326d3e86: OK
repo$ bzr verify-branch a
ghigo at venice-20061025202916-9f472a5cfbc5fc77de3a39c5cecc0d09326d3e86: OK


[*] Below an example of the "testament" used for computing the checksum
-------------------- 
bazaar testament version 3 strict
revision-id:
committer: ghigo <ghigo at venice>
timestamp: 1161808178
timezone: 7200
parents:
message:
  a added
inventory:
  directory . TREE_ROOT  no
  file a a-20061025202938-g0g4vak60dasbtsa-1 
e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e  no
properties:
  branch-nick:
    b
  chksum_testament:
    sha1/strict3
------------------------


Open Point:
* John suggested to use as revision-id only the sha1 checksum. Even tough I am 
not against, I found useful knowing on the fly who and when generated a 
revision. But I am open to other suggestion.

* I think that with the adding of the revision property "checksum_testament" 
we should have resolve any problem for future change of the format of the 
revision-id. I am right ?

* Because the file_id are random based, even tough two commits are equal, the 
revision-id(s) are different: that can be useful ? If we want that two 
commits equal have to generate the same revision id, we can change the 
testament removing, the timestamp and the file_id ( instead we can use the 
path )... 
And what about the parent revision-id(s): if we include these, we compare the 
histories: if the states are the same but the histories are different, have 
the revision-id(s) to be equal ?


Goffredo

-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack at inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87  87C0 BB86 505C 6B2A CFF9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bzr-sha1.diff
Type: text/x-diff
Size: 68490 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061025/d8998e27/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061025/d8998e27/attachment.pgp 


More information about the bazaar mailing list