Onion Information
pages tagged mercurial
No description
Onion Details
Page Clicks: 0
First Seen: 03/11/2024
Last Indexed: 10/21/2024
Onion Content
Feeding the Cloud https://feeding.cloud.geek.nz/tags/mercurial/ Feeding the Cloud ikiwiki 2021-06-11T20:43:57Z Mercurial commit series in Phabricator using Arcanist https://feeding.cloud.geek.nz/posts/mercurial-commit-series-phabricator-using-arcanist/ Creative Commons Attribution-ShareAlike 4.0 International License 2021-06-11T20:43:57Z 2018-08-01T16:00:00Z Phabricator supports multi-commit patch series, but it's not yet obvious how to do it using Mercurial. So this the "hg" equivalent of this blog post for git users . Note that other people have written tools and plugins to do the same thing and that an official client is coming soon . Initial setup I'm going to assume that you've setup arcanist and gotten an account on the Mozilla Phabricator instance . If you haven't, follow this video introduction or the excellent documentation for it (Bryce also wrote additionnal instructions for Windows users ). Make a list of commits to submit First of all, use hg histedit to make a list of the commits that are needed: pick ee4d9e9fcbad 477986 Bug 1461515 - Split tracking annotations from tracki... pick 5509b5db01a4 477987 Bug 1461515 - Fix and expand tracking annotation tes... pick e40312debf76 477988 Bug 1461515 - Make TP test fail if it uses the wrong... Create Phabricator revisions Now, create a Phabricator revision for each commit (in order, from earliest to latest): ~/devel/mozilla-unified (annotation-list-1461515)$ hg up ee4d9e9fcbad 5 files updated, 0 files merged, 0 files removed, 0 files unresolved (leaving bookmark annotation-list-1461515) ~/devel/mozilla-unified (ee4d9e9)$ arc diff --no-amend Linting... No lint engine configured for this project. Running unit tests... No unit test engine is configured for this project. SKIP STAGING Phabricator does not support staging areas for this repository. Created a new Differential revision: Revision URI: https://phabricator.services.mozilla.com/D2484 Included changes: M modules/libpref/init/all.js M netwerk/base/nsChannelClassifier.cpp M netwerk/base/nsChannelClassifier.h M toolkit/components/url-classifier/Classifier.cpp M toolkit/components/url-classifier/SafeBrowsing.jsm M toolkit/components/url-classifier/nsUrlClassifierDBService.cpp M toolkit/components/url-classifier/tests/UrlClassifierTestUtils.jsm M toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1312515.html M xpcom/base/ErrorList.py ~/devel/mozilla-unified (ee4d9e9)$ hg up 5509b5db01a4 3 files updated, 0 files merged, 0 files removed, 0 files unresolved ~/devel/mozilla-unified (5509b5d)$ arc diff --no-amend Linting... No lint engine configured for this project. Running unit tests... No unit test engine is configured for this project. SKIP STAGING Phabricator does not support staging areas for this repository. Created a new Differential revision: Revision URI: https://phabricator.services.mozilla.com/D2485 Included changes: M toolkit/components/url-classifier/tests/UrlClassifierTestUtils.jsm M toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1312515.html M toolkit/components/url-classifier/tests/mochitest/trackingRequest.html ~/devel/mozilla-unified (5509b5d)$ hg up e40312debf76 2 files updated, 0 files merged, 0 files removed, 0 files unresolved ~/devel/mozilla-unified (e40312d)$ arc diff --no-amend Linting... No lint engine configured for this project. Running unit tests... No unit test engine is configured for this project. SKIP STAGING Phabricator does not support staging areas for this repository. Created a new Differential revision: Revision URI: https://phabricator.services.mozilla.com/D2486 Included changes: M toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html M toolkit/components/url-classifier/tests/mochitest/test_privatebrowsing_trackingprotection.html Link all revisions together In order to ensure that these commits depend on one another, click on that last phabricator.services.mozilla.com link , then click "Related Revisions" then "Edit Parent Revisions" in the right-hand side bar and then add the previous commit ( D2485 in this example). Then go to that parent revision and repeat the same steps to set D2484 as its parent. Amend one of the commits As it turns out my first patch wasn't perfect and I needed to amend the middle commit to fix some test failures that came up after pushing to Try . I ended up with the following commits (as viewed in hg histedit ): pick ee4d9e9fcbad 477986 Bug 1461515 - Split tracking annotations from tracki... pick c24f4d9e75b9 477992 Bug 1461515 - Fix and expand tracking annotation tes... pick 1840f68978a7 477993 Bug 1461515 - Make TP test fail if it uses the wrong... which highlights that the last two commits changed and that I would have two revisions ( D2485 and D2486 ) to update in Phabricator. However, since the only reason why the third patch has a different commit hash is because its parent changed, theres's no need to upload it again to Phabricator. Lando doesn't care about the parent hash and relies instead on the parent revision ID . It essentially applies diffs one at a time. The trick was to pass the --update DXXXX argument to arc diff : ~/devel/mozilla-unified (annotation-list-1461515)$ hg up c24f4d9e75b9 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (leaving bookmark annotation-list-1461515) ~/devel/mozilla-unified (c24f4d9)$ arc diff --no-amend --update D2485 Linting... No lint engine configured for this project. Running unit tests... No unit test engine is configured for this project. SKIP STAGING Phabricator does not support staging areas for this repository. Updated an existing Differential revision: Revision URI: https://phabricator.services.mozilla.com/D2485 Included changes: M browser/base/content/test/general/trackingPage.html M netwerk/test/unit/test_trackingProtection_annotateChannels.js M toolkit/components/antitracking/test/browser/browser_imageCache.js M toolkit/components/antitracking/test/browser/browser_subResources.js M toolkit/components/antitracking/test/browser/head.js M toolkit/components/antitracking/test/browser/popup.html M toolkit/components/antitracking/test/browser/tracker.js M toolkit/components/url-classifier/tests/UrlClassifierTestUtils.jsm M toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1312515.html M toolkit/components/url-classifier/tests/mochitest/trackingRequest.html Note that changing the commit message will not automatically update the revision details in Phabricator. This has to be done manually in the Web UI if required. Recovering from a botched hg histedit on a mercurial bookmark https://feeding.cloud.geek.nz/posts/recovering-from-botched-mercurial-bookmark-histedit/ Creative Commons Attribution-ShareAlike 4.0 International License 2021-06-11T20:43:57Z 2018-07-27T05:42:00Z If you are in the middle of a failed Mercurial hg histedit , you can normally do hg histedit --abort to cancel it, though sometimes you also have to reach out for hg update -C . This is the equivalent of git 's git rebase --abort and it does what you'd expect. However, if you go ahead and finish the history rewriting and only notice problems later, it's not as straighforward. With git, I'd look into the reflog ( git reflog ) for the previous value of the branch pointer and simply git reset --hard to that value. Done. Based on a Stack Overflow answer , I thought I could undo my botched histedit using: hg unbundle ~/devel/mozilla-unified/.hg/strip-backup/47906774d58d-ae1953e1-backup.hg but it didn't seem to work. Maybe it doesn't work when using bookmarks . Here's what I ended up doing to fully revert my botched Mercurial histedit . If you know of a simpler way to do this, feel free to leave a comment. Collecting the commits to restore The first step was to collect all of the commits hashes I needed to restore. Luckily, I had sumitted my patch to Try before changing it and so I was able to look at the pushlog to get all of the commits at once. If I didn't have that, I could also go to the last bookmark I pushed and click on parent commits until I hit the first one that's not mine . Then I could collect all of the commits using the browser's back button: https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/3c31c543e736 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/7ddfe5ae2fa6 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/c04b620136c7 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/2d1bf04fd155 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/e194843f5b7a https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/47906774d58d https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/f6a657bca64f https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/0d7a4e1c0079 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/976e25b49758 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/a1a382f2e773 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/b1565f3aacdb https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/3fdd157bb698 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/b1b041990577 https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/220bf5cd9e2a https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/c927a5205abe https://hg.mozilla.org/users/fmarier_mozilla.com/mozilla-unified/rev/4140cd9c67b0 For that last one, I had to click on the changeset commit hash link in order to get the commit hash instead of the name of the bookmark ( /rev/hashstore-crash-1434206 ). Recreating the branch from scratch This is what did to export patches for each commit and then re-import them one after the other: for c in 3c31c543e736 7ddfe5ae2fa6 c04b620136c7 2d1bf04fd155 e194843f5b7a 47906774d58d f6a657bca64f 0d7a4e1c0079 976e25b49758 a1a382f2e773 b1565f3aacdb 3fdd157bb698 b1b041990577 220bf5cd9e2a c927a5205abe ; do hg export $c > ~/$c.patch ; done hg up ff8505d177b9 hg bookmarks hashstore-crash-1434206-new for c in 3c31c543e736 7ddfe5ae2fa6 c04b620136c7 2d1bf04fd155 e194843f5b7a 47906774d58d f6a657bca64f 0d7a4e1c0079 976e25b49758 a1a382f2e773 b1565f3aacdb 3fdd157bb698 b1b041990577 220bf5cd9e2a c927a5205abe 4140cd9c67b0 ; do hg import ~/$c.patch ; done Copying a bookmark As an aside, if you want to make a copy of a bookmark before you do an hg histedit , it's not as simple as: hg up hashstore-crash-1434206 hg bookmarks hashstore-crash-1434206-copy hg up hashstore-crash-1434206 While that seemed to work at the time, the histedit ended up messing with both of them. An a