Fossil Forum

How to see what's on a remote, and how to reset to one side of a fork?
Login

How to see what's on a remote, and how to reset to one side of a fork?

How to see what's on a remote, and how to reset to one side of a fork?

(1.2) By patmaddox on 2023-05-12 18:01:59 edited from 1.1 [link] [source]

I am experimenting with a child project, and have run into difficulty determining what is on the parent so I can reset to it.

The scenario is:

  1. Clone parent to child
  2. Commit some stuff in each one
  3. Pull from parent to child

Demo script

This is now a fork. I decide in the child, I want to match what the parent considers to be trunk. I'm stuck though.

How do I see what the parent considers trunk? With git I would do git show origin/main. I've gone through the documentation and don't see any commands for inspecting the branches / leaves of a remote.

I think I have worked out how to revert to a specific commit. Please let me know if I'm misunderstanding something.

fossil tag cancel trunk <first-bad-commit>
fossil tag add --raw closed <leaf-that-is-no-longer-trunk>
fossil up trunk

Now, I just need to know how to view the trunk tags on a remote repo.

(2) By Warren Young (wyoung) on 2023-05-12 13:24:16 in reply to 1.0 [link] [source]

I started to write a long answer to this, but then I decided it'd be better simply to add this topic to our Git to Fossil Translation Guide. Assuming you have read it once already, the key changes are to the second paragraph up in the introduction, changes to the autosync section, and the addition of a new section on reset.

If you don't see that this answers your questions, you're free to continue this thread. Perhaps the new docs are incomplete and need improving; wouldn't be the first time.

(4) By patmaddox on 2023-05-12 18:10:34 in reply to 2 [link] [source]

Thank you! Very simple (now that I see an example :) I have updated my demo script to use this.

Now that I've seen this, I see that shunning "Alternative" demonstrates this as well - but since my brain is still... fossilizing? (seems undesirable) - I didn't realize that's what was happening.

Thank you for the translation from git!

(3.1) By Andy Bradford (andybradford) on 2023-05-12 17:26:39 edited from 3.0 in reply to 1.0 [link] [source]

> The scenario is:
> 
>    1. Clone parent to child
>    2. Commit some stuff in each one
>    3. Pull from parent to child
> 
> This is now a fork.

A "fork" in  Fossil has different connotations and meanings  than what I
think you intend:

https://www.fossil-scm.org/home/doc/trunk/www/branching.wiki

What you have are just two "cuttings" of the same repository, or clones.
There may be a  "fork" in the timeline if your  commits in each overlap,
however, the act  of cloning does not create a  "fork". Neither does the
act  of committing  in  two different  clones  necessarily constitute  a
"fork"; only if the different commits  are done on the same "branch" and
against the same parent would it introduce  a "fork", and then it is not
said that  the repository is  a "fork", but  rather that there  exists a
"fork" in the DAG (aka timeline) in one or both of the repositories.

Also,  you probably  don't want  to mess  around with  the "fossil  tag"
command, especially  to "revert" or  backout a commit. In  Fossil, there
are a few ways you can do it.

1. fossil merge --backout HASH
2. fossil amend HASH --branch NAME (if leaf you can also use --close)
3. fossil ui (and then move the commit to a new branch; same as 2)

The first simply  makes a new commit against the  repository that is the
reverse of what was done in HASH. The next 2 simply "move" the commit to
a new branch name. Now, if the HASH in  2 and 3 is a leaf then you could
also "close"  it. Also,  if it  has any descendents,  then all  of those
descendants will be moved to the new branch name.

> I decide in the child, I want to match what the parent considers to be
> trunk. I'm stuck though.
>
> How do I see what the parent considers trunk?

If you want to  "see" what the "parent" has, you just  fire up a browser
and point  it to  the location  where the repository  is hosted  (or use
"fossil timeline"). If  it is local, then you can  juse use "fossil ui".
If you're using SSH, then you would  want a "parent" clone that is local
so you  can use "fossil  ui" with  it. That way  you can "see"  what the
"parent" has.

If you want  the "child" to "fetch"  all that the "parent"  has, use the
"fossil pull" command from the "child", or if you use "fossil sync" then
this will cause the "child" to synchronize all commits so that they both
converge.

Hope this helps.

Andy

(6) By patmaddox on 2023-05-12 18:28:50 in reply to 3.1 [link] [source]

only if the different commits are done on the same "branch" and against the same parent would it introduce a "fork"

Yeah, sorry, I didn't include the details in my original post, but that's the scenario I'm describing.

and then it is not said that the repository is a "fork", but rather that there exists a "fork" in the DAG (aka timeline) in one or both of the repositories.

Understood - thank you for the correction.

You probably don't want to mess around with the "fossil tag" command

I took that from the wrong way to close a branch. I will look into the difference between amend --close and branch close.

If you're using SSH, then you would want a "parent" clone that is local so you can use "fossil ui" with it. That way you can "see" what the "parent" has.

While I appreciate a lot that the ui offers, I want to answer questions like this from the command line. You've helped me do that:

ssh remote "fossil info trunk -R path/to/my.fossil

also, have a local undisturbed clone

Hope this helps.

Very much so, thank you!

One thing I'm taking away from this is that branches should eventually resolve to the same thing. That is, if I'm using child projects to make a closed-source enhancement, then I should have a separate branch e.g. my-trunk which is trunk + my enhancements, and keep trunk matching upstream trunk exactly. Is that right?

(8) By John Rouillard (rouilj) on 2023-05-13 17:18:40 in reply to 6 [link] [source]

One thing I'm taking away from this is that branches should eventually resolve to the same thing. That is, if I'm using child projects to make a closed-source enhancement, then I should have a separate branch e.g. my-trunk which is trunk + my enhancements, and keep trunk matching upstream trunk exactly. Is that right?

Yes. I would suggest either renaming the child's trunk or keeping a separate branch for the child's mainline development.

I have a child repo (which I would consider a repository fork since it can never push back to its parent).

The child repo does mainline development on the trunk branch. When I pull from the parent, I get two trunk branches (which is allowed by fossil). The DAG has a fork at the point before my first commit to the child repo.

The parent repo is more active than the child. When I pull the parent into the child I them merge this way

  1. in a checkout/update to the last commit on the child's trunk
  2. merge trunk (which is the tip of the parent's trunk since it is the newest commit)
  3. test, commit
  4. merge child trunk into all child branches (or sometimes merge the tip revision on the parent's trunk by hash into a child branch)

All in all it's confusing that there are two branches named "trunk" that have to be merged. I have wasted time trying to figure out why my commands weren't working. So I suggest renaming the child's mainline to something like default or main starting with the first commit on the child. You may be able to just rename that point in the GUI, I haven't tried. But I may try on a copy of the repo to see if it works as I expect.

(5) By Richard Hipp (drh) on 2023-05-12 18:24:07 in reply to 1.2 [source]

I think you are trying to apply the Git worldview to Fossil. I think you may be assuming that those two systems work exactly the same. They do not.

The Fossil mindset is that all of the repositories stay synced up all of the time. That isn't always the case - for example if you are off network and make changes to your local repo, obviously those changes can not get pushed to remote until you go back on-line. But, generally speaking, the remote and the local repo have all the same info, or nearly so. The default behavior is that every time you "commit" a new code change, that change is immediately and automatically pushed to remove. Similarly, whenever you update your local check-out, the latest changes are automatically pulled from remote into your local repo.

So the question "How to see what's on a remote" does not make a whole lot of sense in Fossil. You can do it - you can find out what is on remote as distinct from what is local. But that is not what Fossil user do. The Fossil mindset is that everybody sees the same thing, all of the time. There is no "my repo", "your repo", "Alice's repo" - all the repositories hold everybody's stuff (almost) all of the time.

So, to see what is on remote, run "fossil ui" to see what is on local. It should be (mostly) the same.

Forks

Unlike Git, Fossil is perfectly happy to maintain two or more concurrent branches with the same name. If you have two or more "trunk" branches, that is what we call a "fork". Forks can be confusing to humans (though Fossil itself doesn't have any trouble with them) so steps are taken to prevent them. But if you are working off network, they can occur. We had an accidental fork in the SQLite repo a couple of months ago:

https://sqlite.org/src/timeline?c=8b524c849f9844ea&n=10

I was off network and made changes. I didn't realized that Larry had made changes at the same time. So for a while there we had two separate "trunk" branches. How to fix that? Just merge them together.

Abandoning one arm of a fork

You can change the name of a branch after it is created in Fossil. So if you have a fork and you want to abandon one arm of that fork, simply go to the /info page for the first checking of the arm you want to abandon. Click the "edit" hyperlink. The select "Make this check-in the start of a new branch named: _______". Fill in the name you want. Press preview then submit and the branch you want to abandon now has a new name. That rename will propagate to other repos. You might want to "close" the branch at the same time. I usually rename the branch that I want to abandon to "mistake". Here is a recent example of that from SQLite:

https://sqlite.org/src/timeline?c=984a07d7f171e03a&n=10

(7) By patmaddox on 2023-05-12 23:06:52 in reply to 5 [link] [source]

I think you are trying to apply the Git worldview to Fossil. I think you may be assuming that those two systems work exactly the same. They do not.

I've run a million git commands over the years, so there is a lot of rewiring to do :) I really appreciate how patient and informative people are around here.

Abandoning one arm of a fork

Yep, I didn't know how to do that and couldn't figure it out... "rename the branch" makes sense in retrospect, and is a clear example of where I need to re-learn things in Fossil.

There is no "my repo", "your repo", "Alice's repo" - all the repositories hold everybody's stuff (almost) all of the time.

I think there is one exception: child projects.

Here, there is "their repo" (upstream) and "our repo" (proprietary). So there is some need to understand what is on "their repo" so we can merge it into "our repo".

How do you handle this in practice? Does your proprietary repo trunk track upstream trunk, and you have a separate proprietary-trunk branch that is trunk + any of your proprietary changes? Or do you merge all upstream and proprietary changes to trunk on your child project?

(9) By John Rouillard (rouilj) on 2023-05-13 17:23:06 in reply to 7 [link] [source]

Just FYI Child Projects/child repos (rather than a cloned repo) seem to be a niche mechanism that is not widely used. IIRC I asked a question a while ago about it and Richard had forgotten about child projects and didn't initially make the connection.

I don't wish to discourage you from using it, but I just wanted to say there isn't really a best practices knowledgebase about it.

Regarding renaming the main branch, see my comment above. TL;DR rename it.

(10) By Andy Bradford (andybradford) on 2023-05-13 20:49:54 in reply to 7 [link] [source]

> I've run a million  git commands over the years, so there  is a lot of
> rewiring to do

I started  using both Git  and Fossil at roughly  the same time  so I've
been able  to compare  them side by  side through the  years. I  use Git
probably 3X more than Fossil, but  I've never been comfortable using it,
despite  having used  it a  lot more.  Fossil just  seems more  sensibly
designed and simpler to grok. I've never worried about conflicts, forks,
branching, losing code, etc. with Fossil.

> I think there is one exception: child projects.

Haha, in all this  time I've never heard of or  used "child projects". I
suppose there  may be some utility  for it, but  it seems like a  lot of
work for not much gain.

> So there is some need to understand  what is on "their repo" so we can
> merge it into "our repo".

One way to do  that is instead of making your  "child project" a "child"
of the remote repository, clone the remote repository, and then make the
"child project" a "child" of your local clone of the remote.

Then you  sync/pull into  the clone  and inspect  the changes  that will
result when you then complete a "fossil pull --from-parent-project".

Andy