Frage

Dies ist eine Best-Practice-Frage, und ich erwarte, dass die Antwort auf seine „es kommt“. Ich hoffe nur, mehr reale Szenarien und Abläufe zu lernen.

Zunächst einmal, ich spreche über verschiedene Änderungen für das gleiche Projekt, so dass keine subrepo bitte.

Lassen Sie uns sagen Sie Ihren Code Base in einem hg-Repository haben. Sie beginnen auf einer komplizierte neue Funktion A zu arbeiten, dann ein komplizierter Fehler B durch vertrauenswürdige Tester gemeldet wird (Sie Tester haben, nicht wahr?).

Es ist trivial, wenn (das Update für) B auf A. hängt Sie simlply ci A dann ci B.

Meine Frage ist, was zu tun ist, wenn sie unabhängig sind (oder zumindest scheint es jetzt).

kann ich denke an die folgenden Möglichkeiten:

  1. Verwenden Sie einen separaten Klon für B.
  2. Verwenden Sie anonym oder benannte Zweige oder Lesezeichen, im gleichen Repository.
  3. Verwenden MQ (mit B-Patch auf der Spitze A).
  4. Verwenden verzweigte MQ (Ich werde später erklären).
  5. Verwenden Sie mehrere MQ (seit 1.6)

1 und 2 abgedeckt werden durch eine ausgezeichnet Blog von @Steve Losh verbunden von einem etwas damit verbundene Frage .

Der eine große Vorteil von 1 gegenüber den anderen Entscheidungen ist, dass es nicht wieder aufzubauen erfordert, wenn Sie von der Arbeit an einer Sache zur anderen wechseln, da die Dateien physisch getrennt und unabhängig. So ist es wirklich die einzige Wahl ist, wenn zum Beispiel A und / oder B berührt eine Header-Datei, die definiert, ein boolean Tri-State und von Tausenden von C-Dateien enthalten ist (sagen Sie mir nicht haben Sie eine solche nicht einen Legacy-Code gesehen Base).

3 ist wahrscheinlich die einfachste (in Bezug auf die Einrichtung und Overhead), und Sie können die Reihenfolge von A und B drehen, wenn B ein kleines und / oder dringende fix ist. Allerdings kann es bekommen heikel, wenn A und B die gleiche Datei (en) berühren. Es ist einfach zu fix Patch großen Stücke, die in derselben Datei orthogonal sind (s), wenn A und B Änderungen zu übernehmen gescheitert, aber es ist immer noch konzeptionell ein wenig riskant.

4 können Sie schwindlig machen, aber es ist das leistungsfähigste und flexible und skalierbare Art und Weise. I Standard hg qinit mit -c da ich Zeichen work-in-progress-Patches und Push wollen / ziehen sie, aber sie einen konzeptionellen Sprung nimmt zu erkennen, dass Sie verzweigen in MQ zu Repo. Hier sind die Schritte (mq = hg --mq):

  1. hg qnew bugA; Änderungen für A; hg qref
  2. mq branch branchA; hg qci
  3. hg qpop; mq up -rtip^
  4. hg qnew bugB; Änderungen für B; hg qref
  5. mq branch branchB; hg qci
  6. Um die Arbeit an A wieder: hg qpop; mq up branchA; hg qpush

Es scheint verrückt, so viele Schritte zu unternehmen, und wann immer Sie Schalter Arbeit benötigen, müssen Sie hg qci; hg qpop; mq up <branch>; hg qpush. Aber bedenken Sie: Sie mehrere Namen Release Filialen im gleichen Repository haben, und Sie müssen die Arbeit an mehreren Projekten und Bug-Fixes zur gleichen Zeit für alle von ihnen (Sie besser garantierten Bonus für diese Art von Arbeit bekommen würde). Sie würden sehr bald mit den anderen Ansätzen verloren gehen.

Jetzt Liebhaber meine Kolleginnen und hg, gibt es andere / bessere Alternativen?


(UPDATE) qqueue macht fast # 4 überflüssig. Siehe Steve Losh elegante Beschreibung

War es hilfreich?

Andere Tipps

I would always use named branches, because that lets Mercurial do its job: to keep your project history, and to remember why you made which changes in what order to your source code. Whether to have one clone or two sitting on your disk is generally an easy one, given my working style, at least:

  1. Does your project lack a build process, so that you can test and run things right from the source code? Then I will be tempted to have just one clone, and hg up back and forth when I need to work on another branch.

  2. But if you have a buildout, virtualenv, or other structure that gets built, and that might diverge between the two branches, then doing an hg up then waiting for the build process to re-run can be a big pain, especially if things like setting up a sample database are involved. In that case I would definitely use two clones, one sitting at the tip of trunk, and one sitting at the tip of the emergency feature branch.

So the question is, at the point when you are told to stop working on feature A, and begin independent feature B, what alternative options are there, for: How to manage concurrent development with mercurial?

Let's look at the problem with concurrency removed, the same way you write threaded code- define a simple work flow for solving any problem given to you, and apply it to each problem. Mercurial will join the work, once it's done. So, programmer A will work on feature A. Programmer B will work on feature B. Both just happen to be you. (If only we had multi-core brains:)

I would always use named branches, because that lets Mercurial do its job: to keep your project history, and to remember why you made which changes in what order to your source code.

I agree with Brandon's sentiment, but I wonder if he overlooked that feature A has not been tested? In the worst case, the code compiles and passes unit tests, but some methods implement the previous requirements, and some methods implement the new ones. A diff against the previous check-in is the tool I would use to help me get back on track with feature A.

Is your code for feature A at a point when you would normally check it in? Switching from feature A to working on feature B is not a reason to commit code to the head or to a branch. Only check in code that compiles and passes your tests. My reason is, if programmer C needs to begin feature C, a fresh checkout of this branch is no longer the best place to start. Keeping your branch heads healthy, means you can respond quickly, with more reliable bug fixes.

The goal is to have your (tested and verified) code running, so you want all your code to end up merged into the head (of your development and legacy branches). My point seems to be, I've seen branching used inefficiently: code becomes stale and then not used, the merge becomes harder than the original problem.

Only your option 1 makes sense to me. In general:

  1. You should think your code works, before someone else sees it.
  2. Favor the head over a branch.
  3. Branch and check-in if someone else is picking up the problem.
  4. Branch if your automated system or testers need your code only.
  5. Branch if you are part of a team, working on a problem. Consider it the head, see 1-4.

With the exception of config files, the build processes should be a checkout and a single build command. It should not be any more difficult to switch between clones, than for a new programmer to join the project. (I'll admit my project needs some work here.)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top