Skip to content
Snippets Groups Projects
  • Mitchell Kember's avatar
    1a99e0c2d6d5
    rust-revlog: add RevisionOrWdir · 1a99e0c2d6d5
    Mitchell Kember authored
    This type represents either a checked Revision or the wdir() pseudo-revision
    (revision 0x7fffffff, node ffffffffffffffffffffffffffffffffffffffff).
    
    You construct it with revision.into() or Revision::wdir(), and destructure it
    with rev.exclude_wdir() which returns Option<Revision>.
    
    I considered something like `enum RevisionOrWdir { Wdir, Revision(Revision) }`,
    but decided on `struct RevisionOrWdir(BaseRevision)` for a few reasons:
    
    - It's more ergonomic for the ways it actually gets used, in my opinion.
    - It also avoids the possibility of an invalid value Revision(0x7fffffff).
    - It remains 4 bytes rather than 8.
    - It maintains the ordering: wdir is greater than all other revisions.
    
    I'm planning to use this for 'rhg annotate -r wdir()'.
    1a99e0c2d6d5
    History
    rust-revlog: add RevisionOrWdir
    Mitchell Kember authored
    This type represents either a checked Revision or the wdir() pseudo-revision
    (revision 0x7fffffff, node ffffffffffffffffffffffffffffffffffffffff).
    
    You construct it with revision.into() or Revision::wdir(), and destructure it
    with rev.exclude_wdir() which returns Option<Revision>.
    
    I considered something like `enum RevisionOrWdir { Wdir, Revision(Revision) }`,
    but decided on `struct RevisionOrWdir(BaseRevision)` for a few reasons:
    
    - It's more ergonomic for the ways it actually gets used, in my opinion.
    - It also avoids the possibility of an invalid value Revision(0x7fffffff).
    - It remains 4 bytes rather than 8.
    - It maintains the ordering: wdir is greater than all other revisions.
    
    I'm planning to use this for 'rhg annotate -r wdir()'.