I have created a fork of repository A in Bitbucket, and named it repository B1.
Repository A has branch default, branch1 and branch2.
I created a copy of A on my machine that has only branches default and branch1, let's call it A2.
There was an error with my repository and I had to delete repository A (which is the parent for fork B), from Bitbucket, thus leaving fork B without a parent.
I uploaded repository A2 on Bitbucket with the name A.
My question is: How can I make repository A be the parent of fork B, so i can use Bitbucket's sync parent option?
ps: I use mercurial as source control.
Fork A1 call it B2.
Manually pull changesets from B into B2.
Check that B2 is now basically the same as B, but connected to A1 with your one click update.
Use B2 instead of B with optional renaming.
I'm afraid you cannot re-attach a parent to a fork, once the relationship is broken.
Related
Using the ACL extension of hg, I managed to prevent users to push on some branches (see [acl.deny.branches]) or some files (see [acl.deny], [acl.allow]).
However I would like to be able to mix both control. Here is an example:
we have two users, alice and bob
the repo is made of two files A and B
we have two branches, default and wip
alice should have RW access to both branches, on both A and B
bob should have RW access to A and B on the wip branch, but should have only
RW access to A on the default branch. bob must not be able to push a commit which modifies B on the default branch.
In this example, the access rights for bob are a mix of branch and file rules. Is it possible ?
Say I cloned a remote repository and called it "A"
Then I cloned another remote repository and called it "B"
"B" has the .hg folder and src folder , and "A" only has the .hg folder.
If I pull changes from "B" to "A", should now "A" also contain the src folder? Because that's exactly what I did and it did not
You mix the concepts of 'repository' with the working directory, the actually checked-out changeset, which indicates the state of the repository at a particular revision.
If the two repositories A and B are pulled into one repository, all changesets are present there, but they are present in different changesets. If you want to bring them together, you have to merge two changesets; most likely you want to merge the two heads you have, the one from repository A and the one from repository B. For example:
# check heads:
hg heads --template="{rev}:{node|short} {desc}\n"
2332:d69c8aaf6db6 Doc: Changelog as it should have been
2128:6f38df710194 Added tag 0.2.5 for changeset 6d89bb9ad3f6
Update to one head and then merge the other. Make sure to use the actual revisions:
hg up -r2332
hg merge -r2128
Whether or not that works without any conflicts depends on how A and B look like.
Does src contain any files? You cannot add an empty directory to a mercurial repo. If you tried hg add src and src was empty, you won't get an error but nothing happens. If that's really what you want, there are ways, but it sounds like you're just experimenting.
More specifically: You can only add files, and the directories that contain them are added implicitly. After you create a file in src, add the file to the repo and commit the change (along with anything else you may want to bring along). Now you have a changeset you can push or pull to repository "B".
Once the changeset has become part of "B"'s history (check with hg log), you need to update to it (hg update); or, if you've ended up with a branch, merge it to your current branch.
I cloned a Mercurial repo and did a bunch of local work, and forgot to make a feature branch for said work.
The normal flow is:
Clone
Create a branch
Switch to that branch
Do your work in that branch
Push that branch
Code review
If code review passes, merge branch w/ default (locally)
Push merged changes to default
Close the feature branch
So I need to create a new branch, port all my unstaged/uncommitted code changes (made to default) over to this branch (so that default is now clean and the new branch contains my changes), and then push my feature branch.
I created the new branch via hg branch new_feature. But after pouring over the Merucrial docs, I can't figure out the next step.
So I ask: How do I move (not just copy) all my unstaged/uncommitted changes from default to my new_feature branch)?
You shouldn't have to do anything in particular.
Your uncommitted working folder changes are fluid, and you can set the branch name before you commit, without losing your changes.
If you're on the command line, simply do this:
hg branch feature-X
hg commit -m "Added feature X"
If you're using TortoiseHg simply click the "Branch: default" button just above the commit message input field and select "Open a new named branch" and give it a name, then click OK, then commit as normal.
Setting the branch name to use during commit does not in fact change your working folder, it doesn't do an update, it doesn't do anything, except record in metadata what the branch name is supposed to be.
Also note that this will only allow you to create a new branch to commit to. If you want to continue on an existing branch you first need to update to the head of that branch and this may cause changes to your working folder. You should not need to do this, however, if you want to create a new branch.
I have a distant repository called http://myrepo
I also have 3 projects with 3 distinct packages (1 in each) stored in D:/Projects/Project[ABC]/src/pack[ABC].
I would like to create a local repo in D:/Mercurial which will reference the packages pack[ABC] as subrepositories, which are to be pushed to my distant repo.
Finally, I would like to have my packages stored in my distant repo so you read http://myrepo/pack[ABC], and they should reflect the changes made in D:/Projects/Project[ABC]/src/pack[ABC].
I can't manage tu push my subrepositories to my distant one. How to set-up such a thing?
You should be able to configure your subrepos in your top repo's .hgsub as:
LocalPathA = http://server/A
LocalPathB = http://server/B
LocalPathC = http://server/C
Then, on Server, you will have to create empty repositories (with appropriate permissions) A, B, C
Your local repositories A,B,C will need their [paths] default=http://server/A, etc set up.
hgrc for the subs
[paths]
default = source repo
hgsub for the surrounding repo
protocol://servername//absolute/path/to/repo = relative/path/from/surrounding/repo/root
Before, when I was using perforce, I could work on multiple bugs at once as long as the code did not affect the same files, by having multiple change sets open at once.
Changeset 1:
A.txt
B.txt
C.txt
Changeset 2:
D.txt
E.txt
F.txt
I could submit changeset 2 to the repository without submitting changeset 1 (because it's still in progress)
Is this possible with Mercurial? other than doing each file as a separate commit?
You can always just do: hg commit D.txt E.txt F.txt to commit just those files which will leave A.txt, B.txt, and C.txt uncommited. Using the -I option to commit lets you do those with patterns if they're, for example, in a common directory: hg commit -I 'dir1/**'
You can have two separate branches (working copies) and make one change in and the other in the other. That's one way.
Another is to use Mercurial Queues. You can use qpush --move to change the order of changesets if they have no dependencies on one another, so you can then use qfinish to 'commit' the first changeset that's ready.
You don't actually hold changesets "open" in Mercurial.
Either you've committed your changes, or you haven't.
You can, however, have multiple files with uncommitted changes, and only commit a few of them. It is even possible to commit parts of files, chunks, instead of the whole file.
If I was to do what you're asking I would simply make another clone locally from my first one, and work on the two different fixes in two different working folders. Then I have all the freedom I need to combine the two (push/pull locally), push to the server, etc.
In Mercurial, cloning is a cheap operation when done locally. Just clone the repository for each thing you are working on. Push back to the main repository as each thing is ready:
hg clone http://project project
hg clone project project-bugfix // uses hardlinks and is inexpensive.
hg clone project project-feature
<edit bugfix and feature as needed>
But remember that the default push location is the project cloned from, so you'll either need to edit .hg\hgrc's default push path for the "project" clones, or make sure to hg push http://project from "project-bugfix" and "project-feature" when complete.
Even if your modifications touches the same file you can select what to include (hunk by hunk). You just have to activate the record extension (it's installed by not activated by default).
To activate the record extension, put this in the [extensions] section of your .hgrc:
[extensions]
hgext.record=
Then to commit, replace hg commit by hg record. Let's assume your example change sets with a G.txt file that have changes for both change sets. Commit with:
hg record D.txt E.txt F.txt G.txt
Answer questions, for example:
2 hunks, 6 lines changed
examine changes to 'D.txt'? [Ynsfdaq?] f # f for full file (help with ?)
... skipped file E and F
6 hunks, 35 lines changed
examine changes to 'G.txt'? [Ynsfdaq?] y
## ... (patch hunk here)
record change 6/16 to 'G.txt'? [Ynsfdaq?] y # y to include the hunk, n to skip