Commits

David Carr committed 85c092f

snapshot patches for latest submission

Comments (0)

Files changed (10)

+# HG changeset patch
+# Parent 3b82cf6ac73ad8455a632516735070610eb5cd32
+docs: include buglink
+
+Mercurial has support for including a link to an issue tracker when it detects
+that an extension has broken.  This change includes the appropriate attribute
+in the extension, pointing it at the issue tracker for the main BitBucket repo.
+
+diff -r 3b82cf6ac73a -r 2f7be60fe85b hggit/__init__.py
+--- a/hggit/__init__.py	Sun Sep 16 14:46:18 2012 -0500
++++ b/hggit/__init__.py	Thu Sep 27 18:21:04 2012 -0400
+@@ -42,6 +42,8 @@
+ import gitrepo, hgrepo
+ from git_handler import GitHandler
+ 
++buglink = 'https://bitbucket.org/durin42/hg-git/issues'
++
+ # support for `hg clone git://github.com/defunkt/facebox.git`
+ # also hg clone git+ssh://git@github.com/schacon/simplegit.git
+ _gitschemes = ('git', 'git+ssh', 'git+http', 'git+https')

fix-no-changes-outgoing-b.diff

+# HG changeset patch
+# Parent 471338caeea1e5ae33013cfc852ac175bc08a74d
+TODO
+
+diff -r 471338caeea1 -r 303933e01d96 tests/test-bookmark-workflow.t
+--- a/tests/test-bookmark-workflow.t	Thu Sep 27 20:23:02 2012 -0400
++++ b/tests/test-bookmark-workflow.t	Thu Sep 27 20:23:49 2012 -0400
+@@ -102,6 +102,7 @@
+   searching for changes
+   no changes found
+   [1]
++  $ hg outgoing -B
+   $ hg push
+   pushing to $TESTTMP/hgremoterepo
+   searching for changes
+@@ -114,6 +115,7 @@
+   searching for changes
+   no changes found
+   [1]
++  $ hg outgoing -B
+   $ hg push
+   pushing to $TESTTMP/gitremoterepo
+   creating and sending data

fix-no-changes-push.diff

+# HG changeset patch
+# Parent d1bd9d33c8b6206358ed471415fc5af9889d2748
+TODO
+
+diff -r d1bd9d33c8b6 hggit/git_handler.py
+--- a/hggit/git_handler.py	Thu Sep 27 19:26:20 2012 -0400
++++ b/hggit/git_handler.py	Thu Sep 27 20:22:36 2012 -0400
+@@ -247,6 +247,10 @@
+     def push(self, remote, revs, force):
+         self.export_commits()
+         old_refs, new_refs = self.upload_pack(remote, revs, force)
++        print 'old:'
++        print old_refs
++        print 'new:'
++        print new_refs
+         remote_name = self.remote_name(remote)
+ 
+         if remote_name and new_refs:
+@@ -834,9 +838,13 @@
+     ## PACK UPLOADING AND FETCHING
+ 
+     def upload_pack(self, remote, revs, force):
++        print 'revs'
++        print revs
+         client, path = self.get_transport_and_path(remote)
+         old_refs = {}
+         def changed(refs):
++            print 'changed:in:'
++            print refs
+             old_refs.update(refs)
+             to_push = revs or set(self.local_heads().values() + self.tags.values())
+             return self.get_changed_refs(refs, to_push, force)
+diff -r d1bd9d33c8b6 tests/test-bookmark-workflow.t
+--- a/tests/test-bookmark-workflow.t	Thu Sep 27 19:26:20 2012 -0400
++++ b/tests/test-bookmark-workflow.t	Thu Sep 27 20:22:36 2012 -0400
+@@ -102,6 +102,11 @@
+   searching for changes
+   no changes found
+   [1]
++  $ hg push
++  pushing to $TESTTMP/hgremoterepo
++  searching for changes
++  no changes found
++  [1]
+   $ cd ..
+   $ cd hggitlocalrepo
+   $ hg outgoing
+@@ -109,4 +114,8 @@
+   searching for changes
+   no changes found
+   [1]
++  $ hg push
++  pushing to $TESTTMP/gitremoterepo
++  creating and sending data
++      default::refs/heads/b1 => GIT:9497a4ee
+   $ cd ..

fix-outgoing.diff

+# HG changeset patch
+# Parent 3b82cf6ac73ad8455a632516735070610eb5cd32
+outgoing: don't delete remote refs
+
+There was a bug introduced in 8c1f2b07c04b such that calling hg outgoing on
+a Git repository would result in all refs being deleted from the remote
+repository (with the possible exception of the currently checked out branch).
+It wasn't noticed before because the existing test for outgoing didn't actually
+verify the refs on the remote.  This changeset fixes the bug, as well as adding
+test coverage to allow verifying that the fix works.
+
+diff -r 3b82cf6ac73a -r f6871baa79c9 hggit/git_handler.py
+--- a/hggit/git_handler.py	Sun Sep 16 14:46:18 2012 -0500
++++ b/hggit/git_handler.py	Thu Sep 27 22:32:01 2012 -0400
+@@ -222,14 +222,10 @@
+             old_refs.update(refs)
+             to_push = set(self.local_heads().values() + self.tags.values())
+             new_refs.update(self.get_changed_refs(refs, to_push, True))
+-            # don't push anything
+-            return {}
++            return refs # always return the same refs to make the send a no-op
+ 
+         try:
+-            try:
+-                client.send_pack(path, changed, lambda have, want: [])
+-            except UpdateRefsError:
+-                pass # dulwich throws an error when send_pack doesn't upload
++            client.send_pack(path, changed, lambda have, want: [])
+ 
+             changed_refs = [ref for ref, sha in new_refs.iteritems()
+                             if sha != old_refs.get(ref)]
+diff -r 3b82cf6ac73a -r f6871baa79c9 tests/test-outgoing.t
+--- a/tests/test-outgoing.t	Sun Sep 16 14:46:18 2012 -0500
++++ b/tests/test-outgoing.t	Thu Sep 27 22:32:01 2012 -0400
+@@ -35,6 +35,10 @@
+   $ echo alpha > alpha
+   $ git add alpha
+   $ commit -m "add alpha"
++  $ git branch alpha
++  $ git show-ref
++  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/alpha
++  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/master
+ 
+   $ cd ..
+   $ hg clone gitrepo hgrepo | grep -v '^updating'
+@@ -42,6 +46,7 @@
+   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ 
+   $ cd hgrepo
++  $ hg update -q master
+   $ echo beta > beta
+   $ hg add beta
+   $ hgcommit -m 'add beta'
+@@ -99,6 +104,11 @@
+   % some more work on master from git
+   $ cd gitrepo
+ 
++Check state of refs after outgoing
++  $ git show-ref
++  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/alpha
++  7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/master
++
+   $ git checkout master 2>&1 | sed s/\'/\"/g
+   Already on "master"
+   $ echo delta > delta

gitrepo-bookmark-support.diff

+# HG changeset patch
+# Parent f40d6c8c0f6c8a8a3bfe054cbe3c22a04aa37d7b
+gitrepo: initial support for bookmarks
+
+diff -r f40d6c8c0f6c hggit/__init__.py
+--- a/hggit/__init__.py	Thu Sep 27 18:32:02 2012 -0400
++++ b/hggit/__init__.py	Thu Sep 27 19:16:05 2012 -0400
+@@ -184,6 +184,14 @@
+     # 1.7+
+     pass
+ 
++def peer(orig, uiorrepo, *args, **opts):
++    newpeer = orig(uiorrepo, *args, **opts)
++    if isinstance(newpeer, gitrepo.gitrepo):
++        if isinstance(uiorrepo, localrepo.localrepository):
++            newpeer.localrepo = uiorrepo
++    return newpeer
++extensions.wrapfunction(hg, 'peer', peer)
++
+ def revset_fromgit(repo, subset, x):
+     '''``fromgit()``
+     Select changesets that originate from Git.
+diff -r f40d6c8c0f6c hggit/gitrepo.py
+--- a/hggit/gitrepo.py	Thu Sep 27 18:32:02 2012 -0400
++++ b/hggit/gitrepo.py	Thu Sep 27 19:16:05 2012 -0400
+@@ -1,3 +1,4 @@
++import os
+ from mercurial import util
+ try:
+     from mercurial.error import RepoError
+@@ -12,7 +13,7 @@
+ from git_handler import GitHandler
+ 
+ class gitrepo(peerrepository):
+-    capabilities = ['lookup']
++    capabilities = ['lookup', 'pushkey']
+ 
+     def _capabilities(self):
+         return self.capabilities
+@@ -22,6 +23,12 @@
+             raise util.Abort('Cannot create a git repository.')
+         self.ui = ui
+         self.path = path
++        self.git = None
++        self.localrepo = None
++
++    def _initializegit(self):
++        if self.git is None and self.localrepo is not None:
++            self.git = GitHandler(self.localrepo, self.ui)
+ 
+     def url(self):
+         return self.path
+@@ -38,6 +45,26 @@
+         return []
+ 
+     def listkeys(self, namespace):
++        if namespace == 'namespaces':
++            return {'bookmarks':''}
++        elif namespace == 'bookmarks':
++            # TODO: reimplement not using tag file, since we won't always have access to repo
++            self._initializegit()
++            if self.git is not None:
++                remote_name = self.git.remote_name(self.path) or 'default'
++                tagfile = self.localrepo.join(os.path.join('git-remote-refs'))
++                if os.path.exists(tagfile):
++                    tf = open(tagfile, 'rb')
++                    tagdata = tf.read().split('\n')
++                    td = [line.split(' ', 1) for line in tagdata if line]
++                    refs = dict([(name, sha) for sha, name in td])
++                    bookmarks = {}
++                    for ref, sha in refs.iteritems():
++                        if ref.startswith(remote_name + '/'):
++                            bookmarks[ref[len(remote_name)+1:]] = sha
++                    return bookmarks
++                else:
++                    print 'TODO'
+         return {}
+ 
+     def pushkey(self, namespace, key, old, new):
+fix-outgoing.diff
+buglink.diff
+testedwith.diff
+test-bookmark-workflow-clone.diff
+test-no-changes-outgoing.diff
+fix-no-changes-push.diff
+fix-no-changes-outgoing-b.diff
+gitrepo-bookmark-support.diff
+test-bookmark-workflow.diff
+test-export
 optimize_get_git_author
 precompile_git_uri_regular_expression
 precompile_git_username_sanitizing_regular_expression
 make_get_valid_git_username_email_static
 implement_treetracker_for_incremental_tree_calculation
 test-git-branch-loss.diff
-test-bookmark-workflow.diff
 bookmark-delete.diff

test-bookmark-workflow-clone.diff

+# HG changeset patch
+# Parent 3b82cf6ac73ad8455a632516735070610eb5cd32
+tests: add coverage for bookmark workflow comparison; cloning
+
+diff -r 3b82cf6ac73a -r b7c14f2af6d1 tests/test-bookmark-workflow.t
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/tests/test-bookmark-workflow.t	Wed Sep 26 23:06:58 2012 -0400
+@@ -0,0 +1,96 @@
++This test demonstrates how Hg works with remote Hg bookmarks compared with
++remote branches via Hg-Git.  Ideally, they would behave identically.  In
++practice, some differences are unavoidable, but we should try to minimize
++them.
++
++This test should not bother testing the behavior of bookmark creation,
++deletion, activation, deactivation, etc.  These behaviors, while important to
++the end user, don't vary at all when Hg-Git is in use.  Only the synchonization
++of bookmarks should be considered "under test", and mutation of bookmarks
++locally is only to provide a test fixture.
++
++bail if the user does not have dulwich
++  $ python -c 'import dulwich, dulwich.repo' || exit 80
++
++  $ echo "[extensions]" >> $HGRCPATH
++  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
++
++  $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
++  $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
++  $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
++  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
++  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
++  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
++
++  $ gitcount=10
++  $ gitcommit()
++  > {
++  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$gitcount +0000"
++  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
++  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
++  >     gitcount=`expr $gitcount + 1`
++  > }
++  $ hgcount=10
++  $ hgcommit()
++  > {
++  >     HGDATE="2007-01-01 00:00:$hgcount +0000"
++  >     hg commit -u "test <test@example.org>" -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
++  >     hgcount=`expr $hgcount + 1`
++  > }
++  $ gitstate()
++  > {
++  >     git log --format="  %h \"%s\" refs:%d" $@ | sed 's/HEAD, //'
++  > }
++  $ hgstate()
++  > {
++  >     hg log --template "  {rev} {node|short} \"{desc}\" bookmarks: [{bookmarks}]\n" $@
++  > }
++  $ hggitstate()
++  > {
++  >     hg log --template "  {rev} {node|short} {gitnode|short} \"{desc}\" bookmarks: [{bookmarks}]\n" $@
++  > }
++
++Initialize remote hg and git repos with equivalent initial contents
++  $ hg init hgremoterepo
++  $ cd hgremoterepo
++  $ hg bookmark master
++  $ for f in alpha beta gamma delta; do
++  >     echo $f > $f; hg add $f; hgcommit -m "add $f"
++  > done
++  $ hg bookmark -r 1 b1
++  $ hgstate
++    3 fc2664cac217 "add delta" bookmarks: [master]
++    2 d85ced7ae9d6 "add gamma" bookmarks: []
++    1 7bcd915dc873 "add beta" bookmarks: [b1]
++    0 3442585be8a6 "add alpha" bookmarks: []
++  $ cd ..
++  $ git init -q gitremoterepo
++  $ cd gitremoterepo
++  $ for f in alpha beta gamma delta; do
++  >     echo $f > $f; git add $f; gitcommit -m "add $f"
++  > done
++  $ git branch b1 9497a4e
++  $ gitstate
++    55b133e "add delta" refs: (master)
++    d338971 "add gamma" refs:
++    9497a4e "add beta" refs: (b1)
++    7eeab2e "add alpha" refs:
++  $ cd ..
++
++Cloning transfers all bookmarks from remote to local
++  $ hg clone -q hgremoterepo purehglocalrepo
++  $ cd purehglocalrepo
++  $ hgstate
++    3 fc2664cac217 "add delta" bookmarks: [master]
++    2 d85ced7ae9d6 "add gamma" bookmarks: []
++    1 7bcd915dc873 "add beta" bookmarks: [b1]
++    0 3442585be8a6 "add alpha" bookmarks: []
++  $ cd ..
++  $ hg clone -q gitremoterepo hggitlocalrepo
++  $ cd hggitlocalrepo
++  $ hggitstate
++    3 fc2664cac217 55b133e1d558 "add delta" bookmarks: [master]
++    2 d85ced7ae9d6 d338971a96e2 "add gamma" bookmarks: []
++    1 7bcd915dc873 9497a4ee62e1 "add beta" bookmarks: [b1]
++    0 3442585be8a6 7eeab2ea75ec "add alpha" bookmarks: []
++  $ cd ..
+# HG changeset patch
+# Parent 3b82cf6ac73ad8455a632516735070610eb5cd32
+diff --git a/test-export.sh b/test-export.sh
+new file mode 100755
+--- /dev/null
++++ b/test-export.sh
+@@ -0,0 +1,28 @@
++#!/bin/sh
++
++rm -rf ~/temp/hg-git-export
++mkdir -p ~/temp/hg-git-export
++
++hg clone -U http://hg.rafaelmartins.eng.br/blohg/ ~/temp/hg-git-export/hr1a
++hg clone -U ~/temp/hg-git-export/hr1a ~/temp/hg-git-export/hr2a
++hg clone -U ~/temp/hg-git-export/hr1a ~/temp/hg-git-export/hr3a
++hg clone -U ~/temp/hg-git-export/hr1a ~/temp/hg-git-export/hr4a
++git init --bare ~/temp/hg-git-export/gr1a
++git init --bare ~/temp/hg-git-export/gr2a
++git init --bare ~/temp/hg-git-export/gr3a
++
++hg clone -U -r f75567782aba http://selenic.com/repo/hg ~/temp/hg-git-export/hr1b
++hg clone -U ~/temp/hg-git-export/hr1b ~/temp/hg-git-export/hr2b
++hg clone -U ~/temp/hg-git-export/hr1b ~/temp/hg-git-export/hr3b
++hg clone -U ~/temp/hg-git-export/hr1b ~/temp/hg-git-export/hr4b
++git init --bare ~/temp/hg-git-export/gr1b
++git init --bare ~/temp/hg-git-export/gr2b
++git init --bare ~/temp/hg-git-export/gr3b
++
++time hg -R ~/temp/hg-git-export/hr2a push ~/temp/hg-git-export/gr1a
++time hg -R ~/temp/hg-git-export/hr3a push ~/temp/hg-git-export/gr2a
++time hg -R ~/temp/hg-git-export/hr4a push ~/temp/hg-git-export/gr3a
++
++time hg -R ~/temp/hg-git-export/hr2b push ~/temp/hg-git-export/gr1b
++time hg -R ~/temp/hg-git-export/hr3b push ~/temp/hg-git-export/gr2b
++time hg -R ~/temp/hg-git-export/hr4b push ~/temp/hg-git-export/gr3b

test-no-changes-outgoing.diff

+# HG changeset patch
+# Parent f40d6c8c0f6c8a8a3bfe054cbe3c22a04aa37d7b
+tests: add coverage for outgoing with no changes
+
+diff -r f40d6c8c0f6c tests/test-bookmark-workflow.t
+--- a/tests/test-bookmark-workflow.t	Thu Sep 27 18:32:02 2012 -0400
++++ b/tests/test-bookmark-workflow.t	Thu Sep 27 19:26:20 2012 -0400
+@@ -94,3 +94,19 @@
+     1 7bcd915dc873 9497a4ee62e1 "add beta" bookmarks: [b1]
+     0 3442585be8a6 7eeab2ea75ec "add alpha" bookmarks: []
+   $ cd ..
++
++No changes
++  $ cd purehglocalrepo
++  $ hg outgoing
++  comparing with $TESTTMP/hgremoterepo
++  searching for changes
++  no changes found
++  [1]
++  $ cd ..
++  $ cd hggitlocalrepo
++  $ hg outgoing
++  comparing with $TESTTMP/gitremoterepo
++  searching for changes
++  no changes found
++  [1]
++  $ cd ..
+# HG changeset patch
+# Parent 2f7be60fe85bf8d30c0206b547c2bfbf5b7a96ff
+docs: include testedwith
+
+Mercurial has support for including information about the tested versions of
+Mercurial for an extension when it detects that an extension has broken.  This
+change includes the appropriate attribute in the extension.
+
+diff -r 2f7be60fe85b -r 8df60de1c4e2 hggit/__init__.py
+--- a/hggit/__init__.py	Thu Sep 27 18:21:04 2012 -0400
++++ b/hggit/__init__.py	Thu Sep 27 18:22:58 2012 -0400
+@@ -42,6 +42,7 @@
+ import gitrepo, hgrepo
+ from git_handler import GitHandler
+ 
++testedwith = '1.9.3 2.0.2 2.1.2 2.2.3 2.3.1'
+ buglink = 'https://bitbucket.org/durin42/hg-git/issues'
+ 
+ # support for `hg clone git://github.com/defunkt/facebox.git`