热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

mercurial使用_使用Mercurial在SQL数据库中对象更改的修订历史记录

mercurial使用SincewehavepresentedawaytoreviewthehistoryofcommittedchangesusingGit,TeamFounda

mercurial使用

Since we have presented a way to review the history of committed changes using Git, Team Foundation Server and Subversion, let’s check how the same can be achieved when working with the Mercurial source control system.

由于我们提供了一种使用Git , Team Foundation Server和Subversion来查看已提交更改的历史的方法,因此让我们检查一下在使用Mercurial源代码控制系统时如何实现相同的更改。

We’ll be using Tortoise Hg, free Mercurial client that comes with Windows shell integration. For the purpose of this article we’ll use a sample database called StoresDB whose objects are scripted in separate files and saved in a local folder called MercLocal. The same folder is initialized to be a local Mercurial repository. I won’t include details about initializing the repository and committing changes. The goal of the article is to cover the following: revision history of all committed changes, comparing two versions of the same object committed in two different changesets and getting specific version of an object from the commit history.

我们将使用Windows Shell集成随附的免费Mercurial客户端Tortoise Hg 。 就本文而言,我们将使用一个名为StoresDB的示例数据库,该数据库的对象被编写在单独的文件中,并保存在名为MercLocal的本地文件夹中。 相同的文件夹被初始化为本地Mercurial存储库。 我不会提供有关初始化存储库和提交更改的详细信息。 本文的目的是涵盖以下内容:所有已提交更改的修订历史记录,比较在两个不同变更集中提交的同一对象的两个版本,并从提交历史记录中获取对象的特定版本。

As a starting point, let’s assume that the following tasks were performed against previously scripted database object files:

首先,假设对先前编写脚本的数据库对象文件执行了以下任务:

  • Initial commit of all database objects

    初始提交所有数据库对象

  • Committing a new table called Balances using the following SQL script:

    使用以下SQL脚本提交一个名为Balances的新表:

     
    CREATE TABLE [dbo].[Balances]([BalanceID] [varchar](15) PRIMARY KEY NOT NULL,[Description] [varchar](255) NULL,[DocID] INT IDENTITY(1,1) NOT NULL)GO


  • In the next changeset the following changes are committed:

    在下一个变更集中,将进行以下更改:

    • New column called BalanceType is added to the Balances table using the following SQL script:

      使用以下SQL脚本,将称为BalanceType的新列添加到Balances表中:

       
      ALTER TABLE dbo.Balances ADD BalanceType NVARCHAR(50)


    • New stored procedure called BalancesList is created using the following script:

      使用以下脚本创建名为BalancesList的新存储过程:

       
      CREATE PROCEDURE dbo.BalancesList
      AS
      BEGIN
      SELECT BalanceID, Description, DocID FROM dbo.Balances
      END
      GO


    • New column added to the ProductCategory table:

      新列添加到ProductCategory表:

       
      ALTER TABLE Production.ProductCategoryADD CategoryDescription NVARCHAR (255)


  • The next changeset holds just a single edit. The previously created BalanceType column in the Balances table is renamed using the following script:

    下一个变更集仅包含一个编辑。 使用以下脚本重命名了Balances表中先前创建的BalanceType列:

     
    EXEC sp_rename 'dbo.Balances.BalanceType', 'BType', 'COLUMN'

  • The last change we committed is deleting the Sales.CreditCard table:

    我们提交的最后一个更改是删除Sales.CreditCard表:

     
    DROP TABLE Sales.ShoppingCartItem;


  • 修订记录 (Revision history)

    In order to review the entire history of committed changes, start the TortoiseHg Workbench application. It can be started from the right click menu inside the folder initialized as a local Mercurial repository (in this case the MercLocal folder):

    为了查看已提交更改的整个历史记录,请启动TortoiseHg Workbench应用程序。 可以从初始化为本地Mercurial存储库(在此情况下为MercLocal文件夹)的文件夹内的右键单击菜单中启动:

    As shown in the above image, the history view presents the task workflow introduced in the article. The first commit (at the bottom of the list) shows initial commit of all database objects, followed by commits where the rest of changes are committed.

    如上图所示,历史视图显示了本文介绍的任务工作流程。 第一个提交(在列表的底部)显示所有数据库对象的初始提交,然后显示提交其余更改的提交。

    Each commit in the list contains the revision ID (the Rev column), branch where it is committed (currently all changes are committed to default branch), description – which is actually the commit message, the author of the commit (all commits are performed by the same user – ApexSQL Test). The Age column stores the time that passed after the commit is performed. The Changes column at the end, shows the exact number of changes included in the specific changeset, along with the appropriate colors that represents the actions performed against committed files:

    列表中的每个提交都包含修订ID(“ 修订”列),提交的分支(当前所有更改都提交给默认分支),描述(实际上是提交消息),提交的作者(执行所有提交)由同一用户-ApexSQL测试)。 “ 年龄”列存储执行提交后经过的时间。 最后的“ 更改”列显示特定更改集中包含的确切更改数量,以及代表针对已提交文件执行的操作的适当颜色:

    比较各个版本中特定对象的版本 (Compare between versions of the specific object across revisions)

    The above described comparison between revisions gives a list of all objects that are compared, so the user can select which one to inspect in details, as we did for the dbo.Balances table. In case we need to inspect differences for the specific object across revision history, there is no need to compare all objects from one changeset with all objects from another changeset. To narrow down the comparison to a single object, select it from the list of objects in any changeset, and from the right click menu select the Compare File Revisions option. We’ll perform that against the dbo.Balances table from the Rev 2 revision:

    修订之间的上述比较给出了所有比较对象的列表,因此用户可以选择要详细检查的对象,就像我们对dbo.Balances表所做的那样 。 如果我们需要检查整个修订历史中特定对象的差异,则无需将一个变更集的所有对象与另一变更集的所有对象进行比较。 要将比较范围缩小到单个对象,请从任何变更集中的对象列表中选择它,然后从右键单击菜单中选择“ 比较文件修订”选项。 我们将针对Rev 2修订版中的dbo.Balances表执行该操作:

    This initiates the Log file viewer form for the selected object. Both sides, left and right, shows the same list of revisions related to specific object (in this case the Balances table). To compare between revisions, simply select one on the left side, and another one on the right (we’ll compare the version of the balances table from Rev 1 with the version from Rev 3):

    这将启动所选对象的日志文件查看器表单。 左右两侧都显示与特定对象相关的相同修订版本列表(在本例中为“ 余额”表)。 要在修订版本之间进行比较,只需在左侧选择一个,在右侧选择另一个(我们将比较Rev 1中的余额表版本和Rev 3中的版本):

    The above image shows that the BType we have introduced in Rev3 didn’t exist in Rev 1 when the Balances table was committed initially.

    上图显示的是BTYPE我们Rev3型已经介绍,当余额表最初承诺没有在版本1存在。

    恢复为特定的修订版 (Revert to the specific revision)

    In case the entire revision needs to be reverted, right click on it from the revision history and select the Revert All Files option:

    如果需要还原整个修订,请在修订历史中右键单击它,然后选择“ 还原所有文件”选项:

    Reverting to Rev 1 discards all changes committed after the Rev 1. This means that BalancesList stored procedure will be deleted, as well as BType column that was committed in the later revision. Checking the Balances table in the local repository gives the following result:

    恢复到修订版1会丢弃在修订版1之后提交的所有更改。 这意味着将删除BalancesList存储过程以及在更高版本中提交的BType列。 检查本地存储库中的余额表将得到以下结果:

    This confirms that the BalanceType column introduced in the next revision, and renamed to BType later, does not exist.

    这确认了在下一个修订版中引入并在以后重命名为BTypeBalanceType列不存在。

    从修订历史记录中获取对象的特定版本 (Get specific version of an object from the revision history)

    In case only specific object(s) need to be reverted, instead of the entire revision, navigate to the specific revision, select one (or multiple files using the CTRL key), and from the right click menu select the Revert to Revision option:

    如果只需要还原特定对象而不是整个修订版本,请导航至该特定修订版本,选择一个(或使用CTRL键的多个文件),然后从右键单击菜单中选择“ 还原为修订版本”选项:

    The above image represents reverting the version of the Balances table from Rev 2, without reverting other changes from the same revision. Selecting the Revert to Revision option from the right click menu gives a confirmation dialog, where optionally all object from the selected revision can be reverted (by checking the Revert all files to this revision option). In order to demonstrate reverting of a single object, this option will be unchecked:

    上面的图像表示从修订版2还原余额表的版本,而未还原同一修订版的其他更改。 从右键单击菜单中选择“ 还原到修订版本”选项,将显示一个确认对话框,在该对话框中,可以选择还原来自选定修订版本的所有对象(通过选中“将所有文件还原到此修订版本”选项)。 为了演示单个对象的还原,将不选中此选项:

    After clicking the OK button, to confirm reverting just the Balances table, let’s inspect the local repository.

    单击“ 确定”按钮后,要确认仅还原“ 余额”表,让我们检查本地存储库。

    The Balances table is shown as changed, and reviewing the actual script shows that BType column committed in Rev 4 is reverted back to BalanceType committed in Rev 2:

    余额表显示为已更改,并且查看实际脚本后发现, 修订版4中提交的BType列已还原为修订版2中提交的BalanceType :

    Also, BalancesList stored procedure still exists in the local repository since we have reverted the Balances table only.

    另外,由于我们仅还原了Balances表,因此BalancesList存储过程仍存在于本地存储库中。

    Using this approach, any revision can be reverted, which will actually revert all files from the revision, or selecting specific object(s) from the revision can be reverted without affecting the rest of changes from the revision.

    使用此方法,可以还原任何修订,这实际上将还原该修订中的所有文件,或者可以还原从该修订中选择特定的对象,而不影响该修订的其余更改。

    To see the full version history of a SQL Server database object under source control, you can try ApexSQL Source Control, an SSMS add-in that allows you to put a database under version control, commit all changes to the repository and easily revert any committed change from the history.

    要查看在源代码管理下SQL Server数据库对象的完整版本历史记录 ,可以尝试ApexSQL Source Control,它是一种SSMS加载项,可让您将数据库置于版本控制下 ,将所有更改提交到存储库并轻松还原任何已提交改变历史。

翻译自: https://www.sqlshack.com/revision-history-object-change-sql-database-using-mercurial/

mercurial使用



推荐阅读
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 关于我们EMQ是一家全球领先的开源物联网基础设施软件供应商,服务新产业周期的IoT&5G、边缘计算与云计算市场,交付全球领先的开源物联网消息服务器和流处理数据 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • 本文讨论了在数据库打开和关闭状态下,重新命名或移动数据文件和日志文件的情况。针对性能和维护原因,需要将数据库文件移动到不同的磁盘上或重新分配到新的磁盘上的情况,以及在操作系统级别移动或重命名数据文件但未在数据库层进行重命名导致报错的情况。通过三个方面进行讨论。 ... [详细]
  • CentOS 6.5安装VMware Tools及共享文件夹显示问题解决方法
    本文介绍了在CentOS 6.5上安装VMware Tools及解决共享文件夹显示问题的方法。包括清空CD/DVD使用的ISO镜像文件、创建挂载目录、改变光驱设备的读写权限等步骤。最后给出了拷贝解压VMware Tools的操作。 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • WhenIusepythontoapplythepymysqlmoduletoaddafieldtoatableinthemysqldatabase,itdo ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • 本文主要复习了数据库的一些知识点,包括环境变量设置、表之间的引用关系等。同时介绍了一些常用的数据库命令及其使用方法,如创建数据库、查看已存在的数据库、切换数据库、创建表等操作。通过本文的学习,可以加深对数据库的理解和应用能力。 ... [详细]
author-avatar
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有