Skip to content

Commit

Permalink
git: fix a histedit edge case on git mode
Browse files Browse the repository at this point in the history
Summary:
The signature of `gitcommittext` is a bit wrong, as the `date` parameter can actually receive a tuple of numbers, and not only a string. On top of that, `git_commit_fields_to_text` does not know how to process floats because the tuple gets serialized into an `HgTime` on the Rust side:

```
pub struct HgTime {
    pub unixtime: i64,
    pub offset: i32,
}
```

Reviewed By: muirdm

Differential Revision: D67353905

fbshipit-source-id: a563ccaea81cc6533a10b359a5bd067fe724887c
  • Loading branch information
sggutier authored and facebook-github-bot committed Dec 18, 2024
1 parent bb6307b commit 2030e47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
8 changes: 5 additions & 3 deletions eden/scm/sapling/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import subprocess
import textwrap
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Tuple, Union

import bindings

Expand Down Expand Up @@ -312,7 +312,7 @@ def gitcommittext(
parents: List[bytes],
desc: str,
user: str,
date: Optional[str],
date: Optional[Union[str, Tuple[Union[int, float], int]]],
extra: Optional[Dict[str, str]],
gpgkeyid: Optional[str] = None,
) -> bytes:
Expand Down Expand Up @@ -390,12 +390,14 @@ def gitcommittext(
if date != authordate and date != committerdate:
authordate = date

author_time, author_tz = util.parsedate(authordate)

# see Rust format-util GitCommitFields for available fields
fields = {
"tree": tree,
"parents": parents,
"author": user,
"date": util.parsedate(authordate),
"date": (int(author_time), author_tz),
"committer": committer,
"committer_date": util.parsedate(committerdate),
"message": desc,
Expand Down
17 changes: 5 additions & 12 deletions eden/scm/tests/test-histedit-git.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@ setup repo

folding should work

FIXME: histedit should work
$ hg histedit -q --commands - 2>&1 << EOF | tail -n 5
$ hg histedit --commands - << EOF
> pick fd2a67d81220 'A1'
> pick bc8bd49c677f 'A2'
> fold 081c9e396fa1 'A3'
> pick 91ad706dafee 'A4'
> EOF
File *, in add (glob)
text = gitcommittext(
File *, in gitcommittext (glob)
text = to_text(fields).encode()
TypeError: 'float' object cannot be interpreted as an integer
$ hg st
A A3
$ tglog
o 91ad706dafee 'A4'
@ 17e3aa7dc15f 'A4'
o 081c9e396fa1 'A3'
@ bc8bd49c677f 'A2'
o 594d4e89c0ff 'A2
│ ***
│ A3'
o fd2a67d81220 'A1'

0 comments on commit 2030e47

Please sign in to comment.