Changeset f8151ea4ffc6…
Parent cf5e6ffac8b7…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to 2 files · Browse files at f8151ea4ffc6 Showing diff from parent cf5e6ffac8b7 Diff from another changeset...
@@ -54,6 +54,17 @@ Creator Person `json:"personCreator"`
DefaultPermission string `json:"permissionDefault"`
Branches []Repo `json:"repoBranches"`
+}
+
+type Changeset struct {
+ Rev string `json:"rev"`
+ Author string `json:"sAuthor"`
+ Description string `json:"sDescription"`
+ Bugs []int `json:"ixBugs"`
+ Reviews []int `json:"ixReviews"`
+ Vcs string `json:"vcs"`
+ MercurialSHAs []string `json:"revsHg"`
+ GitSHAs []string `json:"revsGit"`
}
type Person struct {
@@ -135,3 +146,37 @@ }
return
}
+
+func (k *Client) MercurialEquivalent(repoPath, commit string) (hgSHAs []string, err error) {
+ var repoId int64
+ var resp []byte
+ var fullSHA string
+
+ repoId, err = k.IdForRepo(repoPath)
+ if err != nil {
+ return
+ }
+ fullSHA, err = k.ResolveSHA(commit)
+ if err != nil {
+ return
+ }
+ resp, err = k.apiGet(fmt.Sprintf("Repo/%v/History", repoId), apiParams{"revs": fullSHA})
+ if err != nil {
+ return
+ }
+ var errors ApiErrors
+ if err = json.Unmarshal(resp, &errors); err == nil {
+ if apiErrors, _ := errors["errors"]; len(apiErrors) > 0 {
+ err = fmt.Errorf("failed: %v", apiErrors[0].Description)
+ }
+ }
+ var changesets []Changeset
+ if err = json.Unmarshal(resp, &changesets); err != nil {
+ err = fmt.Errorf("unable to process response: %v", err)
+ } else {
+ for _, changeset := range changesets {
+ hgSHAs = append(hgSHAs, changeset.MercurialSHAs...)
+ }
+ }
+ return
+}
|
@@ -34,6 +34,9 @@ to your remotes via "gitkiln add-remote"
filehistory <file> [<file2> [...]]
show the history for one or more files in Kiln
+ hg-sha <sha> [<sha> [...]]
+ show the equivalent Mercurial SHAs corresponding to the
+ given Git SHAs
history
go to the history of this repository in Kiln
logout
@@ -229,6 +232,17 @@ }
case "help":
showHelp()
+ case "hg-sha":
+ if ensureArgs(3, "you must provide at least one commit SHA to lookup") {
+ requireAuth(k)
+ for _, commit := range os.Args[2:len(os.Args)] {
+ if equivalent, err := k.MercurialEquivalent(repoPath, commit); err == nil {
+ fmt.Printf("%v: %v\n", commit, equivalent)
+ } else {
+ fmt.Printf("%v: <none found> (%v)\n", commit, err)
+ }
+ }
+ }
case "history":
k.BrowseHistory(repoPath)
case "logout":
|
Loading...