[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Apr 25 17:18:04 PDT 2017


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/63097da8b044/
Changeset:   63097da8b044
Branch:      yt
User:        ngoldbaum
Date:        2017-04-24 14:37:41+00:00
Summary:     Adapt hg bits of "yt update" for git transition
Affected #:  2 files

diff -r 634cc55bf0668d551109b3a35850bb6c369b47b4 -r 63097da8b04438dc16a10e04c2e9b1cd2cf985b5 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -512,7 +512,16 @@
 class YTEmptyClass(object):
     pass
 
-def update_hg(path, skip_rebuild = False):
+def update_hg_or_git(path):
+    if os.path.exists(os.sep.join([path, '.hg'])):
+        update_hg(path)
+    elif os.path.exists(os.sep.join([path, '.git'])):
+        update_git(path)
+
+def update_git(path):
+    raise RuntimeError
+
+def update_hg(path):
     try:
         import hglib
     except ImportError:
@@ -521,21 +530,27 @@
         return -1
     f = open(os.path.join(path, "yt_updater.log"), "a")
     with hglib.open(path) as repo:
-        repo.pull()
+        repo.pull(b'https://bitbucket.org/yt_analysis/yt')
         ident = repo.identify().decode("utf-8")
         if "+" in ident:
-            print("Can't rebuild modules by myself.")
-            print("You will have to do this yourself.  Here's a sample commands:")
+            print("Changes have been made to the yt source code so I won't ")
+            print("update the code. You will have to do this yourself.")
+            print("Here's a set of sample commands:")
             print("")
             print("    $ cd %s" % (path))
-            print("    $ hg up")
+            print("    $ hg up -C yt  # This will delete any unsaved changes")
             print("    $ %s setup.py develop" % (sys.executable))
+            print("")
             return 1
         print("Updating the repository")
         f.write("Updating the repository\n\n")
-        repo.update(check=True)
+        books = repo.bookmarks()[0]
+        books = [b[0].decode('utf8') for b in books]
+        if 'master' in books:
+            repo.update('master', check=True)
+        else:
+            repo.update('yt', check=True)
         f.write("Updated from %s to %s\n\n" % (ident, repo.identify()))
-        if skip_rebuild: return
         f.write("Rebuilding modules\n\n")
         p = subprocess.Popen([sys.executable, "setup.py", "build_ext", "-i"],
                              cwd=path, stdout = subprocess.PIPE,
@@ -549,6 +564,16 @@
         f.write("Successful!\n")
         print("Updated successfully.")
 
+def get_hg_or_git_version(path):
+    if os.path.exists(os.sep.join([path, '.hg'])):
+        return get_hg_version(path)
+    elif os.path.exists(os.sep.join([path, '.git'])):
+        return get_git_version(path)
+    return None
+
+def get_git_version(path):
+    raise RuntimeError
+
 def get_hg_version(path):
     try:
         import hglib

diff -r 634cc55bf0668d551109b3a35850bb6c369b47b4 -r 63097da8b04438dc16a10e04c2e9b1cd2cf985b5 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -33,11 +33,11 @@
 from yt.funcs import \
     ensure_dir, \
     ensure_list, \
-    get_hg_version, \
+    get_hg_or_git_version, \
     get_yt_version, \
     mylog, \
     ensure_dir_exists, \
-    update_hg, \
+    update_hg_or_git, \
     enable_plugins, \
     download_file
 from yt.extern.six import add_metaclass, string_types
@@ -83,7 +83,7 @@
 
 def _print_failed_source_update(reinstall=False):
     print()
-    print("The yt package is not installed from a mercurial repository,")
+    print("The yt package is not installed from a git repository,")
     print("so you must update this installation manually.")
     if 'Continuum Analytics' in sys.version or 'Anaconda' in sys.version:
         # see http://stackoverflow.com/a/21318941/1382869 for why we need
@@ -100,6 +100,13 @@
             print("To update all of your packages, you can do:")
             print()
             print("    $ conda update --all")
+    else:
+        print("If you manage your python dependencies with pip, you may")
+        print("want to do:")
+        print()
+        print("    $ pip install -U yt")
+        print()
+        print("to update your yt installation.")
 
 def _print_installation_information(path):
     import yt
@@ -117,7 +124,7 @@
     print()
     print("---")
     print("Version = %s" % yt.__version__)
-    vstring = get_hg_version(path)
+    vstring = get_hg_or_git_version(path)
     if vstring is not None:
         print("Changeset = %s" % vstring.strip().decode("utf-8"))
     print("---")
@@ -223,7 +230,9 @@
 _common_options = dict(
     all     = dict(longname="--all", dest="reinstall",
                    default=False, action="store_true",
-                   help="Reinstall the full yt stack in the current location."),
+                   help=("Reinstall the full yt stack in the current location."
+                         "  This option has been deprecated and may not work "
+                         "correctly."),),
     ds      = dict(short="ds", action=GetParameterFiles,
                    nargs="+", help="datasets to run on"),
     ods     = dict(action=GetParameterFiles, dest="ds",
@@ -416,7 +425,6 @@
 
 def _get_yt_stack_date():
     if "YT_DEST" not in os.environ:
-        print("Could not determine when yt stack was last updated.")
         return
     date_file = os.path.join(os.environ["YT_DEST"], ".yt_update")
     if not os.path.exists(date_file):
@@ -703,8 +711,7 @@
         if vstring is not None:
             print("This installation CAN be automatically updated.")
             if opts.update_source:
-                update_hg(path)
-                print("Updated successfully.")
+                update_hg_or_git(path)
                 _get_yt_stack_date()
         elif opts.update_source:
             _print_failed_source_update()
@@ -1125,8 +1132,7 @@
         if vstring is not None:
             print()
             print("This installation CAN be automatically updated.")
-            update_hg(path, skip_rebuild=opts.reinstall)
-            print("Updated successfully.")
+            update_hg_or_git(path)
             _get_yt_stack_date()
             if opts.reinstall:
                 _update_yt_stack(path)


https://bitbucket.org/yt_analysis/yt/commits/68f97dface72/
Changeset:   68f97dface72
Branch:      yt
User:        ngoldbaum
Date:        2017-04-24 15:48:33+00:00
Summary:     add git update logic for yt update
Affected #:  2 files

diff -r 63097da8b04438dc16a10e04c2e9b1cd2cf985b5 -r 68f97dface72120a4494a4bc3c877d8ed6b5bbca yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -519,7 +519,56 @@
         update_git(path)
 
 def update_git(path):
-    raise RuntimeError
+    try:
+        import git
+    except ImportError:
+        print("Updating and precise version information requires ")
+        print("gitpython to be installed.")
+        print("Try: pip install gitpython")
+        return -1
+    with open(os.path.join(path, "yt_updater.log"), "a") as f:
+        with git.Repo(path) as repo:
+            if repo.is_dirty(untracked_files=True):
+                print("Changes have been made to the yt source code so I won't ")
+                print("update the code. You will have to do this yourself.")
+                print("Here's a set of sample commands:")
+                print("")
+                print("    $ cd %s" % (path))
+                print("    $ git stash")
+                print("    $ git checkout master")
+                print("    $ git pull")
+                print("    $ git stash pop")
+                print("    $ %s setup.py develop" % (sys.executable))
+                print("")
+                return 1
+            if repo.active_branch.name != 'master':
+                print("yt repository is not tracking the master branch so I won't ")
+                print("update the code. You will have to do this yourself.")
+                print("Here's a set of sample commands:")
+                print("")
+                print("    $ cd %s" % (path))
+                print("    $ git checkout master")
+                print("    $ git pull")
+                print("    $ %s setup.py develop" % (sys.executable))
+                print("")
+                return 1
+            print("Updating the repository")
+            f.write("Updating the repository\n\n")
+            old_version = repo.git.rev_parse('HEAD', short=12)
+            try:
+                remote = repo.remotes.yt_upstream
+            except AttributeError:
+                remote = repo.create_remote(
+                    'yt_upstream', url='https://github.com/yt-project/yt')
+                remote.fetch()
+            master = repo.heads.master
+            master.set_tracking_branch(remote.refs.master)
+            master.checkout()
+            remote.pull()
+            new_version = repo.git.rev_parse('HEAD', short=12)
+            f.write('Updated from %s to %s\n\n' % (old_version, new_version))
+            rebuild_modules(path, f)
+    print('Updated successfully')
 
 def update_hg(path):
     try:
@@ -551,18 +600,22 @@
         else:
             repo.update('yt', check=True)
         f.write("Updated from %s to %s\n\n" % (ident, repo.identify()))
-        f.write("Rebuilding modules\n\n")
-        p = subprocess.Popen([sys.executable, "setup.py", "build_ext", "-i"],
-                             cwd=path, stdout = subprocess.PIPE,
-                             stderr = subprocess.STDOUT)
-        stdout, stderr = p.communicate()
-        f.write(stdout.decode('utf-8'))
-        f.write("\n\n")
-        if p.returncode:
-            print("BROKEN: See %s" % (os.path.join(path, "yt_updater.log")))
-            sys.exit(1)
-        f.write("Successful!\n")
-        print("Updated successfully.")
+        rebuild_modules(path, f)
+    print("Updated successfully.")
+
+def rebuild_modules(path, f):
+    f.write("Rebuilding modules\n\n")
+    p = subprocess.Popen([sys.executable, "setup.py", "build_ext", "-i"],
+                         cwd=path, stdout = subprocess.PIPE,
+                         stderr = subprocess.STDOUT)
+    stdout, stderr = p.communicate()
+    f.write(stdout.decode('utf-8'))
+    f.write("\n\n")
+    if p.returncode:
+        print("BROKEN: See %s" % (os.path.join(path, "yt_updater.log")))
+        sys.exit(1)
+    f.write("Successful!\n")
+
 
 def get_hg_or_git_version(path):
     if os.path.exists(os.sep.join([path, '.hg'])):
@@ -572,7 +625,19 @@
     return None
 
 def get_git_version(path):
-    raise RuntimeError
+    try:
+        import git
+    except ImportError:
+        print("Updating and precise version information requires ")
+        print("gitpython to be installed.")
+        print("Try: pip install gitpython")
+        return None
+    try:
+        with git.Repo(path) as repo:
+            return repo.git.rev_parse('HEAD', short=12)
+    except git.InvalidGitRepositoryError:
+        # path is not a git repository
+        return None
 
 def get_hg_version(path):
     try:
@@ -584,7 +649,7 @@
         return None
     try:
         with hglib.open(path) as repo:
-            return repo.identify()
+            return repo.identify().decode('utf-8')
     except hglib.error.ServerError:
         # path is not an hg repository
         return None

diff -r 63097da8b04438dc16a10e04c2e9b1cd2cf985b5 -r 68f97dface72120a4494a4bc3c877d8ed6b5bbca yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -126,7 +126,7 @@
     print("Version = %s" % yt.__version__)
     vstring = get_hg_or_git_version(path)
     if vstring is not None:
-        print("Changeset = %s" % vstring.strip().decode("utf-8"))
+        print("Changeset = %s" % vstring.strip())
     print("---")
     return vstring

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list