Home > Software design >  What is the proper way to create new projects with hgsubversion, svn, and mercurial?
What is the proper way to create new projects with hgsubversion, svn, and mercurial?

Time:01-08

I have switched my development to mercurial, but I still have to talk with a subversion server using hgsubversion. I am up and running locally with hg for all of the projects that already existed in subversion.

My question is this: what is the best workflow for creating a new project that will ultimately live in subversion?

I tried to get a new project off the ground with hg init, followed by pushes to subversion. But I just got lost, and couldn't get it to work. I decided that the best workflow would be to create the project straight into subversion, completely ignorant of mercurial's existence, and then clone with hgsubversion. But I want to know if there is a better way.

For what its worth, we are using the classic trunk/tags/branches directory structure in subversion. Other developers are still using svn directly.

CodePudding user response:

I decided that the best workflow would be to create the project straight into subversion, completely ignorant of mercurial's existence, and then clone with hgsubversion.

It's not only best, but only one possible. Init'ed hg repo with added later extension and Subversion repo in [path] will not work for pull/push


Addition (in reply to comment of @bigh_29)

Yes, starting work with empty Subversion repo (only default dirmap created) from Mercurial give me also unexpected and unpredictable results.

Initial state:

  • Created local (file:///) SVN-repo and trunk/branches/tags tree, using TSVN (tool doesn't matter)

svn log file:///Z:/SVN

------------------------------------------------------------------------

r1 | Badger | 2013-01-09 12:00:10 0600 (Ср, 09 янв 2013) | 1 line

Imported folder structure

------------------------------------------------------------------------

  • Cloned repo (from repo-root) to Mercurial

hg clone file:///Z:/SVN z:\HG

[r1] Badger: Imported folder structure
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

(OK, Mercurial doesn't track empty dirs, so we have nothing to store in changeset)

hg log -R z:\hg produce empty output

  • Usual workflow testing - add, commit, push (TortoiseHG latest)

    % hg add --repository Z:\HG Z:\HG\Intro.txt

    [command completed successfully Wed Jan 09 12:17:31 2013]

    % hg commit ...

    Intro.txt

    committed changeset 0:0a3fc4a9213d

    [command completed successfully Wed Jan 09 12:17:31 2013]

    % hg --repository Z:\HG push file:///Z:/SVN

    pushing to file:///Z:/SVN

    searching for changes

    no changes found

    [command completed successfully Wed Jan 09 12:18:02 2013]

"no changes found" - bad, very bad news. Got diferent history in Mercurial and upstream Subversion

>hg log

changeset:   0:0a3fc4a9213d
summary:     Added file

svn log file:///Z:/SVN
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 12:00:10  0600 (Ср, 09 янв 2013) | 1 line

Imported folder structure
------------------------------------------------------------------------
  • Try to add file into Subversion from SVN WC, added

>svn log file:///Z:/SVN

------------------------------------------------------------------------

r2 | Badger | 2013-01-09 12:22:38 0600 (Ср, 09 янв 2013) | 1 line

Added main file

------------------------------------------------------------------------

r1 | Badger | 2013-01-09 12:00:10 0600 (Ср, 09 янв 2013) | 1 line

Imported folder structure

------------------------------------------------------------------------

  • Pull (really fetch) from SVN

hg --repository Z:\HG fetch --verbose file:///Z:/SVN

pulling from file:///Z:/SVN

[r2] Badger: Added main file

A trunk/Topic.txt

Topic.txt

committed to "default" as fc8bf55ea98f

pulled 1 revisions

updating to 1:fc8bf55ea98f

resolving manifests

removing Intro.txt

getting Topic.txt

1 files updated, 0 files merged, 1 files removed, 0 files unresolved

merging with 0:0a3fc4a9213d

resolving manifests

getting Intro.txt

1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Intro.txt

new changeset 2:98c16d1829d8 merges remote changes with local

  • Got ugly local history

Log after pull

and still can't push ("Sorry, can't find svn parent of a merge revision."): our 0 doesn't have parent on origin

But, if I'll add file to tree in SVN (empty .hgignore, it must appear in Mercurial repo anyway)

> svn log file:///Z:/SVN -q -v
------------------------------------------------------------------------
r2 | Badger | 2013-01-09 13:44:47  0600 (Ср, 09 янв 2013)
Changed paths:
   A /trunk/.hgignore
------------------------------------------------------------------------
r1 | Badger | 2013-01-09 13:43:27  0600 (Ср, 09 янв 2013)
Changed paths:
   A /branches
   A /tags
   A /trunk
------------------------------------------------------------------------

after clone I get

>hg log
changeset:   0:71c7bc7bce68
tag:         tip
user:        Badger@1d57b098-00df-af47-a2e3-c1451e4b2f8d
date:        Wed Jan 09 07:44:47 2013  0000
summary:     Added needed for successful cloning hgignore

and added|commited file was pushed to Subversion without any headache

% hg --repository Z:\HG push file:///Z:/SVN
pushing to file:///Z:/SVN
searching for changes
[r3] Badger: File from Mercurial
pulled 1 revisions
nothing to rebase
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

svn log file:///Z:/SVN -q -v -r "HEAD"
------------------------------------------------------------------------
r3 | Badger | 2013-01-09 13:59:15  0600 (Ср, 09 янв 2013)
Changed paths:
   A /trunk/Test.txt
------------------------------------------------------------------------

Note: I failed in testing of using Mercurial branches with SVN-origin: created (named) branch with saved in this branch changeset disappeared after push to Subversion (and changeset appear in trunk instead of expected /branches/BRANCHNAME)

  • Related