git out of date

16 views
Skip to first unread message

Therneau, Terry M., Ph.D.

unread,
Jun 7, 2022, 7:14:10 AM6/7/22
to hg-...@googlegroups.com
My R survival package is a long term repository in mecurial (more than a decade), I've made a copy on github solely for others to see the code, and hg-git has worked well for me. 
  But somehow the two have gotten out of sync:  my most recent  "hg push github" says that the git repository is up to date, but it isn't.   Is there a way to more or less tell it "your're wrong, look again"?  

For the curious: the git repository is therneau/survival, source code for the survival package in R.  This started out in SCCS around 1984, migrating over time to rcs, then svn, then finally mercurial.   And I'm happy with hg; git drives me a bit banannas when I have to work with it directly.
-- 
Terry M Therneau, PhD
Department of Quantitative Health Sciences
Mayo Clinic
ther...@mayo.edu

"TERR-ree THUR-noh"

Sietse Brouwer

unread,
Jun 8, 2022, 7:35:08 AM6/8/22
to hg-git
Hi Terry,

Terry wrote:
> my most recent  "hg push github" says that the git repository is up to date, but it isn't.   Is there a way to more or less tell it "your're wrong, look again"?

Have you already tried force-pushing with `hg push -f -B mybookmark`?

Alternatively, try moving the bookmark, force-pushing that, then moving it to where you want it and force-pushing that. Like so:

    # 1. Go to mybookmark
    hg update mybookmark

    # 2. Move mybookmark to parent of current commit and force-push
    hg bookmark mybookmark -r 'p1(.)'
    hg push -f -B mybookmark

    # 3. Move mybookmark back to current commit and force-push
    hg bookmark mybookmark -r .
    hg push -f -B mybookmark

If that doesn't work, debugging will be needed. To aid in debugging the incorrect push to Github: is there a public version of your Mercurial repo, or would you be able to create one? If publishing the Mercurial repo is not desired, could you send a copy privately as a zipfile?

Public Mercurial hosts that I know of:
- Sourcehut: https://hg.sr.ht

Kind regards from a user of both R and survival,

Sietse
Sietse Brouwer

Sietse Brouwer

unread,
Jun 8, 2022, 10:10:43 AM6/8/22
to hg-git
Oh, another possible cause: perhaps you committed without activating the bookmark? That causes commits to be created, but the bookmark does not move.

You can recognize it by seeing if your history looks something like this:

    $ hg log --graph

    o changeset: 3:abc123  <-- note: no bookmarks on this head commit
    |  tag: tip
    |  desc: work work work, I wonder why this commit is not pushed
    |
    o changeset: 2:aaa001
    |  bookmark: main  <-- note the bookmark is still back here...
    |  tag: origin/main   <-- ... and the Git remote already knows about it
    |  desc: work work
    |
    ~

If your history looks like that, pushing to Git will do nothing because git only considers commits that are ancestors of git branch pointers (hg bookmarks).

The solution: moving the bookmark to the commit you want to push. 

    $ hg up mybookmark
    $ hg update   # moves bookmark forward
    $ hg pus

Cheers,

Sietse
Reply all
Reply to author
Forward
0 new messages