Source

hg-importfs / test-importfs.t

Load the extension:

  $ echo "[extensions]" >> $HGRCPATH
  $ echo "importfs = $TESTDIR/importfs.py" >> $HGRCPATH

Provoke an error by using a non existent directory for import:

  $ hg importfs r d1
  abort: directory d1 does not exist
  [255]

Create a simple filesystem structure for import:

  $ mkdir d1
  $ echo "c1" > d1/f1
  $ echo "c2" > d1/f2
  $ mkdir d1/d2
  $ echo "c3" > d1/d2/f3
  $ mkdir d1/d3
  $ echo "c4" > d1/d3/f4
  $ echo "c5" > d1/d3/f5

Perform the first import (creates a new repository):

  $ hg importfs r d1
  created repository $TESTTMP/r
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d2/f3
  adding d3/f4
  adding d3/f5
  adding f1
  adding f2

Add a new file to the filesystem structure:

  $ echo "c6" > d1/d2/f6

Perform the second import (uses the repository created before):

  $ hg importfs r d1 -t t1 -m 'm1'
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d2/f6

Show the log of the last changeset:

  $ hg -R r log -vr 1
  changeset:   1:???????????? (glob)
  tag:         t1
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d2/f6
  description:
  m1
  
  

Change the filesystem structure (add, modify, delete):

  $ echo "c7" > d1/d2/f7
  $ echo "c8" > d1/d3/f4
  $ rm d1/d3/f5

Perform a third import using a branch:

  $ hg importfs -b b1 -r 0 -t t2 r d1
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  marked working directory as branch b1
  adding d2/f6
  adding d2/f7
  removing d3/f5

Show the log of the last changeset:

  $ hg -R r log -vr 3
  changeset:   3:???????????? (glob)
  branch:      b1
  tag:         t2
  parent:      0:???????????? (glob)
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d2/f6 d2/f7 d3/f4 d3/f5
  description:
  importfs commit.
  
  
Commit the same files on top of the default branch:

  $ hg importfs r d1
  3 files updated, 0 files merged, 1 files removed, 0 files unresolved
  adding d2/f7
  removing d3/f5

Show the log of the last changeset:

  $ hg -R r log -vr 5
  changeset:   5:???????????? (glob)
  tag:         tip
  parent:      2:???????????? (glob)
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d2/f7 d3/f4 d3/f5
  description:
  importfs commit.
  
  
Add a new file to the filesystem structure:

  $ echo "c9" > d1/d3/f8

Reuse the branch:

  $ hg importfs -b b1 r d1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d3/f8

Show the log of the last changeset:

  $ hg -R r log -vr 6
  changeset:   6:???????????? (glob)
  branch:      b1
  tag:         tip
  parent:      4:???????????? (glob)
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d3/f8
  description:
  importfs commit.
  
  
Move a file and commit it (using the default similarity of 100%):

  $ mv d1/d3/f8 d1/d3/f9
  $ hg importfs -b b1 r d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  removing d3/f8
  adding d3/f9
  recording removal of r/d3/f8 as rename to r/d3/f9 (100% similar)

Show the log of the last changeset:

  $ hg -R r log -vr 7
  changeset:   7:???????????? (glob)
  branch:      b1
  tag:         tip
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d3/f8 d3/f9
  description:
  importfs commit.
  
  
Move a file, add new content and commit it with a similarity of 50%:

  $ mv d1/d2/f7 d1/d2/f10
  $ echo "c10" >> d1/d2/f10
  $ hg importfs -b b1 -s 50 r d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d2/f10
  removing d2/f7
  recording removal of r/d2/f7 as rename to r/d2/f10 (60% similar)

Move a file, add new content and commit it with a similarity of 0%.
The rename will not be detected:

  $ mv d1/d3/f4 d1/d3/f11
  $ echo "c11" >> d1/d3/f11
  $ hg importfs -b b1 -s 0 r d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  adding d3/f11
  removing d3/f4

Add a new file to the filesystem:

  $ echo "c12" > d1/d3/f12

Create a second branch without specifying a rev (so it uses the tip of default):

  $ hg importfs -b b2 -m "Creating branch b2" r d1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  marked working directory as branch b2
  adding d3/f12

Show the log of the last changeset:

  $ hg -R r log -vr 10
  changeset:   10:???????????? (glob)
  branch:      b2
  tag:         tip
  user:        test
  date:        ??? ??? ?? ??:??:?? ???? +???? (glob)
  files:       d3/f12
  description:
  Creating branch b2
  
  
Show all branches of the repository:

  $ hg -R r branches
  b2                            10:???????????? (glob)
  default                        5:???????????? (glob)
  b1                             9:???????????? (inactive) (glob)

Use the branch b1 as base and add a file:

  $ hg -R r -q up b1
  $ rm -rf d1/*
  $ cp -r r/* d1
  $ echo "c13" > d1/d3/f13

Update to the tag t2:

  $ hg -R r -q up t2

Commit to the branch b1.
The repository updates to the last revision and doesn't use the tag t2:

  $ hg importfs -b b1 r d1
  4 files updated, 0 files merged, 2 files removed, 0 files unresolved
  adding d3/f13

Create an anonymous branch:

  $ echo "c14" > d1/d3/f14
  $ hg importfs -r t2 -m "Creating an anonymous branch." r d1
  2 files updated, 0 files merged, 5 files removed, 0 files unresolved
  b1
  adding d2/f10
  removing d2/f7
  adding d3/f11
  adding d3/f13
  adding d3/f14
  removing d3/f4
  adding d3/f9
  created new head

Create a second anonymous branch:

  $ echo "c15" > d1/d3/f15
  $ hg importfs -r t1 -m "Creating a second anonymous branch." r d1
  2 files updated, 0 files merged, 5 files removed, 0 files unresolved
  default
  adding d2/f10
  adding d3/f11
  adding d3/f13
  adding d3/f14
  adding d3/f15
  removing d3/f4
  removing d3/f5
  adding d3/f9
  created new head

Check the new heads:

  $ hg -R r heads --template "changeset: {rev}\nbranch: {branches}\nparent: {parents}\nsummary: {desc}\n\n"
  changeset: 13
  branch: 
  parent: 1:????????????  (glob)
  summary: Creating a second anonymous branch.
  
  changeset: 12
  branch: b1
  parent: 3:????????????  (glob)
  summary: Creating an anonymous branch.
  
  changeset: 11
  branch: b1
  parent: 9:????????????  (glob)
  summary: importfs commit.
  
  changeset: 10
  branch: b2
  parent: 
  summary: Creating branch b2
  
  changeset: 5
  branch: 
  parent: 2:????????????  (glob)
  summary: importfs commit.
  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.