summaryrefslogtreecommitdiff
path: root/tests/test-convert-hg-svn.t
blob: ef002a71157c2cbbd20ee17a5c0d0c60517f01d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

  $ "$TESTDIR/hghave" svn svn-bindings || exit 80
  $ fix_path()
  > {
  >     tr '\\' /
  > }
  $ echo "[extensions]" >> $HGRCPATH
  $ echo "convert = " >> $HGRCPATH
  $ echo "mq = " >> $HGRCPATH
  $ svnpath=`pwd | fix_path`/svn-repo
  $ svnadmin create "$svnpath"
  $ cat > "$svnpath"/hooks/pre-revprop-change <<EOF
  > #!/bin/sh
  > 
  > REPOS="$1"
  > REV="$2"
  > USER="$3"
  > PROPNAME="$4"
  > ACTION="$5"
  > 
  > if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
  > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi
  > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi
  > 
  > echo "Changing prohibited revision property" >&2
  > exit 1
  > EOF
  $ chmod +x "$svnpath"/hooks/pre-revprop-change
  $ 
  $ # SVN wants all paths to start with a slash. Unfortunately,
  $ # Windows ones don't. Handle that.
  $ svnurl="$svnpath"
  $ expr "$svnurl" : "\/" > /dev/null || svnurl="/$svnurl"
  $ svnurl="file://$svnurl"
  $ svn co "$svnurl" "$svnpath"-wc
  Checked out revision 0.
  $ cd "$svnpath"-wc
  $ echo a > a
  $ svn add a
  A         a
  $ svn ci -m'added a' a
  Adding         a
  Transmitting file data .
  Committed revision 1.
  $ cd ..

initial roundtrip

  $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg | grep -v initializing
  scanning source...
  sorting...
  converting...
  0 added a
  $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
  scanning source...
  sorting...
  converting...

second roundtrip should do nothing

  $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg
  scanning source...
  sorting...
  converting...
  $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
  scanning source...
  sorting...
  converting...

new hg rev

  $ hg clone "$svnpath"-hg "$svnpath"-work
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd "$svnpath"-work
  $ echo b > b
  $ hg add b
  $ hg ci -mb

adding an empty revision

  $ hg qnew -m emtpy empty
  $ hg qfinish -a
  $ cd ..

echo hg to svn

  $ hg --cwd "$svnpath"-hg pull -q "$svnpath"-work
  $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
  scanning source...
  sorting...
  converting...
  1 b
  0 emtpy

svn back to hg should do nothing

  $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg
  scanning source...
  sorting...
  converting...

hg back to svn should do nothing

  $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc
  scanning source...
  sorting...
  converting...